#๐Ÿ”’ DXCam + openCV windows application freezing

5 messages ยท Page 1 of 1 (latest)

hoary ledge
#
import dxcam
import cv2
import numpy as np

# Create DXcam camera instance
camera = dxcam.create(output_color="BGR") # returns a DXCamera instance on primary monitor and frames are outputed in BGR format for direct processing in OpenCV.
camera.start() #runs on a seperate thread, captures at 60hz
while camera.is_capturing:
    cv2.imshow('feed', camera.get_latest_frame()) #/creates window application rendering return a numpy array representing an image
    cv2.waitKey(3000) 
camera.stop()

I've read the documentation regarding how cv2.imshow() and cv2.waitKey() works but there are parts im still confused about. Here's my high level understanding (some parts i'm not sure about but i'll mention those points below):

CF2.imshow() will pass an event to the window's GUI event loop detailing it to render the numpy array returned by camera.get_latest_frame() into the windows application named "feed". When cv2.waitKey(3000) is executed, the thread responsible for executing this python script will trigger the OS's GUI system, telling it to process the contents of its event loop to which it then pauses execution of the current thread whilst the thread responsible for the OS GUI system is given control for at least the specified time (3s).

There's a couple things i don't get:

  1. In my code, does the first execution of "cv2.imshow('feed', camera.get_latest_frame())" create the windows application to which subsequent execution just internally refers to this same windows application?

  2. is this python thread responsible for processing the OS GUI event loop as well or is there two threads: this python thread and a thread dedicated to handling the windows OS GUI event loop meaning that they are just prompting each other on when they can continue executing

supple groveBOT
#

@hoary ledge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hoary ledge
#

I ran this through deepseek and this is what it told me. Seems fairly different to what i had in mind so i would appreciate if anyone could clarify what's actually going on. I'm not super concerned with the really low level details but right now I don't even really have a conceptual idea of how things work behind the scenes.

supple groveBOT
#

@hoary ledge

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.