Created
June 7, 2018 18:58
-
-
Save adielfernandez/60b56e9c65109736f48381512593ab3f to your computer and use it in GitHub Desktop.
realsense2 to OF workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rs2::device_list _deviceList; | |
rs2::config _config; | |
rs2::pipeline _pipeline; | |
uint16_t *_depthBuff; | |
ofTexture _depthTex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup(){ | |
//get device info | |
rs2::context ctx; | |
_deviceList = ctx.query_devices(); | |
//enable device | |
string deviceSerial = _deviceList[deviceID].get_info(RS2_CAMERA_INFO_SERIAL_NUMBER); | |
_config.enable_device(deviceSerial); | |
//enable depth stream | |
_config.enable_stream(RS2_STREAM_DEPTH, -1, _depthWidth, _depthHeight, RS2_FORMAT_Z16, fps); | |
//start pipeline | |
_pipeline.start(_config); | |
} | |
update(){ | |
rs2::frameset frameset; | |
if(_pipeline.poll_for_frames(&frameset)) { | |
//get depth data | |
rs2::depth_frame depthFrame = frameset.get_depth_frame(); | |
_depthBuff = (uint16_t*)depthFrame.get_data(); | |
//load depth data into texture | |
_depthTex.loadData(_depthBuff, _depthWidth, _depthHeight, GL_LUMINANCE); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment