Click here to Skip to main content
11,493,233 members (58,104 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ OpenCV
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!
Posted 28-Apr-12 22:54pm
Comments
SAKryukov at 29-Apr-12 17:54pm
   
And ROI is?.. Return Of Investment? Rate Of Return? Royal Institute of Oil Painters? Risk Of Infection? :-)
--SA
BupeChombaDerrick at 29-Apr-12 18:49pm
   
ROI is Region Of Interest. Anyways who knows exactly what it means here in the question :-)
SAKryukov at 29-Apr-12 22:43pm
   
Thank you very much. Anyway, abbreviations is evil in most cases, and using this one makes a question not quite valid.
--SA
BupeChombaDerrick at 30-Apr-12 8:22am
   
you are welcome.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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));

to set ROI where img = image, x,y are anchor points for the rectangle

and

cvResetImageROI(img);


to unset ROI

Then all processing will take place within the specified region of interest (ROI).

Hope this helps
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 393
1 Maciej Los 286
2 F-ES Sitecore 224
3 KarstenK 210
4 CPallini 208
0 Sergey Alexandrovich Kryukov 10,132
1 OriginalGriff 8,630
2 Sascha Lefèvre 3,624
3 Maciej Los 3,392
4 Richard Deeming 2,500


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 30 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100