daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int main() {
  2. std::cout << "Hello, World!" << std::endl;
  3. sorting_contours();
  4. return 0;}
  5. void sorting_contours() {
  6.     Mat image = imread("6.jpg");
  7.     Mat orig = image.clone();
  8.     Mat gray;
  9.     cvtColor(image, gray, CV_BGR2GRAY);
  10.     threshold(gray, gray, 245, 255, CV_THRESH_BINARY);
  11.     Mat edged = imutils::auto_canny(gray);
  12.     vector<Vec4i> hierarchy;
  13.     vector<vector<Point>> contours;
  14.     cv::findContours(edged, contours, hierarchy, CV_RETR_EXTERNAL,
  15.                      CV_CHAIN_APPROX_SIMPLE);
  16.     vector<Rect> boundRect;
  17.     contours = imutils::sort_contours(contours, boundRect, imutils::SortContoursMethods::left_to_right);
  18.     Mat sortedImage = image.clone();
  19.     for (int i = 0; i < contours.size(); i++) {
  20.         sortedImage = imutils::label_contour(sortedImage, vector<vector<Point> >(1, contours[i]), i,
  21.                                              cv::Scalar(240, 0, 159));
  22.     }
  23.     imshow("left_to_right", sortedImage);
  24.     waitKey(0);
  25.  
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top