How to track pixels?

Blitz3D Forums/Blitz3D Programming/How to track pixels?

CopperCircle(Posted 2008) [#1]
Hi does anyone know of a method to track pixels across a series of images?

Say I wanted to track the mouth region of a person on a video clip, frame by frame.

Thanks.


Ross C(Posted 2008) [#2]
I reckon you'd need to keep an array of colours that the area uses. Search the area the mouth was last detected in, outwards, since this might be quicker to scan and find what your after. It's all down to the colours i'd say. Just search for areas of colour that match the ones first recorded, and try and match the rough size. You'll probably need to change the size every frame and maybe the colour values, as light may affect the person's head rotating etc etc.


markcw(Posted 2008) [#3]
I don't think you can.


big10p(Posted 2008) [#4]
This is what is know as 'a non-trivial' task.


H. T. U.(Posted 2008) [#5]
This is no easy task. Because a persons lips are such a different color from the rest of the face, I would try to look for a reddish area and use a bank to remember and track its position and shape. You would still need to detect a range of redish colors for it to fully detect the mouth, and it would have difficulty if the subject was sunburnt or blushing.

Just out of curiosity, what are you using this for?


CopperCircle(Posted 2008) [#6]
I just need to track a box around the mouth area, how does it work with those web cam games that track your hands, anyone know a good method?


jfk EO-11110(Posted 2008) [#7]
It must be possible somehow, remember the new sony feature, that automaticly waits for a smile until it's gonna take a photo.

It's easier to track the eyes. THe mouth, as it was said before, has less significance. Additionally it depends on:
is the mouth always closed or always open, or is the person talking? THis would make it even harder. Second: does the program know where the mouth is located in the beginning, or has it to recognize the mouth "from scratch"? Third: how is the error tolerance? I mean, is this thing guiding nuclear weapons, or doesn't it matter to much if it's gonna take a sandwich for a mouth sometimes? 5. Is it always the same mouth? If so, are the light conditions always the same? Does the program have a mouth reference picture for comparation?

That would be the easiest case. Simply compare the reference mouth with blocks onscreen. scale it, rotate it and distort it, until it fits the rference pic. Compare the pixels with some tolerance parameters. Working with down-scaled versions of both (blocks and reference) allows fast(er) shape detection. Noless it's gonna be dead slow, a bit like encoding an Mpeg2 movie. (That is infact about the same)


markcw(Posted 2008) [#8]
Do you need a program to record a screen area or do you need to record a screen area in Blitz3D?

If you mean in B3D then maybe take multiple screenshots of an area like this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1752


CopperCircle(Posted 2008) [#9]
Hi, I plan to mark an area around the mouth on the first frame, I then want it to move the marked area and keep it over the mouth as the video moves.
I does not have to be pixel perfect but needs to keep the mouth within the marked out square.

It is so that my edge tracing function can be set to different parameters over the mouth area.


Andy(Posted 2008) [#10]
This is one way.

First you create an image that is downsized, and which uses a reduced palette which is taylored to the colour range that you are looking for. Then test the immediate neighbouring squares to the last fixpoint, to see if the mouth has moved. Always test an array of pixels(x number of pixels * y number of pixels). Average the values of each cluste of pixels and add all of the pixels in the area together. If the resulting value is different from a specific range, then you are not where you need to be.

Simply put, you can have a rather small picture with maybe 16 colours. They trick is to find the right representation of color, but using the r,g,b channels individually can make things easier.

The resolution of the marked out square will be smaller than the resolution of the source image, but it will follow the mouth pretty accurately.

I did it as a project in 2D, where I wanted the computer to play like a human opponent, by observing it's surroundings rather than just 'knowing' what was happening.