Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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
Qt 如何将RGB32格式的QImage转换为OpenCV::mat?_Qt_Opencv_Qimage - Fatal编程技术网

Qt 如何将RGB32格式的QImage转换为OpenCV::mat?

Qt 如何将RGB32格式的QImage转换为OpenCV::mat?,qt,opencv,qimage,Qt,Opencv,Qimage,我有一个RGB32格式的图像 当我这样做时: cv::Mat depthMat(depthImg.height(),depthImg.width(),CV_8UC3,(uchar*)depthImg.bits(),depthImg.bytesPerLine()); 我得到了左边的图像。我实际上应该得到右边的图像。 好的!我知道了!RGB32具有8位R、8位G、8位B和8位Alpha。基本上是RGBA。因此,我们可以使用这个: cv::Mat depthMat(depthImg.height()

我有一个RGB32格式的图像 当我这样做时:

cv::Mat depthMat(depthImg.height(),depthImg.width(),CV_8UC3,(uchar*)depthImg.bits(),depthImg.bytesPerLine());
我得到了左边的图像。我实际上应该得到右边的图像。
好的!我知道了!RGB32具有8位R、8位G、8位B和8位Alpha。基本上是RGBA。因此,我们可以使用这个:

cv::Mat depthMat(depthImg.height(),depthImg.width(),CV_8UC4,(uchar*)depthImg.bits(),depthImg.bytesPerLine());

好的!我知道了!RGB32具有8位R、8位G、8位B和8位Alpha。基本上是RGBA。因此,我们可以使用这个:

cv::Mat depthMat(depthImg.height(),depthImg.width(),CV_8UC4,(uchar*)depthImg.bits(),depthImg.bytesPerLine());

你不能将你的QImage从RGB32转换成RGB888吗?这段代码应该和那个格式之王一起工作。。。或者尝试使用CV_32SC3而不是CV_8UC3。对此不确定……不!从RGB32转换为RGB888会改变颜色@Poko和,使用CV_32SC3也不起作用!好啊很抱歉我很高兴你解决了这个问题。你不能把你的QImage从RGB32转换成RGB888吗?这段代码应该和那个格式之王一起工作。。。或者尝试使用CV_32SC3而不是CV_8UC3。对此不确定……不!从RGB32转换为RGB888会改变颜色@Poko和,使用CV_32SC3也不起作用!好啊很抱歉我很高兴你解决了这个问题。