Hi,
How do i capture an image (using raspberry Py v2.0 camera) in openCV on the nano?
(raw so 8 bits for R,G,B total 24bit/pixel, 10bits would be better but well…)
The code I tried is below but doesn’t work.
If I don’t specify the capture (camera) it give an error so I looked around and found something but if I configure it like in the code below it still give an error
Any help would be appreciated, a simple code that captures an image.
Do I need to install additional components? If so please let me know.
thank!
#include <opencv2/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cv.hpp>
#include “opencv2/objdetect.hpp”
#include “opencv2/highgui.hpp”
#include “opencv2/imgproc.hpp”
#include
using namespace std;
using namespace cv;
int main()
{
VideoCapture cap;
//! from here:
// https://devtalk.nvidia.com/default/topic/1025356/how-to-capture-and-display-camera-video-with-python-on-jetson-tx2/
cap = VideoCapture(“udpsrc port=5000 ! application/x-rtp, encoding-name=H264, payload=96 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”, cv2.CAP_GSTREAMER);
// open the default camera, use something different from 0 otherwise;
// Check VideoCapture documentation.
if(!cap.open(0))
return 0;
for(;;)
{
Mat frame;
cap >> frame;
if( frame.empty() )
break; // end of video stream
imshow("Hello captured image :)", frame);
if (waitKey(10) == 27)
break; // stop capturing by pressing ESC
}
// the camera will be closed automatically upon exit
// cap.close();
return 0;
}
The error:
/home/nano/cv-hello/hello.cpp: In function ‘int main()’:
/home/nano/cv-hello/hello.cpp:17:21: error: expected primary-expression before ‘(’ token
cap = VideoCapture(“udpsrc port=5000 ! application/x-rtp, encoding-name=H264, payload=96 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”, cv.CAP_GSTREAMER);
^
/home/nano/cv-hello/hello.cpp:17:195: error: expected primary-expression before ‘.’ token
4dec ! videoconvert ! video/x-raw, format=(string)BGR ! appsink", cv.CAP_GSTREAMER);
^
CMakeFiles/cv_hello.dir/build.make:62: recipe for target ‘CMakeFiles/cv_hello.dir/hello.cpp.o’ failed
make[2]: *** [CMakeFiles/cv_hello.dir/hello.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/cv_hello.dir/all’ failed
make[1]: *** [CMakeFiles/cv_hello.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2