1 | initial version |
first, please have a look at the harris_detector tutorial
you will see, that the output is a Mat with [0..1] float probabilites, you try at converting it to a visible image has 2 flaws:
if you convert from float to uchar, it will round any float value between 0 and 1 to either 0 or 1. you loose precision, and a value of 1 is still almost black (invisible), so you need a scale factor there:
corners.convertTo(corners, CV_8U, 255 );
then, convertTo() only changes the depth of your pixel type, not the number of channels ! (so your CV_8UC4 does not anything else than CV_8U). for this, you would need another :
Imgproc.cvtColor(corners, corners, Imgproc.COLOR_GRAY2BGRA);
2 | No.2 Revision |
first, please have a look at the harris_detector tutorial
you will see, that the output is a Mat with [0..1] float probabilites, you try your attempt at converting it to a visible image has 2 flaws:
if you convert from float to uchar, it will round any float value between 0 and 1 to either 0 or 1. you loose precision, and a value of 1 is still almost black (invisible), so you need a scale factor there:
corners.convertTo(corners, CV_8U, 255 );
then, convertTo() only changes the depth of your pixel type, not the number of channels ! (so your CV_8UC4 does not anything else than CV_8U). for this, you would need another :
Imgproc.cvtColor(corners, corners, Imgproc.COLOR_GRAY2BGRA);