Here are resources and additional documentation about OpenCV and troubleshooting camera permissions:
00:00 Integrating OpenCV With PySimpleGUI. Computer vision is a hot topic. Python allows you to get into computer vision using the opencv-python package, which is a wrapper around the popular OpenCV application.
00:17 If you’re interested in learning more about computer vision, then check out Face Recognition with Python, in Under 25 Lines of Code. PySimpleGUI features straightforward integration with the OpenCV library.
00:50 This application lets you apply some common filters to your video in real time. There’s quite a lot of code in this example, and rather than present all of the code in one go, you’ll see how it’s built up step by step, starting out with a display of the live video using OpenCV and then adding GUI elements and functionality one at a time.
01:10 This will allow you to understand how the different parts of the code relate to each other and will also mimic the process of development more closely. It’s often the case that you’ll start out with the bare bones and then add features and functions as you progress.
cv2.VideoCapture() is used to access the webcam on the machine. The final part of this initial stage of the code is to create an event loop, initially a basic one, which will check if the user wants to leave the program.
And then after that, there will be code which interfaces with OpenCV to get the image data called
frame, and this is encoded to a PNG format and used to update the content of the image in the window.
main() function is called using the code seen at the bottom. It’s good practice to check if your Python script is being run directly in this manner, as it avoids issues if you ever import it as part of a larger project.
03:59 When you run the code, you may see a pop-up asking for permission to use the camera. If you do, then you’ll need to grant permission or the code won’t work. Note that you may see different results if you run the code from your editor’s built-in shell, so if you do, try running it directly in a terminal which is using the appropriate virtual environment. See the notes accompanying this video for more details on this.
04:23 Here you can see the program working and the Exit button working as intended. With the basics of the program in place, in the next video, you’ll see how to add image processing and PySimpleGUI controls for that processing.
Become a Member to join the conversation.