I have a small chessboard and I put a geometric objects in the white squares, now I'm trying to extract them from the image using cv::findContours(), here my code and the source and result images:
int main (){
cv::Mat img = cv::imread("quad.jpg",0);
cv::Mat image ;
cv::Mat result(img.size(),CV_8U,cv::Scalar(255));
std::vector<std::vector<cv::Point>> contours;
//std::vector<std::vector<cv::Point2f>> hiararchy;
cv::threshold(img,img,127,255,CV_THRESH_BINARY_INV);
cv::findContours(img,contours,/*hiararchy,*/CV_RETR_TREE , CV_CHAIN_APPROX_NONE );
-1, // draw all contours
cv::Scalar(0), // in black
2); // with a thickness of 2
cv::imshow("result",result);
//cv::imwrite("con.jpg",result);
cv::waitKey(0);
return 0;
source
result
any idea how to tell the program : care only about the white squares
thanks!