Recently I wanted to make a script which could convert images into game levels (the game is Antiyoy online), the game can give out levels in a special text form which makes them easy to edit just by changing specific text.
I am rather begginer to Python and don't know much yet. I didn't start doing anything yet because I can't figure out which module should I use for the task of the image reading. I want for it to read the color of a chosen pixel on the image (and average out the color of multiple pixels for scaling if possible) and give out it in hex or other form in which I can convert it to the color closest to the ones selected by me.
Doing some research I'm pretty sure NumPy can do this but I have no experience with it and there are probably more specialized modules for this.
If what am I asking for is hard to understand I'm open for questions, thank you in advance.
I'm looking for some advice on what to use for this problem.
I have a camera feed of a flat surface. I want to be able to mark a point on that surface, and then to automatically track the movement of that point in the frame. In other words, I want to track the shift and rotation of the image compared to the initial state.
I think this should be possible using opencv or something similar, but I'm unable to find the right tools.
Could someone point me in the right direction?
Preferably some way in python but other methods are welcome too.
I am writing a python tool to find specific symbols (e.g. a circle/square with a number inside) on a drawing pdf/screenshot.png
I know from another data source the specific number(s) that should be inside the circle/square.
Using opencv matchTemplate I can find symbols and its coordinates.
One way would be to created all possible symbols (so circles/squares with number 1 to 1000) and save them. Then use opencv to find it on the drawing since I know the number to be found, and thus the filled symbol.
I am sure that the is a smart way to do this. Can somebody guide me into the right direction.
Note: pdfminer will not work since I will not be able to distinguish between measurement numbers and the text coming from the symbol, but I could be wrong here.
I am also trying to solve a similar problem in a coding assignment. The input is a n low poly art illustration.
Once you find the location of the UFO's, you need to crop that part and pass it through a classifier to find the number that UFO contains. The classifier is trained on 5000 images.
I am now going to try the matchTemplate method suggested by you to find the co-ordinates of the UFOs.
I'm trying to make a simple game on an FPGA board and I was hoping to use sprites for background and player characters. To do this I was told to use either Python or Matlab to take an image and convert it to a sprite. I am trying to convert the images to have 16 bits per pixel since the memory on the board can hold 16 bits per memory location.
For the past few days I've been searching for a tutorial or some sort of example to help me figure this out, but I've had no real luck. So I'm just hoping someone can give me advice on how to accomplish this or just point me in the right direction.
I don't know if this helps but I've discussed this with another person and the advice they gave me is to just take an image and put it into a matrix and divide it by 8. Then I'll have 15 bits for color, 5 each for RGB, and then a 16th bit for transparency. I should then write this matrix to a hex file and put it onto the boards memory. There is a program that properly edits the hex file into the correct format so that's not something I have to worry about.
Does this approach seem right? Or is there a better way? Thanks in advance!
Here is the image I need to detect: http://s13.postimg.org/wt8qxoco3/image.png
Here is the base64 representation: http://pastebin.com/raw.php?i=TZQUieWe
The reason why I'm asking for your help is because this is a complex problem and I am not equipped to solve it. It will probably take me a week to do it by myself.
Some pseudo-code that I thought about:
1) Take screenshot of the app and store it as image object.
2) Convert binary64 representation of my image to image object.
3) Use some sort of algorithm/function to compare both image objects.
By on screen, I mean in an app. I have the app's window name and the PID.
To be 100% clear, I need to essentially detect if image1 is inside image2. image1 is the image I gave in the OP. image2 is a screenshot of a window.
If you break this down into pieces, they're all pretty simple.
First, you need a screenshot of the app's window as a 2D array of pixels. There are a variety of different ways to do this in a platform-specific way, but you didn't mention what platform you're on, so… let's just grab the whole screen, using PIL:
screenshot = ImageGrab.grab()
haystack = screenshot.load()
Now, you need to convert your base64 into an image. Taking a quick look at it, it's clearly just an encoded PNG file. So:
decoded = data.decode('base64')
f = cStringIO.StringIO(decoded)
image = Image.open(f)
needle = image.load()
Now you've got a 2D array of pixels, and you want to see if it exists in another 2D array. There are faster ways to do this—using numpy is probably best—but there's also a dumb brute-force way, which is a lot simpler to understand: just iterate the rows of haystack; for each one, iterate the columns, and see if you find a run of bytes that matches the first row of needle. If so, keep going through the rest of the rows until you either finish all of needle, in which case you return True, or find a mismatch, in which case you continue and just start again on the next row.
this is probably the best place to start:
http://effbot.org/imagingbook/image.htm
if you don't have access to the image's meta data, file name, type, etc, what you're trying to do is very difficult, but your pseudo sounds on-point. essentially, you'll have to create an algorithmic model based on a photo's shapes, lines, size, colors, etc. then you'd have to match that model against models already made and indexed in some database. hope that helps.
It looks like https://python-pillow.org/ is a more updated version of PIL.