News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

My OpenCV experiment

Started by Farabi, June 05, 2009, 03:04:15 AM

Previous topic - Next topic

Farabi

This is my result on OpenCV study. I managed to successfully implement eigenface face recognition technique. Unfortunately this technique is very sensitive to light wich mean, if the light too bright or too dark than the learned picture it will not identify object face on cam or mistakenly recognitioning it. I will try to improve it. On this test when you are running this program you will see my face with an 17 number on it, 17 is my id number when my program trained and it was a prove if the program is not miss identify my face.

For training purpose check out a function named fCVLearn.
After my laptop back in (maybe) 4 days I will try to create an explanation about how to use my wrapper. But if someone see it clear enough and willing to make it for me, please do it.

Here is the source link:
http://omploader.org/vMXM2OA/FCTest.zip
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

UtillMasm

 :USha1: fd0acd69058d260fca67f1d99030aacdca44f3b3
you are a great man! not terrorist.

btw: i like your mustache, very very cool. :red

Farabi

Quote from: UtillMasm on June 05, 2009, 03:09:21 AM
:USha1: fd0acd69058d260fca67f1d99030aacdca44f3b3
you are a great man! not terrorist.

btw: i like your mustache, very very cool. :red
Haha  :lol .
Try to modify that code and improve it. Im still thinking how to make the light constant so the face recognition can be used outdoor. If Im stuck, I had the second scenario, calculate the distance beetween 2 eyes, I think that was unique enough each person.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

So here is how you do face recognition using my wrapper.
First, you will need a set of picture at minimum 3, the more the better.
Before you do any recognition, you must first train my wrapper first. To do it edit "Train.txt" and put all the picture path on there. You must write on train.txt something like this [ID number] [Picture Path], for example "15 Farabi.jpg".
If you done it, make a new project which include all of my wrapper inside it and put this code:


invoke fCVLearn,addr rc


Where rc is a structure of fMem. fMem is defined as follow

fMem struc
faceImgArr dword 0
personNumTruthMat dword 0
nTrainFaces dword 0
nEigens      dword 0
pAvgTrainImg dword 0
eigenVectArr dword 0
eigenValMat  dword 0
projectedTrainFaceMat dword 0
nTotalImage dword 0
fMem ends


Okay now you have trained it. After that code executed, it will generat am xml file named facedatatest.xml.

Now create a new project with all of my wrapper included just like on the file you downloaded above.
To use the function, you will need an IPL picture format, you can set the source from cam or from a file.
If you want to use a webcam use the code like this

invoke cvCreateCameraCapture,-1
mov fTest,eax

And if you want to use a movie file use the code like this

invoke cvCreateFileCapture,CADD("MOV00033.wmv.AVI")
mov fTest,eax


Please remember that every frame you get from picture or from camera is upside down and you will need to flip it. To flip the camera use this code.

invoke cvFlip,img,0,0


After you successfully initialize your cam or your file you will need to take the frame from it, and here is how to get it.

invoke cvGrabFrame,ftest
invoke cvRetrieveFrame,ftest
.if eax==0
;invoke MessageBox,0,CADD("Failed"),0,0
invoke PostQuitMessage,0
.endif
mov img,eax
invoke cvFlip,img,0,0


Before you do the recognition process you will need to know where the face is located on the frame, or is there any face or not, and to do it, use this function:

invoke FaceDetect2,img,addr buff2


Please note that buff2 must be long enough to store a RECT structure(s), the first byte of buff2 is the total of face detected, and the next byte is the first RECT structure.
After you know the location of the face, extract the face and save it as a picture, or, you can make your own function which able to extract and convert it to IPL format automatically and pass the poiinter to the recognition function.

And last, do the recognition process, call this function

invoke fCVRecognizeS,addr rc,img2


This function will return the id of the trained function you did trained.

Please note that this function is experimental so I posibly change the parameter or the return value, so better keep check the code.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

UtillMasm