Sipeed MaiX Bit OpenMV Demos - Computer Vision

Introduction: Sipeed MaiX Bit OpenMV Demos - Computer Vision

About: https://www.youtube.com/c/hardwareai My channel about robotics with ROS and machine learning!

This is the second article in series about Sipeed AI on the Edge microcontroller platform. This time I will be writing about MaiX Bit(link to Seeed Studio Shop), a smaller, breadboard ready development board. It's specifications are very similar to MaiX Dock, the board I used for last tutorial, since they use the same chip, Kendryte K210.

We're going to be using micropython firmware to try some OpenMV demos. Here's description from OpenMV homepage:

The OpenMV project is about creating low-cost, extensible, Python powered, machine vision modules and aims at becoming the “Arduino of Machine Vision“.
...
Python makes working with machine visions algorithms much easier. For example, the find_blobs() method in the code finds color blobs and returns a list of 8-valued objects representing each color blob found. In Python iterating through the list of objects returned by find_blobs() and drawing a rectangle around each color blob is easily done in just two lines of code.

So, despite MaiX Bit features dedicated neural network accelerator, sometimes it might be easier to just use OpenMV hard-coded algorithms to do the job or use them alongside each other.

Some use cases that come to my mind are:

1) Line detection for line follower bot

2) Detecting traffic lights with circle and color detection

3) Using face detection to find the faces for face recognition(with DNN)

Github repository for this article

Step 1: Flash Micropython Firmware

First of all we will need to flash micropython firmware to our board. A precompiled binary is included in github repository for this article, together with kflash.py( a flash utility). If you wish to compile the firmware from the source code, just download the source code from https://github.com/sipeed/MaixPy, install the toolchain and compile the source code into maixpy.bin file. Detailed build instructions can be found here.

Flash the binary file with

sudo python3 kflash.py kpu.bin

After successful flashing follow to the next step.

Step 2: Connect to MaiX Bit

Now our MaiX Bit should be accessible through a USB serial connection with baudrate 115200. You can use your favorite software for serial communication or just cat and echo commands, whatever suits your needs. I was using screen for serial communication and find it very convenient.

The command for establishing a serial communication session with screen is

sudo screen /dev/ttyUSB0 115200

where /dev/ttyUSB0 is the address of your device.

You might need to press reset button on your microcontroller to see the greeting message and python interpreter prompt.

Step 3: Run the Demos!

Now you can access copy mode by pressing Ctrl+E and copy-paste the demo codes. To run them press Ctrl+D in copy mode.

If you don't want to record the videos, you need to comment the video recording lines. Otherwise the code will throw an exception if there's no SD card inserted.

Here are short descriptions of each demo:

Find circles - uses find_circles function from OpenMV. Needs more tweaking for your specific application, particularly threshold(controls what circles are detected from the hough transform. Only
circles with a magnitude greater than or equal to threshold are returned) and r_min, r_max values.

Find rectangles - uses find_rects function from OpenMV. You can play around with threshold value, but the value I have in demo works quite good for finding rectangles.

Find faces, find eyes - uses find_features function with Haar Cascades for detecting eyes and frontal face in the image. You can play around with threshold and scale values for the right speed-accuracy trade-off.

Find infinite lines - uses find_lines function to find all infinite lines in the image using the hough transform.

Detect color - uses get_statistics function to obtain percentile object and then converts mean values of LAB tuple to RGB values tuple. I wrote this example myself and it works quite well, but do keep in mind the results of color detection will be affected by ambient light conditions.

You can find many more interesting demos in OpenMV github repository! They are mostly compatible with MaiX Bit micropython, the only thing you need to remember is to add sensor.run(1) after setting the pixformat and framesize.

Happy experimentation with OpenMV code. If you have any questions or want to share some of your interesting results, don't hesitate to reach me on Youtube or LinkedIn. Now, excuse me, I'll go make some robots!

Be the First to Share

    Recommendations

    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge

    9 Discussions

    0
    Tanishq Jaiswal
    Tanishq Jaiswal

    7 months ago

    Hey Dimitry! Thanks for this tutorial, I wanted to know if the QR code algorithm of OpenMV would work on main dock, and if yes, how fast will it be compared to OpenMV if I don't use display output?

    1
    DmitryM8
    DmitryM8

    Reply 7 months ago

    Hello! Yes, I have tried QR code algorithm with Sipeed Maxipy and can confirm it working. Concerning the speed, I haven't done this comparison, bit it should at least be on par with OpenMV H7 camera(ARM Cortex M7 with 480 MHz clock speed vs. K210 Dual core 400MHz clock (can be overclocked up to to 800MHz)).

    0
    DmitryM8
    DmitryM8

    Tip 7 months ago

    I may be slow responding to comments here, if you have an urgent issue,
    please post a comment on YouTube or contact me directly on LinkedIn :)
    Also
    welcome to create issues on GitHub and pull requests, if you make
    useful changes to the code or upgrade the code to newer version of
    frameworks used!

    -2019-02-23-4.35.56.png
    0
    tylersuard
    tylersuard

    1 year ago

    Hi Dmitry! Thanks very much for posting this. Just to be clear, can all the OpenMV demos work on the MAIX bit? I'm particularly interested in OpenMV's smile detector demo, and there is a significant price difference between an OpenMV and a MAIX bit. Thanks!

    0
    DmitryM8
    DmitryM8

    Reply 8 months ago

    Sorry for the late reply, instructables doesn't notify me about new messages in the comments... Yes, it is the same firmware for all sipeed maix board - bit, go, dock and maixduino. So, openMV works uniformly across these boards

    0
    ibnutri
    ibnutri

    Reply 12 months ago

    Hi Tyler,

    I just tried it with my recently bought maix bit, and it works.

    0
    Neodyme
    Neodyme

    1 year ago

    Thank you very much !!!
    It is the most useful guide about this board

    0
    DmitryM8
    DmitryM8

    Reply 1 year ago

    Thank you, very glad to hear that! You can check out my YouTube channel, I posted a couple of more videos about another AI acceleration boards, Nvidia Jetson Nano
    http://bit.ly/Youtube_Hardware_AI