how to streo camera?

Hi! I’m MinGu.

I have a Jetson TX2 board(LI-JETSON-KIT-IMX377CS-X).

I want to be able to handle a stereo camera.

Here is the code that controls the mono camera using opencv.

#include <opencv2/opencv.hpp>
#include

#define camera1 “nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)680, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”

int main(void)
{
/* camera connect /
cv::VideoCapture cap1(camera1);
if(!cap1.isOpened()){
std::cout<<“camera1 is not open\n”;
}
else{
std::cout<<“camera1 is open\n”;
}
/
*****************/

/* Show the preview ********************************************************/
cv::Mat video;
cv::namedWindow("camera1");

while(true){
    cap1>>video;
    cv::imshow("camera1",video);
        
    //if press keyboard
    if(cv::waitKey(5)>=0)
         break;
}
/***************************************************************************/

cv::destroyAllWindows();
return 0;

}

How do i control a stereo camera from the code above?
And where can i find sample code or documentation?

This may depend on your stereo camera, but taking a ZED as example, it sends a single image that is just two images (one from each sensor) side by side. So you would manage it as a single camera. You would just adjust the memory type, width, height, framerate and format according to your camera (and maybe format conversions), but this depends on your camera and opencv version. You may give more details for better advice.

What you’ll do from that double image in order to make a 3D or disparity model is a long story I cannot tell, but you may check calib3d and this tutorial.

Thank you for answering my question.

I want to operate two camera.

I found the answer.

I modified the part of the code that define ‘camera1’. As follows.

“nvcamerasrc sensor-id=1 ! video/x-raw(memory:NVMM), width=(int)680, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”

I add ‘sensor-id=1’. Then the second camera worked.