DepthAI Gen2 example 01_rgb_preview Fail to Run on Raspberry Pi Zero W
Jason. Apologies. I was mistaken. I take detailed notes, and should have checked them before responding. (I must have been thinking of something else that resulted in "Illegal instruction".)
My error message was:
(lux_only) pi@oak1b:~/depthai-python/examples $ python3 01_rgb_preview.py
Traceback (most recent call last):
File "01_rgb_preview.py", line 23, in <module>
with dai.Device(pipeline) as device:
RuntimeError: Failed to find device (ma2480), error message: X_LINK_DEVICE_NOT_FOUND
Most likely due to trying to run Gen2 examples with Gen1 depthai, I would think.
My venv/bin is :
(lux_only) pi@oak1b:~/.virtualenvs/lux_only/bin $ ls -al | grep python
lrwxrwxrwx 1 pi pi 16 Apr 1 11:34 python -> /usr/bin/python3
lrwxrwxrwx 1 pi pi 6 Apr 1 11:34 python3 -> python
lrwxrwxrwx 1 pi pi 6 Apr 1 11:34 python3.7 -> python
And in the hope that it might be helpful, I will include my entire install notes below:
Downloaded 32 bit via Raspberry Pi Imager
Set time/loc/passwd/connected to WLAN/ran upddates / rebooted
Renamed host to 'oak1b'
>Preferences>Raspberry Pi Configuration
Renamed to 'oak1b'
Enabled camera, VNC, SSH
Increased GPU to 128
rebooted / checked settings
set static wifi ip / disabled IPv6 / rebooted
connected to vnc
sudo rpi-eeprom-update checked
right click on Task Bar and Add/Remove Panel items.
added CPU temp
added CPU usage
sudo apt update
sudo apt full-upgrade
sudo apt install python3 python3-pip
sudo apt install build-essential cmake pkg-config
sudo apt install libatlas-base-dev gfortran
sudo apt install libhdf5-serial-dev hdf5-tools
mkdir python-envs && cd python-envs
pip3 install virtualenvwrapper
sudo nano ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=./python-envs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_ENV_BIN_DIR=bin
exit
mkvirtualenv lux_only
[my notes are not clear at this point - but essentially - within the lux_only env, I followed the basic steps of dependencies.sh, install_reqs and then I wasn't sure which depth-ai to install, and ended up trying to install Gen1, and I think the snapshot (though maybe I am mistaken and am remembering a previous occasion...);
but the end result was that I ended up running: pip uninstall depthai]
//then my notes start again...
python3 install_requirements.py
...Installing collected packages: depthai
Successfully installed depthai-2.1.0.0
After that I was successfully able to execute the scripts in the examples folder.
I hope this is helpful, and apologies for my initial incorrect response.
Thanks, Ryan! And let us know if this doesn't solve it, Jason.
ryan I followed your notes:
#rpi-eeprom-update is specific to Pi4
sudo apt update
sudo apt full-upgrade
sudo apt install python3 python3-pip
sudo apt install build-essential cmake pkg-config
sudo apt install libatlas-base-dev gfortran
sudo apt install libhdf5-serial-dev hdf5-tools
I'm using virtualenv, which is on the path and I didn't find any env settings related to venv
so I skipped those related to virtualenvwrapper
cd depthai-python && activate its venv
cd examples && python3 install_requirements.py # which uninstall depthai then install depthai-2.1.0.0 successfully.
Run the 01_ example again. Same error "Illegal Instructions"
Clearly, your venv contains python3.7. Mine didn't have it. I found python3 and python3.7 under usr/bin which is on the sys path. So it should not have caused the problem.
Hi @Jason ,
Sorry about the delay. So I'm not sure if it's related, but when we upgraded our Pi's recently, based on a tip from a local company here, we discovered that on the latest Pi OS we have some sort of issue that was not there at all on the previous versions. Here is the summary so far:
https://github.com/luxonis/depthai/issues/354
I do not know if this is related though. We had indeed gotten OAK-1 (and other depthai models working) on Pi Zero, but there may be some regression related to the above, or perhaps some other regression.
Will test it out and report back. We have @themarpe and @GergelySzabolcs in parallel investigating what is going wrong here.
Sorry about the issue/delays here.
-Brandon
- Edited
Jason
We don't have prebuilt wheels for pi zero (armv6).
You need to compile and install wheels manually, according to the instructions from here.
sudo curl -fL http://docs.luxonis.com/_static/install_dependencies.sh | bash
git clone https://github.com/luxonis/depthai-python.git --recursive
cd depthai-python
python3 -m pip install .
Will take up to 1 hour.
- Edited
Here is a wheel for pi zero based on latest release:
install as python3 -m pip install depthai-2.2.0.0.dev0+f9b3c48b2e32937811e3c94261abf1864ebf92f8-cp37-cp37m-linux_armv6l.whl
Brandon The discussion didn't can you get a link to the RPi OS download/install version that worked with pi zero?
GergelySzabolcs Thanks. I followed the process. After 1.5 hr while building the wheels, the RPi Z started blinking and frozen (lost all connections). I had experienced this at least once during Gen2 installs (only some process build wheels, perhaps including the link listed below).
Jason Thanks and sorry for the pain. I'm asking internally about pre-building the Pi Zero wheels as well automatically.
I just responded to the Github issue on which version does work - but TLDR unfortunately I don't know yet as I didn't write down the version I was on when I did a dist-upgrade. But we have logs of this so @Brian is looking into it and we'll circle back.
GergelySzabolcs Is there a link to the wheel shown? It replied with an OSError about not finding the local file.
Our forum software is confusing. It makes the link look like an image because it has Google Docs integration. So the above is actually a link to the Google Drive folder. Below is the same thing written as code so that our forum software doesn't show it looking like an image:
https://drive.google.com/file/d/1pEb0_OCA3eYZAncolTHy8hSlQiK2S0KX/view
Here is the link with our forum software allowed to show it as embedded content:
Brandon Thanks. I downloaded and installed the wheel. When cd examples to run the 01_ example, it reported:
Unable to init server: Could not connect: Connection refused
Traceback (most recent call last):
File "01_rgb_preview.py", line 34, in <module>
cv2.imshow("bgr", inRgb.getCvFrame())
cv2.error: OpenCV(4.5.1) /tmp/pip-wheel-qd18ncao/opencv-python/opencv/modules/highgui/src/window_gtk.cpp:624: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'
I then did a 'python3 -m pip install opencv-python --force-reinstall', successfully, but still had the same error when running the example.
Jason
You need to enable X forwarding if you are connected through SSH,
ssh pi@<ip_address> -X
GergelySzabolcs Brandon
My bad. I should have remembered opencv window doesn't know where to imshow in ssh session. The X forwading still has the same problem. Are there more steps to set it properly? It works in vnc terminal now.
I always forget how to properly get XForwarding working. I ended up getting a mini-HDMI to HDMI adapter cable (here) and then a micro USB adapter (here) which I hooked to a USB hub (here) for doing all the initial testing on the Pi. That way I could get everything working first before fighting XForwarding
- Edited
Last night I tested multiple examples on Pi Zero, all working using the prebuilt wheel. Bravos GergelySzabolcs Brandon ! I'm still curious how you guys got around the problem prebuild the wheel for RPi OS, while my pi zero refused to.
For any newbies exploring practical use, Pi Zero is too slow for handling video streams/files, with or without depthai. May still good for still pictures if Oak-1 or Oak-D handle all the detection and trigger pi zero to store the critical images. Any tips or comments would be great.
RPI zero has only 512 MB ram, which is not enough to compile from sources.
I increased swap size to 1GB to overcome this.
https://pimylifeup.com/raspberry-pi-swap-file/
Thanks for circling back Jason .
And for taking still pictures based on seeing a given class, check out this example:
https://github.com/luxonis/depthai-experiments/tree/master/gen2-class-saver-jpeg
Question on the Pi Zero slowness: Is it fast enough to just save the video that DepthAI outputs from the DepthAI video encoder? I was assuming (and I think I'm quoted that it is) but I'm not sure if I actually tested it (can't recall). The reason I was thinking so is that 1920x1080 on not-high settings is only 3mbps. And I figured an ARMv6 had to be able to ingest that and save to uSD card without a problem. I wouldn't expect it to be able to play it, but at least to be able to save it.
Thoughts?
Thanks,
Brandon