1.     Background

Realising that the Beaglebone AI could be used to detect invasive species and then eradicate them without the use of pesticides led me to suggest the AI Vision - iBox project.

Kindly Element14 and tariq.ahmad sent me a Beaglebone-AI board to experiment with. I know nothing about AI and therefore thought this a great opportunity to learn and blog my experiences. This blogpost #2 will be more focused on getting the BB-AI working and to the point of experimentation with AI techniques rather than the actual moth identification. What follows is the start of a quite long journey as I am not the most knowledgeable of Linux users although projects like this really help push me onwards.

 

I am using my nice little portable TENMA 72-2660 PSU for the USB output, also a gift from Element14.  This is great as it also details the current consumption - a real insight into what the BB-AI is doing. You can see it in one of the gallery photo below with a current draw of 713mA by the BB-AI.

 

2.     Cooling Issues

Anyone logging into Element14 over the last few days would likely have seen a few blogs about the BB-AI overheating and unfortunately a few members seem to have damaged their boards as a consequence. Luckily for me and my board I didn't have a USB-C power connector and had to wait a few days to get one. Therefore my first task was to add additional cooling and I did that as detailed in Re: Beaglebone Ai Heating Issues

{gallery} BB-AI

3.     Logging in And Updating

More issues were raised regarding the update process. I followed the guide on Beaglebone AI website and didn't seem to run into any issues using the following:

sudo apt update
sudo apt upgrade

 

For clarification, I am only using the inbuilt 16GByte memory for the OS (as was pre-installed). I did try adding a separate 4GByte MicroSD card but I think the BB_AI then trys to boot from it. Initially it contained an image from my Beagleboard Pocket and I never saw the Cloud9 IDE appearing. I then wiped the SD Card and it didn't seem to boot at all. Taking the SD Card out allowed boot to the Cloud9 IDE again.

 

4.     OpenCV

Onto the task of my project I knew I needed to interpret images and had heard that OpenCV was full of algorithms and utilities. I therefore thought that would be an essential install and set about getting the software onto my BB-AI. Not being a Linux expert I searched around for a beginners guide but didn't find something that related to OpenCV4 and Beaglebone-AI so I had to try and use/interpret various sections from several documents. Some of these made a VM on the BB-AI, some talked about installing swap-disks but those steps failed and there were various choices in the CMAKE command. Below is just a few snippets of the disappointment after hours of sitting in from of my screen .

 

Scanning dependencies of target pch_Generate_opencv_perf_stitching
[ 34%] Generating perf_precomp.hpp
[ 34%] Generating perf_precomp.hpp.gch/opencv_perf_stitching_RELEASE.gch
[ 34%] Building CXX object modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/euclidean_resection.cc.o
[ 34%] Built target pch_Generate_opencv_perf_stitching
Scanning dependencies of target pch_Generate_opencv_stitching
[ 34%] Generating precomp.hpp
[ 34%] Generating precomp.hpp.gch/opencv_stitching_RELEASE.gch
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/build.make:86: recipe for target 'modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/euclidean_resection.cc.o' failed
make[2]: *** [modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/euclidean_resection.cc.o] Error 4
CMakeFiles/Makefile2:10917: recipe for target 'modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/all' failed
make[1]: *** [modules/sfm/src/libmv/libmv/multiview/CMakeFiles/multiview.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 34%] Built target pch_Generate_opencv_stitching
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
(cv) debian@beaglebone:~/opencv/build$

 

One of the articles I tried to follow was focused on OpenCV 4.1.1 (good as that is the current version) and the title was for Raspberry Pi 4 or Beagleboard....so not far off the BB-AI in my thinking. The article detailed two builds and of course opted for the more difficult by more 'open' option 4b. Most of the install seemed to make sense but there was a part that talked about creating a swap file and I skipped that. Other articles seem to cause issues that when I investigated were related to cross-compiler between x86 and ARM (that seems irrelevant to my situation). A couple of the external links I tried to follow are:

 

 

At one point in my endevours there was a virtual machine creation session, name 'CV' and again most of that appeared to be correct to the online guide. However running the make -jN options gave mixed results. It sometime hung very early on or at a specific point. Once it ran all night and I found it had hung early into that session.

 

After various cmake attempts I get a summary of the setup, this was the most recent but I've also had other depending upon the article I attempted to follow and which CMAKE options were included:

