Open Takhmasib opened 3 years ago
If you are talking about something other than macOS 12, I'm not sure what the cause is. However, if you are trying to run on macOS 12, this seems to be a fundamental problem that cannot be solved forever. It seems to me that we have three options in this case
The following issue is a good reference for this problem. I have yet to find a solution to this problem other than the above. libusb/libusb#1014
If anyone has succeeded in capturing 16-bit temperature images from PureThermal module on macOS 12, I would appreciate it if you could tell me how to do it.
uvc_open()
is a function of a library called libuvc
that the sample code for PureThermal is using to capture 16-bit temperature images from a USB-connected PureThermal. And that libuvc
is using another library called libusb
for USB access.
As I understand, when we try to capture images using libusb
+ libuvc
on macOS, we need to unload some of the existing loaded kernel drivers to avoid macOS conflicts, and reload those kernel drivers when we exit the app.
Refer to Apple macOS API: IOUSBHostObjectInitOption's 'deviceCapture'
Callers must have either the com.apple.vm.device-access entitlement and the IOUSBHostDevice object from IOServiceAuthorize(::) authorization, or have root privileges. Using this option terminates all clients and drivers of the IOUSBHostDevice and associated IOUSBHostInterface clients, as well as the caller. Upon destroy() of the IOUSBHostDevice, the device resets and IOUSBHostInterface reregisters for IOKit matching.
Until macOS 11, the macOS API could be used with user privileges without difficulty, but in macOS 12, only apps with root privileges or com.apple.vm.device-access
entitlement can use this API.
Also, if this entitlement is forged for temporary use, the app will not be allowed to run by macOS. Therefore, it is necessary to have this entitlement officially granted by Apple, but Apple seems to have a policy of not granting it to any apps other than VMware, and not to regular applications. I also applied, but was rejected.
A potential workaround seems to be the suggestion to use libusb/hidapi, another cross-platform library, instead of libusb
libuvc
. However, hidapi
uses IOKit
's IOHIDManager
, a macOS API, to create the connected device list. This API does not recognize the PureThermal module as a HID, so we could not use hidapi
to capture images from PureThermal.
CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
The second possible workaround is to give up the cross-platform library and use macOS AVFoundation
's AVCapture
directly. So I tried this API. However, although the PureThermal module's RGB image profile was listed by that API, the 16-bit temperature image profile was not listed. So, of course, the RGB image capture was successful, but the 16-bit temperature image capture was not.
AVCaptureDevice.DiscoverySession(
deviceTypes: [AVCaptureDevice.DeviceType.externalUnknown],
mediaType: AVMediaType.video, position: AVCaptureDevice.Position.unspecified)
So, unfortunately, my final remaining options are as mentioned before.
- run your app on macOS 11
- run your app with root privileges on macOS 12
- run VMware on macOS 12 and run your app on ubuntu or other OS on it
If anyone has succeeded in capturing 16-bit temperature images from PureThermal module on macOS 12, I would appreciate it if you could tell me how to do it.
I experienced the same issue. Unable to capture the video stream using Python and PT2 + Lepton 3 using MacOS Monterey.
Thanks for the information. I am using a Raspberry Pi 4. The problem was with the camera. I just changed it and it worked. Thank you
I have confirmed that there is a version of uvc_open() that fails even on macOS 11. To be precise, uvc_open() fails on 11.6.3 or later due to com.apple.vm.device-access entitlement
issue.
(I also modified my comment at the top of this issue.)
I've tried this again, and as of now some of this has been cleaned up. At least for MacOS 12.4, with libuvc/libuvc master and libusb from homebrew, and the master+libuvc-upstream
branch here, it is working for me.
hi @shinya-ohtani , any update on this?
strangely, i could route the purethermal2 video stream through OBS software then start the virtual camera from OBS and stream those virtual camera using cv2. But the bit depth is only 8 bit.
Hi @mctosima could you share how you did this? I'm trying the same but trying to find the virtual camera index (for python) if proving problematic.
I end up with the error: [ERROR:0@1.273] global cap.cpp:323 open VIDEOIO(AVFOUNDATION): raised unknown C++ exception! while running opencv-capture.py
Hi @mctosima could you share how you did this? I'm trying the same but trying to find the virtual camera index (for python) if proving problematic.
I end up with the error: [ERROR:0@1.273] global cap.cpp:323 open VIDEOIO(AVFOUNDATION): raised unknown C++ exception! while running opencv-capture.py
Really sorry that I didn't notice that there's a reply to me.
Here's how you can connect to OBS virtual camera.
pip install pygrabber==0.1
from pygrabber.dshow_graph import FilterGraph
graph = FilterGraph()
print(graph.get_input_devices())# list of camera device
try:
device =graph.get_input_devices().index("name camera that I want to use it ")
except ValueError as e:
device = graph.get_input_devices().index("Integrated Webcam")#use default camera if the name of the camera that I want to use is not in my list
vid=cv2.VideoCapture(device)
instead of OBS, VLC streaming works as well, but the delay is huge though
Hi
I also encountered this problem today, and I am pleased to introduce my solution, hope this helpful for others:
Trouble intro
uvc_open error
both when exec uvc-deviceinfo.py and uvc-radiometry.py, the res of res = libuvc.uvc_open(dev, byref(devh))
is -3.Solution
lsusb
in terminal, find the thermal camera device: Bus 001 Device 039: ID 1e4e:0100 Cubeternet WebCamcd /etc/udev/rules.d
, sudo gedit 70-thermal-camera.rules
, SUBSYSTEM=="usb", ATTRS{idVendor}=="1e4e", ATTRS{idProduct}=="0100",MODE="0666"
Hi, I'm trying to run the code. I'm using Pure Thermal 2. everything works fine, but at the end I get uvc_open error. Does anyone have an idea? How I can solve that and what is the base of the problem?