Welcome: Hunan Intelligent Applications Tecgnology CO.,ltd.-HNIAT.com
Language: Chinese ∷  English

Basic knowledge

Application of Halcon-based Visual Detection Software

ABSTRACT: In view of the increasing application of vision in the field of industrial automation, a visual software is developed using Halcon and C#. The software has the functions of two-dimensional code recognition, OCR character recognition and location. It can cooperate with robots and modules to complete positioning and monitoring functions.

Key words: Halcon; C#; Vision; Epson Robot

Chinese Library Classification Number: TP273 Document Identification Code: A

Introduction

In recent years, the pace of social development has become faster and faster, people's thinking has undergone tremendous changes, coupled with the reduction of age-appropriate labor force, all walks of life want to import automation equipment. As the working conditions become more and more complex, the requirement for the accuracy of equipment becomes higher and higher. In order to improve the accuracy, the camera vision positioning is introduced.

There are two ways to use vision in the industry, intelligent camera and vision software developed independently based on PC. The former is easy to use and high cost, many small-scale companies can not afford it. The latter has moderate cost but heavy development tasks and long development cycle. If we can independently develop a set of common visual software with common functions, it will greatly save cost and can be applied in a relatively short time. This article gives a brief introduction to this aspect.

1. Overall introduction of software

The software is developed by C# and Halcon mixed programming. The development tools are VS2012 and Halcon 11.0. The software function mainly consists of seven parts: camera parameter setting module, two-dimensional code reading module, OCR recognition module, pattern matching module, serial communication module, network communication module and status display module. Following is a brief introduction of the following module functions:

The camera parameter setting module is mainly used for camera type selection, camera name selection, exposure and gain adjustment, searching the currently connected camera and saving the current parameters.

Two-dimensional code reading module can set two-dimensional code type, bar code polarity and other parameters, and can display the results and content of reading code.

OCR recognition module can set OCR parameters, area and display the current reading results.

Template matching module can set matching parameters, template parameters, create templates, set ROI and display current test results.

Serial communication module is used to set relevant parameters for external communication, including serial number, etc. After setting, it can be saved to XML file.

Network communication module can set TCP/IP related parameters and save them to XML file. The overall software interface is shown in Figure 1 below.

machine vision

Figure 1

2. Software details

This software adopts the traditional method of software development life cycle, adopts top-down development sequence, and gradually finishes the structured software design method. From the aspect of user requirements, the software can be divided into operation status, test type, real-time display, mode selection, file loading and other functions, as shown in Figure 2.

Visual Detection

2.1 Communication Protocol

The software has two communication modes and external interactive data, namely serial communication and network communication.

Visual Detection

Serial communication includes serial password, baud rate, data bit, stop bit, check bit, save and open serial port information, as shown in Figure 3. The serial number is connected to the camera port number, and the figure is COM6. The baud rate should be set in accordance with the data interaction terminal. The figure is 9600 (commonly used baud rates are 9600, 19200, 38400, 43000, 56000, 57600, 115200, etc.). Data bits, stop bits and check bits are set. The figure is set to 8 bits, 1 bits and no check. "Save" is used to store set parameter information. "Open Serial Port" is used to test whether the communication port can be opened.

Network communication interface includes port number, online information, data content, examination monitoring, sending information and saving information, as shown in Figure 4. The "port number" is set to 60000, the "on-line information" will display the connection status, the "data content" will display the received data, and when you need to enable network communication, Click to start listening.

2.2 Camera parameters

The camera parameter setting interface is mainly used for camera type, camera name, exposure, gain, search camera, save, open camera, real-time image, stop. As shown in Figure 5,

Visual Detection

Fig. 5 The camera parameter setting interface chooses the camera type: choose the camera brand, such as Basler, Dahua, etc.

Search camera: Search for the model of the camera currently connected;

Choose the name of the camera: choose the corresponding model according to the type of camera searched; Open the camera: manually open the camera, so that the camera can work properly;

Real-time image: Real-time display of objects within the current camera's field of view;

Exposure and gain: adjust the exposure value and gain value of the camera so that the image can be clearly imaged; save: save all current parameters to the corresponding file;

Stop: Make the camera stop working;

2.3 Two-Dimensional Code

The two-dimensional code testing interface includes two parts: two-dimensional code testing and two-dimensional code parameters, as shown in Figure 7. The green pickup frame in the picture is the edge of the two-dimensional code. It can automatically search the position of the two-dimensional code in the field of vision. The content of the two-dimensional code is 1234567890, and the pixel of the camera is 640*480, that is, the black-and-white camera with 300,000 pixels. The two-dimensional code test is mainly to manually test whether the two-dimensional code is qualified or not, and to display the two-dimensional code content of the test, as shown in Figure 7. The parameters of two-dimensional codes are mainly to set the type of two-dimensional codes (commonly used are DataMatrix, MaxiCode, Aztec, QRCode, Vericode, PDF417, Ultracode, Code49, Code16K, etc.), the polarity of barcode (dark_on_light or light_on_dark), and the timeout time, as shown in Figure 8.

machine vision

2.4 OCR Recognition

OCR recognition includes three parts: OCR recognition, setting area and OCR parameters. The green frame in the figure is the ROI area set. The smaller the ROI area set, the more accurate the detection will be.


Please the Chinese version for details.

CONTACT US

Contact: Manager Xu

Phone: 13907330718

Tel: 0731-22222718

Email: hniatcom@163.com

Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province

Scan the qr codeClose
the qr code