PyObjC ImageCaptureCore Framework Bindings

12.1 · active · verified Tue Apr 14

This library provides Python bindings for Apple's ImageCaptureCore.framework, enabling Python applications to interact with scanners, cameras, and other image capture devices on macOS. It is part of the larger PyObjC project, which wraps various macOS frameworks. The current version is 12.1, with releases tightly coupled to macOS SDK updates and Python version support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `ICDeviceBrowser` to discover image capture devices on macOS. It sets up a delegate to receive callbacks for device additions and removals and runs a console event loop to keep the application responsive. Note that `PyObjCTools.AppHelper` requires `pyobjc-framework-AppKit` to be installed.

import ImageCaptureCore
import objc
from PyObjCTools import AppHelper

class MyDeviceBrowserDelegate(objc.NSObject):
    def deviceBrowser_didAddDevice_moreComing_(self, browser, device, moreComing):
        print(f"[*] Found device: {device.name()} (UUID: {device.uuid()})")
        # You can access device properties here, e.g., device.type(), device.icon().

    def deviceBrowser_didRemoveDevice_moreComing_(self, browser, device, moreComing):
        print(f"[-] Removed device: {device.name()} (UUID: {device.uuid()})")

def main():
    browser = ImageCaptureCore.ICDeviceBrowser.alloc().init()
    delegate = MyDeviceBrowserDelegate.alloc().init()
    browser.setDelegate_(delegate)
    
    print("Starting ImageCaptureCore device browser. Press Ctrl+C to exit.")
    print("Detected devices will be printed as they are found or removed.")
    
    browser.start()
    # Run the Cocoa event loop indefinitely to receive delegate callbacks.
    # This keeps the script alive and responsive to system events.
    AppHelper.runConsoleEventLoop(installInterrupt=True)

if __name__ == "__main__":
    main()

view raw JSON →