Get point image¶
Point images belongs to upper layer of synthetic data. To get this kind of data through GetStreamData()
, you need to start the EnableStreamData()
beforehand. It should be check not empty before use.
For detail process description, please see Get original binocular image Get stereo camera correction image .
It is recommended to use plugin to calculate depth: the depth map will be better with a higher frame rate. Please see Using the plugin to get data for detail.
Sample code snippet:
auto &&api = API::Create(argc, argv);
api->EnableStreamData(Stream::POINTS);
api->Start(Source::VIDEO_STREAMING);
cv::namedWindow("frame");
PCViewer pcviewer;
while (true) {
api->WaitForStreams();
auto &&left_data = api->GetStreamData(Stream::LEFT);
auto &&right_data = api->GetStreamData(Stream::RIGHT);
cv::Mat img;
cv::hconcat(left_data.frame, right_data.frame, img);
cv::imshow("frame", img);
auto &&points_data = api->GetStreamData(Stream::POINTS);
if (!points_data.frame.empty()) {
pcviewer.Update(points_data.frame);
}
char key = static_cast<char>(cv::waitKey(1));
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
break;
}
if (pcviewer.WasStopped()) {
break;
}
}
api->Stop(Source::VIDEO_STREAMING);
PCL is used to display point images above. Program will close when point image window is closed.
Complete code examples, see get_points.cc .
Attention
Sample code only compiles when PCL is ready. If your PCL was installed in a different directory, please set CMAKE_PREFIX_PATH
in tutorials/CMakeLists.txt to the path of PCLConfig.cmake
. You can find CMAKE_PREFIX_PATH
near find_package(PCL)
.