Of course, OpenCV must be already installed in your Pi. To do this, just follow the third step of my previous post “Magic Mirror”
1. Modify your CMakeFiles.txt to include OpenCV library cmake_minimum_required(VERSION 2.8)
project( camcv )
SET(COMPILE_DEFINITIONS -Werror)
#OPENCV
find_package( OpenCV REQUIRED )
#except if you’re pierre, change the folder where you installed libfacerec
#optional, only if you want to go till step 6 : face recognition
link_directories( /home/pi/pierre/libfacerec-0.04 )
include_directories(/opt/vc/userland/host_applications/linux/libs/bcm_host/include)
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)
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.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 /home/pi/pierre/libfacerec-0.04/libopencv_facerec.a ${OpenCV_LIBS})
2. Recompile. Should be ok. No change (of course!) since you didn’t modify your source code
make
./camcv
Actually, this was a pretty easy step !
Pingback: OpenCV and Pi Camera Board ! | Think RPI
Do you mean to say CMakeLists.txt rather than CMakeFiles.txt?
Bump, which directory are we talking about? ~/camcv/ this file does not exist, unless you mean CMakeLists.txt
Maybe there shouldn’t be a library in CMakeLists.txt
anyone figure this out?
make[2]: *** Keine Regel vorhanden, um das Target »libfacerec-0.04/libopencv_facerec.a«,
benötigt von »camcv«, zu erstellen. Schluss.
i checked out libfacerec-0.0.4 included the Path in CMakeLists.txt and got the error i already posted. if i omit that libopencv_facereg.a in target_link_librarys i get a bunch of camcv.c:(.text+0x1f4c): undefined reference to `cvXXXXX’ messages and it bails out.
Can you please give a tarball of your functioning installation of a reworked tutorial please?
As stated from the Developer of libfacerec:
“If you are in (a recent) OpenCV 2.4: There is no need to compile libfacerec yourself, you have everything to get started.”
Is it possible to adapt this tutorial to the acutal OpenCV Version with included libfacerec?
Thanks for your hard Work 😉
He said on his previous post “Magic Mirror” ( https://thinkrpi.wordpress.com/2013/04/05/step-3-install-softwares-for-webcam-and-computer-vision/ )
“Today (April, 2013), only OpenCV 2.3 is available for RPI. Unfortunatly, face reco API is only available on version 2.4. Thus, we will need to install OpenCV in two steps.”
I have installed OpenCV 2.4. But I think it will not serve us for this.. =(
Ah got it. You have to do cmake . and make in the libfacerec-0.4.0 directory.
If I run the program like so ‘./camcv’ I get all the command line options. Is this the same for everyone else? I instead have to run it like so ‘./camcv -t 1000’
help me! when i do the make i got this error:
CMake Error: Error in cmake code at
/home/pi/camcv/CMakeLists.txt:6:
Parse error. Expected a command name, got unquoted argument with text ” “.
— Configuring incomplete, errors occurred!
make: *** [cmake_check_build_system] Error 1
cmake_minimum_required(VERSION 2.8)
project( camcv )
SET(COMPILE_DEFINITIONS -Werror)
find_package( OpenCV REQUIRED )
link_directories( /home/pi/libfacerec )
include_directories(/opt/vc/host_applications/linux/libs/bcm_host/include)
include_directories(/opt/vc/interface/vcos)
…etc…etc
nevermind, it was an empty space 😀
I have the same problem with you… how did you solve it?
The space that Real said was actually at the end of the line with “link_directories”.
After ) you should delete every space there so that the ) is the last character of the line.Then I did cmake and make and all is good!
Every time i try “make” on ,camcv, i got this error:
— Configuring done
— Generating done
— Build files have been written to: /home/pi/camcv
make[2]: *** Sem regra para processar o alvo `/home/pi/libfacerec-0.04/libopencv_facerec.a’, necessário por `camcv’. Pare.
make[1]: ** [CMakeFiles/camcv.dir/all] Erro 2
make: ** [all] Erro 2
I get this error, anyone can help?
pi@raspberrypi /home/camcv $ sudo make
Scanning dependencies of target camcv
[ 14%] Building C object CMakeFiles/camcv.dir/RaspiCamControl.c.o
[ 28%] Building C object CMakeFiles/camcv.dir/RaspiCLI.c.o
[ 42%] Building C object CMakeFiles/camcv.dir/RaspiPreview.c.o
[ 57%] Building C object CMakeFiles/camcv.dir/camcv.c.o
[ 71%] Building C object CMakeFiles/camcv.dir/RaspiTex.c.o
In file included from /home/camcv/RaspiTex.c:47:0:
/home/camcv/gl_scenes/mirror.h:33:22: fatal error: RaspiTex.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/camcv.dir/RaspiTex.c.o] Error 1
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
make: *** [all] Error 2
Try adding “RaspiTex.c” in your CMakeLists.txt :
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.c RaspiTex.c)
Maybe you have to add a lot of others files. My CMakeLists looks like this:
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-master/host_applications/linux/libs/bcm_host/include)
include_directories(/opt/vc/userland-master/interface/vcos)
include_directories(/opt/vc/userland-master)
include_directories(/opt/vc/userland-master/interface/vcos/pthreads)
include_directories(/opt/vc/userland-master/interface/vmcs_host/linux)
include_directories(/opt/vc/userland-master/interface/khronos/include)
include_directories(/opt/vc/userland-master/interface/khronos/common)
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(.)
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.c 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 ${OPENCV_LIBS})
thank you very much Jennifer
thanks Jennifer. I couldn’t get it to compile and had loads of undefined references but coping your CMakeList did the trick.
I did have to change userland-master to userland though as for some reason I have userland.
guys I am having problem , where can I download the camcv.c file from can someone either send me this file or post a link because I have try searching for it and I can’t seem to find it , couldn’t complete step 3 either hence why I can’t complete this stage
I am getting following error at this step –
CMake error at CMAKELists.txt:4 (find_package):
Found package configuration file:
/home/pi/OpenCV-2.4.2/cmake/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be NOT FOUND
I have been struggling with the “OpenCV_FOUND FALSE” issue for a couple of weeks now and the only solution seems to be to simply NOT USE find_package( OpenCV REQUIRED )!
I have opencv working perfectly in my Mac OS X environment and there find_package is not used, so I did the same for my raspberry Pi!
In CMakeLists.txt do the following:
Add:
include_directories(/usr/local/include)
include_directories(/usr/local/lib)
and instead of ${OpenCV_LIBS} in target_link_libraries(…) add all opencv files from /usr/local/lib.
/usr/local/lib/libopencv_calib3d.so.2.4.8 /usr/local/lib/libopencv_contrib.so.2.4.8 /usr/local/lib/libopencv_core.so.2.4.8 /usr/local/lib/libopencv_features2d.so.2.4.8 /usr/local/lib/libopencv_flann.so.2.4.8
/usr/local/lib/libopencv_gpu.so.2.4.8 /usr/local/lib/libopencv_highgui.so.2.4.8 /usr/local/lib/libopencv_imgproc.so.2.4.8 /usr/local/lib/libopencv_legacy.so.2.4.8
/usr/local/lib/libopencv_ml.so.2.4.8
/usr/local/lib/libopencv_nonfree.so.2.4.8 /usr/local/lib/libopencv_objdetect.so.2.4.8 /usr/local/lib/libopencv_ocl.so.2.4.8
/usr/local/lib/libopencv_photo.so.2.4.8 /usr/local/lib/libopencv_stitching.so.2.4.8 /usr/local/lib/libopencv_superres.so.2.4.8
/usr/local/lib/libopencv_ts.a
/usr/local/lib/libopencv_video.so.2.4.8 /usr/local/lib/libopencv_videostab.so.2.4.8
What does this mean?
collect2: ld returned 1 exit status
make[2]: *** [camcv] Error 1
make[1]: *** [CMakeFiles/camcv.dir/all] Error 2
make: *** [all] Error 2
Hey,
I have the solution for all of your problems,
i forgot to copy the folders: ‘imv_examples’ and ‘gl_scenes’ in my ‘compile’-folder from the userland-folder.
Most of you forgot this (mv* takes only files, not folders).
Hope this helps you. (:
My CmakeList:
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)
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv.c 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})
After so long of smashing together scripts I still get an error.
CMakeFiles/camcv.dir/RaspiTex.c.o: In function `raspitex_init’:
RaspiTex.c:(.text+0x10d0): undefined reference to `vcsm_square_open’
collect2: error: ld returned 1 exit status
I’m still looking but any help would be appreciated.
Same here … after so much fixing I am landing in the same as bateboy. Any help?
lastest userland has error.
so I use old version userland.
if you want old version, click to below link.
https://drive.google.com/open?id=0B0zY0_cE5KkfYVczcC1vTkN2dW8