Computer Vision Object Detection

Blitz3D Forums/Blitz3D Beginners Area/Computer Vision Object Detection

splinux(Posted 2005) [#1]
Does anyone know anythings about programming an application wich, seeing an image, it detects a defined pattern(to recognize an object, a face, an animal,...)?


jfk EO-11110(Posted 2005) [#2]
This is all very specialized. EG. there are face recognition pogramms. Or Optical Character recognition. Two completely diffrent things, both pretty hard.

You can try this in Blitz easily, just read the pixels of an image. Maybe you want to start with highlights, EG. try to find the highlights of the eyes of a human face.

Then there are methods of comparing shapes, with similarity tolerance, variable perspectives, scales and rotation etc.
You better buy a supercomputer with a few teraflops unless you want to wait for years until it recoginzes only a coffecup.


Panno(Posted 2005) [#3]
lol jfk but thrue


Shambler(Posted 2005) [#4]
http://www.ai-junkie.com/ann/evolved/nnt1.html
http://www.psych.utoronto.ca/~reingold/courses/ai/nn.html
http://www-106.ibm.com/developerworks/linux/library/l-neural/


splinux(Posted 2005) [#5]
It's possible with an AMD Athlon XP too.
I know about comparing shapes, but i don't know how to do it.


jfk EO-11110(Posted 2005) [#6]
You are talking about complex matter here. If you are not experienced with basic programming skills, you should start there.

First write a function that detects if two images are the same or not.

Then modify it in a way that it will recognize SIMILAR images, eg. the same image with diffrent color or contrast settings. Learn to use tolerance when comparing pixels or groups of pixels. Well, there's a lot to do.


_PJ_(Posted 2005) [#7]
Just curious, Would 'GammaRed/Green/Blue' commands help with this? Perhaps if a screen image was of a simpler Black/White contrasting silhouette image?


splinux(Posted 2005) [#8]
I mada an edge detection program wich draw the approximately shape of an object.
I think that if i'll compare two shapes i'll must apply this algorithm on tha image as on the pattern.
But in wich way i can compare two shapes?
Doing:
red=red2-red1
...

(where red1 and red2 are the red color of the points to compare) and:
if red<40
  ;this points are similar
else
  ;this points aren't similar
endif



splinux(Posted 2005) [#9]
So, could anyone help me?


jfk EO-11110(Posted 2005) [#10]
yes, you're right. tho I'd say

red_diff= red1-red2

It may be better to make a greyscale image out of both images before comparing, so you can work with the brightnesses only.
rgb=readpixelfast(x,y) and $FFFFFF
; separate RGB
red=(rgb and $FF0000) shr 16
green=(rgb and $FF00) shr 8
blue= rgb and $FF
; get greyscale (well, not fully correct since green has a higher value than red or blue, but that's peanuts)
grey=(red+green+blue)/3


now you can compare greyscales directly.

It may be a good idea to increase the images contrast now, to make the shape more visible. You even may increase the contrast that much that you'll have black and white only, but this requires that the images where well balanced before.

Anyway, increasing contrast can be done in many ways, eg:
if grey>128 then
 grey=(grey+2)*1.1
else
 grey=(grey-2)*0.9
endif
if grey >255 then grey=255
if grey <0 then grey =0


Don't expect too much help here. Because none of us has been there. Even the more experienced programmers don't know how to do this. If you are a beginner, don't expect that you can sit down and write a super artifical intelligence on a rainy weekend. And especially don't expect other people to do this for you instead. We can help you with the Blitz Commands. The AI info is out there, in the web.


jfk EO-11110(Posted 2005) [#11]
Some more thoughts:

if you compare images, you may not compare them pixel by pixel. Because if you do this and only add the diffrences, you probably get results that will be misinterpreted easily. You better compare groups of pixels. Personally I would use a set of primitives that will describe a group of pixels. A set for 8*8 Pixel groups could be:
straight line (any angle)
curve (any angle and curve size)
dot
corner
line that ends inside the group
etc.

your reference pics (dog, cat rat etc.) would then need to be resolved in such primitives too, so you could compare them easily.
The main problem I see when camparing real world images is:

-diffrent perspectives: you rarely get a perfect sideview of a horse, unless you use a special gate photo construction or somthing.
-diffrent scales. this can be solved partially by scaling the image in a way that the shape fits on the image (assuming the perspective is ok)
-rotation - you won't know if the rotation is right (well, maybe you know it based on the hardware and possible objects etc.). If rotation is unknown, you probably got to compare 360 rotated copies of the image - could be pretty slow...

These are only some thoughts, and I am pretty sure, If I'd try to realize such a programm, a bunch of further problems would pop up immediately.

Anyway, it's a fascinating chapter. Good luck!


splinux(Posted 2005) [#12]
Thanks for the help, i'll try some programs.