Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS webcam capture #1231

Open
totaam opened this issue Jun 16, 2016 · 9 comments
Open

MacOS webcam capture #1231

totaam opened this issue Jun 16, 2016 · 9 comments
Labels
Milestone

Comments

@totaam
Copy link
Collaborator

totaam commented Jun 16, 2016

A native port should solve #1113 on OSX (also blocked by #840) and will allow us to improve platform support and remove the dependency on opencv.

Also remove the hard-coded csc dependency.

@totaam
Copy link
Collaborator Author

totaam commented Jun 16, 2016

Hopefully we can use the same code for enumerating video devices on osx. (see #1113#comment:4)

The same code can probably be used to capture the whole desktop on win32: DirectShow and may help with #389.

@totaam
Copy link
Collaborator Author

totaam commented Dec 30, 2016

@totaam
Copy link
Collaborator Author

totaam commented Feb 1, 2018

2018-02-01 14:36:26: antoine uploaded file webcam.py (3.5 KiB)

working capture script

@totaam
Copy link
Collaborator Author

totaam commented Feb 1, 2018

The macos capture script above is based on How can I capture iSight frames with Python in Snow Leopard?. It works.. just not on my dev VM (light comes on, but frames never arrive), so I have to ssh to the mac mini to test it.

Still TODO:

  • clean it up and add it to "darwin" webcam module
  • implement device enumeration
  • improve memory management so we can compress in another thread and release the buffer after we're done
  • port to AVFoundation (ie: AVCaptureDevice) since all the documentation for QTKit is now 404 (dead links everywhere - thanks apple!): Transitioning QTKit Code to AV Foundation

Note: the py2app packaging for QTKit involved using packages and not modules? (IIRC)


For win32:

See also #1627

@totaam
Copy link
Collaborator Author

totaam commented Feb 4, 2018

2018-02-04 08:08:41: antoine uploaded file opencv.patch (3.6 KiB)

PKGBUILD patch to limit the number of opencv modules we build with makepkg

@totaam
Copy link
Collaborator Author

totaam commented Feb 4, 2018

The patch above removes all the dependencies we don't need from the opencv MSYS2 package build, saving around 80MB of disk space.
The savings for our installer package are much smaller (~5MB) because we already trimmed it quite a bit and the file is compressed.

This should make things less brittle too: the opencv package seems to break very regularly in MSYS2 due to the huge amount of dependencies it has and because of the way the module loads them all - they would need to rebuild the package every time a dependency is updated.

Only problem is that the 32-bit version crashes hard, even the simple opencv_version.exe tool does... so r18290 disables webcam support in 32-bit builds.

@totaam
Copy link
Collaborator Author

totaam commented Feb 4, 2018

2018-02-04 15:08:43: antoine uploaded file webcam_avfoundation.py (3.7 KiB)

port to AVFoundation

@totaam
Copy link
Collaborator Author

totaam commented Feb 4, 2018

We now build AVFoundation (r18246, also for python3: r18296 + r18297), and we have a nasty py2app packaging workaround too: r18298.

The webcam port to AVFoundation above might work, but we're blocked by this pyobjc bug: Support marshalling OS_dispatch_queue on macOS 10.10 and 10.11
I'm not sure if this can be worked around using ctypes either.

Once that's fixed, we'll need to to parse the sampleBuffer object using:
from Quartz import CoreVideo then:

@totaam
Copy link
Collaborator Author

totaam commented Mar 2, 2020

pyobjc has moved to github: https://github.com/ronaldoussoren/pyobjc/
But this particular issue was not, it's been wiped like it never existed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant