由于 cv::findContours 函数,我有一个堆损坏错误。我需要帮助找出解决这个问题的方法。
int GetEndPoints(cv::Mat image)
{
cv::Mat imgBW = cv::Mat::zeros(image.rows, image.cols, CV_8UC1);
cv::cvtColor(image, imgBW, CV_BGR2GRAY);
std::cout << std::endl << imgBW.channels();
cv::threshold(imgBW, imgBW, 150, 255, cv::THRESH_BINARY);
cv::namedWindow("image", 0);
cv::imshow("image", imgBW);
std::vector<std::vector<cv::Point>> contours;
cv::Mat image1 = image.clone();
// Find the Contours
std::cout << std::endl << imgBW.channels();
cv::findContours(imgBW, contours, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
cv::drawContours(image1, contours, -1, cv::Scalar(255, 0, 0), 2, 8);
cv::namedWindow("contours", 0);
cv::imshow("contours", image1);
cv::waitKey();
return 0;
}