May 31, 2016

OPENCV RASPBERRY PI2 (JESSIE) 5 -face recognition




This posting is face recognition.

Download opencv-2.3.1



Extract and Copy OpenCV-2.3.1/data/harrcascades to usr/share/opencv/haarcascades

SAMBA is useful



If use Terminal 


permission


Extract and move /usr/share/opencv/haarcascades



Download camcv_vid1.cpp use below link.


Editing cmakelists.txt.

1
sudo nano CMakeLists.txt
cs

changing name camcv.c to camcv_vid1.cpp

Editing camcv_vid1.cpp

1
sudo nano camcv_vid1.cpp
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Line 59
----------------------------------------------------------------------------------------------
#include "/home/pi/pierre/libfacerec-0.04/include/facerec.hpp"
=>#include "/home/pi/camcv/libfacerec/include/facerec.hpp"
----------------------------------------------------------------------------------------------
face recognition API
 
Line 681
---------------------------------------------------------------------------------------------------
fn_haar = "/usr/share/opencv/haarcascades/lbpcascade_frontalface.xml";
=>fn_haar = "/usr/share/opencv/lbpcascades/lbpcascade_frontalface.xml"
---------------------------------------------------------------------------------------------------
opencv library
 
Line 764
---------------------------------------------------------------------------------------------------
else if (!raspipreview_create(&state.preview_parameters))
=>else if ( (status = raspipreview_create(&state.preview_parameters)) != MMAL_SUCCESS) 
---------------------------------------------------------------------------------------------------
cs


If difficult edit, download below link.


Download sample face image.


Extract to /home/pi/camcv/others/

1
sudo zip 100x100.zip
cs



csv.txt has face setting information.

Structure is File path and ID

Line 65 in camcv_vid1.cpp

define ID number.

Line 661 
define display name

Many image is hige accuracy but low speed.


Cmake and make

1
2
sudo cmake .
sudo make
cs

If you see below error, Download contrib.hpp




copy to /usr/include/opencv2/contrib/contrib.hpp 



cmake and make.

Run camcv (5500 is accuracy)

1
./camcv others/csv.txt l 5500
cs








If include little sample image, low accuracy.


This is low accuracy value



OPENCV RASPBERRY PI2 (JESSIE) 4 -VIDEO



This posting is video

This post use RaspVid.c

Editing RaspVid.c

1
2
3
4
5
6
7
We  delete- all lines related to the preview component,
- all lines related to the encoder component.
- all lines related to inline command parsing and picture info…
We change :
- add the callback directly to the video_port  (line 286)
- create and attach the pool (to get/send message)  to the video port… (line 320)
- change format encoding to ENCODING_I420 in line (268) (instead of OPAQUE)
cs

And changing name.

1
mv Raspvid.c camcv.c
cs

If difficult editing, download below link

Download camcv_vid0.c

Changing name and cmake





Run camcv in window mode

1
./camcv
cs

You can see video.

If you want change pixel and color mode, editing Line 119~120 and Line 124

Frame in Pi 1


  • 320×240 color : FPS = 27,2
  • 320×240 gray : FPS = 28,6
  • 640×480 color : FPS = 8
  • 640×480 gray : FPS = 17


  • Frame in Pi 2


  • 320×240 color : FPS = 29.9
  • 320×240 gray : FPS = 29.9
  • 640×480 color : FPS = 24.3
  • 640×480 gray : FPS = 29.9
  • 1280x960 color : FPS=6.6
  • 1280x960 gray : FPS=15