Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "opencv2/highgui/highgui.hpp"
- #include "opencv2/imgproc/imgproc.hpp"
- using namespace cv;
- using namespace std;
- int main(int argc, char *argv[]) {
- Mat input_image = imread(argv[1], 0);
- Mat canny_op;
- Canny(input_image, canny_op, 100, 200, 3);
- vector<vector<Point> > contours;
- vector<Vec4i> hierarchy;
- findContours( canny_op, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE, Point(0, 0) );
- cout << "Size of contours [vector] is " << contours.size() << endl;
- cout << "Size of hierarchy [vector] is " << hierarchy.size() << endl;
- // Draw contours
- Mat drawing = Mat::zeros( input_image.size(), CV_8UC3 );
- for( int i = 0; i< contours.size(); i++ ) {
- cout << i << endl;
- Scalar color(0,0,255);
- drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );
- }
- namedWindow("output here", 1);
- imshow("output here", drawing);
- waitKey(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement