Google Coral USB Accelerator on Raspbian Lite Buster and Raspberry PI 4 - raspberry-pi

I am following the getting started guide for the Google Coral USB Accelerator and even though I was able to trick the install.sh file to install for RPI4
https://twitter.com/hansamann/status/1154021771554766849
I cannot run the example with the image classification. When I run the sample, I get this:
python3 classify_image.py --model ~/Downloads/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --label ~/Downloads/inat_bird_labels.txt --image ~/Downloads/parrot.jpg
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_edgetpu_cpp_wrapper', [dirname(__file__)])
File "/usr/lib/python3.7/imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_edgetpu_cpp_wrapper'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "classify_image.py", line 19, in <module>
from edgetpu.classification.engine import ClassificationEngine
File "/usr/local/lib/python3.7/dist-packages/edgetpu/classification/engine.py", line 17, in <module>
from edgetpu.basic.basic_engine import BasicEngine
File "/usr/local/lib/python3.7/dist-packages/edgetpu/basic/basic_engine.py", line 15, in <module>
from edgetpu.swig.edgetpu_cpp_wrapper import BasicEngine
File "/usr/local/lib/python3.7/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 28, in <module>
_edgetpu_cpp_wrapper = swig_import_helper()
File "/usr/local/lib/python3.7/dist-packages/edgetpu/swig/edgetpu_cpp_wrapper.py", line 20, in swig_import_helper
import _edgetpu_cpp_wrapper
ModuleNotFoundError: No module named '_edgetpu_cpp_wrapper'
Any idea whay I could try?

I had the same problem but with an older Rpi 3. This is the solution I used. I don't think it's a make or break to complete the project:
$ sudo cp _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-37m-arm-linux-gnueabihf.so

Can you go through : https://github.com/google-coral/edgetpu-platforms ?
This repository holds auxiliary platform-related material related to Google Coral Edge TPU. Here you can find precompiled images, shared libraries and patches for using the USB Edge TPU accelerator on additional platforms to the main supported ones.
For convenience Google has uploaded prebuilt images for Raspberry Pi Zero, Pi 3 and Pi 4. Simply write the image to an sd card and boot up your Pi. The images contain several examples that should work out of the box.

Related

nrf24l01 Module not Working with Raspberry Pi Pico W

I can use the nrf24l01 wireless module just fine with a Raspberry Pi Pico, but when I try to compile the same code on the Raspberry Pi Pico W, it fails to recognize the device. I am using this library, and I get this error:
Traceback (most recent call last):
File "<stdin>", line 31, in <module>
File "nrf24l01.py", line 78, in __init__
OSError: nRF24L01+ Hardware not responding
The boards are supposed to have the same footprint, so what is the difference here? How can I use these modules with the Pico W?

OSError: libmmal.so: cannot open shared object file: No such file or directory while trying to run picamera on Raspbian

