프로그램 사용/kinect2024. 7. 14. 11:19

처음 실행하니 권한부족.. libusb가 권한이 필요한 녀석이었던가?

libfreenect2/build/bin$ ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 10 usb devices connected
[Error] [Freenect2Impl] failed to open Kinect v2: @4:3 LIBUSB_ERROR_ACCESS Access denied (insufficient permissions)
[Info] [Freenect2Impl] found 0 devices
no device connected!

 

짜잔~하고 먼가 나오길 기대했지만... 안된다 -_-

$ sudo ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 10 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @4:5 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
[Debug] [Freenect2DeviceImpl] status 0x090000: 9729
[Error] [protocol::UsbControl] failed to set ir interface state! LIBUSB_ERROR_OTHER Other error. Try debugging with environment variable: export LIBUSB_DEBUG=3 .
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] releasing usb interfaces...
[Info] [Freenect2DeviceImpl] deallocating usb transfer pools...
[Info] [Freenect2DeviceImpl] closing usb device...
[Info] [Freenect2DeviceImpl] closed

 

LIBUSB_DEBUG를 줘도 두 줄 추가 되는 것 외에는 별다른 에러 메시지가 없다.

# LIBUSB_DEBUG=3 ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
libusb: warning [libusb_init] installing new context as implicit default
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 10 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @4:7 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
libusb: error [udev_hotplug_event] ignoring udev action change
libusb: error [udev_hotplug_event] ignoring udev action change
[Debug] [Freenect2DeviceImpl] status 0x090000: 9731
libusb: error [op_set_interface] set interface failed, errno=28
[Error] [protocol::UsbControl] failed to set ir interface state! LIBUSB_ERROR_OTHER Other error. Try debugging with environment variable: export LIBUSB_DEBUG=3 .
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] releasing usb interfaces...
[Info] [Freenect2DeviceImpl] deallocating usb transfer pools...
[Info] [Freenect2DeviceImpl] closing usb device...
[Info] [Freenect2DeviceImpl] closed
libusb: warning [libusb_exit] device 4.7 still referenced
libusb: warning [libusb_exit] device 4.6 still referenced
libusb: warning [libusb_exit] device 4.1 still referenced

 

커널 메시지로는.... 엥? 왜 갑자기 대역폭 부족?

$ sudo dmesg -w
[  415.484074] usb 4-1.1: reset SuperSpeed USB device number 7 using xhci_hcd
[  415.595900] usb 4-1.1: Not enough bandwidth for new device state.
[  415.595907] usb 4-1.1: Not enough bandwidth for altsetting 1

 

라이브러리 홈페이지 가서 다시 보니 

make install 하고 udev rule을 복사한 뒤, 키넥트를 뽑았다 꽂으라고 한다.

Build (if you have run cd depends previously, cd .. back to the libfreenect2 root directory first.)
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install
You need to specify cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 for CMake based third-party application to find libfreenect2.
Set up udev rules for device access: sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/, then replug the Kinect.
Run the test program: ./bin/Protonect
Run OpenNI2 test (optional): sudo apt-get install openni2-utils && sudo make install-openni2 && NiViewer2. Environment variable LIBFREENECT2_PIPELINE can be set to cl, cuda, etc to specify the pipeline.

[링크 : https://github.com/OpenKinect/libfreenect2]

 

먼가 잔뜩 뜨긴 한데.. udev 쪽 먼가 실행하는 것 같진 않고..

[  517.098960] usb 3-1: new high-speed USB device number 5 using xhci_hcd
[  517.251097] usb 3-1: New USB device found, idVendor=045e, idProduct=02d9, bcdDevice= 0.70
[  517.251115] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  517.251122] usb 3-1: Product: NuiSensor Adaptor      
[  517.251127] usb 3-1: Manufacturer: Microsoft Corporation  
[  517.254367] hub 3-1:1.0: USB hub found
[  517.254752] hub 3-1:1.0: 1 port detected
[  517.704842] usb 4-1: new SuperSpeed USB device number 8 using xhci_hcd
[  520.690577] usb 4-1: New USB device found, idVendor=045e, idProduct=02d9, bcdDevice= 0.73
[  520.690597] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  520.690604] usb 4-1: Product: NuiSensor Adaptor      
[  520.690610] usb 4-1: Manufacturer: Microsoft Corporation  
[  520.694210] hub 4-1:1.0: USB hub found
[  520.694623] hub 4-1:1.0: 1 port detected
[  521.187545] usb 4-1.1: new SuperSpeed USB device number 9 using xhci_hcd
[  521.212947] usb 4-1.1: New USB device found, idVendor=045e, idProduct=02d8, bcdDevice= 1.00
[  521.212966] usb 4-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=4
[  521.212973] usb 4-1.1: Product: Xbox NUI Sensor
[  521.212977] usb 4-1.1: Manufacturer: Microsoft
[  521.212982] usb 4-1.1: SerialNumber: 501441643042

 

키넥트 관련은 MODE 주는 것 외에는 별다른게 없어 보인다.

src/libfreenect2/build/bin# cat ../../platform/linux/udev/90-kinect2.rules 
# this file belongs in /etc/udev/rules.d/
# ATTR{product}=="Kinect2"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02c4", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02d8", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02d9", MODE="0666"

 

에러는 동일하게 대역폭 부족이 뜬다.

$ sudo ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 10 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @4:13 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting...
[Debug] [Freenect2DeviceImpl] status 0x090000: 9731
[Error] [protocol::UsbControl] failed to set ir interface state! LIBUSB_ERROR_OTHER Other error. Try debugging with environment variable: export LIBUSB_DEBUG=3 .
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] releasing usb interfaces...
[Info] [Freenect2DeviceImpl] deallocating usb transfer pools...
[Info] [Freenect2DeviceImpl] closing usb device...
[Info] [Freenect2DeviceImpl] closed

 

