基于LabVIEW机器视觉的二维码实时识别系统设计

2021-06-22 09:05史丽萍
黑龙江大学工程学报 2021年2期
关键词:工程学院哈尔滨黑龙江

梁 博,史丽萍

(黑龙江大学 机电工程学院,哈尔滨 150080)

1 Overall system design

When the system is running, an interface will pop up on the front panel to let the user customize an Region Of Interest (ROI) focus area. When the QR code is recognized, it must be placed in the ROI area before the program can read the information.In LabVIEW platform, Image Acquisition (IMAQ) vision and motion module was used to carry out image import, image positioning, image grayscale and image binarization processing, and finally IMAQ Read QR Code module was used to read the two-dimensional code information[6-8]. The while loop statement is adopted in the process of image acquisition to ensure the efficient and accurate operation of the system. Fig.1 is the overall design flow chart of the system.

Fig.1 Overall design flow chart of the system

2 Software design

LabVIEW provides many functional modules and controls, as long as the user will be the graphical program correctly connected to the corresponding port, it can achieve good man-machine interaction function in the front panel.

2.1 Image acquisition

Select the appropriate camera name, the program wakes up the camera, configure the driver file, and create the IMAQ image cache. All externally captured images need to be stored temporarily through a set of image cache, but at the end of the program, the cache must be released using IMAQ dispose control, otherwise the program will have an error. In order to achieve the purpose of real-time image acquisition, a while loop statement should be added. The new image acquired in the loop continuously overcovers the old image in the cache, and at the same time, it appears in the front panel[9].

2.2 Image positioning

In the LabVIEW vision and motion module, ROI focus area method is mainly used for image positioning, and the division of ROI area is crucial for QR code recognition. The size of ROI region has a great impact on improving the speed of QR code recognition.

Use the various graphics on the front panel to box out the area that needs to be processed and positioned, which is the ROI area for further processing.Using the IMAQ Construct ROI control to display the image allows you to customize the graphic style, delineate the ROI area, and adjust it as the program runs to meet subsequent requirements.

The ROI area is essentially a cluster of data, type represents a user-defined shape for the area, and coordinates for the upper left and lower right corners of the ROI area. The custom ROI area program is showed in Fig.2.

Fig.2 Custom ROI diagram

2.3 Image graying and binarization processing

Image preprocessing is the first step of digital image processing, including image grayscale and binarization, filtering noise reduction, etc., to eliminate irrelevant information of images, reserves the main information area required by the system and strengthen the important information can be detected, but also maximize the simplified graphical data, fundamentally improve the feature extraction, image segmentation, matching and recognition of the stability and accuracy.

At present, most color images adopt RGB mode, and three components of RGB should be processed at the same time when processing images. In fact, RGB does not reflect the morphological characteristics of images, but only performs color allocation on the optical principle of images. The value range of R, G and B is 0~255, and each pixel point has a selection range of more than 16 million, which will occupy a large amount of computer memory and greatly increase the computer's operating load and computing speed. Therefore, image preprocessing should be carried out.

Grayscale means that there is no color, and all three components of RGB of each pixel have the same value.The gray image is presented by different gray values. The grayscale image can effectively avoid stripe distortion. The standard gray value calculation formula is:W=R×0.30+G×0.59+B×0.11,Where R, G and B respectively represent red, green and blue color components, and W represents gray value[10]. Using IMAQ ExtractSingleColorPlane controls to quickly implement image gray level of the RGB image is converted into an HSL images, an HSL color mode is a kind of color standard industry, through the hue (H) and saturation (S), lightness (L) the change of the three color variables and their mutual superposition to get all sorts of color, is one of the most widely used color system[11].

Binary image, its pixel value is only 0 or 255, 0 means black, 255 means white, the color of the entire image is either black or white, after processing will make the target object separated from the background, improve the running speed, and easy to program, greatly reduce the load of the computer.

The binarization process uses an IMAQ threshold control, in which the threshold judgment range is set as 128~255. When the pixel value is less than 128, it is replaced with 0 (black), and when the pixel value is within the range, it is replaced with 255 (white). The grayscale image is showed in Fig.3(a), the threshold change image after graying processing is showed in Fig.3(b), and the block diagram of the image preprocessing program is showed in Fig.4.

Fig.3 Grayscale image and binarization image

Fig.4 Block diagram of image preprocessor

2.4 Identification ability test and analysis

The main influencing conditions of QR code recognition in the field of life or industry: scanning and recognition under the change of external light intensity, the position of placing the QR code and different scenes of scanning and recognition.According to these main conditions, the following comparative experiments are conducted. The QR code recognition experiment with an inclined angle is showed in Table 1, and the QR code recognition experiment with a facing camera is showed in Table 2.

Table 1 Experimental chart without inclination angle

Table 2 Experimental chart of tilt angle comparison

Through comparative experiment and analysis, it was found that this system had a high recognition accuracy rate for the printed QR code of drawings and the QR code of mobile phones, and the recognition speed for the QR code of mobile phones was significantly faster than the recognition speed for the QR code of drawings, no matter in the dark environment or under the normal natural light source. In the case that the tilt angle was not right to the camera, the recognition accuracy and detection speed of the QR code on the drawing were affected, the impact on the QR code on the mobile phone was very small, it can be seen that the system algorithm for the optimization of the QR code on the mobile phone was stronger than the QR code on the drawing. In general image processing, for a pixel, the simplest approximate expression of grayscale generation is g=r*l, where g is the grayscale value, r is the reflectivity, and l is the intensity of incident light. When r is constant, the intensity of incident light decreases and the gray value decreases.In the gray image, the QR code itself was a binary image with pixel value of 0 or 255, and the gray value of the background decreased, which reduced the running load of the computer during the binarization processing. In the dim environment, the QR code was more likely to stand out, thus reducing the time spent in scanning and recognition.

The experiment also tested the QR code that was partially damaged or partially blocked. The number of bits represented by a QR code was fixed, and the more information it contains, the less redundant it will be. On the contrary, the less information it contains, the more redundant it will be. The information contained in a QR code does not need to be very large, which means that the redundancy of QR code can be done very high, based on the QR code itself has strong fault tolerance and error correction function, found in the maximum damage or cover area up to 30%, can still effectively read the information contained therein.

2.5 System optimization design

Write the LabVIEW program, standard the while loop is often used, but the software comes with a while loop structure takes up a lot of CPU resources, greatly reduce the speed of application, so optimization method can delay for entry in the standard while loop, control loop execution rate, can be seen in Fig.5.CPU utilization is greatly reduced, this method can reduce the CPU load, which makes the running speed of the program itself is improved. CPU utilization without delay is showed in Fig.5(a), and CPU utilization with delay is showed in Fig.5(b).

Fig.5 CPU utilization

2.6 Test results

The pre-processed image was read by IMAQ read QR code control. At present,100 QR codes generated by QR code generator were used for testing, and the QR codes displayed on mobile phones by 1 280×720 camera were used to capture one by one. The recognition rate of mobile phone QR codes in different environments can reach 100%, and the recognition rate of paper QR codes was also relatively high. It was also found that different light intensity and scanning angle affect the time of system recognition to different extent.But the system had strong anti-interference

ability for the background environment. Even though the area of QR code only accounts for a small part, it could still realize fast recognition.When the light intensity was appropriate and the QR code was complete, the system recognition time was about 35 ms/graph, which can be well applied in practice. The image that recognizes the information contained in the QR code of the mobile phone is showed in Fig.6(a), and the image that recognizes the effect of the QR code of printing is showed in Fig.6(b).

Fig.6 QR code recognition

3 Conclusions

By combining the camera, LabVIEW and NI Vision machine vision detection technology, a high-precision QR code recognition system was designed. By comparing the image processing technology in Vision Assistant, the image preprocessing method of first graying the image and then binarizing is adopted, and the feature extraction of the QR code is determined by the ROI positioning method, finally completed the identification of the QR code information.

In the industrial field, whether it is a machine QR code or a printed QR code, it will inevitably be difficult to recognize due to complex reasons such as geometric distortion or light changes in the QR code. A method is proposed that can be identified in different lighting environments or in response to different materials. The QR code recognition system that maintains high-precision and fast recognition of objects at all times can be stably recognized even if there is a large amount of background interference in the camera capture screen. A good human-computer interaction interface is formed through LabVIEW. Compared with the QR code recognition system developed and written by libdmtx, zbar, etc. The QR code recognition system improves the recognition speed by about 15%, and has the advantages of higher recognition accuracy and low cost. It can be collected by using a common camera, which can better meet the needs of social life and has practical application significance. Another stable and efficient solution for the industrial field is provided.

猜你喜欢
工程学院哈尔滨黑龙江
行书张光藻《入黑龙江境》(53cm×36cm)
福建工程学院
湖南师范大学设计与工程学院作品
哈尔滨国际冰雪节
福建工程学院
化学与材料工程学院简介
Homeless children in India publish newspaper
黑龙江:河湖治理保护成效明显
静听花开
哈尔滨“8·25”大火 烧出了什么