Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
Last active March 15, 2018 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnaNancyOwen/d7df70bddf4ae8fa4f812c64e743b7e6 to your computer and use it in GitHub Desktop.
Save UnaNancyOwen/d7df70bddf4ae8fa4f812c64e743b7e6 to your computer and use it in GitHub Desktop.
How to workaround for high CPU usage when enable BUILD_WITH_OPENMP
// Set Color Stream format to YUYV insted of BGR8
rs2::config config;
config.enable_stream( rs2_stream::RS2_STREAM_COLOR, width, height, rs2_format::RS2_FORMAT_YUYV, fps );
// Start Pipline
const rs2::pipeline_profile pipeline_profile = pipeline.start( config );
// Retrieve Frameset
const rs2::frameset frameset = pipeline.wait_for_frames();
// Retrieve Color Frame from Frameset
const rs2::video_frame frame = aligned_frameset.get_color_frame();
const uint32_t width = frame.get_width();
const uint32_t height = frame.get_height();
// Retrieve cv::Mat from Color Frame, and Convert Color Space to BGR from YUYV using OpenCV.
cv::Mat image = cv::Mat( height, width, CV_8UC2, const_cast<void*>( frame.get_data() ) );
cv::cvtColor( image, image, cv::COLOR_YUV2BGR_YUYV );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment