How to crop circles (found with Hough Transform) in OpenCV?

前端 未结 4 1743
轻奢々
轻奢々 2021-01-25 13:04

I\'m using the code from the page. It works very well and I get a circle that I am looking for. All my image have only 1 circle and I have modified parameters of HoughCirc

4条回答
  •  忘了有多久
    2021-01-25 13:41

    You can define a Region of Interest (ROI) on your image based on the coordinates of the circle, then imwrite will only save the cropped portion:

    cv::Rect roi(x, y, w, h); // I let you do the math ;)
    cv::Mat cropped = original(roi);
    cv::imwrite("cropped.png", cropped);
    

提交回复
热议问题