Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of digit recognition based on OpenMV

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to achieve digital recognition function based on OpenMV, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

Brief introduction of OpenMV for Image recognition based on OpenMV

What is OpenMV?

OpenMV is an open source machine vision project based on MicroPython initiated by Chris team in the United States, which aims to create low-cost, scalable, python-driven machine vision modules. OpenMV is equipped with a MicroPython interpreter so that it can develop python on the embedded side. For more information about MicroPython, please refer to my previous blog column: MicroPython. Based on the 32-bit ARM Cortex-M7 kernel OpenMV-H7 and a variety of cameras, OpenMV can implement a variety of machine vision applications, such as face detection, object classification and so on.

OpenMV is an open source, low-cost and powerful machine vision module, which takes STM32F427CPU as the core and integrates OV7725 camera chip. on the small hardware module, C language is used to efficiently implement the core machine vision algorithm and provide Python programming interface. At the same time, OpenMV is also a programmable camera, through the Python language can achieve the logic you want. And the camera itself also has some image processing algorithms, which is more convenient to use, only need to write some simple Python code, you can easily complete a variety of machine vision-related tasks. Here, we realize the digital recognition through OpenMV.

When you open the OpenMV camera and link to your computer, a window will pop up for you to upgrade

Do not choose the cancel key at this time.

You cannot choose to upgrade!

You cannot choose to upgrade!

You cannot choose to upgrade!

And then proceed to the next step.

OpenMV video tutorial for getting started with Chinese

I. digit recognition

Numeric recognition is based on the need to configure NCC template matching. Through the matching of NCC templates, you can set the

The digital template pictures that need to be identified are saved to the SD card, and then the next step of recognition can be carried out.

1. You can directly open the code for use by opening the process of template matching.

2. If this window appears in the run, it means that the template image has not been saved.

So you need to create a template picture: a detailed video tutorial for creating a template picture.

To create a template picture, you must first open a helloworld history file.

Then match the basic numbers such as 0x9 in the helloworld course file, and enter these numbers into

Intercept them one by one and use them as our template pictures.

Intercept in the Frame Buffer box on the right. Note: do not need Zoom, because the Zoom display

It is the magnified effect, which may lead to frame loss during recognition.

Then click the left button to select a box (as shown)

After selecting the box, right-click to select Save Image selection to PC

Finally, save the intercepted digital picture, be sure to save it to the SD card of OpenMV, and save the file name yourself.

Define

3. Change template.pgm to the name of the template image you created

(note: the format of the template image must be pgm, and the conversion format can be found in

Direct conversion of https://convertio.co/zh/bmp-pgm/ website)

4. After the change, you can run it.

Here is some code about number recognition.

This code is the source code and can be changed according to your own needs.

Code source: numeric identification code, which can be directly referenced and modified

# Template Matching Example-Normalized Cross Correlation (NCC) # # This example shows off how to use the NCC feature of your OpenMV Cam to match# image patches to parts of an image... Expect for extremely controlled enviorments# NCC is not all to useful.## WARNING: NCC supports needs to be reworked! As of right now this feature needs# a lot of work to be made into somethin useful. This script will reamin to show# that the functionality exists, but, in its current state is inadequate.import time, sensor, imagefrom image import SEARCH_EX, SEARCH_DS# Reset sensorsensor.reset () # Set sensor settingssensor.set_contrast (1) sensor.set_gainceiling (16) # Max resolution for template matching with SEARCH_EX is QQVGAsensor.set_framesize (sensor.QQVGA) # You can set windowing to reduce the search image.#sensor.set_windowing 60) sensor.set_pixformat (sensor.GRAYSCALE) # Load template.# Template should be a small (eg. 32x32 pixels) grayscale image.template8 = image.Image ("/ 8.pgm") template9 = image.Image ("/ 9.pgm") clock = time.clock () # Run template matchingwhile (True): clock.tick () img = sensor.snapshot () # find_template (template, threshold, [roi, step, search]) # ROI: The region of interest tuple (x, y, w, h). # Step: The loop step used (y+=step, x+=step) use a bigger step to make it faster. # Search is either image.SEARCH_EX for exhaustive search or image.SEARCH_DS for diamond search # # Note1: ROI has to be smaller than the image and bigger than the template. # Note2: In diamond search, step and ROI are both ignored. R8 = img.find_template (template8, 0.70, step=4, search=SEARCH_EX) #, roi= (10,0,60,60) if R8: img.draw_rectangle (R8) R9 = img.find_template (template9, 0.70,step=4, search=SEARCH_EX) #, roi= (10,0,60,60) if R9: img.draw_rectangle (R9) print (clock.fps ())

The result of the operation is shown in the figure.

The above is all the content of this article "how to achieve digital recognition function based on OpenMV". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report