//Color Frame getters int getRealsenseColorWidth(int devID) { return rs_get_stream_width( device[devID].dev, device[devID].colorStreamToUse , &e ); }
//Depth Frame getters int getRealsenseDepthWidth(int devID) { return rs_get_stream_width( device[devID].dev, device[devID].depthStreamToUse , &e ); }
int RealSenseDevice::open() { rs_error * e = 0; ctx = rs_create_context(RS_API_VERSION, &e); int devices = rs_get_device_count(ctx, &e); if (devices == 0) { std::cerr << "no realsense capture device" << std::endl; return 1; } dev = rs_get_device(ctx, 0, &e); std::cout << "Realsense Device: " << rs_get_device_name(dev, &e) << std::endl; std::cout << "Realsense Serial: " << rs_get_device_serial(dev, &e) << std::endl; std::cout << "Realsense FW ver: " << rs_get_device_firmware_version(dev, &e) << std::endl; int framerate = 30; rs_enable_stream(dev, depthStream, 0, 0, RS_FORMAT_Z16, framerate, &e); int depthWidth = rs_get_stream_width(dev,depthStream,NULL); int depthHeight = rs_get_stream_height(dev,depthStream,NULL); rs_enable_stream(dev, colorStream, depthWidth, depthHeight, RS_FORMAT_RGB8, framerate, &e); rs_get_stream_intrinsics(dev,colorStream,&intrinsics,0); std::cout << "width:" << intrinsics.width << " height:" << intrinsics.height << " focalx:" << intrinsics.fx << " focaly:" << intrinsics.fy << " ppx:" << intrinsics.ppx << " ppy:" << intrinsics.ppy << " coeff0:" << intrinsics.coeffs[0] << " coeff1:" << intrinsics.coeffs[1] << " coeff2:" << intrinsics.coeffs[2] << " coeff3:" << intrinsics.coeffs[3] << std::endl; int colorWidth = rs_get_stream_width(dev,colorStream,NULL); int colorHeight = rs_get_stream_height(dev,colorStream,NULL); depthScale = rs_get_device_depth_scale(dev,0); std::cout << "depth image " << depthWidth << "x" << depthHeight << " scale:" << depthScale << std::endl; std::cout << "color image " << colorWidth << "x" << colorHeight << std::endl; rs_start_device(dev, &e); int res = pthread_create(&_thread, NULL, RealSenseDevice_freenect_threadfunc, this); if(res){ std::cerr << "error starting realsense thread " << res << std::endl; return 1; } depth_index = 0; return 0; }