How to track a real track image, for race Level design? - python

i am creating a game using pygame and python.
i have develoved a square that goes up and down, flows a path.
how do i set a particular path for the square?
My question is how do i take this image and convert it into a path equation the square follows?
Any other idea to use this or any track from an image is appreciated.
i tried imread() of matlab and many other things. i dont think grayscale applies here. i even tried superimposing it on a grid and plot points along the track.
i am out of ideas and from all the vedios i have seen i am missing something very basic here i think. any help?

Related

Splitting an image into overlapping tiles, and recording the tile name as the top left pixel coords from the image

I'm very new to image processing in Python (and not massively adept at python in general), so forgive me for how stupid this may sound. Im working with an AI for object detection, and need to submit 1000x1000 pixel images to it, that have been divided up from larger images of varying lengths and widths (not necessarily divisible, but I have a way of padding out images less than 1000x1000). In order for this to work, I need 200 pixel overlap on each segment or the AI will pick may miss objects.
I've tried a host of methods, and have either got the image to divide up using the methods suggested in Creating image tiles (m*n) of original image using Python and Numpy and how can I split a large image into small pieces in python (plus a few others that effectively do the same techniques in different words. I've been able to make a grid and get the tile names from this, using How to determine coordinate of grid elements of an image, however have not been able to get overlap to work in this, as I would then just tile it normally.
Basically what I'm saying is that I've found one way to cut the images up that works, and one way to get the tile coordinates, but I am utterly failing at putting it all together. Does anyone have any advice on what to do here?
So far I've not found a direct approach to my end goal online - and I've tried mucking around with different scripts (like the ones listed above), but feel like Im barking up totally the wrong tree.

How can I fit circles into a shape using python?

So for a project, I gotta make a web-site that fills a shape with circles that wont intersact at any point.The user is going to upload a shape, and also choose the radius of the circles, and the code is going to place as many circles(with the chosen radius) as it can into the shape.
For example, if the user uploads an 16cmx16cm square and chooses 4cm as the radius of the circles, the system is going to place as many circles with a radius of 4cm as possible into the square, and the circles wont intersact at any point.
I tried many things using python and failed eveytime. The shape can be anything, it can be completely random and no matter what the shape is, the site has to find out where to place the circles with the selected radius, place the circles, and show the final shape. I dont know if there is a way to do this without python, but I am open to every suggestion-solution.
You could try the package circle-packing. It looks like you can get the behavior you want by setting the arguments rho_max and rho_min of the class ShapeFill to the radius provided by user. I've not used it so cannot attest to its' correctness or usability. Please let us know if it works for you.
Note: The license is GPLV2 so keep in mind the implications. And don't forget to attribute.
I believe filling it with the actual possible maximum amount would be far from easy, if you actually just want fill it and don't care about the best solution then it's fairly easy.
just start to for the top left corner place a circle, if collides with another circle or the shape it, shift it to the right of an arbitrary small amount and try again. once you reached the end on the right side, move it down and to the left and start the process again.

What module to use for checking the color in a specific place on the image

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.

Detecting shift in image using opencv

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.

Pygame sprite transformation with interpolation

Im currently working on a Python/Pygame module to wrap some basic sprite animation. Animation in the sense that the image itself is static but I apply rotation and scale with start and end values with a sine wave interpolation. That is, sprite transformation like the ones that could be made in Flash. I hope you understand, otherwise feel free to ask and I try to clarify.
I cant find a module that does this already. Does anyone know of one? Would save me some work. :)
Edit: Oh, and if this transformation with interpolation thingie has a proper name I would love to hear it. Would probably make my search results better.
You can transform images by pygame.transform, but interpolation is not included in pygame.
Rabbyt provides animation including interpolation, even though I haven't used it.

Categories

Resources