Video of thresholded image

I’m trying to record a video of a color-enhanced webcam stream. I’m using:

capture= cv.VideoCapture(0)
cv2image= cv.cvtColor([1],cv.COLOR_BGR2RGB)
img = Image.fromarray(cv2image)
enh = cv.inRange(np.array(ima), ref, 255)

The problem is the resulting video cannot be played.

even super genius python masters should read docs

(see last arg)

Thanks for the quick reply, certainly not a super genius python master here. Now I’m getting a single frame instead of video. I tried putting it in a while loop and it crashed.

what do you think, the last line does ?

I was under the impression it was needed to save the file. In any case, I am still getting a single frame. I’m guessing there is a mismatch between the framerate and the frequency at which the image is refreshed, but I’m not entirely sure how to solve this; I’ll do some more digging aroung. Thanks.

Solved! It turns out tkinter doesn’t like while loops.

please do not do that. that’s just silly.

you can either do the same with nothing but numpy slicing, or use cv.split() to take the planes apart.

and don’t use BGR2RGB conversion here. that’s pointless too. you’re about to extract a single plane anyway.

and do not say[1]. that’s cryptic. say (success, frame) =; if not success: break

not just Tkinter, but any GUI framework, doesn’t like if you try to do things your own way. you need to learn how GUIs work (event loop, event handlers, threads for processing).

I’m a newbie, so most of what I do is Frankensteined from tutorials showing how to do similar things.