-- General configuration for OpenCV 4.1.0 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /home/debian/opencv_all/opencv_contrib-4.1.0/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2019-10-06T13:50:35Z
--     Host:                        Linux 4.14.108-ti-r113 armv7l
--     Target:                      Linux 1 arm
--     CMake:                       3.7.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
--
--   CPU/HW features:
--     Baseline:                    VFPV3 NEON
--       requested:                 DETECT
--       required:                  VFPV3 NEON
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/arm-linux-gnueabihf-g++  (ver 6.3.0)
--     C++ flags (Release):         -mthumb  -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -mthumb  -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/arm-linux-gnueabihf-gcc
--     C flags (Release):           -mthumb  -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -mthumb  -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now   -Wl,--gc-sections
--     Linker flags (Debug):        -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now   -Wl,--gc-sections
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java js matlab ovis sfm viz
--     Applications:                perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         YES
--
--   GUI:
--     GTK+:                        YES (ver 3.22.11)
--       GThread :                  YES (ver 2.50.3)
--       GtkGlExt:                  NO
--
--   Media I/O:
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        libjpeg-turbo (ver 2.0.2-62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.36)
--     TIFF:                        build (ver 42 - 4.0.10)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (57.64.101)
--       avformat:                  YES (57.56.101)
--       avutil:                    YES (55.34.101)
--       swscale:                   YES (4.2.100)
--       avresample:                YES (3.1.0)
--     GStreamer:                   YES (1.10.4)
--     v4l/v4l2:                    YES (linux/videodev2.h)
--
--   Parallel framework:            pthreads
--
--   Trace:                         YES (built-in)
--
--   Other third-party libraries:
--     Lapack:                      NO
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/debian/opencv_all/opencv-4.1.0/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.13)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython2.7.so
--     numpy:                       /usr/lib/python2/dist-packages/numpy/core/include (ver undefined - cannot be probed because of the cross-compilation)
--     install path:                lib/python2.7/dist-packages/cv2/python-2.7
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.3)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython3.7m.so
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver undefined - cannot be probed because of the cross-compilation)
--     install path:                lib/python3.5/dist-packages/cv2/python-3.5
--
--   Python (for build):            /usr/bin/python2.7
--
--   Install to:                    /opt/opencv-4.1.0
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/debian/opencv_all/opencv-4.1.0/build

 

5.     Has it Crashed - How can I tell ?

After over 24 hours of cycling around trying different approaches I've had a thought. The make -jN option has seen varied progress. Sometimes it hangs almost immediately, which is what I am seeing now. What I'm not sure about is whether this is an actual hang or the BB-AI is just doing some processing/configuration. I've lost connection to the Cloud9 IDE which is cycling about trying to reconnect. However current consumption to BB-AI is up at about 1A and the user LED's are still flashing away.

 

I'm a bit loathed to turn it off in case it is actually progressing the install.

 

-- Build files have been written to: /home/debian/opencv_all/opencv-4.1.0/build
debian@beaglebone:~/opencv_all/opencv-4.1.0/build$ make -j16
Scanning dependencies of target ade
Scanning dependencies of target libjasper
Scanning dependencies of target gen_opencv_python_source
Scanning dependencies of target libprotobuf
Scanning dependencies of target opencv_videoio_plugins
Scanning dependencies of target zlib
Scanning dependencies of target quirc
Scanning dependencies of target libjpeg-turbo
Scanning dependencies of target carotene_objs
Scanning dependencies of target libwebp
[  0%] Built target opencv_videoio_plugins
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/decode.c.o
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/version_db.c.o
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/quirc.c.o
[  0%] Generate files for Python bindings and documentation
[  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/edge.cpp.o
[  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/assert.cpp.o
[  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp.o
[  0%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/check_cycles.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.o
[  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/execution_engine.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/compress.c.o
[  1%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_cm.c.o
[  1%] Building CXX object 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/absdiff.cpp.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jcapimin.c.o
[  1%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_debug.c.o
[  1%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_getopt.c.o
[  1%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/alpha_dec.c.o
[  1%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_icc.c.o
[  1%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/graph.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/crc32.c.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jcapistd.c.o
[  1%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_iccdata.c.o
[  1%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/deflate.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzclose.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzlib.c.o
[  1%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/buffer_dec.c.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jccoefct.c.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jccolor.c.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jcdctmgr.c.o
[  1%] Building C object 3rdparty/libwebp/CMakeFiles/libwebp.dir/src/dec/frame_dec.c.o
[  1%] Building C object 3rdparty/libjpeg-turbo/CMakeFiles/libjpeg-turbo.dir/src/jchuff.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzread.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzwrite.c.o

 

6.     Powering Off BB-AI

When running my BB-AI is drawing about 700mA to 1A in the idle state and the green user LEDs are flickering away.

 

6.1     Reset From Crash

Once 'crashed' and the Cloud9 IDE is unresponsive I have little choice but to use:

  • the 'reset' button
  • 'power off' button
  • PSU off

 

In this instance the power button has no effect, the current drawn is staying at around 1A and the user LEDs continue to flash. I also tried a 10s hold-down to no avail. Actually the current consumption just swung all over the place like I had made it angry !

 

Pressing reset instantly extinguished the LEDs and the current consumption fell to 400mA. It then just sits like this and I am unsure if it has powered off or is in some half-state. It doesn't connect to the Cloud9 IDE either. Pressing reset again kicks the board into life....I'm partly thinking the two buttons are reversed in operation ? This second press increases the current back up to 700mA and the Cloud9 IDE can be refreshed and starts to work.

 

6.2     IDE Reset / Power Off

For a more graceful approach if I have IDE control I would use:

sudo shutdown -h now

 

7.     My Thoughts

Strangely this approach of struggling my way through is really good fun - I guess the challenge is to try and understand so much of the BB-AI, the Linux, OpenCV as just a starter. I've learnt a lot about the BB-AI already although not very much on the AI aspects. Maybe in time I'll loose that enthusiasm if I keep hitting a brick wall, but it is definitely a long way off still .

 

Perhaps my approach of installing OpenCV is not required and I think I'll change direction for a bit, do some more reading on AI, read about TensorFlow and if I can get that onto the BB-AI.

 

[update: now looking at the TIDL examples...]