Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen UnaNancyOwen/main.cpp
Last active Mar 15, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.