Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从(视频)帧Intel Realsense获取RGB值时出现指针异常_C++_Pointers_Rgb_Intel_Realsense - Fatal编程技术网

C++ 从(视频)帧Intel Realsense获取RGB值时出现指针异常

C++ 从(视频)帧Intel Realsense获取RGB值时出现指针异常,c++,pointers,rgb,intel,realsense,C++,Pointers,Rgb,Intel,Realsense,我试图用Realsense SDK从一个帧中获取不同的RGB值。这适用于带有RGB的3D深度摄影机。根据我需要使用 int i = 100, j = 100; // fetch pixel 100,100 rs2::frame rgb = ... auto ptr = (uint8_t*)rgb.get_data(); auto stride = rgb.as<rs2::video_frame>().stride(); cout << "R=" << ptr[

我试图用Realsense SDK从一个帧中获取不同的RGB值。这适用于带有RGB的3D深度摄影机。根据我需要使用

int i = 100, j = 100; // fetch pixel 100,100
rs2::frame rgb = ...
auto ptr = (uint8_t*)rgb.get_data();
auto stride = rgb.as<rs2::video_frame>().stride();
cout << "R=" << ptr[3*(i * stride + j)];
cout << ", G=" << ptr[3*(i * stride + j) + 1];
cout << ", B=" << ptr[3*(i * stride + j) + 2];
这是我的密码。也许它与RS2_格式_RGB8有关


提前谢谢

步幅以字节为单位,行的长度以字节为单位,不需要与3相乘

cout << "  R= " << int(ptr[i * stride + (3*j)    ]);
cout << ", G= " << int(ptr[i * stride + (3*j) + 1]);
cout << ", B= " << int(ptr[i * stride + (3*j) + 2]);

啊,就是这样。谢谢但是我认为'3'站在错误的位置,对吗?库特
frameset frames = pl.wait_for_frames();
frame color = frames.get_color_frame();

uint8_t* ptr = (uint8_t*)color.get_data();
int stride = color.as<video_frame>().get_stride_in_bytes();

int i = 1000, j = 1000; // fetch pixel 100,100

cout << "R=" << int(ptr[3 * (i * stride + j)]);
cout << ", G=" << int(ptr[3 * (i * stride + j) + 1]);
cout << ", B=" << int(ptr[3 * (i * stride + j) + 2]);
cout << endl;
cout << "  R= " << int(ptr[i * stride + (3*j)    ]);
cout << ", G= " << int(ptr[i * stride + (3*j) + 1]);
cout << ", B= " << int(ptr[i * stride + (3*j) + 2]);