使用OpenCV设置图像上的ROI [英] Set ROI on image with OpenCV
问题描述
大家好!
我正在图像处理领域,并且在编程领域我是一个初学者.
我想使用OpenCV库和C ++在图片上检测矩形.
如果我有白色背景,并且在图像中心大约有一个黑色背景的矩形,如何使用Opencv在图像上设置ROI.
图片尺寸为(800 * 600px),矩形尺寸为(150 * 150px);
我不知道图像中的矩形到底在哪里.
这是灰度图像.
HI Everyone!
I am working in image processing and in this field of programming i am a beginner.
I wanna detect rectangel on picture i am using openCV librarys and C++.
How can i set a ROI on image, with Opencv, if i have white background and about in the center of image i have an rectangle with black background.
The image size is(800*600px) and the rectangel''s size (150*150px);
I dont know exactly where is that rectangle in image.
This is a gray scaled image.
Thank you advance!
推荐答案
,您可以使用霍夫变换来检测矩形.参见 ^ ]
you can use Hough Transform to detect rectangles. see http://www.google.co.in/url?sa=t&rct=j&q=detecting%20rectangle%20with%20hough%20transform&source=web&cd=4&ved=0CEcQFjAD&url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.59.4239%26rep%3Drep1%26type%3Dpdf&ei=thmeT8q-OMbMrQeOi9Vr&usg=AFQjCNH3Ar8j1qq5aeOtKD2fPLNOunub9A&cad=rja[^]
您是否要寻找检测矩形的算法或如何设置矩形以及未设置兴趣区(ROI)?
使用
Are you asking for an algorithm to detect a rectangle or how to set and unset Region of Interest(ROI)?
use
cvSetImageROI(img,cvRect(x,y,width,height));
设置ROI,其中img =图片,x,y是矩形的锚点
和
to set ROI where img = image, x,y are anchor points for the rectangle
and
cvResetImageROI(img);
取消ROI
然后所有处理将在指定的关注区域(ROI)内进行.
希望对您有帮助
to unset ROI
Then all processing will take place within the specified region of interest (ROI).
Hope this helps
这篇关于使用OpenCV设置图像上的ROI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!