I do not know how to specifiy a color using Scalar class in the below posted method?
Features2d.drawKeypoints(mKeyPoints_0, mKeyPoints_0, outImage, Scalar color, Features2d.DRAW_RICH_KEYPOINTS);
Color data holds the RGB values that define the color of the pixels in a texture. Scalar data on the other hand, defines properties of the texture such as shader inputs that define bumpiness, roughness or shininess. Essentially, color data exists to be seen, scalar data is used to calculate.
ScalarRepresents a 4-element vector. The type Scalar is widely used in OpenCV for passing pixel values. In this tutorial, we will use it extensively to represent BGR color values (3 parameters). It is not necessary to define the last argument if it is not going to be used.
A circle has a center and a radius. To draw a circle using OpenCV, we have to define the center and the radius. In OpenCV we have to include <imgproc. hpp> header because 'circle()' function is defined in this header.
Usage of Scalar
to specify color, depends on the Mat
type. Attempting to store/draw Red
color on a grayscale Mat
will fail.
Type CV_8UC1
- grayscale image
//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]
Type CV_8UC3
- 3 channel color image
// BLUE: color ordering as BGR
Scalar color = new Scalar( 255, 0, 0 )
Type CV_8UC4
- color image with transparency
//Transparent GREEN: BGRA with alpha range - [0 : 255]
Scalar color = new Scalar( 0, 255, 0, 128 )
In the question, the first parameter to drawKeyPoints
should be your source image(Mat
) and not keypoints. The code would have compiled because MatOfKeyPoint
is derived from Mat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With