Why bitwise_and does not compute intersection? [closed]
I have written this lines of code:
cv::Mat maskC(m_imgSize, CV_8UC1, cv::Scalar::all(0));
cv::Mat maskPC(m_imgSize, CV_8UC1, cv::Scalar::all(0));
cv::Mat maskIntersection(m_imgSize, CV_8UC1, cv::Scalar::all(0));
cv::imshow("maskC", maskC);
cv::imshow("maskPC", maskPC);
cv::imshow("maskIntersection", maskIntersection);
cv::waitKey();
PointVector contourCvx = convexingContour(contourIn);
PointVector plateContourCvx = convexingContour(plateContourIn);
cv::fillConvexPoly(maskC, contourCvx, cv::Scalar::all(255));
cv::fillConvexPoly(maskPC, plateContourCvx, cv::Scalar::all(255));
cv::bitwise_and(maskC, maskPC, maskIntersection);
double mi=-1, ma=-1;
cv::minMaxLoc(maskIntersection, &mi, &ma, 0, 0);
std::cerr << "(min,max) = (" << mi << "," << ma << ") ";
cv::imshow("maskC", maskC);
cv::imshow("maskPC", maskPC);
cv::imshow("maskIntersection", maskIntersection);
cv::waitKey();
But the maskIntersection
is not changed; it is still a zero matrix. The standard output is displaying: (min,max) = (0, 0)
every time.
Why bitwise_and
does not return the intersection of the two: maskC
and maskPC
?
Sorry, I have forgot to add the offset to the contours... please close it