我有一个realsense SR300,但是当我在OpenCV的窗口中显示我的深度图像,它看起来太黑了。我怎样才能解决这个问题?当我运行真实的例子时,图像看起来不错,但这些例子使用OpenGL。但我的项目需要OpenCV。这里是我的代码:
int main(int argc, char ** argv)
{
// realsense camera setup
rs::log_to_console(rs::log_severity::warn);
// Create a context object. This object owns the handles to all connected realsense devices
rs::context ctx;
if (ctx.get_device_count() == 0)
{
throw std::runtime_error("No device detected. Is it plugged in?");
}
// Access the first available RealSense device
rs::device * dev = ctx.get_device(0);
// Configure depth to run at VGA resolution at 30 frames per second
dev->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 30);
rs::intrinsics depth_intrin;
rs::format depth_format;
depth_intrin = dev->get_stream_intrinsics(rs::stream::depth);
depth_format = dev->get_stream_format(rs::stream::depth);
cv::namedWindow("Send Display Image", CV_WINDOW_AUTOSIZE);
/* Set callbacks prior to calling start(). */
auto depth_callback = [depth_intrin, depth_format](rs::frame f)
{
cv::Mat image(cv::Size(640, 480), CV_16UC1,
(void*)f.get_data(), cv::Mat::AUTO_STEP);
cv::imshow("Send Display Image", image);
cv::waitKey(1000/80);
};
/* callback to grab depth fream and publish it. */
dev->set_frame_callback(rs::stream::depth, depth_callback);
// Start streaming
dev->start();
While(1)
{
}
return 0;
}
我不知道为什么我的图像是如此黑暗。我希望它看起来像Kinect的或Xtion当我从ROS运行openni_launch
当我做了“归一化深度”的步骤,我的新的8位图像看起来跳动,这意味着,图像中的所有像素变得很亮,那么很黑(所有像素的数量相同)。这有点奇怪。大约需要一秒钟才能变得非常光明,然后再过一秒钟才能变得非常黑暗,然后重复。你知道那可能是什么吗?也许一些自动曝光问题或相机的东西? – Pototo
当我将最大值和最小值设置为常量时,闪烁消失。当我看着一个静态物体时没有闪烁。当事情四处移动时,会发生闪烁。这是有道理的,因为至少alpha总是在变化。 – Pototo
您应该使用'make_depth_histogram()'来显示深度图。它有点花费时间,但可视化只能用于调试目的。 – Catree