geaxgx / depthai_hand_tracker

Running Google Mediapipe Hand Tracking models on Luxonis DepthAI hardware (OAK-D-lite, OAK-D, OAK-1,...)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xlink error when trying the demo on ubuntu arm

TheBricktop opened this issue · comments

Im trying to use the demo on ubuntu arm (twisterOS)
and while the minimal depth ai setup works without a hitch, now there is some problems with XLINK

(venv) pi@twisteros-zero:~/pythonScripts/depthai-hand-tracker$ /home/pi/pythonScripts/depthai-hand-tracker/venv/bin/python /home/pi/pythonScripts/depthai-hand-tracker/demo.py Palm detection blob : /home/pi/pythonScripts/depthai-hand-tracker/models/palm_detection_sh4.blob Landmark blob : /home/pi/pythonScripts/depthai-hand-tracker/models/hand_landmark_lite_sh4.blob Internal camera FPS set to: 23 Sensor resolution: (1920, 1080) Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252 896 anchors have been created Creating pipeline... Creating Color Camera... Creating Palm Detection Neural Network... Creating Hand Landmark Neural Network (1 thread)... Pipeline created. [14442C1051FD60D700] [2752.231] [NeuralNetwork(4)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance Pipeline started - USB speed: HIGH [14442C1051FD60D700] [2752.233] [NeuralNetwork(6)] [warning] Number of inference threads assigned for network is 1, assigning 2 will likely yield in better performance [14442C1051FD60D700] [2752.233] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance [14442C1051FD60D700] [2752.243] [NeuralNetwork(4)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary [14442C1051FD60D700] [2752.243] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 185, resource id: 0, major code: 140 (Unknown), minor code: 20 Traceback (most recent call last): File "/home/pi/pythonScripts/depthai-hand-tracker/demo.py", line 80, in <module> frame, hands, bag = tracker.next_frame() File "/home/pi/pythonScripts/depthai-hand-tracker/HandTracker.py", line 504, in next_frame inference = self.q_pd_out.get() RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'pd_out' (X_LINK_ERROR)'

Well the culprit was sudden drop in voltage due to the oakd initialisation so ive powered it up from more robust source.

Okay it seems that it was not that, ive tried running it with attached power source and still the same crash happens.

I already had X_LINK_ERROR on my ubuntu x86_64 when using an extension usb cable. The errors disappeared when not using the extension cable.
I haven't tested with a raspberry pi.
I see in your log: USB speed: HIGH
Your rpi does not support usb3, is it correct ? Otherwise you should see: USB speed: SUPER
Do you get the problem is host mode ? In edge mode ? Both ?
Do you get the error immediately, or do you have time to see some frames ?
Are you using the latest depthai version ? And version of my repo ?

Well im using radxaZero that has a usb-c with 3.1 specs so the speed aint an issue, i have this problem in both host and edge mode on radxa but its not throwing any errors on my pc setup.
The oakd is connected directly through usbc-c (3.0 compatible) to the oakd and aforementioned socket.
Same cable is doing great on pc.
it always happens after some frames.
Im using depthai 2.11.1 because of image structure errors.
I think it was the version of the repo with the opencv 4.5.4 fix.

As your usb port is 3 compatible, I wonder wether having USB speed at HIGH instead of the expected SUPER is the symptom of a connection problem. On my side, I already had USB speed: HIGH, on my desktop, but it was a problem of cable length.

I also remember that a few months ago, the Luxonis team was aware of some issues in similar case. Here is a link on the luxonis discord about this : https://discord.com/channels/790680891252932659/799407361986658354/878247392766472232
In case, you don't have access to the discord, I copy the message below:

So there's a problem when using the default USB3-enabled firmware (that should support both USB2 and USB3), with an USB2 connection (determined by host port or USB cable), with certain hosts it causes issues. 
But forcing to use the USB2-only firmware, with that usb2Mode=True , the problem gets resolved. We still haven't found the root cause of this, so need to manually apply the workaround.

In our case, to force usb2Mode means to replace in the code:
self.device = dai.Device()
by:
self.device = dai.Device(version=dai.OpenVINO.Version.VERSION_2021_4, usb2Mode=True)
It is something you can potentially try, but it is also probable that Luxonis has already solved this problem so maybe it is a better idea that you open an issue on their discord or github.

Another remark: as the throughput of usb2 is significantly lower than usb3, the default internal FPS of the hand tracker is certainly unneccessary high. Do you still get the X_LINK_ERROR, if you force (with '-f' option) the internal FPS to a lower value, for instance ./demo.py -f 10

Same happened now while testing on raspberrypi4 :

Pipeline started - USB speed: SUPER Traceback (most recent call last): File "/home/pi/programs/oak_hands/demo.py", line 82, in <module> frame, hands, bag = tracker.next_frame() File "/home/pi/programs/oak_hands/HandTracker.py", line 503, in next_frame inference = self.q_pd_out.get() RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'pd_out' (X_LINK_ERROR)'

To limit the number of variables, can you try the following test: run in host mode with a single image as input (./demo.py -i image.jpg). Using an image as input is like using a video file where all the frames are identical.
Then observe if the X_LINK_ERROR still happens or not. If there is no error, try several kind of images (image with no hands, image with one hand,...) as the processing varies with the number of hands. If the error occurs, is it always on the same iteration or not ? If not, it means there is some instability somewhere : cable ? depthai firmware ? host ? Probably not the host since, you get the problem with 2 different hosts.

No more activity. Closing the issue.