0
我想考出pyobjc绑定ImageCaptureCore,我不能让我的委托的回调在所有火:使用ImageCaptureCore与pyobjc
"""ImageCaptureCore test app.""" from __future__ import ( absolute_import, division, print_function, ) import time import objc from AppKit import NSObject from ImageCaptureCore import ( ICCameraDevice, ICDeviceBrowser, ICDeviceLocationTypeMaskLocal, ICDeviceTypeMaskCamera, ) class ICDelegate(NSObject): """Implements ICDeviceBrowserDelegate.""" def __new__(cls): """Create a new `ICDelegate`.""" return ICDelegate.alloc().init() def init(self): self = objc.super(ICDelegate, self).init() if self is None: return None self.devicesFetched = False print("Delegate initialized.") return self # ICDeviceBrowserDelegate callbacks def deviceBrowserDidEnumerateLocalDevices_(self, browser): print("Done fetching devices.") self.devicesFetched = True def deviceBrowser_didAddDevice_moreComing_(self, browser, device, moreComing): print("Device added.") def deviceBrowser_didRemoveDevice_moreGoing_(self, browser, device, moreGoing): print("Device removed.") delegate = ICDelegate() browser = ICDeviceBrowser.alloc().init() browser.setDelegate_(delegate) browser.setBrowsedDeviceTypeMask_(ICDeviceTypeMaskCamera | ICDeviceLocationTypeMaskLocal) browser.start() print("Fetching cameras...") while not delegate.devicesFetched: time.sleep(1) print("Still fetching cameras...") # We never get past this!
从我的API的理解,一旦ICDeviceBrowser
完成获取设备列表(即使没有设备插入),我应该得到didEnumerateLocalDevices
回拨,并且我应该为每个连接的设备获得didAddDevice
。相反,我得到什么(不管我是否插上的设备或没有,之前或之后,我开始我的剧本,我已经尝试了普通的USB摄像头以及一个iPhone):
Delegate initialized. Fetching cameras... Still fetching cameras... Still fetching cameras... Still fetching cameras... Still fetching cameras...
有什么其他类型的设置需要发生才能使ICDeviceBrowser
开始工作?我看过本地objc示例,它看起来看起来就像我正在做同样的事情,但我一直无法找到任何可以跟随的pyobjc绑定示例。