[英]Recognizing rectangles in OpenCV Java
I'm trying to crop rectangles out of an image using OpenCV/Java. 我正在尝试使用OpenCV / Java从图像中裁剪出矩形。 I've been somewhat successful finding the lines that make up the rectangular sections I want to crop, but I'm having a hard time finding the best way to do the following: 我已经很成功地找到了要裁剪的矩形部分的线条,但是我很难找到执行以下操作的最佳方法:
Any guidance is appreciated! 任何指导表示赞赏!
I had been using OpenCV's Impgproc.HoughLinesP
, which produced the line segments seen in the question's screenshot. 我一直在使用OpenCV的Impgproc.HoughLinesP
,它生成了在问题的屏幕截图中看到的线段。 I ended up scrapping that path, opting for a combination of Imgproc.findContours
, Imgproc.contourArea
and Imgproc.boundingRect
instead. 我最终取消了该路径,而是选择了Imgproc.findContours
, Imgproc.contourArea
和Imgproc.boundingRect
的组合。 This approach worked for me, and allowed me to avoid writing a bunch of recursive line-combining code. 这种方法对我有用,并且使我避免编写一堆递归的行合并代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.