This step is easy : we reuse the source code of previous step 6 and we add the OpenCV face recognition treatment of step 6 of “Mirror Magic”.
Watch this video to see result (http://www.youtube.com/watch?v=yzYIxNgDZu4).
Source code modification
Except some new #include statements and some global variables, all modification are in the callback function video_buffer_callback
For face recognition, gray pictures are required. Thus, once we get the I420 frame, we don’t need to extract color information. This is a great new, since we saw on last post, that this step takes a lot of cpu !
Make it simple : we forget the pu and pv channels, we only keep the “py” IplImage (gray channel) and convert it to a Mat object.
The face detection is made by the detectMultiScale function. This call requires most of the cpu needed in a loop, it’s important to optimize it.
- Let’s use the LBP cascade (Local Binaries Patterns) instead of the Haar cascade file (haarcascade_frontalface_alt.xml). Modify the fn_haar variable to link to lbpcascade_frontalface.xml. Response time is much more faster but less accurate. Sometimes, (and you can see exemple on the video), the soft gives wrong predictions
- Let’s increase the size of minimum rectangle to search size(80,80) instead of size(60,60) as last parameter of the call.
- I read on the “blog de remi” a way to optimize this function, using an alternative home-made function smartDetect. Unfortunatly, but I didn’t notice any improvment. Thus, I removed it. (perhaps I did a mistake or a misuse ?)
Results
- With a 320×240 frame, I’m between 8 and 17 FPS with almost no lag (17 FPS = no face to detect and to analyse. 8 FPS = analyse face at each loop)
- With a 640×480 frame, I’m around 4-5 FPS whith a small lag (1 s)
Conclusions
For me, these results are very good for a such affordable computer like Rasperry Pi. Of course, for a real-time use like RC robot or vehicle it’s too slow (need to detect quickly an obstacle, except if you build a RPCS (Raspberry Pi Controlled Snail) ;-).
But for most of others uses like domotic or education it’s fine.
Anyway, it’s far better than my USB webcam : I was even unable to do face recognition in 640×480 !
Download the source code here (http://raufast.org/download/camcv_vid1.cpp). It’s really a quick&dirty code, don’t be offended by non-respect of C++ state-of-the-art coding rules !
At this stage, you should be able to detect Mona Lisa, in case of she rings at your door tonight 😉
I got eror message like this :
login as: pi
pi@192.168.137.9’s password:
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon
Sep 8 15:28:00 BST 2014 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Sep 28 17:00:29 2014 from deden-pc.mshome.net
pi@raspberrypi ~ $ sudo su
root@raspberrypi:/home/pi# cd /home/camcv/
root@raspberrypi:/home/camcv# ls
camcv Doxyfile RaspiCLI.c RaspiTexUtil.h
camcv.c foobar.bmp RaspiCLI.h RaspiVid.c
camcv_vid0.c gl_scenes RaspiPreview.c README.md
camcv_vid1.cpp imv_examples RaspiPreview.h tga.c
CMakeCache.txt Makefile RaspiStillYUV.c tga.h
CMakeFiles RaspiCamControl.c RaspiTex.c
cmake_install.cmake RaspiCamControl.h RaspiTex.h
CMakeLists.txt RaspiCamDocs.odt RaspiTexUtil.c
root@raspberrypi:/home/camcv# clear
root@raspberrypi:/home/camcv# make
[ 7%] Building CXX object CMakeFiles/camcv.dir/camcv_vid1.cpp.o
In file included from /home/camcv/camcv_vid1.cpp:58:0:
/home/pi/Qodir/libfacerec-004/include/facerec.hpp:33:7: error: redefinition of ‘class cv::FaceRecognizer’
/usr/include/opencv2/contrib/contrib.hpp:921:22: error: previous definition of ‘class cv::FaceRecognizer’
CMakeFiles/camcv.dir/build.make:123: recipe for target ‘CMakeFiles/camcv.dir/camcv_vid1.cpp.o’ failed
make[2]: *** [CMakeFiles/camcv.dir/camcv_vid1.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/camcv.dir/all’ failed
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
root@raspberrypi:/home/camcv#
Can you help me guys ?
Maybe you got fixed problem like thisw ?
FIXED.
but i got new eror message :
root@raspberrypi:/home/camcv# make
Linking CXX executable camcv
CMakeFiles/camcv.dir/camcv_vid1.cpp.o: In function `video_buffer_callback(MMAL_P
ORT_T*, MMAL_BUFFER_HEADER_T*)’:
camcv_vid1.cpp:(.text+0xb90): undefined reference to `cv::Eigenfaces::predict(cv
::_InputArray const&, int&, double&) const’
collect2: ld returned 1 exit status
CMakeFiles/camcv.dir/build.make:407: recipe for target ‘camcv’ failed
make[2]: *** [camcv] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/camcv.dir/all’ failed
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
root@raspberrypi:/home/camcv#
can you help me guys ?
Do you have /libopencv_facerec.a in the list of target_link_libraries of CMakeLists.txt ?(see my earlier comment above)
how do you fix this problem, pls help me, i have same issue
/home/pi/Qodir/libfacerec-004/include/facerec.hpp:33:7: error: redefinition of ‘class cv::FaceRecognizer’
/usr/include/opencv2/contrib/contrib.hpp:921:22: error: previous definition of ‘class cv::FaceRecognizer’
this problem 🙂
I’m FIXED it by Download libfacerec from other resource.
which other resource? I dowloaded it as Pierre said at “Step 3 – Install softwares (for webcam and computer vision)”, and now have the sam problem like you guys, with this FaceRecognizer….I’d appreciate the link for resource download 🙂
Can someone here explain how to make .csv / txt ? I’m still confused , please explain step by step , thank you very much . 🙂
If you go to step 9 and download 100X100 (40men faces) you will see a text file that contain ./others/001.jpg;1./others/002.jpg;1 and so on..
. = current directory
/others = directory that contain the faces
/001.jpg = name of first picture that you will use to train
;1 = in your camcv.cpp file you will see these lines
#define MAX_PEOPLE 4
#define P_PIERRE 0
#define P_NATASHA 1
#define P_LISA 3
#define P_MONA 2
So if you ;1 it means this person will be recognized as Natasha.
then repeated the ./others/002.jpg;1 and so on….
and then save as faces.txt (or any name u want)
then you execute …. ./camcv name of your file.txt 1 5800
… Clear?
Sorry for my bad English. 😀
Ok, thankyou Ice.. 🙂
I’m has been folow your intructions..
But I got eror message like this :
root@raspberrypi:/home/camcv# ./camcv faces.txt 1 5800
start
(init) People initialized
(init) 21 pictures read to train
(init) 21 pictures of Qodri (0) read to train
(init) taille images ok
(init) start train images
Segmentation fault
Can you help me Ice ?
Maybe you got fixed problem like this ?
@Setiawan There’re many problems to deal with Segmentation fault .. can you send me your camcv.cpp,CMakeLists and faces.txt to my email (kamaelIce@hotmail.com) ? maybe I can help.
I haven’t been on this thread for a while as I gave up trying to get it to repeatable recognise faces it would either not recognise anyone or mis recognise people. I never got it to work like you did Pierre. I’d be most happy to get it to work like it does for you in the video. I spent months on it and I suppose I paid the price for being a beginner at this stuff as I just had to give up in the end. I’ve seen there may be a new version of this somewhere ? Could anyone tell me where it is please ? What would be really really helpful would be if I could download an SD card image with it working. I could then maybe spot what I did wrong…
I started off saying this was a fantastic project Pierre and I still think so even though a bit above my skills at present….
Thanks
Hi
Thank you very much for your code.
BUT after compile I received following ERRORS.
Would appreciate someone help me PLEASE
/home/pi/Face/faceReco.cpp:80:1: error: ‘Eigenfaces’ does not name a type
/home/pi/Face/faceReco.cpp: In function ‘void video_buffer_callback(MMAL_PORT_T*, MMAL_BUFFER_HEADER_T*)’:
/home/pi/Face/faceReco.cpp:320:3: error: ‘model’ was not declared in this scope
/home/pi/Face/faceReco.cpp: In function ‘int main(int, const char**)’:
/home/pi/Face/faceReco.cpp:708:2: error: ‘Eigenfaces’ was not declared in this scope
/home/pi/Face/faceReco.cpp:708:13: error: expected ‘;’ before ‘model’
/home/pi/Face/faceReco.cpp:714:5: error: ‘model’ was not declared in this scope
CMakeFiles/reco.dir/build.make:54: recipe for target ‘CMakeFiles/reco.dir/faceReco.cpp.o’ failed
make[2]: *** [CMakeFiles/reco.dir/faceReco.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/reco.dir/all’ failed
make[1]: *** [CMakeFiles/reco.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
Dear Pierre
would appreciate to help me about following error:
/home/pi/Face/faceReco.cpp: In function ‘int main(int, const char**)’:
/home/pi/Face/faceReco.cpp:356:2: error: ‘Eigenfaces’ was not declared in this scope
/home/pi/Face/faceReco.cpp:356:13: error: expected ‘;’ before ‘model’
/home/pi/Face/faceReco.cpp:362:5: error: ‘model’ was not declared in this scope
CMakeFiles/reco.dir/build.make:123: recipe for target ‘CMakeFiles/reco.dir/faceReco.cpp.o’ failed
make[2]: *** [CMakeFiles/reco.dir/faceReco.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/reco.dir/all’ failed
make[1]: *** [CMakeFiles/reco.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
Please, anyone??? A working SD
card image? Just so the rest if us can actually get it working and have a play…
Finally I compile everything successfully
But after ./camcv
I can see just:
init done
opengl support available
time=1330000
then nothing else , while red light of camera is on
Would appreciate someone help me how can I see windows or any face detection
How do you do to finally compile without ” error: ‘Eigenfaces’ was not declared”. Because class Eigenfaces is declared in facerec.cpp but not in facerec.hpp, which is include in camcv_vid1.cpp…
Have you move class Eigenfaces (and other used) declaration in facerec.hpp instead of facerec.cpp ?
Thank you for your answer…
Hi Majid! I have same problem. Did u known how to solve it?
Hi, Tuan
In this stage, the problem is speed of raspberry pi.
after compile you should run and wait, just wait for 10 second, then the application will work
Hi Majid
when i run ./camcv faces.csv 1 5500 and wait for a long time but program says:
-init done
-opendgl support avaible
The red light of camera is on
and thats all, notking more happens, i can’t see camcv window appear.
Need your help. Thank you!
Hi Tuan
It is my email address
bakhtiari.majid@gmail.com
please email me your source code.
I try to see and then reply back to you.
Regards
Hi Majid!
I already send to you my soucre code. Beside, are you install the V4L2 driver for the Dual Raspberry Pi Camera Module when you do? (http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14).
Thank you very much!
Comment out the line “cvNamedWindow(‘camcvWin’,CV_WINDOW_AUTOSIZE);”
It worked for me.
How did you remove the error for model???
I got eror message like this :
root@raspberrypi:/home/camcv# ./camcv faces.csv 1 5800
start
(init) People initialized
(init) 21 pictures read to train
(init) 21 pictures of Qodri (0) read to train
(init) taille images ok
(init) start train images
Segmentation fault
Can you help me guys ?
Maybe you got fixed problem like this ?
Just to let you guys know, at least for me it was essential NOT to use histogram equalization with preparePhoto tool, in order for the Raspberry to recognize me. It took me one full day this weekend to figure that out, goind through different settings and switches, and taking a billion (well, at least tens) of selfies. I had my biggest doubts on possible false settings in camcv_vid1 but so it turned out that my photo templates were of low quality for the recognition due to the equalization. After trying with a few dozen pictures that were prepared without the equalization, the result got improved by many orders of magnitude!
Thanks for sharing that, metso. All though performance was acceptable with the histogram equalization enabled, I found that omitting it gave a significant performance boost too.
It seems that I got the facial recognition to work as expected on my Raspberry Pi. As I built my software, purely based on Pierre’s instructions, I took notes on my steps in a bit more detail than what was included in the instructions. I put those notes here in case someone is interested:
http://metso.sdf.org/facialRecognition.txt
All thanks to Pierre!
hi metso i have problem in this section , same when i folowing pierre tuttorial.
install face recognition API
The face recognition API is called libfacerec-0.04.
Download the zip file from here:
https://github.com/bytefish/libfacerec/zipball/v0.04
Unzip it and transfer the whole directory on rpi, for example to /pi/camcv/libfacerec/.
Go on the directory and just compile it using
cmake .
make
when i make command cmake i get eror.
— Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: /home/pi/camcv/libfacerec/CMakeCache.tx t.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. /home/pi/camcv/libfacerec /CMake Cache.txt
CMake Error: : System Error: Permission denied
(its longer i just paste the end)
now its ok with that eror i needed to use sudo cmake . but i have other problem with this
run to test that it works, in x session
startx
alt-f2
lxterminal
/home/pi/camcv/camcv
-> a camera module picture should be taken and displayed now by opencv
I got this eror, mabye you have idea ?
(==) Using system config directory “/usr/share/X11/xorg.conf.d”
modprobe: FATAL: Module g2d_23 not found.
metso hi again, when i try to do 40 photos of me i got this eror, and those photo shuld be saved in that folder where i execute my program ?
bash camCapture.sh
mmal: main: Error opening output file: /home/pi/picam/151227_182828.jpg~
No output file will be generated
1
mmal: main: Error opening output file: /home/pi/picam/151227_182828.jpg~
No output file will be generated
2
mmal: main: Error opening output file: /home/pi/picam/151227_182828.jpg~
No output file will be generated
Could someone share some insight as to how to solve this error? Thanks in advance.
pi@raspberrypi ~/camcv $ make
[ 7%] Building CXX object CMakeFiles/camcv.dir/camcv_vid1.cpp.o
/home/pi/camcv/camcv_vid1.cpp:79:1: error: ‘Eigenfaces’ does not name a type
/home/pi/camcv/camcv_vid1.cpp: In function ‘void video_buffer_callback(MMAL_PORT_T*, MMAL_BUFFER_HEADER_T*)’:
/home/pi/camcv/camcv_vid1.cpp:319:3: error: ‘model’ was not declared in this scope
/home/pi/camcv/camcv_vid1.cpp: In function ‘int main(int, const char**)’:
/home/pi/camcv/camcv_vid1.cpp:711:5: error: ‘model’ was not declared in this scope
CMakeFiles/camcv.dir/build.make:146: recipe for target ‘CMakeFiles/camcv.dir/camcv_vid1.cpp.o’ failed
make[2]: *** [CMakeFiles/camcv.dir/camcv_vid1.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/camcv.dir/all’ failed
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
I have actually been able to fix a previous error by simply including
“/home/pi/opencv-2.4.9/modules/contrib/src/facerec.cpp”
on my camcv_vid1.cpp file since facerec.cpp contains the Eigenfaces type class and it was causing issues.
i have chage simply including
“/home/pi/opencv-2.4.9/modules/contrib/src/facerec.cpp” but it’s not such file or directory. Are you change CmakeLists.txt file? Need your help!
Hi Javier!
I’ve got the same error. But when i including “/home/pi/opencv-2.4.9/modules/contrib/src/facerec.cpp” then meet error: no such file or directory? Are you change CMakeLists.txt? Need your help!
Hi Javier!
I’ve got the same error. But when i including “/home/pi/opencv-2.4.9/modules/contrib/src/facerec.cpp” then meet error: no such file or directory? Are you change CMakeLists.txt? i use opencv-2.4.9. Need your help!
Hello Tuân Nguyễn, If you get this error no such file or directory, manually find the file. Maybe use the ‘find’ command or start a session of Raspbian (startx) and find the file and include the real path.
Thank you Javier! It worked 🙂
Hi Javier?
Finally I compile everything successfully on my Pi cam
But after ./camcv
I can see just:
init done
opengl support available
then nothing else , while red light of camera is on
Did you have same problem when you do?And how to solve it?
Hey Guys,
I’ve tried all the things you mention and I’m still getting the “Eigenfaces does not name a type” error. Any other ideas?
Thanks!!
The issue seems to be that Pierre used OpenCV 2.3 + libfacerec 0.04 but OpenCV 2.4.1 (the latest package) integrates libfacerec 0.05, which has a new API (http://bytefish.de/dev/libfacerec/facerec_api.html). I’m trying to figure out how to rewrite the code to work with this change…
I followed every step and at last I found this issue:
(init) webcam initialized :ok
(E) Capture Device cannot be opened.
But I passed the video test and picture capture in the previous step.
Anyone have good idea?
Thanks!
This happened to me at some point too. I went ahead and deleted my CMakeFiles directory and the CMakeCache.txt in camcv, ran
cmake .
make
sudo apt-get update
sudo apt-get upgrade
and then it worked for me. Was this the only error that was output?
I have the following error:
start
(init) prediction treeshold = 4500.0 by default
(init) People initialized
(init) 10 pictures read to train
(init) 10 pictures of Pierre (0) read to train
(init) 0 pictures of Natacha (1) read to train
(init) 0 pictures of Mona Lisa (2) read to train
(init) 0 pictures of Lisa (3) read to train
(init) taille images ok
(init) start train images
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed) in reshape, file /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/core/src/matrix.cpp, line 801
terminate called after throwing an instance of ‘cv::Exception’
what(): /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/core/src/matrix.cpp:801: error: (-13) The matrix is not continuous, thus its number of rows can not be changed in function reshape
Abgebrochen
Anyone have good idea?
Thanks!
when i run ./camcv faces.csv 1 5500 and wait for a long time but program says:
-init done
-opendgl support avaible
The red light of camera is on
and thats all, notking more happens, i can’t see camcv window appear
Anyone can help me?
Can someone please help…
I’ve got everything working and the training working. I can get Magic Mirror 1 to ‘classify’ a face as belonging to someone, but this version recognises faces, but doesn’t say who it is!
Please help!
And I’ve got it all working! 30fps even with face detection…. now to work on improving recognition!
@ Keukpa let me know please if you manage to get decent recognition out of this ? I never managed…
I wonder if anyone has tried this with the new PI a lot more processing power available may give a clever sod the opportunity to improve the recognition to a point where it may be useful.
i compiled the code but got this error
(init) People initialized
(init) 21 pictures read to train
(init) 0 pictures of Natacha (0) read to train
(init) 21 pictures of Abhi (1) read to train
(init) 0 pictures of Mona Lisa (2) read to train
(init) 0 pictures of Lisa (3) read to train
(init) taille images ok
(init) start train images
(init) train images : ok
(E) face cascade model not loaded :/usr/share/opencv/haarcascades/lbpcascade_frontalface.xml
can someone help please …
I ran this on a Pi 2 with openCV 2.4. You need to edit camcv_vid1.cpp and look for this line:
fn_haar = “/usr/share/opencv/haarcascades/lbpcascade_frontalface.xml”;
change it to:
fn_haar = “/usr/share/opencv/lbpcascades/lbpcascade_frontalface.xml”;
I installed the locate utility (sudo apt-get install locate) and ran updatedb. You can then type:
locate frontalface (or any part of the filename) and it will tell you where it is.
Hope this helps.
I’m trying to get a good face recognition, but I never reach a threashold of 5000 or more. Max my threashold is of 4000 using haarcascade_frontalface_alt.xml
I have 30-40 photo of two different people but recognition often fail.
I made many hack for correctly compile the code, following comments in tutorial posts.
There are others suggest to me ?
my opencv version is 2.4.1 but I link libfacerec0.4 as shown in tutorial
I try using opencv 2.3.1 too, I have same bad results in classification.
Increasing photo dimension (150×150) in training step I improve the score, now I can reach 5000 and more, but using two people it give wrong result yet.
you wont. is the short answer… it is a proof of concept thing. I haven’t heard of anyone getting it to be reliable enough to do something practical with it.. I’m still watching the post as I hope some one (maybe Pierre) will use the new PI and solve the inaccuracies…
In pierre’s video, the results are better than my test using same code. I think that light is an important factor for bad classification.
After reading libfacerec documentation I tried LBPH model insted of fisherfaces or eigenfaces, and I can reach results similar to pierre’s video but with a lower fps. Lbph model is more hard to run for raspberry pi 2.
For better result I use haarcascade_frontalface_alt.xml in face detection function
i’m stuck in the same problem here :
– i’m using Opencv 2.4.9 and the libfacerec 0.0.4 and when i compile it shows /home/pi/test/libfacerec-004/include/facerec.hpp:33:7: error: redefinition of ‘class cv::FaceRecognizer’
anyone has solved this???
you need to comment this line :
#include “opencv2/contrib/contrib.hpp”
I suggest you to start with opencv 2.3.1, then follow this tutorial, otherwise you need more other trick to make think working, all answer is in comment section of step by step tutorial.
I’ve got the same error as Ayman:
pi@raspberrypi ~/camcv $ make
[ 7%] Building CXX object CMakeFiles/camcv.dir/camcv_vid1.cpp.o
In file included from /home/pi/camcv/camcv_vid1.cpp:59:0:
/home/pi/pierre/libfacerec-0.04/include/facerec.hpp:33:7: error: redefinition of ‘class cv::FaceRecognizer’
/usr/include/opencv2/contrib/contrib.hpp:921:22: error: previous definition of ‘class cv::FaceRecognizer’
tried to remove:
#include “opencv2/contrib/contrib.hpp”
from camcv_vid1.cpp and then got the message:
pi@raspberrypi ~/camcv $ make
[ 7%] Building CXX object CMakeFiles/camcv.dir/camcv_vid1.cpp.o
make[2]: *** No rule to make target ‘/home/pi/pierre/libfacerec-0.04/libopencv_facerec.a’, needed by ‘camcv’. Stop.
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/camcv.dir/all’ failed
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
any ideas?
p.s. I have changed camcv_vid0.c from previous step into camcv_vid1.cpp in CMakeLists.txt and put in CMakeLists.txt lines:
link_directories( /home/pi/pierre/libfacerec-0.04 )
/home/pi/pierre/libfacerec-0.04/libopencv_facerec.a —>this one is in “target_link_libraries”
@frezo, what did u do to solve the “no rule to make target” facerec.a problem?
please help me im at step 2
when i tried to make the the error came
No rule to make target ‘home/pi/git/raspberrypi/userland/lib/libmmal_util.so’
Hello, first of all I want to thank for this excellent tutorial, it’s been very helpful!
I got stuck on this step for a while and I can’t find the problem. After the command sudo make I get the following message on the terminal:
Linking CXX executable camcv
CMakeFiles/camcv.dir/camcv.cpp.o: In function `main’:
camcv.cpp:(.text+0x1354): undefined reference to `mmal_status_to_int(MMAL_STATUS_T)’
collect2: ld returned 1 exit status
CMakeFiles/camcv.dir/build.make:428: recipe for target ‘camcv’ failed
make[2]: *** [camcv] Error 1
CMakeFiles/Makefile2:63: recipe for target ‘CMakeFiles/camcv.dir/all’ failed
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
Makefile:75: recipe for target ‘all’ failed
make: *** [all] Error 2
I assume it has something to do with my CMakeLists.txt, so I’ll post it as well:
cmake_minimum_required(VERSION 2.8)
project( camcv )
SET(COMPILE_DEFINITIONS -Werror)
#OPENCV
find_package( OpenCV REQUIRED )
link_directories( /home/pi/libfacerec-0.04 )
include_directories(/opt/vc/userland/host_applications/linux/libs/bcm_host/include)
include_directories(/opt/vc/userland/host_applications/linux/apps/raspicam/gl_scenes)
include_directories(/opt/vc/userland/interface/vcos)
include_directories(/opt/vc/userland)
include_directories(/opt/vc/userland/interface/vcos/pthreads)
include_directories(/opt/vc/userland/interface/vmcs_host/linux)
include_directories(/opt/vc/userland/interface/khronos/include)
include_directories(/opt/vc/userland/interface/khronos/common)
include_directories(./gl_scenes)
include_directories(.)
include_directories(/opt/vc/include)
include_directories(/opt/vc/include/interface/vcos)
include_directories(/opt/vc/include/interface/vcos/pthreads)
include_directories(/opt/vc/include/interface/vmcs_host/linux)
include_directories(/usr/include/c++/4.6)
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.cpp RaspiTex.c RaspiTexUtil.c gl_scenes/teapot.c gl_scenes/models.c gl_scenes/square.c gl_scenes/mirror.c gl_scenes/yuv.c gl_scenes/sobel.c tga.c)
target_link_libraries(camcv /opt/vc/lib/libmmal_core.so /opt/vc/lib/libmmal_util.so /opt/vc/lib/libmmal_vc_client.so /opt/vc/lib/libvcos.so /opt/vc/lib/libbcm_host.so /opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so pthread -lm ${OpenCV_LIBS})
I’ve tried everything, I hope someone can help
Thanks a lot in advance!!
HI,
I having the following error
fatal error: bcm_host.h: No such file or directory
compilation terminated.
CMakeFiles/reco.dir/build.make:54: recipe for target ‘CMakeFiles/reco.dir/camcv_vid1.cpp.o’ failed
make[2]: *** [CMakeFiles/reco.dir/camcv_vid1.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/reco.dir/all’ failed
make[1]: *** [CMakeFiles/reco.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
Can anyone help please?
hello , should id do all the steps to make the face recognition . I installed OpenCV
plz answer me as soon as possible
Hello, should I do all the steps if I want to make a face recognition
Plz help me!!
Yes if you want to write it in c , but no if you find an easiest Way in Python with usb cam…
Ok, but I didn’t find any source code in Python, I have project and I don’t know how to do!
Thanks for your reply
Hello Pierre !
First of all thank you for this amazing project.
but i have a question for you, i have done this project and i have done the csv file and trained the images but the problem is that it not recognizing anyone and if it recognize then its worng i mean it gives the worn id . what should i do ?
I wonder if anyone got this to work with OpenCV 2.4 or later? I have tried several tips posted in the comments but was unable to compile it properly and I am also having troubles building OpenCV 2.3.1 on my current version of raspbian.
I believe Pierre has probably moved on by now but hopefully someone that understands C++ code better than me got some interested on this project and ported it to the new versions of OpenCV?
Would love to know.
Hi Pierre,
Thank you for a smashing job on the tutorials!
But need your help on the video_buffer_callback mods and I got this ->
root@raspberrypi:~/camcvvidface# make
[ 7%] Building CXX object CMakeFiles/camcvvidface.dir/camcvvidface.cpp.o
[ 15%] Building C object CMakeFiles/camcvvidface.dir/RaspiTex.c.o
[ 23%] Building C object CMakeFiles/camcvvidface.dir/RaspiTexUtil.c.o
[ 30%] Building C object CMakeFiles/camcvvidface.dir/tga.c.o
[ 38%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/teapot.c.o
[ 46%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/models.c.o
[ 53%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/square.c.o
[ 61%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/mirror.c.o
[ 69%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/yuv.c.o
[ 76%] Building C object CMakeFiles/camcvvidface.dir/gl_scenes/sobel.c.o
Linking CXX executable camcvvidface
CMakeFiles/camcvvidface.dir/camcvvidface.cpp.o: In function `video_buffer_callback(MMAL_PORT_T*, MMAL_BUFFER_HEADER_T*)’:
camcvvidface.cpp:(.text+0xb90): undefined reference to `cv::Eigenfaces::predict(cv::_InputArray const&, int&, double&) const’
collect2: ld returned 1 exit status
CMakeFiles/camcvvidface.dir/build.make:429: recipe for target ‘camcvvidface’ failed
make[2]: *** [camcvvidface] Error 1
CMakeFiles/Makefile2:60: recipe for target ‘CMakeFiles/camcvvidface.dir/all’ failed
make[1]: *** [CMakeFiles/camcvvidface.dir/all] Error 2
Makefile:72: recipe for target ‘all’ failed
make: *** [all] Error 2
Thank you in advance.
Hi,thank you for ths tuto ,it s very useful,can you help me ,i wann to compare two faces with opencv and pyrhon with raspberry
hi,
is possible have complet File please ? camcv.c and CMakeLists.txt ?
Thank all
Hey! Nice Project! I am looking for a similar Project. I want to use the Pi with camera to check if an object leaves a predefined circle or zone. Are there some Projects who do this or is this easy to code? Maybe the object is colored and the camera follows it?
I would appreciate your help very much!
Hi! first, thanks a lot for this tutorial!
But I always get the same Error and can not solve it, hope someone can help me here, thanks!!!
pi@raspberrypi:~/camcv$ ./facerec csv.txt 0 5000
start
(init) People initialized
(init) 30 pictures read to train
(init) 10 pictures of Pierre (0) read to train
(init) 7 pictures of Natacha (1) read to train
(init) 6 pictures of Mona Lisa (2) read to train
(init) 7 pictures of Lisa (3) read to train
(init) taille images ok
(init) start train images
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed) in reshape, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp, line 802
terminate called after throwing an instance of ‘cv::Exception’
what(): /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp:802: error: (-13) The matrix is not continuous, thus its number of rows can not be changed in function reshape
Aborted
Does anyone can help me, pls! =)
Hi,
Thanks for this useful tutorial! But I got an error, which I can not solve. Hopf someone can help me!
pi@raspberrypi:~/camcv$ ./facerec csv.txt 0 5000
start
(init) People initialized
(init) 30 pictures read to train
(init) 10 pictures of Pierre (0) read to train
(init) 7 pictures of Natacha (1) read to train
(init) 6 pictures of Mona Lisa (2) read to train
(init) 7 pictures of Lisa (3) read to train
(init) taille images ok
(init) start train images
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed) in reshape, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp, line 802
terminate called after throwing an instance of ‘cv::Exception’
what(): /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp:802: error: (-13) The matrix is not continuous, thus its number of rows can not be changed in function reshape
Aborted
Thanks!!! =)
Hello. I remember, this occurs when all pictures were not same size or when the config file (with list of pictures) has blank lines.
I have check both of this issues. I use the 100×100 pics from step 9 and also the csv.txt from step 9.
This error can be solved, if I change the seperator from the csv.txt to comma. But the I will get this:
./frec tes.csv 0 5000
start
(init) People initialized
(OK) csv=tes.csv
(init) 0 pictures read to train
(init) 0 pictures of Emmy (0) read to train
(init) 0 pictures of MALE (1) read to train
(init) 0 pictures of FEMALE (2) read to train
(OK) read CSV ok
Segmentation fault
Ok, I got solve everything! Thanks a lot Pierre for this tut! =)
Could you please tell me how did you fixed that? please
Hello, could you please tell me how did you solve this?
Hello, could youu please tell me how did you fix this?
Hi,
instead of using libfacerec v0.04, I use the libfacerec v0.05 and instead of OpenCV2.3 I use OpenCV 2.4. Due to this, u have to change/modify some lines:
line 80:
Ptr model = createEigenfaceRecognizer();
line 322 change to:
model->predict(face_resize, prediction,predicted_confidence);
line 743 change to:
model->train(images, labels);
I hope, I could help u.. =)
Is there a way to develop the face recognition using C instead of C++? I’m reading that OpenCV does support C (may be phasing it out in the future) so I’m wondering if I can use C. All applications I’ve seen use solely C++ since I’m guessing C++ is easier to implement using OpenCV. Any thoughts are appreciated!
I also have the Segmantation fault problem. can someone help me?
how to capture my face? always i should setting my background is black?
this program can’t catch to me .