Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV setroi

Hello to whomever is reading this. I'm new to opencv and I've only recently installed opencv.

I would like to ask as to how do I go on about in setting the ROI of an image. An example is I have an image of an electric meter and I would just like to get the ROI of the values part of the electric meter. Not the entire electric meter. I would love to post some image as example but I'm lacking in karma as I'm a new user. Sorry about that

I've used this code over here

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("D:/sample.jpg");
    if ( img.empty() ) { /* bark!!*/ }
    Mat roi = img( Rect(170,150,250,100));
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

I've not set the proper rect for the ROI but for some reason I'm always getting an error even before I can test it out. The error has something to do with the + &ThisException 0x0000004532f7f6d0 {ExceptionCode=3765269347 ExceptionFlags=1 ExceptionRecord=0x0000000000000000 {ExceptionCode=...} ...} EHExceptionRecord *

When I use a different image, it isn't an issue.

Bear in mind I'm new to opencv so if the question does sound pretty noobish, sorry.

OpenCV setroi

Hello to whomever is reading this. I'm new to opencv and I've only recently installed opencv.

I would like to ask as to how do I go on about in setting the ROI of an image. An example is I have an image of an electric meter and I would just like to get the ROI of the values part of the electric meter. Not the entire electric meter. I would love to post some image as example but I'm lacking in karma as I'm a new user. Sorry about that

I've used this code over here

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("D:/sample.jpg");
    if ( img.empty() ) { /* bark!!*/ }
    Mat roi = img( Rect(170,150,250,100));
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

I've not set the proper rect for the ROI but for some reason I'm always getting an error even before I can test it out. The error has something to do with the + &ThisException 0x0000004532f7f6d0 {ExceptionCode=3765269347 ExceptionFlags=1 ExceptionRecord=0x0000000000000000 {ExceptionCode=...} ...} EHExceptionRecord *

When I use a different image, it isn't an issue.

Bear in mind I'm new to opencv so if the question does sound pretty noobish, sorry.