简体   繁体   English

OpenCV C ++从矩形区域设置ROI

[英]OpenCV C++ set ROI from a rectangular area

Anyone know how to set ROI based on image bellow? 有谁知道如何根据图像波纹度设置ROI?

I used Hough Transform to detect the white line and draw the red line into the image. 我使用了Hough变换来检测白线并将红线绘制到图像中。 What I need to do is to set the ROI in the rectangle. 我需要做的是在矩形中设置ROI。

Since Hough Transform unable to get location of each rectangle and the main problem is I cannot defined the location (x,y) manually. 由于霍夫变换无法获取每个矩形的位置,并且主要问题是我无法手动定义位置(x,y)。

Any solution that able to auto detect the rectangle and set the ROI? 有什么解决方案能够自动检测矩形并设置ROI?

Anyone can give some idea for me or the code can be use? 任何人都可以为我提供一些想法或使用代码吗?

Please forgive my poor english and thank you. 请原谅我的英语不好,谢谢。

在此处输入图片说明

this blog post is very good in explaining how to find a rectangle with the hough transform and it has also some c++ code with opencv 2 API. 这篇博客很好地解释了如何使用hough变换查找矩形,并且还提供了一些带有opencv 2 API的c ++代码。

The approach is to find lines, intersect them, and find the rectangle. 方法是找到线,将它们相交,然后找到矩形。 In your case you will have more rectangles and so it's a little bit more complicated.. 在您的情况下,您将拥有更多的矩形,因此会稍微复杂一些。

But if you manage to obtain such image.. why don't use just some threshold and find connected regions (aka blob)? 但是,如果您设法获得此类图像,为什么不只使用一些阈值并找到相连的区域(又称为斑点)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM