Congratulation !, you’ve got your new rasperry pi camera ! Isn’t-it cute ?
But after first try, you discover that it’s not an usb-webcam. 😦 Thus, OpenCV doesn’t work natively. (forget cvCaptureFromCAM for example and all your wonderful apps you’ve thought up !)
However, some nice apps (such as raspivid or raspistill) controls the pi camera using MMAL functions.
The idea is to modify source code of such apps, use buffer memory of the camera to feed OpenCV image objects. Pretty easy (said like that).
This could be done in 7 steps, because of 7 :
- step 1 : install csi webcam
- step 2 : installation and compilation of userland-master (including mmal and raspicam tools)
- step 3 : create your own project
- step 4 : link with OpenCV libraries
- step 5 : basic use of OpenCV and Pi camera : display an image from camera
- step 5.5 : use many snapshots to emulate a video (slow)
- step 6 : capture video within OpenCV window !
- Step 7 : Face recognition (magic mirror release 2 🙂
Enjoy !
Hello, first of all I want to thank you for this excellent tutorial, its been of great help! I’ve been working on this 7th step for a while and I can’t make it work, I can’t figure out whats wrong.
After the command sudo make I get this text on the console:
root@raspberrypi:/home/piCam_step6/camcv# sudo make
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 the CMakeLists.txt file, so I’ll post it here 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})
For the record, I deleted the face recognition sections of the code, since I I-m trzing something else at the moment, for now I would like to have a real time camera, and be able to take a shot or video after pressing a button.
I would really appreciate if someone could help me with this.
Thanks in advance
Pingback: Rozpoznawanie twarzy na Raspberry Pi za pomocą OpenCV
I read all your posts but I couldn’t figure out how can I set EV compensation.
https://www.raspberrypi.org/documentation/raspbian/applications/camera.md
In this webpage, -ev command described as a manual exposure setting. I tried it and it works.
I checked all codes including raspicamstill.c but I couldn’t find any definition for -ev command.
Basicly, I want to take a picture with lowest exposure time and fastest ISO and put this RGB data into an array. How can I do this?
You state “you discover that it’s not an usb-webcam” surely one connect an USB Camera to the Pi and save a lot of trouble and compatibility?
Pingback: Michael Update – Week 3 | CSULB CECS 490 ServoArm
Can i use HDMI to CSI-2 module (B101) and do some image processing knowing that my source is not a camera but another sourse (PS4).
Hi,
is possible for you , do re -write this post complete and opérational for all in one shot ?.
Thank for World ^^
Ps: i stop on post 4. because i not anderstand where a cascade folder and fill need … english dificult where don’t have an good tuto ^^ (jock)
Thank
Pingback: #KITop3 Raspberry Pi und Machine Learning – 3 Projekte zum Nachbauen – Künstliche Intelligenz Blog
Hello, First of all thank you for this great post, I have a small doubt here though, I have been using USB camera made by Logitech, I was wondering if there is any different configuration process that i have to go through for setting this up.
Thanks in advance.
Reblogged this on Making Things.
Pingback: Raspberry Pi camera module openCV object tracking and following self balancing robot | Hillary Love Trump
sir I loved this project and really wanted to make this can you please make the coding for aurdino also , as I have to give the project on aurdino and I really wanted to make something like this amit.nayal24@gmail.com
Pingback: Raspberry Pi camera module openCV object tracking and following self balancing robot - PCB Board Manufacturer