Ask Your Question
1

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

asked 2020-02-03 08:54:08 -0600

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...

edit retag flag offensive reopen merge delete

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 2020-02-03 10:51:25 -0600

berak gravatar image

updated 2020-02-03 10:55:48 -0600

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]
edit flag offensive delete link more

Comments

1

It worked for me! Thanks :)

Kayoh gravatar imageKayoh ( 2020-02-03 19:42:01 -0600 )edit

@Kayoh. Why not upvote?

supra56 gravatar imagesupra56 ( 2020-02-03 21:28:24 -0600 )edit
1

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

Kayoh gravatar imageKayoh ( 2020-02-03 21:30:25 -0600 )edit

OIC. I didn't know that.

supra56 gravatar imagesupra56 ( 2020-02-03 22:22:51 -0600 )edit

You can click for close for right answer by you

supra56 gravatar imagesupra56 ( 2020-02-04 07:06:30 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-03 08:54:08 -0600

Seen: 737 times

Last updated: Feb 03 '20