StereoCamera - julian-steiner/Waveshare-Stereo-Camera GitHub Wiki
Stereo Camera
Connecting to the camera
To connect to the camera just create a camera object, this will automatically try to connect to the camera at the given ports
#include <StereoCamera.h>
waveshare::StereoCamera camera(2, 4);
Set the resolution of the camera
You can manually set the resolution of the camera, the maximum resolution is 720p The code examples and the example calibration is for a resolution of 720p
camera.setResolution({1280, 720});
Loading calibration data from previous calibrations
Provide the camera calibration file in xml or yml format Without loading a calibration file, you get the raw images from the sensors which could be distorted by the lenses The camera captures rectified stereo images when a calibration is loaded
camera.loadCalibrationData("calibration/CameraCalibration.xml");
Reading single images from the camera
The images are stored in Stereo Image objects which have functions for showing them and saving them to files
waveshare::StereoImage image;
image = camera.read();
Creating a video stream
The library provides a function to start a video stream in a separate thread enabling the user to execute code while the stream is running The stream has to be terminated before the end of the code to prevent errors
camera.startVideoStream("Stream Name");
// Do something
camera.endVideoStream();
Creating a depth map
For this step it is recommended that the camera is calibrated and the calibration is loaded otherwise the depth maps may be unusable The depthMaps are handled like the stereoImage but they are only one image and get saved to the directory provided
waveshare::DepthImage depthMap = camera.generateDepthMap();