Ask Your Question
0

Region of Interest in Video File

asked 2013-08-12 01:03:28 -0600

mabg gravatar image

updated 2013-08-12 09:18:03 -0600

Hi to all,

This is my first time posting here and hoping for a positive result since my research is near its conclusion.

I want to add in my code a function that will process only the define region of interest of a video file.

image description

Storyboard:

Im making a program that will make the pedestrians and vehicles look that they are not in the scene/disappear by getting the running average of the videos frame. I already made that. Now my problem is I do want only the portion of the video that is under the region of interest to be processed because I want to preserve the Lighting/Illumination of the christmas lights while their blinking.

Why? I want to use this method to capture only the blinking lights this coming yuletide season without the disturbance of vehicle and people in the scene.

How can I do that? Getting a region of interest in a video file

Thanks in advance.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-08-12 01:33:31 -0600

You should apply a ROI on each frame captured.

cv::Rect rectangle( x, y, w, h ); // set your ROI
...
capture >> frame;
cv::Mat roi = frame.clone(); // to avoid issue with the internal pointer
roi( rectangle ); // rectangle of interest.
compute_my_stuff( roi );
edit flag offensive delete link more

Comments

Thanks for the reply @Mathieu Barnachon BTW, what should be the value of my x,y, width, height Say my video frame is 640x360 then as the picture suggest, my desired region of interest is around 640x100. What do you mean by "cv::Mat roi = frame.clone(); // to avoid issue with the internal pointer"

mabg gravatar imagemabg ( 2013-08-12 02:14:29 -0600 )edit
1

answered 2013-08-12 01:36:00 -0600

Haris gravatar image

For setting ROI in Video you can have some thing like below.

      VideoCapture cap(0);   
      cv::Mat frame;   
      while(1)
      cap >> frame; //Get the frame from cam    
      // SetImageRoi    
      cv::Rect roi(x, y, width, height);
      cv::Mat image_roi = frame(roi);  // note: this assignment does not copy data, frame and   image_roi now share data

      // Do some processing on ROI region
      process(image_roi);  // any changes to image_roi will also be in frame

      // Reset ROI  
      //     -- nothing required

    }
edit flag offensive delete link more

Comments

Thanks for the reply @Haris Moonamkunnu BTW, what should be the value of my x,y, width, height

Say my video frame is 640x360 then as the picture suggest, my desired region of interest is around 640x100.

mabg gravatar imagemabg ( 2013-08-12 02:04:18 -0600 )edit

x and y are the points from where it cropped, width and height are the size of image to be cropped. In the above image x and y are top left corner of your red rectangle, width and height are its size. See Opencv Doc for more details http://docs.opencv.org/modules/core/doc/basic_structures.html#rect

Haris gravatar imageHaris ( 2013-08-12 02:42:31 -0600 )edit

Question Tools

Stats

Asked: 2013-08-12 01:03:28 -0600

Seen: 12,607 times

Last updated: Aug 12 '13