You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.9 KiB
61 lines
1.9 KiB
/**
|
|
* @file example_getRectFrame.cc
|
|
* @brief This file is part of UnitreeCameraSDK.
|
|
* @details This example that how to get depth frame
|
|
* @author ZhangChunyang
|
|
* @date 2021.07.31
|
|
* @version 1.0.1
|
|
* @copyright Copyright (c) 2020-2021, Hangzhou Yushu Technology Stock CO.LTD. All Rights Reserved.
|
|
*/
|
|
|
|
#include <UnitreeCameraSDK.hpp>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char *argv[]){
|
|
|
|
int deviceNode = 0; ///< default 0 -> /dev/video0
|
|
cv::Size frameSize(1856, 800); ///< default frame size 1856x800
|
|
int fps = 30; ///< default camera fps: 30
|
|
|
|
if(argc >= 2){
|
|
deviceNode = std::atoi(argv[1]);
|
|
if(argc >= 4){
|
|
frameSize = cv::Size(std::atoi(argv[2]), std::atoi(argv[3]));
|
|
}
|
|
if(argc >=5)
|
|
fps = std::atoi(argv[4]);
|
|
}
|
|
|
|
UnitreeCamera cam("stereo_camera_config.yaml"); ///< init camera by device node number
|
|
if(!cam.isOpened()) ///< get camera open state
|
|
exit(EXIT_FAILURE);
|
|
|
|
cam.setRawFrameSize(frameSize); ///< set camera frame size
|
|
cam.setRawFrameRate(fps); ///< set camera camera fps
|
|
cam.setRectFrameSize(cv::Size(frameSize.width >> 2, frameSize.height >> 1)); ///< set camera rectify frame size
|
|
cam.startCapture(); ///< disable image h264 encoding and share memory sharing
|
|
|
|
usleep(500000);
|
|
while(cam.isOpened()){
|
|
cv::Mat left,right;
|
|
if(!cam.getRectStereoFrame(left,right)){ ///< get rectify left,right frame
|
|
usleep(1000);
|
|
continue;
|
|
}
|
|
|
|
cv::Mat stereo;
|
|
// cv::flip(left,left, -1);
|
|
// cv::flip(right,right, -1);
|
|
cv::hconcat(left, right, stereo);
|
|
cv::flip(stereo,stereo, -1);
|
|
cv::imshow("Longlat_Rect", stereo);
|
|
char key = cv::waitKey(10);
|
|
if(key == 27) // press ESC key
|
|
break;
|
|
}
|
|
|
|
cam.stopCapture(); ///< stop camera capturing
|
|
|
|
return 0;
|
|
}
|