Skip to content

Fix #4665: list_cameras() returns None on Windows with integrated camera#4800

Open
samsepro wants to merge 2 commits into
pygame:mainfrom
samsepro:main
Open

Fix #4665: list_cameras() returns None on Windows with integrated camera#4800
samsepro wants to merge 2 commits into
pygame:mainfrom
samsepro:main

Conversation

@samsepro

Copy link
Copy Markdown

Problem :
pygame.camera.list_cameras() returns None on Windows with integrated
webcams because the #else branch in the original code did Py_RETURN_NONE.

Solution :
Add a Windows Media Foundation (MSMF) backend to _camera.c that:

  • Enumerates cameras via MFEnumDeviceSources
  • Opens/closes cameras via IMFActivate and IMFSourceReader
  • Forces RGB32 output format for consistent frame capture
  • Handles format change events on first ReadSample with a retry loop
  • Accepts both int index and str device name in Camera()

Testing :
Tested on Windows 11 with integrated webcam (Integrated Webcam).
All 34 unit tests pass.

Fixes #4665

…ed camera

Add Windows Media Foundation (MSMF) backend to _camera.c:
- list_cameras() now enumerates cameras via MFEnumDeviceSources
- Implement camera_start/stop/get_image/get_raw for Windows
- Handle format change events on first ReadSample (retry loop)
- Force RGB32 output format for consistent frame capture
- Add win_source, win_reader, device_index fields to pgCameraObject
- Add CAM_MSMF constant to camera.h
- Accept both int index and str device name in Camera()
- Add MF libs to Setup_Win_Camera.in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list_cameras() returns None on laptop with integrated camera

1 participant