Dec 25, 2013

Raspberry Pi - OpenCV with Picam (final)



5. implement OpenCV


Finally this step is final!!

5-1 Prepare camcv

Download  camcv_vid1.cpp 


Modify cmakelists.txt


sudo nano cmakelists.txt


Change camcv.c to camcv.vid1.cpp in add_executable





Modify camcv_vid1.cpp

sudo nano camcv_vid1.cpp


Line 59 (face recognition API)

----------------------------------------------------------------------------------------------
#include "/home/pi/pierre/libfacerec-0.04/include/facerec.hpp"
=>
#include "/home/pi/camcv/libfacerec/include/facerec.hpp"
----------------------------------------------------------------------------------------------


Line 681 (openCV lib)

---------------------------------------------------------------------------------------------------------------------------
fn_haar = "/usr/share/opencv/haarcascades/lbpcascade_frontalface.xml";
=>
fn_haar = "/usr/share/opencv/haarcascades/haarcascade_frontalface_default"; 
--------------------------------------------------------------------------------------------------------------------------


Line 764 (If you meet error last step)

--------------------------------------------------------------------------------------------------------------------------
else if (!raspipreview_create(&state.preview_parameters))
=>
else if ( (status = raspipreview_create(&state.preview_parameters)) != MMAL_SUCCESS) 
--------------------------------------------------------------------------------------------------------------------------

this error
---------------------------------------------------------------------------------------------
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

---------------------------------------------------------------------------------------------



If you not have haarcascades folder in /usr/share/opencv/  need a download opencv2.3.1


Click to link OpenCV_2.3.1 

Here Change new link

Unzip and  copy /opencv_2.3.1/data/haarcascades/ to /usr/share/opencv/haarcascades/ 



5-2 make DB

Make DB or download sample


sample file  << Click to link for download sample file


Unzip and copy to /home/pi/camcv/others 





Include 400 pictures and 1 text file.

One person has 10 pictures.

ID LIST (csv.txt) file for link person and picture.




Last number mean ID




5-3 Modify camcv_vid1.cpp

sudo nano camcv_vid1.cpp


Line 65

Define name and id

id is csv.txt' id number.



Line 661

This is name for display!! 

PS. many picture make high accuracy but slow run time.



5-4 Run

sudo cmake .


sudo make


You can see change camcv_vid1.cpp instead of camcv.c

Run!!

./camcv others/csv.txt l 5500



init person list


If recognize your listed person, display name.


No comments:

Post a Comment