Ask Your Question
0

Drawing a rectangle and masking the outside area

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

sentientnativeplant gravatar image

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

Comments

Send me this code that is used to draw the rectangle and masking the outside area of the rectangle

Revanth gravatar imageRevanth ( 2019-11-07 05:36:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 3,701 times

Last updated: Apr 17 '19