Ask Your Question
0

OpenCV Error: Assertion failed (src.type() == CV_8UC1) in cv::findNonZero?

asked 2016-11-30 15:33:31 -0600

Noo7 gravatar image

updated 2016-11-30 15:46:56 -0600

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;
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-11-30 16:39:09 -0600

Noo7 gravatar image

converting xrayImg to 1 channel image using

cv::cvtColor(xrayImg,xray1Channel,CV_BGR2GRAY);

solved the roblem.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-11-30 15:33:31 -0600

Seen: 14,069 times

Last updated: Nov 30 '16