0

I am trying to gather a position and a direction of an object inside an image.

The image can look like this for example: https://i.stack.imgur.com/4ehUy.jpg

The object is shown as a blue circle.

What I've tried so far is using a basic pixel search, but it seems like the circles blue isnt always the same (maybe because of the shapes and the enviroment) and when I give it a color range (e.g. red 130 - 150, green 110 - 120 and blue 90 - 100), it isnt reliable, because sometimes the pixel is recogniced on top of the hole, sometimes on the right site and so on. Further more the next step would be getting the direction of the object, which is even more difficult, because of the enviroment, which can be very similar to the light infront of the object.

Again, what I'd like to know is the current center of the circle and the angle it is aiming atm...

Is there a library or a way to do this? I am using C# / WPF to program my application.

user4653488
  • 31
  • 1
  • 4
  • I would guess that the problem is JPEG. Due to the conversion into YCbCr colorspace and compression, this messes with the colors. I would suggest using PNG or BMP if possible. Then it would probably be wise to search not only for one pixel, but for a whole row, or multiple rows. For example try 4 pixels, when on the left side, top, right and bottom of the circle. This will minimize errors I guess. – Jens May 02 '15 at 10:57
  • yeah i already build that in with top right left and bottom, but with a range. Unfortunately i cant change the JPEG format to another, it is game based. – user4653488 May 02 '15 at 11:01
  • I've made a screenshot directly from C# now instead of using ingame mechanics, the o – user4653488 May 02 '15 at 12:07

1 Answers1

0

I found a solution on my own:

All you need is the AForge library. With the AForge library you can do some experiments with color filtering (I used a blue) and after some calculations you will get the center position of the player. :)

user4653488
  • 31
  • 1
  • 4