Skip to content Skip to sidebar Skip to footer

Opencv Core.line Draws White When Color Is Expected

In an OpenCv4Android environment, when I create a Mat image and use Core.line() to draw on the image, it always shows a white instead of the color I specify. I have seen a quest

Solution 1:

The problem is with the color you have initialized

publicstaticfinalScalarGREEN=newScalar(0,255,0); 

as per this statement

MatmatImage=newMat(bitmap.getHeight(), bitmap.getWidth(), CV_8UC4);`

you are creating a 4-channel Mat, but initializing the GREEN Scalar with 3 components only, hence the 4th component, which defines the color of fourth channel of your line, which is set of default value 0 in your case.

So, what you are perceiving as white color is transparent in reality. You may fix this either by creating matImage with CV_8UC3 or changing your GREEN scalar to be public static final Scalar GREEN = new Scalar(0,255,0, 255);

Post a Comment for "Opencv Core.line Draws White When Color Is Expected"