Skip to content
Advertisement

Record Video Button in tkinter GUI python

I’m pretty new to python and espcially tkinter and opencv.

I’ve got someway (a little way) to creating a gui that will eventually control a microscope and ai. But I’ve hit a stumbling block, trying to record the video that is displayed within the gui, I think its to do with the video feed already been captured in the display, but I can’t find a way around it. It all works fine until I hit record then it crashes and i get the error: open VIDEOIO(V4L2:/dev/video0): can’t open camera by index.

Apologies for the long code but I’ve cut it down to as much as I think possible.

The problem is in the root.recbtn and def rec sections.

JavaScript

Thanks!

Advertisement

Answer

This answer is similar to @Art’s answer but I removed the after_id and queue.

JavaScript

It uses the boolean flag running instead of using after_id. Also instead of storing the images in a queue then showing it, I only keep the last image. That way it can run in real time on my computer. Don’t worry all of the frames are still being stored in the video file.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement