Hello,
I read on the forums that gstreamer can be used to access the on-board camera stream
Is there some code/guideline available on how to access the camera feed and get frames for processing?
However I am facing errors while trying to do it in C++ and OpenCV2.4.11 that I compiled from source.
here is the error,
ubuntu@tegra-ubuntu:~/code/camera$ ./bin
(bin:16258): GStreamer-WARNING **: 0.10-style raw video caps are being created. Should be video/x-raw,format=(string).. now.
0123
Available Sensor modes :
2592 x 1944 FR=30.000000 CF=0x10d9208a isAohdr=0
2592 x 1458 FR=30.000000 CF=0x10d9208a isAohdr=0
1280 x 720 FR=120.000000 CF=0x10d9208a isAohdr=0
2592 x 1944 FR=24.000000 CF=0x10d9208a isAohdr=1
NvCameraSrc: Trying To Set Default Camera Resolution. Selected 640x480 FrameRate = 30.000000 ...
GStreamer Plugin: Embedded video playback halted; module nvcamerasrc0 reported: Internal data flow error.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in icvStartPipeline, file /home/ubuntu/opencv-2.4.11/modules/highgui/src/cap_gstreamer.cpp, line 383
terminate called after throwing an instance of 'cv::Exception'
what(): /home/ubuntu/opencv-2.4.11/modules/highgui/src/cap_gstreamer.cpp:383: error: (-2) GStreamer: unable to start pipeline
in function icvStartPipeline
Aborted
ubuntu@tegra-ubuntu:~/code/camera$
For the following code:
//using g++ opencv.cpp `pkg-config --cflags --libs opencv`
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int, char**)
{
VideoCapture cap("nvcamerasrc ! 'video/x-raw, format=(string)RGB, width=(int)640, height=(int)480 ! ffmpegcolorspace ! video/x-raw-rgb ! appsink");
const char* env = "GST_DEBUG=*:3";
putenv((char*)env);
cout<< "0";
cout<< "1";
if(!cap.isOpened())
{
cout << "cant open camera" << endl;
return -1;
}
cout<<"2";
Mat frame;
for(;;)
{
cout <<"3";
cap >> frame; // get a new frame from camera
cout << "4";
imwrite("1.png", frame);
cout<< "5";
}
return 0;
}
Is there some code/guideline available on how to access the camera feed and get frames for processing?
Regards,
Ankit