Open source AI intelligent follow PTZ OpenFollow based on K210 (Foundation) -- micropthon foundation of K210

Posted by pessi on Thu, 28 Oct 2021 08:59:28 +0200

 OpenFollow click here     

         OpenFollow uses the RISC-V core AI chip K210, which has a dual core processor with independent FPU, 64 bit CPU bit width, 8M on-chip SRAM, 400M adjustable nominal frequency, and a double precision FPU supporting multiplication, division and square root operation; It also carries USB to serial port chip CH340, RGB LED, 24pin DVP camera interface, DC5V motor interface and 4000maH lithium battery charging circuit, all of which are designed on a 50mm*42mm circuit board. The main features of this product are RISC architecture, high performance, low price, AI concept, and support for micro python.

1, What is K210?

         K210 is a chip developed by Jianan technology. Its full name is k210. The chip adopts RISC-V dual core 64 bit CPU architecture to support machine vision and machine hearing. Using edge computing (I don't know this very well, but it sounds advanced.) computing power 1TOPS. In a word, k210 is an AI development chip used in embedded. Its computing power is fairly good among its peers and can run the deep learning model.

2, Some development boards

         After the launch of K210, many development boards also came into being, such as the MaixPy series development board launched by sipeed company (in other words, the MaixPy project is launched, and the opportunity is also K210), as well as the learning kits launched by some other companies. This is mainly about the OpenFollow platform designed based on the MaixDuino development board of sipeed company. It is also the only K210 development board I have used.

3, Introduction to micro Python

         Micro python, as its name implies, is a derivative language of Python language. Like python, it can use a general API to control the underlying hardware on any board. It can support many microcontrollers, and k210, the protagonist of this series, is one of them.

         My personal opinion on micro Python is just one word: incense. Personally, when I was a freshman, I also studied embedded development. At that time, after reading 51 single chip microcomputer, I confidently went to the library and borrowed an introduction book to the development of stm32 standard library. At the beginning, I directly persuaded me to retreat from a large series of complex function names and initialization, which undoubtedly dampened my enthusiasm. So much so that I now learn electronic control with a shadow... But now, with the blessing of micro python, I have found the confidence to learn again. Micro Python development belongs to library development, but it feels higher than 32 standard library development (I don't know how it is compared with hal Library). It inherits the interpretive, multi interface, object-oriented, simple and concise advantages of Python. After talking so much, it's to my taste anyway~

4, About MaixPy #

        MaixPy   Will be   Micropython   Migrate to   K210 (a 64 bit dual core RISC-V CPU with hardware FPU, convolution accelerator, FFT and Sha256) supports the conventional operation of MCU and integrates hardware acceleration   AI   Machine vision and microphone array, 1TOPS   The core module of computing power is less than ¥ 50, so as to quickly develop a practical module with very low cost and volume   AIOT   Domain intelligence applications.

         Micro Python is a parser based on Python 3 syntax, which contains most of the basic syntax of Python 3. It mainly runs on embedded chips with limited performance and memory. (note that microprython does not contain all the syntax of Python 3)

MaixPy   Let's make programming on K210 easier and faster. We also open source the source code on Github.

Using MaixPy can do many interesting things, specifically   Look here

5, Concise code examples #

         For example, we need to scan   I2C   The equipment on the bus does not need complex development environment and engineering, but only needs to send the following code through the serial port:

from machine import I2C                          # Import built-in Library

i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29) # Define an I2C object. Use I2C0 with a frequency of 100kHz. The SCL pin is io28 and the SDA pin is IO29
devices = i2c.scan()                             # Call function scan device
print(devices) 

Similarly, we need to implement a breathing lamp. We only need the following code:

board_info   It is related to boards. Different boards have different configurations and need to be used before use Manual configuration.

from machine import Timer,PWM
from board import board_info
import time

tim = Timer(Timer.TIMER0, Timer.CHANNEL0, mode=Timer.MODE_PWM)
ch = PWM(tim, freq=500000, duty=50, pin=board_info.LED_G)
duty=0
dir = True
while True:
    if dir:
        duty += 10
    else:
        duty -= 10
    if duty>100:
        duty = 100
        dir = False
    elif duty<0:
        duty = 0
        dir = True
    time.sleep(0.05)
    ch.duty(duty)

Real time photography:

import sensor
import image
import lcd

lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
while True:
    img=sensor.snapshot()
    lcd.display(img)

AI object detection:

import KPU as kpu
import sensor

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((224, 224))

model = kpu.load("/sd/mobilenet.kmodel")  # load model
while(True):
    img = sensor.snapshot()               # take picture by camera
    out = kpu.forward(task, img)[:]       # inference, get one-hot output
    print(max(out))                       # print max probability object ID

Topics: Python AI