Today I’d love to talk about Pixy Cam a bit, which I do NOT recommend at all. There are several reasons:
Price: As you can see from Amazon, it’s comparatively expensive, $95 USD.
Warranty period: 90 days from date of purchase
Size: too big
Actually, I purchased PIXY (with pan tilt mount base) in 2016 from amazon.com. However, it went died long time ago. What’s more, I’ve tested ALL possible solutions from Pixycam Troubleshooting, but the 90-day warranty is easy to pass.
I do NOT want to talk more about Pixy Cam, and here is **my conclusion: Please use esp32-cam instead.
Therefore, it looks the simplest solution is to just download OpenMV IDE from https://openmv.io/pages/download. However, to run the installed openmvide only brought me the following ERROR messages.
1 2 3 4 5 6 7
➜ openmv ./openmv-ide-linux-x86_64-2.2.0.run This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.
Reinstalling the application may fix this problem.
Test OpenMV
In the following, we ONLY use picocom to carry out the test.
port is : /dev/ttyACM0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no
Type [C-a] [C-h] to see available commands Terminal ready MicroPython v1.9.3-4922-ge0f81c867 on 2018-04-23; OPENMV2 with STM32F427 Type "help()" for more information. >>>
Press Ctrl+A then Ctrl+x, picocom will terminate its execution.
port is : /dev/ttyACM0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no
Type [C-a] [C-h] to see available commands Terminal ready MicroPython v1.9.4-4510-g23e8457de on 2018-06-29; OPENMV3 with STM32F765 Type "help()" for more information. >>> Terminating... Thanks for using picocom ➜ ~
Flash OpenMV Firmware Onto OpenMV Board
1. Entering DFU Mode
Similar to what’s discussed in our previous blog, we need to enter DFU mode before flashing.
Disconnect the power for OpenMV board FIRST
Connect BOOT pin and RST pin afterwards
Then, reconnect the USB cable for flashing.
Before entering DFU mode:
1 2 3 4
➜ ~ lsusb ... Bus 001 Device 027: ID 1209:abd1 InterBiometrics ...
After entering DFU mode:
1 2 3 4
➜ ~ lsusb ... Bus 001 Device 028: ID 0483:df11 STMicroelectronics STM Device in DFU Mode ...
2. Flashing OpenMV’s Firmware
Checkout the NEWESTOpenMV. Find the corrensponding version of OpenMV board, flash it by command python pydfu.py -u <firmware.dfu>.
1) OpenMV Cam M4 V2 (OPENMV2 with STM32F427)
1 2 3 4 5 6 7 8 9 10 11
➜ openmv git:(master) python ./tools/pydfu.py -u firmware/OPENMV2/firmware.dfu ./tools/pydfu.py:80: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec() if 'length' in inspect.getargspec(usb.util.get_string).args: File: firmware/OPENMV2/firmware.dfu b'DfuSe' v1, image size: 834757, targets: 1 b'Target' 0, alt setting: 0, name: "ST...", size: 834472, elements: 1 0, address: 0x08010000, size: 834464 usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0x9dfe8e73 Writing memory... 0x08010000 834464 [=========================] 100% Exiting DFU...
port is : /dev/ttyACM0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no
Type [C-a] [C-h] to see available commands Terminal ready 6792 18.86792 18.86792 18.86792 18.86792 18.86792 18.86792 ...... Traceback (most recent call last): File "/main.py", line 51, in <module> KeyboardInterrupt: MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV2 with STM32F427 Type "help()" for more information. >>> Terminating... Thanks for using picocom
Check file main.py, which starts running automatically while testing with picocom.
# Face Detection Example # # This example shows off the built-in face detection feature of the OpenMV Cam. # # Face detection works by using the Haar Cascade feature detector on an image. A # Haar Cascade is a series of simple area contrasts checks. For the built-in # frontalface detector there are 25 stages of checks with each stage having # hundreds of checks a piece. Haar Cascades run fast because later stages are # only evaluated if previous stages pass. Additionally, your OpenMV Cam uses # a data structure called the integral image to quickly execute each area # contrast check in constant time (the reason for feature detection being # grayscale only is because of the space requirment for the integral image).
import sensor, time, image
# Reset sensor sensor.reset()
# Sensor settings sensor.set_contrast(1) sensor.set_gainceiling(16) # HQVGA and GRAYSCALE are the best for face tracking. sensor.set_framesize(sensor.HQVGA) sensor.set_pixformat(sensor.GRAYSCALE)
# Load Haar Cascade # By default this will use all stages, lower satges is faster but less accurate. face_cascade = image.HaarCascade("frontalface", stages=25) print(face_cascade)
# FPS clock clock = time.clock()
while (True): clock.tick()
# Capture snapshot img = sensor.snapshot()
# Find objects. # Note: Lower scale factor scales-down the image more and detects smaller objects. # Higher threshold results in a higher detection rate, with more false positives. objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
# Draw objects for r in objects: img.draw_rectangle(r)
# Print FPS. # Note: Actual FPS is higher, streaming the FB makes it slower. print(clock.fps())
2) OpenMV Cam M7 (OPENMV3 with STM32F765)
1 2 3 4 5 6 7 8 9 10 11
➜ openmv git:(master) python ./tools/pydfu.py -u firmware/OPENMV3/firmware.dfu ./tools/pydfu.py:80: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec() if 'length' in inspect.getargspec(usb.util.get_string).args: File: firmware/OPENMV3/firmware.dfu b'DfuSe' v1, image size: 1297173, targets: 1 b'Target' 0, alt setting: 0, name: "ST...", size: 1296888, elements: 1 0, address: 0x08020000, size: 1296880 usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0xeff0bf62 Writing memory... 0x08020000 1296880 [=========================] 100% Exiting DFU...
port is : /dev/ttyACM0 flowcontrol : none baudrate is : 9600 parity is : none databits are : 8 stopbits are : 1 escape is : C-a local echo is : no noinit is : no noreset is : no hangup is : no nolock is : no send_cmd is : sz -vv receive_cmd is : rz -vv -E imap is : omap is : emap is : crcrlf,delbs, logfile is : none initstring : none exit_after is : not set exit is : no
Type [C-a] [C-h] to see available commands Terminal ready MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV3 with STM32F765 Type "help()" for more information. >>> Terminating... Thanks for using picocom ➜ openmv git:(master)
As you can see, firmware has NOW been updated to MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02.
# Snapshot Example # # Note: You will need an SD card to run this example. # # You can use your OpenMV Cam to save image files.
import sensor, image, pyb
RED_LED_PIN = 1 BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.skip_frames(time = 2000) # Let new settings take affect.
pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 2000) # Give the user time to get ready.
# MJPEG Video Recording Example # # Note: You will need an SD card to run this demo. # # You can use your OpenMV Cam to record mjpeg files. You can either feed the # recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished # recording a Mjpeg file you can use VLC to play it. If you are on Ubuntu then # the built-in video player will work too.
import sensor, image, time, mjpeg, pyb
RED_LED_PIN = 1 BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.skip_frames(time = 2000) # Let new settings take affect. clock = time.clock() # Tracks FPS.
pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 2000) # Give the user time to get ready.
By following our previous blog Build GCC, we should be able to CROSS-BUILD GCC for various ARM architectures. Today, we are building GCC 9.1.0 for Hikey 970, which is of aarch64 architecture. (More details about aarch64 can be found on ARM architecture )
➜ aarch64 mkdir build-binutils ➜ aarch64 cd build-binutils lvision@hikey970:~/Downloads/Programming/GCC/build-binutils$ ../binutils-2.32/configure --prefix=/opt/aarch64 --enable-shared --enable-vtable-verify checking build system type... aarch64-unknown-linux-gnu checking host system type... aarch64-unknown-linux-gnu checking target system type... aarch64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /bin/sed checking for gawk... gawk checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... gnatbind checking for gnatmake... gnatmake checking whether compiler driver understands Ada... no checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for isl 0.15 or later... yes checking for default BUILD_CONFIG... checking for --enable-vtable-verify... yes checking for bison... bison -y checking for bison... bison checking for gm4... no checking for gnum4... no checking for m4... m4 checking for flex... flex checking for flex... flex checking for makeinfo... makeinfo checking for expect... expect checking for runtest... no checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for ranlib... ranlib checking for strip... strip checking for windres... no checking for windmc... no checking for objcopy... objcopy checking for objdump... objdump checking for readelf... readelf checking for cc... cc checking for c++... c++ checking for gcc... gcc checking for gfortran... gfortran checking for gccgo... gccgo checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for objcopy... objcopy checking for objdump... objdump checking for ranlib... ranlib checking for readelf... readelf checking for strip... strip checking for windres... no checking for windmc... no checking where to find the target ar... just compiled checking where to find the target as... just compiled checking where to find the target cc... host tool checking where to find the target c++... host tool checking where to find the target c++ for libstdc++... host tool checking where to find the target dlltool... just compiled checking where to find the target gcc... host tool checking where to find the target gfortran... host tool checking where to find the target gccgo... host tool checking where to find the target ld... just compiled checking where to find the target lipo... host tool checking where to find the target nm... just compiled checking where to find the target objcopy... just compiled checking where to find the target objdump... just compiled checking where to find the target ranlib... just compiled checking where to find the target readelf... just compiled checking where to find the target strip... just compiled checking where to find the target windres... just compiled checking where to find the target windmc... just compiled checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile ➜ build-binutils make -j4 ...... ➜ build-binutils make install ➜ build-binutils cd ..
➜ aarch64 mkdir -p build-gcc ➜ aarch64 cd build-gcc $ ../gcc-9.1.0/configure --prefix=/opt/aarch64 --enable-multiarch --enable-languages=c,c++,fortran,go --disable-multilib --disable-libvtv --enable-vtable-verify checking build system type... aarch64-unknown-linux-gnu checking host system type... aarch64-unknown-linux-gnu checking target system type... aarch64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /bin/sed checking for gawk... gawk checking for libatomic support... yes checking for libitm support... yes checking for libsanitizer support... yes checking for libhsail-rt support... no checking for libphobos support... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... gnatbind checking for gnatmake... gnatmake checking whether compiler driver understands Ada... no checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for the correct version of gmp.h... yes checking for the correct version of mpfr.h... yes checking for the correct version of mpc.h... yes checking for the correct version of the gmp/mpfr/mpc libraries... yes checking for isl 0.15 or later... yes *** This configuration is not supported in the following subdirectories: gnattools target-libada target-libhsail-rt target-libphobos target-zlib target-libobjc target-liboffloadmic target-libvtv (Any other directories should still work fine.) checking for default BUILD_CONFIG... bootstrap-debug checking for --enable-vtable-verify... yes checking for bison... bison -y checking for bison... bison checking for gm4... no checking for gnum4... no checking for m4... m4 checking for flex... flex checking for flex... flex checking for makeinfo... makeinfo checking for expect... expect checking for runtest... no checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for ranlib... ranlib checking for strip... strip checking for windres... no checking for windmc... no checking for objcopy... objcopy checking for objdump... objdump checking for otool... no checking for readelf... readelf checking for cc... cc checking for c++... c++ checking for gcc... gcc checking for gfortran... gfortran checking for gccgo... gccgo checking for gdc... no checking for ar... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ar checking for as... /opt/aarch64/aarch64-unknown-linux-gnu/bin/as checking for dlltool... no checking for dlltool... no checking for ld... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ld checking for lipo... no checking for lipo... no checking for nm... /opt/aarch64/aarch64-unknown-linux-gnu/bin/nm checking for objcopy... /opt/aarch64/aarch64-unknown-linux-gnu/bin/objcopy checking for objdump... /opt/aarch64/aarch64-unknown-linux-gnu/bin/objdump checking for otool... no checking for otool... no checking for ranlib... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ranlib checking for readelf... /opt/aarch64/aarch64-unknown-linux-gnu/bin/readelf checking for strip... /opt/aarch64/aarch64-unknown-linux-gnu/bin/strip checking for windres... no checking for windres... no checking for windmc... no checking for windmc... no checking where to find the target ar... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target as... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target cc... just compiled checking where to find the target c++... just compiled checking where to find the target c++ for libstdc++... just compiled checking where to find the target dlltool... host tool checking where to find the target gcc... just compiled checking where to find the target gfortran... just compiled checking where to find the target gccgo... just compiled checking where to find the target gdc... host tool checking where to find the target ld... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target lipo... host tool checking where to find the target nm... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target objcopy... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target objdump... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target otool... host tool checking where to find the target ranlib... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target readelf... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target strip... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin checking where to find the target windres... host tool checking where to find the target windmc... host tool checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile ➜ build-gcc make -j4 all-gcc ➜ build-gcc make install-gcc ➜ build-gcc cd ..
Today, let’s try to build the MOST RECENTGCC 9.1. We strictly follow the TERRIFIC blog How to Build a GCC Cross-Compiler with trivial modifications for my x86_64 desktop instead of aarch64 cross compile.
Preparations
Packages Required on HOST
Some packages are required to install on the host computer, including:
g++
make
gawk
bison
flex
expect
gnat etc.
Get ALL Packages for Building GCC
A wget-list.txt file is provided to download ALL required packages up-to-date. After having downloaded this single text file, the UNIQUE command to download all files is as follows:
1
➜ gcc ✗ wget -i wget-list.txt
You can of course download the files one by one. All concerned files are listed below:
➜ gcc mkdir build-binutils ➜ gcc cd build-binutils ➜ build-binutils ../binutils-2.32/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-vtable-verify checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /usr/bin/sed checking for gawk... gawk checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... gnatbind checking for gnatmake... gnatmake checking whether compiler driver understands Ada... yes checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for isl 0.15 or later... no required isl version is 0.15 or later checking for default BUILD_CONFIG... checking for --enable-vtable-verify... yes checking for bison... bison -y checking for bison... bison checking for gm4... no checking for gnum4... no checking for m4... m4 checking for flex... flex checking for flex... flex checking for makeinfo... makeinfo checking for expect... expect checking for runtest... no checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for ranlib... ranlib checking for strip... strip checking for windres... no checking for windmc... no checking for objcopy... objcopy checking for objdump... objdump checking for readelf... readelf checking for x86_64-linux-gnu-cc... no checking for cc... cc checking for x86_64-linux-gnu-c++... no checking for c++... c++ checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc checking for x86_64-linux-gnu-gfortran... x86_64-linux-gnu-gfortran checking for x86_64-linux-gnu-gccgo... no checking for gccgo... no checking for x86_64-linux-gnu-ar... x86_64-linux-gnu-ar checking for x86_64-linux-gnu-as... x86_64-linux-gnu-as checking for x86_64-linux-gnu-dlltool... no checking for dlltool... no checking for x86_64-linux-gnu-ld... x86_64-linux-gnu-ld checking for x86_64-linux-gnu-lipo... no checking for lipo... no checking for x86_64-linux-gnu-nm... x86_64-linux-gnu-nm checking for x86_64-linux-gnu-objcopy... x86_64-linux-gnu-objcopy checking for x86_64-linux-gnu-objdump... x86_64-linux-gnu-objdump checking for x86_64-linux-gnu-ranlib... x86_64-linux-gnu-ranlib checking for x86_64-linux-gnu-readelf... x86_64-linux-gnu-readelf checking for x86_64-linux-gnu-strip... x86_64-linux-gnu-strip checking for x86_64-linux-gnu-windres... no checking for windres... no checking for x86_64-linux-gnu-windmc... no checking for windmc... no checking where to find the target ar... just compiled checking where to find the target as... just compiled checking where to find the target cc... host tool checking where to find the target c++... host tool checking where to find the target c++ for libstdc++... host tool checking where to find the target dlltool... just compiled checking where to find the target gcc... host tool checking where to find the target gfortran... host tool checking where to find the target gccgo... host tool checking where to find the target ld... just compiled checking where to find the target lipo... host tool checking where to find the target nm... just compiled checking where to find the target objcopy... just compiled checking where to find the target objdump... just compiled checking where to find the target ranlib... just compiled checking where to find the target readelf... just compiled checking where to find the target strip... just compiled checking where to find the target windres... just compiled checking where to find the target windmc... just compiled checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile ➜ build-binutils make -j4 ...... ➜ build-binutils make install ➜ build-binutils cd ..
Linux Kernel Headers
1 2 3
➜ gcc cd linux-5.1.12 ➜ linux-5.1.12 make ARCH=x86 INSTALL_HDR_PATH=/opt/native/linux headers_install ➜ linux-5.1.12 cd ..
C/C++ Compilers
1 2 3 4 5 6
➜ gcc mkdir -p build-gcc ➜ gcc cd build-gcc ➜ build-gcc ../gcc-9.1.0/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-languages=c,c++,fortran,go --disable-multilib --enable-vtable-verify ➜ build-gcc make -j4 all-gcc ➜ build-gcc make install-gcc ➜ build-gcc cd ..