I am trying to open camera with the picamera module in my Raspberry pi B+ with has Raspbian 64 bit OS installed in it. I get this error:
Traceback (most recent call last):
File "/home/pi/Documents/hydroponics/scripts/picamera_test.py", line 1, in <module>
from picamera import PiCamera
File "/home/pi/.local/lib/python3.9/site-packages/picamera/__init__.py", line 72, in <module>
from picamera.exc import (
File "/home/pi/.local/lib/python3.9/site-packages/picamera/exc.py", line 41, in <module>
import picamera.mmal as mmal
File "/home/pi/.local/lib/python3.9/site-packages/picamera/mmal.py", line 49, in <module>
_lib = ct.CDLL('libmmal.so')
File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmmal.so: cannot open shared object file: No such file or directory
The camera is enabled (I tried to capture the camera with opencv and it worked).
I tried sudo rpi-update as well and it says that my firmware is already up to date.
Tried sudo apt update and sudo apt upgrade but none of them solve the above issue.
I tried sudo ldconfig -p | grep mmal as well and it outputs:
libmmal_vc_client.so (libc6) => /opt/vc/lib/libmmal_vc_client.so
libmmal_util.so (libc6) => /opt/vc/lib/libmmal_util.so
libmmal_core.so (libc6) => /opt/vc/lib/libmmal_core.so
libmmal_components.so (libc6) => /opt/vc/lib/libmmal_components.so
libmmal.so (libc6) => /opt/vc/lib/libmmal.so
Any suggestions on what I can do to solve this error? Thanks!
I just found out that picamera is still not supported for Raspbian 64 bit OS.
https://github.com/raspberrypi/firmware/issues/1558#issuecomment-983483179
So we could probably use libcamera (didn't try it yet) or opencv (tried and works fine)

TypeError: object with buffer protocol required - trying to write to SMBus

I'm using a raspberry pi pico to read data from a SHT3x sensor using the I2C protocol. I'm quite new to (micro)python so I used this example. This example is for a regular Raspberry Pi since I didn't find any for the Pico. However, the SMBus library is not found. I assume it is just not available for micropython (I have version 1.17).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'smbus'
There seems to be only one micropython wrapper for SMBus (as far as I found), this one. When I use this wrapper, the problem I have and don't understand is the following error:
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
File "usmbus.py", line 50, in write_i2c_block_data
TypeError: object with buffer protocol required
Refering to this line function: writeto_mem(addr, register, data) (documentation).
The data that I pass in is as follows
addr = 0x44
register = 0x2C
data = [0x06]
I understood that it has something to do with framebuffer in micropython not being supported, but I don't understand how to fix it. Can someone help me out? Or suggest me other solutions?
If the sensor supports I2C, you should be able to use the builtin MicroPython I2C support.
I also found a library for the SHT3x, by searching on the MicroPython forum.

Import error: cannot import name 'label_cython'

I am a new user for Ubuntu16.04 as well as caffe.
Few days ago I was working with Intel Movidius with the ncappzoo thingy and it worked. Afterward I tried to download the toolkit and API to play with. As I was verifying the installation of the toolkit, I found that the function importing caffe can no longer work. It keeps giving me this error.
I tried googling but find no solution. The $PYTHONPATH was check and verified. I also reinstalled the scikit-image.
Here's the block of gibberish thingy it bounced back to me :
File "<stdin>", line 1, in <module>
File "/workspace/SDK/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/workspace/SDK/caffe/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/workspace/SDK/caffe/python/caffe/io.py", line 4, in <module>
from skimage.transform import resize
File "/usr/local/lib/python3.5/dist-packages/skimage/transform/__init__.py", line 1, in <module>
from .hough_transform import (hough_line, hough_line_peaks,
File "/usr/local/lib/python3.5/dist-packages/skimage/transform/hough_transform.py", line 3, in <module>
from .. import measure
File "/usr/local/lib/python3.5/dist-packages/skimage/measure/__init__.py", line 6, in <module>
from ._regionprops import regionprops, perimeter
File "/usr/local/lib/python3.5/dist-packages/skimage/measure/_regionprops.py", line 7, in <module>
from ._label import label
File "/usr/local/lib/python3.5/dist-packages/skimage/measure/_label.py", line 1, in <module>
from ._ccomp import label_cython as clabel
ImportError: cannot import name 'label_cython'
Any idea what went wrong?
We are able to make use of all the apps/networks available from ncappzoo without any issues.
Our configuration is as follows:
movidius#osboxes:~$ python --version
Python 2.7.12
movidius#osboxes:~$ echo $PYTHONPATH
:/opt/movidius/caffe/python
movidius#osboxes:~$ lscpu | grep "Model name"
Model name: Intel(R) Core(TM) i5-5300U CPU # 2.30GHz
movidius#osboxes:~$ lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial
Assuming that you have downloaded the ncsdk and then installed it. If not,
First we need to install 'ncsdk' which enable rapid prototyping, validation, and deployment of deep neural networks
please follow the links mentioned below to install ncsdk
(It includes software tools, API and examples)
https://developer.movidius.com/start
https://movidius.github.io/ncsdk/install.html
once the ncsdk installation is suceessfull, then you can make use of all the apps/networks available in ncappzoo.

Using Gurobi solver in the Enthought Canopy Editor on Linux

I am currently working with Gurobi solver using python. Previously, I have just been using a mix of a text editor and the terminal to write and run my models but I am currently experimenting with using Enthought Canopy Editor. I have a model that is works when I run in in the terminal using python model.py but when I try doing%run model.py in Canopy's iPython shell I get:
%run /home/cdhagmann/Copy/Code_Env/Farmer/model.py
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/cdhagmann/Canopy/appdata/canopy-1.0.1.1189.rh5-x86_64/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
181 else:
182 filename = fname
--> 183 __builtin__.execfile(filename, *where)
/home/cdhagmann/Copy/Code_Env/Farmer/model.py in <module>()
----> 1 from gurobipy import *
2 from data_IO import read_data,currency
3 import time
4
5 # Import model data
ImportError: No module named gurobipy
My guess is that the terminal and Canopy look for modules in different places but I don't know how to rectify it. I found this reference on the Gurobi group site about Enthought Canopy and Gurobi on OS X 10.8 but didn't know how much those instruction would differ from doing it on Linux and even what he meant about installing Gurobi in Canopy's site-packages.
UPDATE: Based on information found the first link I clicked on, I did in fact leave the boxed clicked making Canopy my default directory. You have to manually prepend the PATH variable, which I missed them saying that I had to do. So I did that. I now have Canopy's version of iPython running in my terminal (check by using sys.path); however, I get a huge list of errors when I try run python.
cdhagmann#Crispin ~ $ python
Traceback (most recent call last):
File "/usr/lib/python2.7/site.py", line 563, in <module>
main()
File "/usr/lib/python2.7/site.py", line 545, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python2.7/site.py", line 237, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 505, in get_config_vars
import re
File "/usr/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/usr/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Suggestions?
And to answer #Jonathan questions:
sys.prefix = '/usr'
sys.path:
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
gurobipy.__file__ = '/usr/local/lib/python2.7/dist-packages/gurobipy/gurobipy.so'
If the terminal is correctly configured for Canopy Python, then python in terminal and Canopy Python should be looking for modules in the same places. If during installation, you disabled "make Canopy be default Python", or if you have not restarted terminal since installation, then it won't automatically be configured correctly.
These articles should help you understand and configure:
http://docs.enthought.com/canopy/configure/faq.html#where-are-all-of-the-python-packages-in-my-user-python-environment
https://support.enthought.com/entries/23646538-Make-Canopy-s-Python-be-your-default-Python-i-e-on-the-PATH-
https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line
If these articles do not suffice for you to solve this, then please report -- when you run python from terminal, what are these?
sys.prefix
sys.path
gurobipy.__file__