12,077,911 members (47,326 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 29-Apr-12 17:54pm

And ROI is?.. Return Of Investment? Rate Of Return? Royal Institute of Oil Painters? Risk Of Infection? :-)
--SA
BupeChombaDerrick 29-Apr-12 18:49pm

ROI is Region Of Interest. Anyways who knows exactly what it means here in the question :-)
SAKryukov 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 30-Apr-12 8:22am

you are welcome.

## 2 solutions

Rate this:
Please Sign up or sign in to vote.

## Solution 2

Comments
BupeChombaDerrick 30-Apr-12 8:31am

thumbs up
jk chan 30-Apr-12 8:35am

:)
Rate this:
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

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

Top Experts
Last 24hrsThis month
 Richard MacCutchan 400 Richard Deeming 280 Dave Kreskowiak 265 OriginalGriff 205 CHill60 200
 Dave Kreskowiak 3,026 OriginalGriff 3,000 Richard MacCutchan 2,539 CPallini 1,722 CHill60 1,579

Advertise | Privacy | Mobile
Web03 | 2.8.160212.1 | Last Updated 30 Apr 2012
Copyright © CodeProject, 1999-2016
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