Ask Your Question
0

Drawing a rectangle and masking the outside area

asked 2019-04-15 07:45:02 -0500

image description

I wrote some code that uses background subtraction to measure movement. The above image shows the first frame (1), Original video (2), and movement via background subtraction (3).

I was able to draw a rectangle during the video and I know that the value (-1) fills the rectangle. Is there a way to have everything outside of the rectangle be masked instead? That way I can reset the first frame and then only measure the inside of the rectangle.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-17 07:25:48 -0500

Chris gravatar image

There is a version of the copyto function that takes a mask image. A mask image is the same size as the image copying from. Pixels that are 255 in the mask get copied to the new image, pixels that are 0 in the mask do not get copied.

image description

edit flag offensive delete link more

Comments

Thank you, that is what I was looking for.

sentientnativeplant gravatar imagesentientnativeplant ( 2019-04-17 13:17:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-04-15 07:45:02 -0500

Seen: 42 times

Last updated: Apr 17