change camera logic

This commit is contained in:
2024-12-11 15:37:31 +01:00
parent 60ba177dc2
commit 7f786d5197

View File

@@ -293,13 +293,20 @@ void sendKobukiData(TKobukiData &data)
void CapnSend()
{
std::string pipeline = "libcamerasrc ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! appsink";
VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
if (!cap.isOpened())
VideoCapture cap;
if (!cap.open("/dev/video0", cv::CAP_V4L2))
{
cerr << "Error: Could not open camera" << endl;
cerr << "Error: Could not open camera with /dev/video0" << endl;
if (!cap.open("/dev/video1", cv::CAP_V4L2))
{
cerr << "Error: Could not open camera with /dev/video1" << endl;
if (!cap.open("/dev/media2", cv::CAP_V4L2))
{
cerr << "Error: Could not open camera with /dev/video1" << endl;
return;
}
}
}
Mat frame;
while (true)