OpenCV Error: Assertion failed (src.type() == CV_8UC1) in cv::findNonZero?
I have the following code snippet which fails at the line where I call cv::findNonZero(... I dont know why, I did manual conversion on cmprResult and the type is still unchanged, which is type 16 according to the cout<<
cv::Mat cmprResult = cv::Mat::zeros(xrayImg.size(),CV_8U);
std::vector<cv::Point> pointsZeroXray;
cv::compare(xrayImg, 0, cmprResult, cv::CMP_EQ);
std::cout << "ompare Result " << cmprResult << std::endl;
std::cout << "type " << cmprResult.type() <<std::endl;
cmprResult.convertTo(cmprResult, CV_8UC1);
cv::findNonZero(cmprResult, pointsZeroXray);
std::cout << "nonzero after" << pointsZeroXray << std::endl;
std::cout << "finished comparing xray" << std::endl;