0
我閱讀了很多帖子,但仍找不到解決方案。鏈接的庫是正確的,並且代碼可以很好地適用於許多其他openCV函數,但不適用於findContours。 我要發佈我的代碼:使用findContours時發生堆錯誤openCV
int check_broken(Mat src, Mat check){
vector<Mat> contours;
vector<Vec4i> hierarchy;
Mat check_gray,check_g;
cvtColor(src,check_gray,CV_BGR2GRAY);
threshold(check_gray,check_g,100,255,THRESH_BINARY);
namedWindow("ventana",CV_WINDOW_AUTOSIZE);
imshow("ventana",check_gray);
waitKey(0);
Mat dst(check.rows,check.cols,CV_8UC1,Scalar::all(0));
int count = 0;
findContours(check_g, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
for (int i = 0; i < contours.size() ; i = hierarchy[i][0]){
Rect r = boundingRect(contours[i]);
if(hierarchy[i][2]<0){
rectangle(check,Point(r.x,r.y), Point(r.x+r.width,r.y+r.height),Scalar(0,0,255),3,8,0);
count++;
}
}
namedWindow("ventana",CV_WINDOW_AUTOSIZE);
imshow("ventana",dst);
waitKey(0);
destroyWindow("ventana");
return 0;
}
我在編譯發佈模式,所有的庫相同版本的2413,我與VS10工作。我想知道如何處理這個問題。感謝幫助!
你的鏈接庫是*
編譯opencv_calib3d2413.lib opencv_contrib2413.lib opencv_core2413.lib opencv_features2d2413.lib opencv_flann2413.lib opencv_gpu2413.lib opencv_highgui2413.lib opencv_imgproc2413.lib opencv_legacy2413.lib opencv_ml2413。 LIB opencv_nonfree2413.lib opencv_objdetect2413.lib opencv_photo2413.lib opencv_stitching2413.lib opencv_superres2413.lib opencv_ts2413.lib opencv_video2413.lib opencv_videostab2413.lib 這些是爲釋放模式鏈接的庫,我確定它們是正確的 –
這些是發佈庫。一定要在發佈中運行你的代碼。還請顯示這些庫的路徑 – Miki