c++ - how to examin white quads in opencv -


i have small chessboard , put geometric objects in white squares, i'm trying extract them image using cv::findcontours(), here code , source , 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 contours cv::scalar(0), // in black 2); // thickness of 2     cv::imshow("result",result);     //cv::imwrite("con.jpg",result);     cv::waitkey(0);      return 0; 

source

source

result

result

any idea how tell program : care white squares

thanks!

use hough transform find longest lines in image. give grid of checkerboard. next can check average pixel colour within each "cell" on grid determine whether it's black or white square.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -