adr
adr

Reputation: 5

How to find the difference between one frame to another for a specified part of an image only

I'm using OpenCV for my project on video feature tracking. I need to create a mask which is the difference between one frame to the next one. I know to do this, we can use the cv.absdiff function. The problem is I want the mask to contain only the difference for a specified small part of the frame, i.e. not the entire image. I'm not sure how to go about doing this.

Upvotes: 0

Views: 169

Answers (1)

Michael Burdinov
Michael Burdinov

Reputation: 4438

// define regions of interest in images
Rect roiRect1(x1, y1, roiWidth, roiHeight);
Rect roiRect2(x2, y2, roiWidth, roiHeight);

// create images of regions of interest. no copy is performed, this is just new pointers to existing data
Mat roiImage1(frame1, roiRect1);
Mat roiImage2(frame2, roiRect2);

// do whatever you want with those images
......

Upvotes: 1

Related Questions