Closed zoltanszalontay closed 4 years ago
Nice catch, yes the order of devices and their ids can't be guaranteed... On my machine the índices are in order so this didn't come up. We can probably replace it with something like:
dev.append(int(device.split('video')[-1]))
I was thinking about the same, except it is not guaranteed that the number of devices is less than 10 (one decimal figure).
That should be OK, e.g.
>>> '/sys/class/video4linux/video12'.split('video')
['/sys/class/', '4linux/', '12']
Split returns the string, not the character.
I can confirm, that the patch above is working on my config.
Thanks a lot! Zoltan
Thanks, glad it works - I'll patch this shortly!
https://github.com/LJMUAstroecology/flirpy/blob/9a35fb1a4ceca557acea165543acf5cd9d900f1e/flirpy/camera/lepton.py#L66
Automatic video capture device enumeration using lepton.find_video_device() on a Raspberry + Lepton 3.5 + PureThermal setup does not work for me when picamera is also connected.
I guess the problem is at the 66. 'i' is the number of order the video device has been found, which depends on the folder structure. However, cv2.videocapture(id) expects an id that is equivalent to the last figures of the filename of the device driver (as in /sys/class/video4linux/).
Background info: Video devices: ['/sys/class/video4linux/video12', '/sys/class/video4linux/video1', '/sys/class/video4linux/video10', '/sys/class/video4linux/video2', '/sys/class/video4linux/video11', '/sys/class/video4linux/video0']
print d => "[1, 5]" based on filtering capabilities.
The correct id would be '0' (../video0) and cam = camera.setup_video(0) is working.