void Run() { int win_w = 800; int win_h = 600; o3d3xx::FrameGrabber::Ptr fg = std::make_shared<o3d3xx::FrameGrabber>(this->cam_); o3d3xx::ImageBuffer::Ptr buff = std::make_shared<o3d3xx::ImageBuffer>(); // // Setup for point cloud // std::shared_ptr<pcl::visualization::PCLVisualizer> pclvis_ = std::make_shared<pcl::visualization::PCLVisualizer>(this->description_); pclvis_->setBackgroundColor(0, 0, 0); pclvis_->setSize(win_w, win_h); pclvis_->setCameraPosition(-3.0, // x-position 0, // y-position 0, // z-position 0, // x-axis "up" (0 = false) 0, // y-axis "up" (0 = false) 1); // z-axis "up" (1 = true) // use "A" and "a" to toggle axes indicators pclvis_->registerKeyboardCallback( [&](const pcl::visualization::KeyboardEvent& ev) { if (ev.getKeySym() == "A" && ev.keyDown()) { pclvis_->addCoordinateSystem(); } else if (ev.getKeySym() == "a" && ev.keyDown()) { pclvis_->removeCoordinateSystem(); } }); // // Setup for amplitude, depth, and confidence images // // used for all 2d images cv::namedWindow(this->description_, cv::WINDOW_NORMAL|cv::WINDOW_OPENGL); cv::resizeWindow(this->description_, win_w, win_h); int retval; double min, max; cv::Rect roi; // depth cv::Mat display_img; cv::Mat depth_colormap_img; // confidence cv::Mat conf_img; cv::Mat conf_colormap_img; // amplitude cv::Mat amp_colormap_img; cv::Mat raw_amp_colormap_img; bool is_first = true; while (! pclvis_->wasStopped()) { pclvis_->spinOnce(100); if (! fg->WaitForFrame(buff.get(), 500)) { continue; } //------------ // Point cloud //------------ pcl::visualization::PointCloudColorHandlerGenericField<o3d3xx::PointT> color_handler(buff->Cloud(), "intensity"); if (is_first) { is_first = false; pclvis_->addPointCloud(buff->Cloud(), color_handler, "cloud"); } else { pclvis_->updatePointCloud(buff->Cloud(), color_handler, "cloud"); } //------------ // 2D images //------------ // depth image cv::minMaxIdx(buff->DepthImage(), &min, &max); cv::convertScaleAbs(buff->DepthImage(), depth_colormap_img, 255 / max); cv::applyColorMap(depth_colormap_img, depth_colormap_img, cv::COLORMAP_JET); // confidence image: show as binary image of good pixel vs. bad pixel. conf_img = buff->ConfidenceImage(); conf_colormap_img = cv::Mat::ones(conf_img.rows, conf_img.cols, CV_8UC1); cv::bitwise_and(conf_img, conf_colormap_img, conf_colormap_img); cv::convertScaleAbs(conf_colormap_img, conf_colormap_img, 255); cv::applyColorMap(conf_colormap_img, conf_colormap_img, cv::COLORMAP_SUMMER); // amplitude cv::minMaxIdx(buff->AmplitudeImage(), &min, &max); cv::convertScaleAbs(buff->AmplitudeImage(), amp_colormap_img, 255 / max); cv::applyColorMap(amp_colormap_img, amp_colormap_img, cv::COLORMAP_BONE); cv::minMaxIdx(buff->RawAmplitudeImage(), &min, &max); cv::convertScaleAbs(buff->RawAmplitudeImage(), raw_amp_colormap_img, 255 / max); cv::applyColorMap(raw_amp_colormap_img, raw_amp_colormap_img, cv::COLORMAP_BONE); // stich 2d images together and display display_img.create(depth_colormap_img.rows*2, depth_colormap_img.cols*2, depth_colormap_img.type()); roi = cv::Rect(0, 0, depth_colormap_img.cols, depth_colormap_img.rows); depth_colormap_img.copyTo(display_img(roi)); roi = cv::Rect(depth_colormap_img.cols, 0, conf_colormap_img.cols, conf_colormap_img.rows); conf_colormap_img.copyTo(display_img(roi)); roi = cv::Rect(0, depth_colormap_img.rows, amp_colormap_img.cols, amp_colormap_img.rows); amp_colormap_img.copyTo(display_img(roi)); roi = cv::Rect(depth_colormap_img.cols, depth_colormap_img.rows, raw_amp_colormap_img.cols, raw_amp_colormap_img.rows); raw_amp_colormap_img.copyTo(display_img(roi)); cv::imshow(this->description_, display_img); // `ESC', `q', or `Q' to exit retval = cv::waitKey(33); if ((retval == 27) || (retval == 113) || (retval == 81)) { break; } } // end: while (...) }
void vss_doslideshow( VSS_INFO *vss_info ) { GEM_WINDOW *wprog ; int (*OnKeyPressed)(int key) ; INFO_IMAGE inf ; MFDB mfdb ; CMD *cmd ; int fini = 0 ; int current_pal[256*3] ; int n ; int load_ret ; OnKeyPressed = GemApp.OnKeyPressed ; GemApp.OnKeyPressed = OnKeyPressedSldShow ; get_tospalette( current_pal ) ; cmd = vss_info->cmds ; if ( cmd == NULL ) fini = 1 ; if ( vss_info->do_not_show_mouse ) v_hide_c( handle ) ; /* Prend la configuration courante */ vss_info->wait_mini_sec = config.wait_mini_sec ; vss_info->do_not_show_mouse = config.do_not_show_mouse ; vss_info->do_not_cls_scr = config.do_not_cls_scr ; vss_info->back = config.back ; vss_info->display_type = config.display_type ; vss_info->transition = config.transition ; vss_info->cycle = config.cycle ; vss_info->ignore_vss = config.ignore_vss ; vss_info->aff_name = config.aff_name ; vss_info->aff_prog = config.aff_prog ; if ( Truecolor ) { int rvb_blanc[3] = { 1000, 1000, 1000 } ; int rvb_noir[3] = { 0, 0, 0 } ; vs_color(handle, 20, rvb_blanc) ; vs_color(handle, 21, rvb_noir) ; } stop_sldshow = 0 ; num_courant = 0 ; wprog = DisplayStdProg( "", "", "", 0 ) ; GWShowWindow( wprog, 0 ) ; while ( !fini ) { nb_steps = 0 ; switch( cmd->cmd_id ) { case CMD_DISPLAY : load_ret = load_nextimg( cmd->params, &mfdb, &inf, vss_info, wprog ) ; if ( load_ret == 0 ) { compute_colors( vss_info, &inf ) ; if ( ( num_courant > 0 ) && ( wait_for_event( vss_info ) < 0 ) ) fini = 1 ; else { sldcls_screen( vss_info, &inf ) ; display_img( &mfdb, &inf, vss_info, cmd->params ) ; } } if ( load_ret == 0 ) { if ( inf.palette != NULL ) free( inf.palette ) ; if ( mfdb.fd_addr != NULL ) free( mfdb.fd_addr ) ; } nb_steps++ ; break ; default : /* Impossible */ break ; } for (n = 0; n < nb_steps; n++ ) { if ( cmd != NULL ) { cmd = cmd->next_cmd ; num_courant++ ; } if ( (cmd == NULL ) && vss_info->cycle ) { cmd = vss_info->cmds ; num_courant = 0 ; } } if ( stop_sldshow || !cmd ) fini = 1 ; } if ( !cmd ) { PerfInfo.total_load_time = 0 ; wait_for_event( vss_info ) ; } restore_gemscreen( GemApp.Menu ) ; set_tospalette( current_pal, nb_colors ) ; if ( vss_info->do_not_show_mouse ) v_show_c( handle, 1 ) ; GWDestroyWindow( wprog ) ; GemApp.OnKeyPressed = OnKeyPressed ; }