[  786.203660] usb 4-2.1: reset SuperSpeed USB device number 13 using xhci_hcd
[  786.318931] usb 4-2.1: Not enough bandwidth for new device state.
[  786.318939] usb 4-2.1: Not enough bandwidth for altsetting 1

 

혹시나 해서 USB2.0에 꽂아보니 아래와 같이 에러가 발생한다.

$ sudo ./Protonect 
Version: 0.2.0
Environment variables: LOGFILE=<protonect.log>
Usage: ./Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>]
        [-noviewer] [-norgb | -nodepth] [-help] [-version]
        [-frames <number of frames to process>]
To pause and unpause: pkill -USR1 Protonect
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 9 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:5 with serial 501441643042
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening...
[Error] [protocol::UsbControl] failed to claim interface with IrInterfaceId(=1)! LIBUSB_ERROR_BUSY Resource busy. Try debugging with environment variable: export LIBUSB_DEBUG=3 .
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] deallocating usb transfer pools...
[Info] [Freenect2DeviceImpl] closing usb device...
[Info] [Freenect2DeviceImpl] closed
[Error] [Freenect2Impl] failed to open Kinect v2: @2:5
failure opening device!

 

dmesg 상에는 아래와 같이 BOS desciptor 가 없거나 너무 짧다는게 그건 또 머냐..

[  683.513603] usb 2-1.1.1: reset high-speed USB device number 5 using ehci-pci
[  683.634757] usb 2-1.1.1: unable to get BOS descriptor or descriptor too short

 

expresscard to USB3.0 을 써서 생기는 문제인가.. 아니면 빌드라던가 다른 문제인가..

 

 

+

2024.07.15

usbfs 크기가 적으니 늘리는게 도움이 된다는데 해도 해결은 안된다.

기본은 ubutu 22.04 에서 16MB 인 듯한데 1000MB로 늘려도 안된다.

$ cat /etc/default/grub | grep GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
$ cat /sys/module/usbcore/parameters/usbfs_memory_mb
16
$ sudo sh -c 'echo 1000 > /sys/module/usbcore/parameters/usbfs_memory_mb'
$ cat /sys/module/usbcore/parameters/usbfs_memory_mb
1000

[링크 : https://github.com/OpenKinect/libfreenect2/issues/971]

[링크 : https://importgeek.wordpress.com/2017/02/26/increase-usbfs-memory-limit-in-ubuntu/]

 

+

혹시나 해서 찾아보는데..

expresscard의 경우 PCIe 2 or USB 3 mode 일 경우 3.2Gbps로 USB3.0의 5Gbps 에는 어떤 모드던 부족하다.

그런데 풀 대역폭을 쓰진 않을수도 있긴한데.. USB 장치에서 필요로 하는 대역폭을 다 커버 할 수 없는건가?

 

Speed
480 Mbit/s effective (USB 2 mode)
1.6 Gbit/s effective (PCIe 1 mode)
3.2 Gbit/s effective (PCIe 2 or USB 3 mode)

[링크 : https://en.wikipedia.org/wiki/ExpressCard]

 

칩셋인 uPD720202도 스펙상 PCIe Gen2 1 lane 이고, 속도까진 나와있지 않다

System I/F: PCIe Gen2 x 1 Lane

[링크 : https://www.renesas.com/us/en/products/interface/usb-switches-hubs/upd720202-usb-30-host-controller#overview]

 

i5-2520m 도 PCIe Gen 2 라고 하는데

확장 옵션
PCI Express 개정판 2.0
PCI Express 구성 ‡ 1x16, 2x8, 1x8+2x4
최대 PCI Express 레인 수 16

[링크 : https://www.intel.co.kr/content/www/kr/ko/products/sku/52229/intel-core-i52520m-processor-3m-cache-up-to-3-20-ghz/specifications.html]

 

pci-e 2.0 lane 1은 5.0GT/s 이고 5Gbps로 계산이 되긴한다.

반대로 생각하면 USB3.0이 생각외로 빠른거구나..

[링크 : https://en.wikipedia.org/wiki/PCI_Express]

 

Depends on your thinkpad's generation of Expresscard
Gen 1 is 1.6gbps
Gen 2 is 3.2gbps
Gen 3 is 6.4gbps, but each usb port can only do a max of 5gbps
In this case it's a T420 so it has gen 2 expresscard

[링크 : https://www.reddit.com/r/thinkpad/comments/xy44zj/finally_got_the_cheapest_usb_30_express_card_for/]

 

expresscard 34 규격의 sony sxs pro 라는 저장장치 인데

우연인지 아니면 대역폭 한계인지 3.2Gbps가 검색되서 나온다. expresscard와 pci-e 와는 속도 차이가 존재하는건가?

Max. Speeds
Read speed 3.5Gbps (=440MB/s) (1)
Write Speed 3.2Gbps (=400MB/s) (1)

[링크 : https://ccktech.com/product/sony-sxs-pro/]

[링크 :  https://ccktech.com/product-interface/expresscard-34/]

'프로그램 사용 > kinect' 카테고리의 다른 글

libfreenect2 성공  (0) 2024.07.17
libfreenect2 실행 성공..  (0) 2024.07.15
libfreenect2 CUDA 끄고 빌드 성공  (0) 2024.07.13
kinect v2 / freenect 실패  (0) 2024.07.09
xbox one S / 기본형?  (0) 2024.06.25
Posted by 구차니