I build the source code as a ROS-NODE, and i rosrun the node in TX2 board
there is a Error :
Error “V4L2: Pixel format of incoming image is unsupported by OpenCV”
ERROR! Unable to open camera
what is the problem?
I use ROS-kinetic
ros build is completed correctly
source code is :
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
//VideoCapture cap(“nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”);
//Mat frame;
//— INITIALIZE VIDEOCAPTURE
VideoCapture cap(0);
// open the default camera using default API
//cap.open(-1);
// OR advance usage: select any API backend
//int deviceID = -1; // 0 = open default camera
//int apiID = cv::CAP_ANY; // 0 = autodetect default API
// open selected camera using selected API
//cap.open(deviceID + apiID);
// check if we succeeded
if (!cap.isOpened()) {
cerr << “ERROR! Unable to open camera\n”;
return -1;
}
cout << “Start grabbing” << endl
<< “Press any key to terminate” << endl;
for(;;)
{ Mat frame;
// wait for a new frame from camera and store it into ‘frame’
cap.read(frame);
// check if we succeeded
if (frame.empty()) {
cerr << “ERROR! blank frame grabbed\n”;
break;
}
// show live and wait for a key with timeout long enough to show images
imshow(“TJUAE”, frame);
if (waitKey(5) >= 0)
break;
}
return 0;
}