• Advertisement
Sign in to follow this  

2D image scrolling and recognizing pattern

This topic is 770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a large image, say 100x1000, with some patterns inside, like a man and a car. It's kind of a sprite with white spaces between two images. 

When it reaches the half of the screen, I have to see what pattern it is and have a switch-case there. So if it's the car I'll do something, and so on.

What's the best way to do this?

 

I imagine I could find the pattern by putting just the car on the top of the scrolling image and see if it matches, but I've never done it

Share this post


Link to post
Share on other sites
Advertisement

There are couple of ways you can solve this:
1) Set hardcodded/Configurable positions for the car/other objects which you could simply test for.

2) Create an outline for your car and test the pixels against the outline. 

3) Actual image processing of edges. 

 

I personally would use (2) because it is more precise with no overhead of image recognition and no configurable values. 

 

Good luck! 

Edited by WoopsASword

Share this post


Link to post
Share on other sites

I would do (2) too, but how can I rest pixels like that?

I have this image:

 

|                                     C                                  P                     | C                            P                                C

Then it scrolls to the left and it'll be like

 

 

|C                                  P                      C                            P |                              C

( | is the window border) Here I need to test C. For example, C and P both have width W and height H.

Is there any simple way of testing the pixels? And how about scrolling the image (I've been working on just little images that fit in the window)?

Edited by destouch

Share this post


Link to post
Share on other sites

If your problem is detecting known patterns in an unknown image and doing something when a moving window touches the patterns, the simplest and most efficient approach is preprocessing to find cars, men etc. in the image and obtain a list of object positions and types, Then as you display the image with scrolling you can transform the "triggers" from a fixed screen location to a variable image location, and compare their position with object positions to see if they hit.

 

1D Example: cars at x=4, and x=150 in the image (location of some conventional reference point, say the front wheel hub); if a car scrolls past screen x=90 a collision imminent alarm begins; the scrolling amount is D, screen x = D + image x. The first car triggers when you scroll to D=86, which can be in the middle of a move (e.g. D decreasing from 88 to 85), while the second triggers at D=-60. As you know D, you can search a sorted list of object locations for the items that overlap the interval between the D values of the previous and current frame.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement