Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, check the type of your image (CurrentMat). If it is a single channel image, the rectangle will be drawn in gray. Then you can use cv::cvtColor() function to convert the image into a RGB image.

cv::cvtColor(CurrentMat, CurrentMat_RGB, CV_GRAY2RGB);

Hi, check the type of your image (CurrentMat). If it is a single channel image, the rectangle will be drawn in gray. Then you can use cv::cvtColor() function to convert the image into a RGB image and draw the rectangle in this image.

cv::Mat CurrentMat_RGB;
cv::cvtColor(CurrentMat, CurrentMat_RGB, CV_GRAY2RGB);

CV_GRAY2RGB); rectangle( CurrentMat_RGB, matchLoc, Point( matchLoc.x + TemplateMat.cols , matchLoc.y + TemplateMat.rows ), Scalar(0,0,255), 2, 8, 0);