Ask Your Question
1

how can I change the video frame in selectROI area from RGB to grayscale? [closed]

asked Feb 3 '0

Kayoh gravatar image

Sorry about bad English :(

I want to change the video frame(videoStream or videoCapture, both) in selectROI area from RGB to grayscale.

I'm using python, and I need help...

Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by Kayoh
close date 2020-02-04 07:10:54.300834

1 answer

Sort by » oldest newest most voted
-1

answered Feb 3 '0

berak gravatar image

updated Feb 3 '0

assuming, your (numpy) frame has 3 channels,

you could copy one of the channels (e.g. green) to make it look grayscale:

# x,y,w,h are selected, get a numpy slice:
roi = frame[y:y+h, x:x+w]

# replace b and r channel in that area with g, so they're all the same:
roi[:,:,0] = roi[:,:,1]
roi[:,:,2] = roi[:,:,1]
Preview: (hide)

Comments

1

It worked for me! Thanks :)

Kayoh gravatar imageKayoh (Feb 4 '0)edit

@Kayoh. Why not upvote?

supra56 gravatar imagesupra56 (Feb 4 '0)edit
1

It says '5 points required to upvote'... I'm new to here I'm sorry TT

Kayoh gravatar imageKayoh (Feb 4 '0)edit

OIC. I didn't know that.

supra56 gravatar imagesupra56 (Feb 4 '0)edit

You can click for close for right answer by you

supra56 gravatar imagesupra56 (Feb 4 '0)edit

Question Tools

1 follower

Stats

Asked: Feb 3 '0

Seen: 947 times

Last updated: Feb 03 '20