Quickstart in 10 minutes
视频教程1 - OpenMV简介:https://singtown.com/learn/688
视频教程2 - 开箱介绍:https://singtown.com/learn/856
视频教程3 - 驱动、ide的安装与使用:https://singtown.com/learn/49989/
Download IDE
OpenMV official website:https://openmv.io/pages/download
Windows
Download and then click the next step to complete installation.
You can drag a window of image from right side if there is no.
Driver installation
Plug OpenMV in your computer and it would install driver by itself under normal circumstance. You can see it in device manager:
However, it could not work without your operation on some devices. Then there would be an exclamation mark in device manager, suggesting that the driver is not installed properly.
So you have to install it by yourself. First, download a driver: https://dl.singtown.com/openmv/openmv_windows%E9%A9%B1%E5%8A%A8.zip
Decompress it to the desktop and right-click on the device in device manager, then choose update driver:
Errors of Windows
If you encounter problems as follows(which is very rare and is computer’s faults):
OpenMV 驱动安装失败,90%的情况都是电脑的问题,精简版操作系统和使用了一些优化软件通常是引起此类问题的原因。OpenMV 驱动解决办法跟 arduino 类似。
这是因为精简版的 window 系统删掉了一些不常用的驱动信息引起的。
Reference on errors:
https://forum.singtown.com/topic/230
At last, we have some suggestions for you:
- Buy computers with legal system
- Allow Windows to update itself
- If you have to use pirated system, please download clean version on MSDN.
- NEVER use Ghost to install system, in which 90% problems lie.
MacOS
Finish the downloading of IDE, double click on install the app and keep clicking on next step.
If you are warned that you can only install apps admitted by App Store, then change the setting of security and privacy into any sources.
Ubuntu
Ubuntu需要给下载的文件权限。然后双击安装。
Run hello world!
First, make sure that you have finished the installation of IDE and divers.
Match your computer and OpenMV with USB line and there would be a USB flash disk.
Open OpenMV IDE.
Attention on this picture!
- Click
Connect
- Then click
Run
The image would be displayed in the window in upper right corner.
Click the lowest Serial Terminal and there would be a terminal window.
At the meantime, Serial Terminal always keeps on printing data, the frame rate, the result executed by print(clock.fps())
in the 17th line of the code.
Tracking balls
Replace the content in edit box with the following code:
# Monitoring blobs:
#
# The example shows how to search blobs in images through find_blobs() fuction.
# Here we are searching dark green.
import sensor, image, time
# Take control of light in the environment to keep light stable when searching colors.
green_threshold = ( 0, 80, -70, -10, -0, 30)
# Set the threshold of green and the value in brackets is the minimum and maximum of L A B.
#(minL, maxL, minA, maxA, minB, maxB) The value of LAB can be selected from the three coordinate graphs on the left of the image. And you only need to set (min, max)if it is a grey-scale map.
sensor.reset() # Reset the camera.
sensor.set_pixformat(sensor.RGB565) # The format is RGB565.
sensor.set_framesize(sensor.QQVGA) # QQVGA can save time.
sensor.skip_frames(time = 2000) # Skip 10 frames to bring the new setting into effect.
sensor.set_auto_whitebal(False)
# Turn off white balance which is enabled by default. Remember to turn off it when the device is identifying colors.
clock = time.clock() # Track frame rates.
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Get an image from sensor chip.
blobs = img.find_blobs([green_threshold])
#find_blobs(thresholds, invert=False, roi=Auto),thresholds is the threshold of the color.
# It is a tuple which should be marked by[ ]. Invert=1 Invert the threshold of the color. invert=False is the default.
# Not invert. ROI sets the visual area. ROI is a tuple. Roi = (x, y, w, h) is a rectangular area with its width as w and height as from the upper left vertex (x,y). The default of ROI is the whole image.
#The function returns to a list. [0] is the x coordinate of the upper left vertex in the identified target color area and[1]the y.[2]is the width of the target area and[3]the height.[4]is the amount of the pixels in the area.[5]is the x coordinate of the center of the target area and [6]the y coordinate.[7]is the rotation angle of the target color area(It is the value of camber, floating-point type. Other elements in the list is integer).[8]is the amount of the targets overlapped with the target area.[9]is the number of colors(It can used to identify by which threshold of color the area is identified).
if blobs:
#If you find the target color:
for b in blobs:
#Iteration find the target color area. 迭代找到的目标颜色区域
# Draw a rect around the blob.
img.draw_rectangle(b[0:4]) # rect
#Mark the target area with a rectangular.
img.draw_cross(b[5], b[6]) # cx, cy
#Draw a cross in the center of the target color area.
print(clock.fps()) # Note: The frame rate of OpenMV is the half when you connect it with computer.
#The frame rate would increase if you cut off the computer.
When you run it:
This program would search blobs according to the threshold of green_threshold.
Changing threshold
How to change the threshold by yourself? How can we know the thresholds of colors?
- First, the subject of number list find the target color in the camera and click the target color to draw a rectangular in frame butter.
- Choose LAB Color Space in the following graphs in frame butter.
- The three coordinate graphs means the LAB value of the color of the rectangular area. Choose the minimum and maximum of the three graphs, ( 0, 60, -70, -10, -0, 30)
File system
File system is an extraordinary character of OpenMV (or MicroPython). So what is a file system? Put it simply, it is an arrangement of your files and folders with tree-like structure, like that in your USB flash disk. And you can use routine in code to read-in and create files.
Offline operation
视频教程附二 - 脱机运行:https://singtown.com/video
So here is the question: What is the function of OpenMV’s supporting file system?
The answer is: Convenient! OpenMV make its built-in Flash a file system. And when you plug OpenMV into your computer, you will see a USB flash disk on your device in which the file system is. When you want to burn firmware, what you need to do is no more than copying script files into main.py in the disk. Then OpenMV would operate what is stored in main.py. This is the very offline operation.
One-click downloading
Click Save open script to OpenMV Cam
in tool and IDE would store the current file into main.py directly.
Power supply
OpenMV has two power input ends:
- VIN(or VCC)
- USB input
VIN use 3.7V~5V and we recommend 5V. USB and VIN can supply power in the meantime.
OpenMV has a power output ends:
- The voltage stabilizer of OpenMV produces an output voltage ended up being 3.3V, which is used to supply power to other sensors. Note: Do not charge the 3.3V for it is easy to burn without the protection of internal chip.
SD card
What should I do if my code has 100000 lines and the built-in flash is not enough? What should I do if I want to store images?
You can use SD card!
How to use SD card? The card is also a file system and its files would replace the built-in Flash file system when electrified and plugged in. Then it would run main.py in SD card
. The maximum capacity of SD card is 32G.