我不知道如何在下面列出的方法中使用 Scalar 类指定颜色?
Features2d.drawKeypoints(mKeyPoints_0, mKeyPoints_0, outImage, Scalar color, Features2d.DRAW_RICH_KEYPOINTS);
最佳答案
使用Scalar
指定颜色,取决于Mat
类型。尝试在灰度 Mat
上存储/绘制 Red
颜色将失败。
键入
CV_8UC1
- 灰度图像//8 bits per pixel and so range of [0:255]. Scalar color = new Scalar( 255 ) //For type: 16UC1, range of [0:65535]. For 32FC1 range is [0.0f:1.0f]
类型
CV_8UC3
- 3 channel 彩色图像// BLUE: color ordering as BGR Scalar color = new Scalar( 255, 0, 0 )
类型
CV_8UC4
- 带透明度的彩色图像//Transparent GREEN: BGRA with alpha range - [0 : 255] Scalar color = new Scalar( 0, 255, 0, 128 )
在问题中,drawKeyPoints
的第一个参数应该是您的源图像(Mat
)而不是关键点。代码会被编译,因为 MatOfKeyPoint
派生自 Mat
关于c++ - 如何使用 Scalar 类指定颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29301903/