Product irregular deformation character detection method and device based on deep learning

Through deep learning algorithms and hand-eye collaboration technology, the efficiency and accuracy of deformation character detection of irregular surface products are solved, and high-precision automated detection is realized to adapt to the deformation character detection needs of different products.

CN119049054AActive Publication Date: 2024-11-29江西省通讯终端产业技术研究院有限公司 +2

Patent Information

Application Number
CN202411248664.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-11-29
Estimated Expiration
2044-09-06

AI Technical Summary

Technical Problem

Existing visual detection methods are difficult to accurately identify the deformed characters of irregular surface products. They are affected by reflection, material and curvature factors, resulting in low detection efficiency and poor accuracy, and insufficient adaptability and versatility of traditional methods.

Method used

Using the product irregular deformation character detection method based on deep learning, image acquisition is carried out through hand-eye collaboration robotic arms and camera components, image preprocessing and feature extraction is used using deep learning algorithms, character recognition is achieved in combination with CRNN text recognition model, and through the device Automatic detection system improves detection efficiency and accuracy.

Benefits of technology

It realizes high-precision detection of irregularly deformed characters, improves detection efficiency and accuracy, reduces the subjectivity of manual detection, adapts to the deformation character detection needs of different products, and has strong versatility and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119049054A_ABST
    Figure CN119049054A_ABST
Patent Text Reader

Abstract

The invention discloses a deep learning-based product irregular deformation character detection method and device, and the method employs a robot hand-eye cooperative special-shaped curved surface optimal perception posture adjustment method to adjust the optimal collection of product regular characters. The problems of irregular curved surface character imaging irregularity, large imaging noise interference, single product irregular detection and the like in the detection process are innovatively solved, normalized cross-correlation-based template matching is introduced in the detection process, character images and background images are effectively separated by utilizing affine transformation and feature extraction, and the detection accuracy is improved. And sending the separated character image into a deep learning RCNN text recognition model to obtain a character sequence for matching, and outputting whether product character information is qualified or not according to a matching result. The equipment using the detection method solves the problem that current special-shaped curved surface characters mainly depend on a large amount of manual detection, efficiency and detection precision are improved, and industrial detection production of various characters with irregular product surfaces can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for detecting irregular deformed characters of products based on deep learning, and in particular to a universal detection technology for deformed characters such as laser engraving, printing, and pad printing on products with different special-shaped curved surfaces. Background Art

[0002] In the manufacturing process of industrial products, laser engraving, printing, pad printing and other technologies are often used to present product information in the form of characters on the surface of the product. Then, in the automatic production process, visual imaging technology is used to identify the characters on the surface of the product to determine the corresponding information of the product. The characters displayed on the surface of products with cylindrical, spherical or irregular surfaces have deformities and distortions. At the same time, such products with irregular surfaces are affected by reflections, materials, curvatures and other factors during the imaging process. Fig. 9 As shown, it is difficult to detect product information characters. At present, it is difficult to use a unified standard to determine character defects such as character breakpoints, ghosting, offset and heterochromaticity. They can only be detected by manual visual inspection. Manual inspection methods have the disadvantages of low efficiency, high missed detection rate and strong subjectivity of inspection results.

[0003] The traditional visual inspection method based on fixed template matching can only accurately identify relatively regular characters, and is difficult to apply to the inspection of products with irregular surface deformed characters, which brings great trouble to the quality inspection of product production. Therefore, there is an urgent need for a product irregular character detection method and equipment based on deep learning to solve the above problems.

[0004] The following technical challenges are faced during visual inspection of deformed characters on the surface of complex and irregular products:

[0005] (1) Irregular surface characters are imaged irregularly, making modeling difficult. During the pinhole imaging process, the cylindrical, spherical or irregularly curved surface characters are projected from three-dimensional space to a two-dimensional imaging plane. The loss of depth information causes the character image to show features such as stretching, compression or distortion, making it difficult to reversely judge the character quality by building a model.

[0006] (2) Product materials vary greatly, resulting in large imaging noise interference. The surface materials of different categories of products vary greatly, and the appearance varies from smooth to rough and different colors. When the lighting is imaged, reflections, light absorption, and uneven brightness occur, resulting in strong noise interference such as overexposure, uneven brightness, and poor contrast during the imaging process, affecting the distinction between background and character information.

[0007] (3) The existing universal surface detection methods have poor adaptability. Most of the existing optical detection equipment is developed and designed for a single product, with a single optical solution and a simple detection algorithm. It is difficult to meet the needs of existing production lines for small varieties, diversification, and rapid changeover. There is an urgent need to develop a highly universal surface character detection device.

[0008] In addition, the Chinese patent application with publication number CN116168395A discloses a character detection method and device, electronic device and storage medium. The technical solution of the patent is: obtain a text image, extract features from the text image, obtain the center position and character area information corresponding to the characters in the text image, and thus detect the characters in the text image. However, it does not take into account that the curved surface is prone to reflection and exposure under lighting conditions, resulting in blurring and missing of surface characters, affecting the extraction of subsequent edge, color or texture features of the characters, thereby affecting the detection performance.

[0009] The Chinese patent application with publication number CN117727052A discloses a character defect detection method and device, electronic equipment and storage medium. The technical solution of the patent is: obtaining the character information corresponding to the area to be tested in the image, generating a template character image based on the character information, and using the template character image to match and detect at least one character to be tested, which can avoid the situation where the character to be tested cannot be detected. However, new characters will continue to appear in the character detection process, so template character images will be frequently generated. The characters to be tested need to be accurately matched from a large number of template character images, which consumes a lot of time in the detection process, thereby affecting production capacity.

[0010] Therefore, it is of great significance and market demand to develop a product irregular deformed character detection technology that combines the optimal perception posture of robot hand-eye collaboration with a deep learning algorithm to solve the shortcomings of existing detection methods. Summary of the invention

[0011] The technical problem solved by the present invention is: in view of the shortcomings of existing visual detection methods in detecting irregularly deformed characters, a method and device for detecting irregularly deformed characters of products based on deep learning are provided.

[0012] The present invention is implemented by the following technical solutions:

[0013] The present invention first discloses a method for detecting irregularly deformed characters of products based on deep learning, which specifically comprises the following steps:

[0014] S1. Use a camera-equipped robotic arm with hand-eye coordination to perform trial image acquisition of irregularly deformed characters on the product, obtain the acquisition posture deviation of the robotic arm by comparing the positional features and structural features between the trial acquired image of the irregularly deformed characters and the standard image, optimize and adjust the optimal acquisition posture of the robotic arm, and the robotic arm acquires images of the characters on the product to be inspected through the optimal acquisition posture;

[0015] S2, after denoising and preprocessing the character image of the product to be detected collected in step S1, confirm the region of interest where the character of the product to be detected is located in the image through normalized cross-correlation, perform affine transformation on the region of interest and the standard image, correct the character distortion and tilt in the character image of the product to be detected, and obtain a corrected character image of the region of interest;

[0016] S3, sending the corrected character image of the region of interest to a deep learning character recognition model based on image edge segmentation, separating the character text area from the background area in the image, and generating a text box for the character text area;

[0017] S4, the text box is input into the CRNN text recognition model, the character line in the text box is recognized as a unit, and after the character recognition is completed, the text sequence of the character line is returned in the form of a sequence;

[0018] S5. Match the text sequence identified in step S4 with the product standard character text sequence, determine whether the identified characters of the product to be tested are unqualified or qualified, and output product information on whether the product to be tested is qualified based on the matching result.

[0019] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S1, the camera is fixed to the execution end of the robotic arm and moves with the robotic arm, and the camera and the robotic arm are calibrated by hand and eye using a checkerboard calibration method.

[0020] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S1, a trial collected image of irregularly deformed characters of products is matched with a standard image input image matching model to extract position features and structural features of the two images.

[0021] First, according to the position feature, select the feature point F with common features in the test acquisition image and the standard image and calculate the Euclidean distance d between the feature points F of the two images, compare the Euclidean distance d with the set threshold D, if d>D, convert the feature point coordinates of the test acquisition image to the world coordinates where the robot is located through the intrinsic and extrinsic parameters of the camera, obtain the first movement vector of the feature point F in the test acquisition image and the standard image in the world coordinates, calculate the second movement vector of the robot in the world coordinates through the first movement vector conversion, solve the position and posture parameters of the robot for the test acquisition movement, adjust the position and posture parameters of the robot to move the test acquisition, and ensure that d≤D;

[0022] Then, for the structural features, the brightness, contrast and structural parameters of the test image and the standard image are used to obtain the SSIM index between the two images through the following formula:

[0023] SSIM(x,y)=l(x,y)α·c(x,y) β ·s(x, y)γ

[0024] l(x, y) represents the brightness parameter, which is obtained by comparing the average brightness of the two images. c(x, y) represents the contrast parameter, which is obtained by comparing the standard deviation of the two images. s(x, y) represents the structure parameter, which is obtained by comparing the covariance between the two images. (x, y) represents the position coordinates of the brightness, contrast and structure parameters extracted from the test image and the standard image. α, β and γ are weight parameters. The value range of the SSIM index is [-1, 1]. When the SSIM index approaches 1, it means that the two images are exactly the same. When the SSIM index approaches -1, it means that the similarity between the two images is poor.

[0025] The SSIM index between the trial image and the standard image is then optimized using the following loss function Loss:

[0026] Loss = (SSIM current -SSIM target ) 2 +λ·Penalty(x,T)

[0027] Among them, SSIM current is the current SSIM index between the trial image and the standard image, SSIMt arget is the target SSIM index between the test image and the standard image, SSIM tarhet The value is 0.8 to 0.9, where λ is the weight used to adjust the penalty term, and Penalty(x, T) is the penalty function that constrains the current position x of the manipulator to be within the spherical area T. P If the penalty function is within the spherical area with a radius of 0, then the penalty function is 0. Otherwise, the penalty function is the distance from the robot position x to the spherical area TP The Euclidean distance is calculated, and the position of the robot arm x is adjusted through the gradient descent optimization algorithm so that the current SSIM index between the trial image and the standard image reaches the set target SSIM index, or the optimization is stopped when the loss function Loss is minimized. At this time, the robot arm stops moving, and the current position x of the robot arm is the optimal acquisition posture of the irregularly deformed characters of the product.

[0028] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S2, a non-local mean denoising method is used to perform denoising processing on the collected character image of the product to be detected.

[0029] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S2, a template matching method based on normalized cross-correlation is used to locate the core area of ​​the characters in the character image of the product to be detected, and a template target image T of the character area is intercepted from the standard image in step S1. m×n , using the template target image T m×n In the product character image I to be detected M×N In the sliding matching, the normalized cross-correlation similarity is used to measure the template target image T during the sliding process. m×n And the character image I of the product to be detected M×N The similarity includes:

[0030] For the template target image T m×n The average gray value And the character image I of the product to be detected M×N The average gray value Perform cross-correlation calculation to obtain the average grayscale cross-correlation term corr(x, y), and compare the average grayscale cross-correlation term corr(x, y) with the template target image T m×n The standard deviation term σ T And the character image I of the product to be detected M×N The standard deviation term σ I The cross-correlation term is normalized by the following formula to obtain the template target image T m×n And the character image I of the product to be detected M×N NCC similarity:

[0031]

[0032] A sliding window with a step size of 1 and a sliding size of Q is selected in the character image of the product to be detected, and the NCC similarity of the template target image in each sliding window is calculated. The area where the NCC similarity is higher than the set similarity threshold is regarded as the matching area, and the area with the largest NCC similarity is found as the matched area of ​​interest. A bounding box is generated according to the position and size of the area of ​​interest to identify the area of ​​interest.

[0033] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S3, the deep learning character recognition model adopts the Canny edge segmentation algorithm, which specifically includes the following sub-steps:

[0034] Performing Gaussian blur on the corrected character image of the region of interest to reduce noise;

[0035] The blurred and corrected character image is used to calculate the horizontal gradient G using the Sobel operator x and the vertical gradient G y , obtain the gradient amplitude M, perform non-maximum suppression on the gradient amplitude M, compare the gradient amplitude of each pixel of the corrected character image with the gradient amplitudes of its two adjacent pixels along the gradient direction, and retain the local maximum;

[0036] The double threshold edge connection method is used to threshold the corrected character image after non-maximum suppression, and the high threshold T is set. high , select a value greater than the high threshold T high The strong edge pixels are used for edge tracking to determine the connected edge lines;

[0037] Finally, the connected edge lines are refined, and the inner area of ​​the edge lines is the character text area of ​​the area of ​​interest.

[0038] In a method for detecting irregularly deformed characters of a product based on deep learning of the present invention, specifically, the character text areas in the region of interest are clustered, local areas belonging to the same text are identified and merged, the clustered character text areas are screened, and the text character areas that are continuous and larger than a set area size threshold S are retained. a The character text area retained by the filter is used to generate a text box using an enclosing rectangle.

[0039] In a method for detecting irregularly deformed characters of products based on deep learning of the present invention, specifically, in step S4, the CRNN text recognition model outputs a text sequence of character lines in a text box through the following sub-steps:

[0040] The first step is to convert the character image in the text box into the CNN model format, adjust the character image in the text box to a fixed size and normalize it;

[0041] The second step is to use the VGG16 model to perform convolution and pooling operations on the character image in the input text box to extract the feature map;

[0042] The third step is to serialize the extracted feature graph to obtain a feature sequence;

[0043] Step 4: Input the serialized feature sequence into the RNN model, combine the feature sequence recursively with the text character context information, and output a vector at each time step to represent the prediction result of that time step;

[0044] The fifth step is to decode the prediction result sequence output by the RNN model, and use the CTC loss function to convert the output sequence into the final text sequence and output it. The final text sequence is the text sequence of the character lines in the text box recognized by the CRNN text recognition model.

[0045] The present invention also discloses a deep learning-based product irregular deformed character detection device, including a character detection robotic arm, the execution end of the character detection robotic arm is equipped with a camera component for capturing images of irregularly deformed characters of the product, the character detection robotic arm captures images of the irregularly deformed characters of the product to be detected, and transmits the captured images to the device control host, and the device control host determines whether the irregularly deformed characters of the product are qualified through the above-mentioned detection method of the present invention.

[0046] In a product irregular deformed character detection device based on deep learning of the present invention, it also includes a transport conveyor belt, a product feeding module and a product sorting module;

[0047] The product loading module is located upstream of the transport conveyor belt and includes a loading robot arm that grabs the product to be inspected onto the transport conveyor belt;

[0048] The product sorting module is located downstream of the transport conveyor belt, and includes a sorting robot arm that takes the inspected products from the transport conveyor belt, and a material tray for placing qualified products and unqualified products by category. The sorting robot arm sorts the inspected products to the corresponding material tray according to the inspection result of the equipment control host on whether the products to be inspected are qualified;

[0049] The character detection robot arm is located between the feeding robot arm and the sorting robot arm, and performs image acquisition on the deformed characters of the product to be detected which is grabbed by the feeding robot arm and placed on the transport conveyor belt.

[0050] The present invention adopts the above technical solution to achieve the following beneficial effects:

[0051] 1. The present invention designs a method for adjusting the optimal perception posture of special-shaped surfaces based on robot hand-eye coordination to adjust the optimal collection of regular characters of products, and innovatively solves the problems of irregular imaging of irregular surface characters, large imaging noise interference, and single irregular detection of products during the detection process. The method uses a robotic arm to flexibly drive the camera assembly to conduct multi-directional and multi-angle trial collection of special-shaped surface characters, matches the real-time image collected by the trial with the standard image, calculates the posture deviation parameters of the robotic arm, and selects the robotic arm posture with the highest matching degree between the real-time image and the standard image as the optimal collection posture. In order to improve the search speed of the optimal collection posture, a gradient descent algorithm is used to accelerate convergence to solve the problem of long first posture adjustment time of the robotic arm. The camera assembly of the present invention adopts a dual telecentric lens proportional non-distortion imaging to eliminate the problems such as inconsistent magnification of different depths of field brought about by ordinary lens pinhole imaging, solves the problem of irregular deformation of characters under non-optimal viewing angle imaging under special-shaped surfaces, and maps the imaging within the local surface range to plane imaging through the dual telecentric lens imaging scheme under the optimal viewing angle, realizing the detection feasibility of the traditional plane character detection algorithm and enhancing the versatility and flexibility.

[0052] 2. The present invention designs a method for detecting slightly deformed characters based on deep learning to solve the problem of poor adaptability to slightly deformed characters such as stretching, compression, expansion, and thinning, and it has universality. Template matching based on normalized cross correlation (NCC) is introduced in the detection process, and NCC has a certain degree of anti-interference to image contrast changes and character deformation. Affine transformation and feature extraction are then used to effectively separate the character image from the background image, and the separated character image is sent to the deep learning RCNN text recognition model to obtain a character sequence, which is then sent to the character database for transmission. The character database matches the received characters and outputs whether the product character information is qualified based on the matching results. This method solves the difficult problem of uncertain deformation character detection, and compared with the problems of poor anti-interference ability and low accuracy of traditional fixed template matching, it has stronger robustness and adaptability.

[0053] 3. The present invention designs a device for automated high-precision detection of irregularly deformed characters on products, which solves the problem that currently special-shaped curved surface characters mainly rely on a large number of manual inspections, and both efficiency and detection accuracy are improved. The device is equipped with two four-degree-of-freedom robotic arms in both the loading module and the sorting module, which completely replaces manual loading and unloading, and improves the work efficiency of the entire detection process; in order to avoid subjective influences on product detection accuracy during manual detection, the device combines visual detection equipment with character detection robotic arms, and based on deep learning character recognition models, realizes automated high-precision detection of special-shaped product characters. In addition, the detection system composed of character detection robotic arms and machine vision camera components can adaptively adjust the visual detection angle, which is convenient for quickly responding to product model changes.

[0054] In summary, the method and equipment for detecting irregular deformed characters on products based on deep learning provided by the present invention can replace existing manual inspection, eliminate the fact that irregular character detection on the product surface is easily affected by light and curved surface material, improve detection accuracy and detection speed, and can meet the industrial production of general detection methods for deformed characters on special-shaped curved surfaces such as laser engraving, printing, and pad printing of different products.

[0055] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 This is an overall schematic diagram of the irregular deformed character detection device of the first embodiment.

[0057] Figure 2 This is a schematic diagram of a product feeding module of the product irregularly deformed character detection device of Example 1.

[0058] Figure 3 This is a schematic diagram of a conveyor belt of the irregularly deformed character detection device for products in Example 1.

[0059] Figure 4 This is a schematic diagram of a character detection module of the irregularly deformed character detection device of the product of Example 1.

[0060] Figure 5 This is a flow chart of the method for detecting irregularly deformed characters on a product according to the second embodiment.

[0061] Figure 6 Schematic diagram of hand-eye collaborative calibration of the character detection robot arm and camera assembly of Example 2.

[0062] Figure 7 This is a schematic diagram of the process of optimizing and adjusting the optimal acquisition posture of the robotic arm in Example 2.

[0063] Figure 8 This is a schematic diagram of the CRNN text recognition model in Example 2.

[0064] Fig. 9 This is a schematic diagram of the analysis of the irregularly deformed character samples of the product tested in Example 2.

[0065] Fig.10 This is a diagram showing the detection effect of the irregularly deformed character sample of the product in Example 2.

[0066] Numbers in the figure:

[0067] 1-product loading module, 11-loading platform, 12-material tray to be tested, 13-loading mechanical arm, 14-pneumatic gripper;

[0068] 2-transport conveyor belt, 21-belt, 22-roller, 23-belt support guard plate, 24-support block, 25-motor 26-frame;

[0069] 3- character detection module, 31- character detection support, 32- character detection mechanical arm, 33- area array camera, 34- double telecentric lens, 35- light source, 36- visual acquisition fixture;

[0070] 4-product sorting module, 41-sorting table, 42-qualified material tray, 43-defective material tray, 44-sorting robot arm, 45-sorting claw. DETAILED DESCRIPTION

[0071] Embodiment 1

[0072] See also Figure 1 , the figure shows a specific implementation scheme of the irregularly deformed character detection device for products in the present invention, the device comprises a product loading module 1, a transport conveyor belt 2, a character detection module 3 and a product sorting module 4, wherein the product loading module 1 is located upstream of the transport conveyor belt 2, grabs the product to be detected onto the transport conveyor belt 2 and transports it downstream, the product sorting module 4 is located downstream of the transport conveyor belt 2, removes the detected product from the transport conveyor belt 2, the character detection module 3 is located on one side of the transport conveyor belt 2 between the product loading module 1 and the product sorting module 4, and performs image acquisition on the irregularly deformed characters of the product to be detected grabbed by the product loading module 1 onto the transport conveyor belt 2.

[0073] The following combination Figure 2 , Figure 3 and Figure 4 A further detailed description of this device is given.

[0074] The product loading module 1 of this embodiment is used to transfer the character product to be tested to the conveyor belt 2, and is composed of a loading platform 11, a material tray 12 to be tested, a loading robot arm 13 and a pneumatic clamp 14. The main body of the loading platform 11 is constructed of aluminum alloy profiles, and multiple material trays 12 of products to be tested can be placed; the loading robot arm 13 is installed on the loading platform 11, and is fixed by bolts to grab the product to be tested onto the conveyor belt. The loading robot arm 13 in this embodiment is an industrial robot with four degrees of freedom. The pneumatic clamp 14 is connected to the front end of the loading robot arm 13 by bolts as the end effector of the loading robot arm 13, and is used to clamp the product to be tested in the material tray 12 and place it on the conveyor belt 2.

[0075] The transport conveyor belt 2 is used to receive the products with characters to be inspected transferred by the product feeding module 1, and transport the products to be inspected to the inspection area of ​​the character detection module 3. The transport conveyor belt 2 includes a belt 21, a roller 22, a belt support guard plate 23, a support block 24, a motor 25 and a frame 26, wherein the frame 26 is a box structure composed of aluminum and aluminum plates, and the inside of the frame 26 is used to store the device driver and the device control host. A plurality of support blocks 24 are arranged above the frame 26 along the conveyor belt direction, and the front and rear rows of support blocks 24 are connected to the frame 26 by screws, and the two rows of support blocks are connected to the two belt support guard plates 23, and the rollers 22 are installed on the two belt support guard plates 23, one each in the front and rear, and the two rollers 22 are connected by the belt 21, and the shaft of one of the rollers 22 passes through the belt support guard plate 23 and is connected to the motor 25, and the motor 25 is fixed to the side of the belt support guard plate 23 by screws.

[0076] The character detection module 3 is used to detect whether there are character defects on the surface of the product to be detected, and includes a character detection support 31, a character detection mechanical arm 32, an array camera 33, a double telecentric lens 34, a light source 35 and a visual acquisition fixture 36. In this embodiment, the character detection mechanical arm 32 is a six-degree-of-freedom industrial mechanical arm, which is connected to the character detection support 31 by screws. The execution end of the character detection mechanical arm 32 is equipped with a camera component for image acquisition of irregular deformed characters on the product to be detected. The camera component is composed of an array camera 33, a double telecentric lens 34 and a light source 35. After the array camera 33 and the double telecentric lens 34 are connected, they are installed on the visual acquisition fixture 36 by screws. The light source 35 is a circular hollow light source. After passing through the double telecentric lens 34, it is fixedly installed on the visual acquisition fixture 36. The camera component for visual acquisition is combined into the end actuator of the mechanical arm 32 through the visual acquisition fixture 36, and combined with the mechanical arm into a set of hand-eye detection system.

[0077] The product sorting module 4 is used to sort out unqualified character products and transfer qualified character products to the corresponding material rack, including a sorting platform 41, a qualified material tray 42, a defective material tray 43, a sorting mechanical arm 44 and a sorting claw 45. The main body of the sorting platform 41 is constructed of aluminum alloy profiles, and the qualified material tray 42 and the defective material tray 43 are placed on the sorting platform 41 respectively; the sorting mechanical arm 44 is installed on the sorting platform 41 and fixed by bolt connection. The sorting mechanical arm 44 in this embodiment adopts an industrial robot with four degrees of freedom. The sorting claw 45 is connected to the front end of the sorting mechanical arm as the end effector of the sorting mechanical arm 44 by bolts, and is used to clamp the inspected products on the transport conveyor belt and place them in the designated material tray.

[0078] When using the above-mentioned product irregular deformation character detection equipment, first place the product to be detected in the material tray 12 to be detected of the product feeding module 1, the material tray 12 to be detected is placed on the feeding platform 11, the feeding robot arm 13 drives the end pneumatic clamp 14 to the position of the product to be tested, the pneumatic clamp 14 ventilates and clamps the product to be tested and transfers the product to the top of the belt 21 of the transport conveyor 2, and places the product to be detected, and the product to be detected is continuously transferred from the material tray 12 to the belt 21 in sequence by the feeding robot arm 13 and the pneumatic clamp 14. The belt 21 transports the product to be detected to the detection area where the character detection module 2 is located in sequence, and the camera component in the character detection module 2 is moved and adjusted by the character detection robot arm 32 to collect images of the character products on the material tray, and the collected images are transmitted to the device control host, and the device control host determines whether the irregularly deformed characters of the product are qualified through the detection method of the present invention. The sorting robot arm 44 of the product sorting module 4 sorts the inspected products to the corresponding material tray according to the inspection result of the equipment control host on whether the inspected products are qualified. If a sorting signal of a qualified product is received, the sorting robot arm 44 transfers it to the qualified material tray 42. If a sorting signal of an unqualified product is received, the sorting robot arm 44 transfers it to the defective material tray 43.

[0079] Embodiment 2

[0080] This embodiment describes in detail the method for detecting irregularly deformed characters on products by the device in Embodiment 1. It should be noted that this embodiment is only a specific implementation scheme of the method for detecting irregularly deformed characters on products based on deep learning provided by the present invention applied to the detection device in Embodiment 1, and does not limit Embodiment 1 to be the only detection device applicable to the detection method of the present invention.

[0081] See also Figure 5 The method for detecting irregular deformed characters of products in this embodiment includes deformed character image acquisition, deformed character image processing, deformed character image processing and deformed character detection post-processing, which specifically includes the following steps:

[0082] S1. Use a hand-eye coordinated character detection robot to perform trial image capture of irregularly deformed characters on the product, obtain the capture posture deviation of the robot by comparing the positional features and structural features between the trial captured image of the irregularly deformed characters and the standard image, optimize and adjust the optimal capture posture of the robot, and the robot captures images of the characters on the product to be detected through the optimal capture posture.

[0083] The camera component for collecting images is fixed at the execution end of the character detection robot and moves with the robot. The camera component and the character detection robot are calibrated by hand and eye through the checkerboard calibration method. The transformation matrix of the camera coordinate system and the robot coordinate system is calibrated, and the camera intrinsic and extrinsic parameter matrix is ​​calculated. The coordinate transformation relationship between the camera and the character detection robot is established. The point corresponding to a certain point in the image in the real world is obtained through the coordinate transformation relationship. The specific checkerboard calibration method process is as follows.

[0084] like Figure 6 As shown, a 10*7 chessboard calibration board is selected, and the side length of each small square on the chessboard is 21.5mm. The camera remains stationary, and the chessboard is rotated to collect chessboard images with different postures and tilt angles. Through the mapping of the two-dimensional calibration board to the two-dimensional imaging plane, the calibration board information at different angles and positions is used to solve the camera's intrinsic parameter matrix. In this embodiment, the eye-on-hand calibration method is selected, that is, the camera is fixed to the end of the character detection robot arm and moves with the robot arm, and the conversion matrix of the camera coordinate system and the robot arm coordinate system is calibrated.

[0085] The camera calibration process is mainly divided into two parts: first, according to the constraints of geometric optics, the optical and physical parameters of the imaging model are solved; second, by establishing constraint relationships, the solved parameters are iteratively optimized. Assume that the chessboard is located in the world coordinate system O W Middle Z W = 0, the transformation relationship between the known pixel coordinate system and the world coordinate system is:

[0086]

[0087] In the formula, t WC It is the transformation matrix between the world coordinate system (base coordinate system) and the camera coordinate system, that is, the camera's external parameter matrix. CI is the mapping matrix between the two-dimensional image coordinate system and the three-dimensional camera coordinate system, that is, the intrinsic parameter matrix, R 3×3 With T 1×3 They are the X-axis coordinate system between the camera coordinate system and the robot arm coordinate system. W , Y W and Z W The three-axis rotation matrix and translation matrix, u, v represent a point in the pixel coordinate system, v0, u0 represent the coordinates of the center origin of the pixel coordinate system, f x 、f y Set the pixel value per millimeter in the x and y axis directions in the pixel coordinate system. c The depth information parameter of a point in the world coordinate system.

[0088] The result of camera intrinsic calibration is three-dimensional space (X C , Y C , Z C) to the two-dimensional imaging plane (u, v), each marking point on the chessboard calibration board is recorded as [X i , Y i ,0] T , the corresponding point in the pixel coordinate system is recorded as [u i , v i , 1] T , substituting into the above conversion relationship, we can get:

[0089]

[0090] A[r1 r2 t1] in the formula is recorded as the homography matrix, and H = [H1, H2, H3] is used to describe the homography matrix of the correspondence between two image planes. Then a point M(X i , Y i ) and its pixel coordinates (u i , v i ) are as follows:

[0091]

[0092] Where Z i Represents the depth information of point M, and the depth information Z in the above formula is i Eliminate, and we get:

[0093]

[0094] According to the relationship that r1 and r2 in the rotation matrix are unit orthogonal, and the homography matrix H = [H1, H2, H3] = A[r1r2 t1], we can know that:

[0095] r1=A -1 H1, r2 = A -1 H2,

[0096]

[0097] Among them, H1=Ar1 represents the mapping relationship between the image plane and the checkerboard plane in the first direction, H2=Ar2 represents the mapping relationship between the image plane and the checkerboard plane in the second direction, H2=At1 represents the translation relationship between the image plane and the checkerboard plane, B=A -T A -1 ).

[0098] Let B = A -T A -1 , where A 3×3 is the intrinsic parameter matrix of the camera, we can get:

[0099]

[0100] The internal parameters of the camera are as follows:

[0101]

[0102] α and β are the scale factors of the image axis (focal length), and γ is the angle between the image axes (sensor axis and optical axis). According to the homography matrix H=A[r1 r2 t1], we get [R1, R2, T] corresponding to each chessboard calibration plate image. Since R1, R2 and R3 are orthogonal to each other, we can get the rotation vector R3 and translation vector T of the camera extrinsic parameter:

[0103] R3=R1×R2,T=A -1 H3.

[0104] The “eyes on hands” calibration algorithm is as follows Figure 6 As shown, the camera is fixed at the end of the character detection robot arm. At this time, the rotation and translation matrix between the camera and the end of the character detection robot arm is The transformation matrix between the chessboard calibration plate and the robot base coordinate system remains unchanged. unchanged, according to these two unchanged transformation matrices, the following relationship exists:

[0105]

[0106] In the formula, is the position transformation relationship between the robot base coordinate system and the end of the robot. It is the conversion relationship between the camera coordinate system and the calibration plate coordinate system. Let the character detection robot be in two different positions, and the camera obtains the chessboard calibration plate image. According to the transformation relationship of the coordinate system, we can get:

[0107]

[0108] in It is the transformation relationship between two different robot end positions and the robot base coordinate system, which can be obtained by 5-point calibration of the robot. is the conversion relationship between two different pose cameras and the chessboard calibration plate, which can be obtained by the chessboard calibration method, that is, the camera external parameter. Combining the above two equations, we can get:

[0109]

[0110] Then we get:

[0111]

[0112] Then the above formula can be simplified to CX=XD, where is an unknown number. Convert CX=XD into a homogeneous linear equation and solve X using the least squares method. In the matrix, C, X, and D are all 4*4 homogeneous matrices composed of the rotation vector R3 and the translation vector T. The matrix form of the equation group CX=XD is as follows:

[0113]

[0114] Then CX=XD can be decomposed into the following equation:

[0115]

[0116] Among them, R C Represents the 3×3 rotation matrix of the robot between two different positions, R D Represents the 3×3 rotation matrix of the camera between different poses, R X Represents the 3×3 rotation matrix between different positions of the robot end, T C represents the 3×1 translation matrix of the robot between two different positions, T D Represents the 3×1 translation matrix of the camera between two different positions, T X represents the 3×1 translation matrix of the end of the robot between two different positions. First solve R X , and then solve for T X , the hand-eye calibration of the robotic arm vision system can be completed.

[0117] In step S1, an optimal perception posture adjustment method for special-shaped surfaces based on robot hand-eye collaboration is used to test-collect irregular product deformed characters. This method performs image test collection on irregularly deformed product characters, matches the test-collected images of irregularly deformed product characters with the standard image input image matching model, extracts the position features and structural features of the two images, calculates the position offset and structural difference vector between the two images, further calculates the posture deviation parameters of the character detection robot arm, and determines the optimal collection posture of the robot arm through a fast gradient descent optimization algorithm.

[0118] The camera assembly carried by the character detection robot in this embodiment includes an area array CCD camera, a dual telecentric lens, and a square shadowless light source. The characters on the surface of irregular products are tested and the tested images are sent to the image matching model for matching. There are two inputs in the image matching model. One is the standard image of the deformed character. The standard image is collected by the same optical device. During the standard image collection process, the light is parallel to the character mapping to ensure that the character is located in the middle of the image and the light interference is small. The other input is the test image to be matched collected by the character detection robot. The test image collected by the character detection robot for the first time may have characters offset, incomplete, distorted, etc. The image matching model is used to match the image to be matched with the standard image, and the posture deviation parameters of the character detection robot during the test collection are calculated. The robot posture with the highest matching degree between the test real-time image and the standard image is selected as the optimal collection posture.

[0119] Specific as Figure 7 As shown, firstly, the position features between the trial-collected image and the standard image are processed, and the difference analysis of the Euclidean distance in the position features is performed. The feature points F with common features in the trial-collected image and the standard image are selected and the Euclidean distance d between the feature points F of the two images is calculated. The Euclidean distance d is compared with the set threshold value D. If d>D, the feature point coordinates of the trial-collected image are converted to the world coordinates where the manipulator is located through the intrinsic and extrinsic parameters of the camera, and the first movement vector of the feature point F in the trial-collected image and the standard image in the world coordinates is obtained. The second movement vector of the manipulator in the world coordinates is calculated through the first movement vector conversion, and the position and posture parameters of the manipulator for trial collection are solved. The position and posture parameters of the manipulator are adjusted to move the trial collection to ensure d≤D.

[0120] The specific calculation process is as follows: the coordinates of the feature point F in the standard image are (x1, y1), and the coordinates in the trial image to be matched are (x2, y2). Project (x1, y1) to the trial image to be matched. The Euclidean distance d between the two points (x1, y1) and (x2, y2) is calculated as follows:

[0121]

[0122] Then subtract the coordinates of the feature points in the standard image from the coordinates of the feature points in the image to be matched to obtain the difference vector:

[0123] (Δx, Δy)=(x1-x2, y1-y2).

[0124] Given two points (x1, y1) and (x2, y2) express them as homogeneous coordinates:

[0125]

[0126] Using the camera's intrinsic parameter A, convert the image coordinates to camera coordinates:

[0127]

[0128] Use the camera's external parameter matrix R t , where R is the rotation vector and t is the translation vector, convert the camera coordinates to world coordinates:

[0129]

[0130] in, are the coordinates of the point in the world coordinate system, is the coordinate of the point in the camera coordinate system. The first moving vector of the two points (x1, y1) and (x2, y2) in the real physical world between the collected image and the standard image is

[0131] Assume that the current position and posture of the character detection robot arm are represented by a six-dimensional vector: T = [XYZ α β γ] T , where X, Y, and Z represent the position of the end of the character detection robot arm in the base coordinate system, and α, β, and γ represent the posture of the end of the character detection robot arm.

[0132] Assume that the rotation matrix from the world coordinate system to the mechanical coordinate system is R wb and the translation vector t wb :

[0133]

[0134] Calculate the second movement vector Δp ​​in the robot coordinate system b =R wb ·Δp w , since it is only a translation operation, by moving the vector Δp b Calculate the new character detection robot arm position, while the robot arm posture remains unchanged, and the position and posture of the robot arm after the move are obtained as follows:

[0135]

[0136] That is, the new position and posture of the character detection robot arm is: T new =[X' Y' Z' α' β' γ'] T =[X+Δx b Y+Δy b Z+Δz b α β γ] T , where Δx b , Δy b and Δz b is through Δpb The calculated movement amount.

[0137] After obtaining the new position and posture of the robotic arm, the joints of the robotic arm are driven to rotate or move until d is less than the set threshold D.

[0138] See again Figure 7 For the structural features between the trial image and the standard image, calculate the mean values ​​μ1 and μ2, standard deviations σ1 and σ2, and covariance σ of the standard image and the trial image to be matched. 12 The brightness, contrast and structure of the two images were measured to obtain the SSIM index.

[0139] Specifically, the brightness of the test image and the standard image is measured by comparing the average brightness of the two images. The formula is as follows:

[0140]

[0141] In the formula, C1 is a constant used to avoid the denominator being 0. Usually C1=(K1L) 2 , where L is the dynamic range of pixel values. For an 8-bit image, L=255, and K1 is a very small constant, usually 0.01.

[0142] The contrast between the collected image and the standard image is measured by comparing the standard deviation of the image. The formula is as follows:

[0143]

[0144] In the formula, C2 is a constant used to avoid the denominator being 0. Usually C2 = (K2L) 2 , where L is the dynamic range of pixel values, for 8-bit images, K=255, and K2 is a constant, which is 0.03.

[0145] The structure measurement of the test image and the standard image is achieved by comparing the covariance between the images. The formula is as follows:

[0146]

[0147] In the formula, C3 is a constant, usually C3=C2 / 2.

[0148] The brightness, contrast and structure parameters of the test image and the standard image are compared to obtain the SSIM index between the two images through the following formula:

[0149] SSIM(x,y)=l(x,y) α c(x, y) β s(x, y) γ, l(x, y) represents the brightness parameter, which is obtained by comparing the average brightness of the two images, c(x, y) represents the contrast parameter, which is obtained by comparing the standard deviation of the two images, s(x, y) represents the structure parameter, which is obtained by comparing the covariance between the two images, (x, y) represents the position coordinates of the brightness, contrast and structure parameters extracted from the test image and the standard image, α, β, γ are weight parameters, which are adjusted according to the largest difference between the images, and are generally taken as 1. The value range of the SSIM index is [-1, 1]. The SSIM index approaching 1 means that the two images are exactly the same, and the SSIM index approaching -1 means that the similarity between the two images is poor.

[0150] In order to make the trial image to be matched more similar to the standard image, this embodiment designs a loss function Loss. The optimization goal is to minimize the difference between the current SSIM index and the target SSIM index between the trial image and the standard image. The constraint goal is that after the character targets in the two images roughly overlap, the acquisition module driven by the robot moves in a spherical space with a radius of T. The specific expression of the loss function Loss is:

[0151] Loss = (SSIM current -SSIM target ) 2 +λ·Penalty(x,T),

[0152] Among them, SSIM current is the current SSIM index between the test image and the standard image, SSIM target is the target SSIM index between the test image and the standard image, SSIM target The value is 0.8 to 0.9, where λ is the weight used to adjust the penalty term, and Penalty(x, T) is the penalty function that constrains the current position x of the manipulator to be within the spherical area T. P If the penalty function is within the spherical area with a radius of 0, then the penalty function is 0. Otherwise, the penalty function is the distance from the robot position x to the spherical area T P The Euclidean distance, T P It is equal to the Euclidean distance threshold D of the feature points set when matching the trial image with the standard image input image matching model. The position of the robot arm x is adjusted through the gradient descent optimization algorithm so that the current SSIM index between the trial image and the standard image reaches the set target SSIM index, or the optimization is stopped when the loss function Loss is minimized. At this time, the robot arm stops moving, and the current position x of the robot arm is the optimal acquisition posture of the irregularly deformed characters of the product.

[0153] At this point, the optimization adjustment of the optimal acquisition posture of the character detection robot arm in step S1 is completed. The character detection robot arm collects images of irregular characters of the products to be detected on the conveyor belt according to this optimal acquisition posture, and uploads the collected character images of the products to be detected to the equipment control host.

[0154] S2. After denoising and preprocessing the character image of the product to be detected collected in step S1, the region of interest where the characters of the product to be detected are located in the image is confirmed by normalized cross-correlation, the region of interest is affine transformed with the standard image, and the character distortion and tilt in the character image of the product to be detected are corrected to obtain a corrected character image of the region of interest.

[0155] The device control host receives the character image of the product to be detected collected from step S1, and uses the non-local mean denoising method to denoise the collected character image of the product to be detected, thereby weakening the influence of exposure or reflection caused by different lighting conditions and different curved surface materials on the character image of the product to be detected.

[0156] Specifically, the basic idea of ​​non-local mean denoising is to use the similarity between each pixel in the image to perform filtering operations. Non-local mean denoising calculates the weighted average of the similarity of the pixels in the entire image, thereby better removing noise and maintaining image texture detail information. The specific reasoning process of this non-local mean denoising is as follows:

[0157] The size of the product character image I to be detected is M×N, and the pixel value of the i-th row and j-th column is defined as I ij For each pixel I in the character image of the product to be detected ij , define a window of size (2W+1)×(2W+1), where W is the window radius. For the current pixel I ij , calculate the similarity of the pixel values ​​in each window around it, and let the pixel value of the kth window in image I be I k , then the similarity between the current window and the kth window is:

[0158]

[0159] Where p and q are the count identifiers in the summation formula. The weight of each pixel is calculated based on the similarity. For the current pixel I ij , whose weight W ij,k for:

[0160]

[0161] Among them, h is a parameter that controls the similarity weight. Use the weight to perform weighted averaging on the current pixel to obtain the denoised pixel value:

[0162]

[0163] Repeat the above steps for all pixels in the image to obtain the denoised image.

[0164] Then, the template matching method based on normalized cross-correlation is used to locate the core area of ​​the characters in the character image of the product to be detected, that is, the area where the irregular characters on the product surface are located. M×N (That is, the denoised image above ), and a template target image T m×n , template target image T m×n is the character image to be matched, which is obtained by cutting out the character area from the standard image in step S1, in order to find the character image I of the product to be detected. M×N Find the target image T that matches the template m×n The most similar area, using the template target image T m×n In the product character image I to be detected M×N In the sliding matching, the normalized cross-correlation similarity is used to measure the template target image T during the sliding process. m×n And the character image I of the product to be detected M×N The similarity includes:

[0165] First, calculate the template image T m×n And the character image I of the product to be detected M×N The average gray value of and To T m×n and I M×N The cross-correlation calculation is performed to obtain the average grayscale cross-correlation term corr(x, y). The calculation formula of the cross-correlation term is as follows:

[0166]

[0167] Here (u, v) is the template target image T m×n The coordinates in (x, y) are the characters in the product image I to be detected. M×N The coordinates in .

[0168] Then, calculate the template target image T respectively m×n The standard deviation term σ T And the character image I of the product to be detected M×N The standard deviation term σ I , the calculation formula of the standard deviation term is as follows:

[0169]

[0170] The average grayscale cross-correlation term corr(x, y) is compared with the template target image T m×nThe standard deviation term σ T And the character image I of the product to be detected M×N The standard deviation term σ I The cross-correlation term is normalized by the following formula to obtain the template target image T m×n And the character image I of the product to be detected M×N NCC similarity:

[0171]

[0172] A sliding window with a step size of 1 and a sliding size of Q is selected in the character image of the product to be detected, and the NCC similarity of the template target image in each sliding window is calculated. The area with NCC similarity higher than the set similarity threshold is regarded as the matching area, and the area with the largest NCC similarity is found as the matched area of ​​interest. A bounding box is generated according to the position and size of the area of ​​interest to identify the area of ​​interest.

[0173] The standard image used in step S1 and the region of interest matched in this step are used to construct an affine transformation matrix, and the slight distortion and tilt of the character image are corrected by the constructed affine transformation matrix to obtain the corrected character image of the region of interest. There may be translation, rotation, scaling and other transformations in the local area, which may cause the geometric shape and posture between the matched region of interest and the template image to be inconsistent. Through affine transformation, the matched region of interest is further adjusted to a shape more similar to the template image, so that the subsequent curved character recognition task can be carried out accurately.

[0174] S3. The corrected character image of the region of interest is sent to a deep learning character recognition model based on image edge segmentation. The character text area in the image is effectively separated from the background area through image segmentation, and a boundary box of the character text area, i.e., a text box, is generated.

[0175] Considering that curved characters usually have obvious edge features, the deep learning character recognition model of this embodiment adopts the Canny edge segmentation algorithm, which specifically includes the following sub-steps:

[0176] Gaussian blur is performed on the corrected character image of the region of interest to reduce noise. Gaussian blur can be achieved by convolving the corrected character image of the region of interest with a Gaussian kernel G:

[0177] I blur (x,y)=I(x,y)*G(x,y).

[0178] The horizontal gradient G is calculated by using the Sobel operator on the blurred and corrected character image through the following formula: x and the vertical gradient G y ,

[0179] G x =I blur (x,y)*S x , G y =I blur (x,y)*S y ,

[0180] Where S x and S y are the Sobel operators in the horizontal and vertical directions respectively.

[0181] The gradient magnitude M and direction θ are calculated by the following formula:

[0182]

[0183] The non-maximum value of the gradient amplitude M is suppressed. The gradient amplitude of each pixel of the corrected character image is compared with the gradient amplitudes of its two adjacent pixels along the gradient direction. The local maximum value is retained. The process of suppressing the non-maximum value can be expressed as:

[0184]

[0185] In the formula, Δx and Δy represent the small increments in the x and y directions respectively. The double threshold edge connection method is used to threshold the corrected character image after non-maximum suppression, and the high threshold T is set. high and low threshold T low , pixels greater than the high threshold are marked as strong edges, pixels less than the low threshold are marked as weak edges, and pixels between the two are marked as intermediate edges. high The strong edge pixels are tracked, and the calculated direction θ is used to guide the extension direction of the edge to determine the connected edge lines. Finally, the connected edge lines are refined. This step is to further refine the edge shape and make it more accurate. The area inside the edge lines is the character text area of ​​the area of ​​interest. By executing the above steps, the Canny edge detection algorithm can detect clear and accurate edges in the image of interest, which helps to separate characters from the background.

[0186] Cluster the character text areas in the region of interest, identify and merge local areas belonging to the same text, filter the clustered character text areas, remove too small or irregular areas, retain larger and continuous character text areas, and the size of the text character area is determined by the set area size threshold S a To judge, greater than or equal to S a The area is larger than S aThe area is too small. A bounding box is generated for the filtered text area as a text box to mark the location and scope of the text. The bounding box is represented by the outer rectangle of the text area.

[0187] S4. The text box is input into the offline trained CRNN text recognition model. The CRNN model of this embodiment is specifically used to recognize sequence objects of indefinite length in images. The character line in the text box is recognized as a unit. After the character recognition is completed, the text sequence of the character line is returned in the form of a sequence. The recognized character information is then uploaded to the device control host and saved in the database for subsequent product qualification judgment.

[0188] The above steps effectively separate the character text area from the background in the irregular character image of the product to be detected, and generate a text box for the text area, providing accurate input for the CRNN text recognition model in this step. Figure 8 As shown in FIG. 1 , the CRNN text recognition model in this embodiment outputs a text sequence of character lines in a text box through the following sub-steps:

[0189] The first step is to preprocess the character image in the text box as the input image, convert it into a format suitable for the CNN model, adjust the character image in the text box to a fixed size and normalize it.

[0190] In the second step, the VGG16 model is used to perform convolution and pooling operations on the character image in the input text box to extract the feature map. Specifically, let the character image in the input text box be X, and the VGG16 model parameter be W, then the forward propagation process of CNN can be expressed as:

[0191] F=M1(X;W),

[0192] Where F is the feature map extracted by CNN and M1 is the VGG16 model.

[0193] The third step is to serialize the extracted feature graph to obtain the serialized feature sequence S:

[0194] S = Flatten (F).

[0195] Step 4: Recurrent neural network processing. Input the serialized feature sequence S into the RNN model. Combine the feature sequence recursively with the text character context information. Output a vector at each time step, representing the prediction result of that time step. The final output form of the RNN model is a prediction result sequence composed of all time step output vectors. This sequence is composed of the vectors output by the RNN model at each time step, and each vector represents the prediction result of that time step. This sequence will be used for the next decoding operation.

[0196] Taking the BiLSTM model as an example, assuming that the BiLSTM model parameter is θ and the output of the BiLSTM model is Y, the forward propagation process of the BiLSTM can be expressed as:

[0197] BiLSTMY=M2(S;θ),

[0198] Among them, M2 is a BiLSTM model.

[0199] Step 5: Decode the prediction sequence output by the RNN model, and use the CTC loss function to convert the output sequence into the final text sequence and output it. The CTC loss function is usually used for sequence labeling tasks. Assume that the output of the above step is an input sequence x = (x1, x2, ..., x w ), where each x w Represents a feature vector and a label sequence y = (y1, y2, ..., y U ) represents the target sequence, where each y u Represents a label. The calculation of CTC loss is divided into two steps: forward algorithm and backward algorithm.

[0200] (1) Forward algorithm. First, define a (w×U) matrix y', where each element y' t,u represents the probability of generating label u at time step t. For each time step t, each label u, define:

[0201] α t (u) = p(y[1:u]|x[1:t]),

[0202] where α t (u) represents the probability of generating the label sequence y[1:u] at time step t.

[0203] Using dynamic programming, we can calculate α t The recursive formula of (u):

[0204]

[0205] Blank represents a special label for the blank symbol. Finally, the CTC loss generates the negative logarithm of the probability of the entire label sequence at the end of time step T:

[0206]

[0207] (2) Reverse algorithm. In order to calculate the derivative, the reverse algorithm is needed to calculate the gradient. The reverse algorithm is the inverse process of the forward algorithm. It calculates β through dynamic programming. t (u), β t(u) represents the probability of generating the label sequence y[u+1:U] at the end of time step t. The recursive formula of the reverse algorithm is:

[0208]

[0209] The text sequence finally obtained is the recognition result of the character line in the text box recognized by the CRNN text recognition model, which represents the character text sequence detected in the image.

[0210] S5. Match the text sequence identified in step S4 with the product standard character text sequence in the equipment control host database, determine whether the identified characters of the product to be tested are unqualified (NG) or qualified (OK), and output product information on whether the product to be tested is qualified based on the matching result. The information includes whether it is a qualified product (if unqualified, it is marked as a defective product) and product location information.

[0211] This embodiment Fig. 9 The irregularly deformed character samples of the products shown in are tested, and the character sequence of the test results is as follows Fig.10 As shown in the figure, the defective curved characters were not successfully detected, while other normal curved characters were successfully detected. The sorting robot arm downstream of the character detection robot arm sorts the products that have been tested according to the detected product information. The unqualified character products are sorted by the sorting robot arm to the residual material tray using the position signal in the product information, and the qualified character products are sorted by the sorting robot arm to the qualified material tray; finally, the sorted material tray containing qualified character products is transferred to the unloading material rack.

[0212] In this document, the directions or positional relationships indicated by terms such as "up", "down", "front", "back", "left", "right", "top", "bottom", "inside", "outside", "vertical", and "horizontal" are based on the directions or positional relationships shown in the accompanying drawings and are only for the clarity of expressing the technical solutions and the convenience of description, and therefore should not be understood as limitations of the present invention.

[0213] In this document, the terms "comprises," "comprising," or any other variations thereof, are intended to cover a non-exclusive inclusion of elements other than those listed and may also include additional elements not expressly listed.

[0214] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for detecting irregularly deformed characters of products based on deep learning, characterized in that The steps include: S1. Use a camera-equipped robotic arm with hand-eye coordination to perform trial image acquisition of irregularly deformed characters on the product, obtain the acquisition posture deviation of the robotic arm by comparing the positional features and structural features between the trial acquired image of the irregularly deformed characters and the standard image, optimize and adjust the optimal acquisition posture of the robotic arm, and the robotic arm acquires images of the characters on the product to be inspected through the optimal acquisition posture; S2, after denoising and preprocessing the character image of the product to be detected collected in step S1, confirm the region of interest where the character of the product to be detected is located in the image through normalized cross-correlation, perform affine transformation on the region of interest and the standard image, correct the character distortion and tilt in the character image of the product to be detected, and obtain a corrected character image of the region of interest; S3, sending the corrected character image of the region of interest to a deep learning character recognition model based on image edge segmentation, separating the character text area from the background area in the image, and generating a text box for the character text area; S4, the text box is input into the CRNN text recognition model, the character line in the text box is recognized as a unit, and after the character recognition is completed, the text sequence of the character line is returned in the form of a sequence; S5. Match the text sequence identified in step S4 with the product standard character text sequence, determine whether the identified characters of the product to be tested are unqualified or qualified, and output product information on whether the product to be tested is qualified based on the matching result.

2. According to claim 1, a method for detecting irregularly deformed characters of products based on deep learning is characterized in that: In step S1, the camera is fixed to the end of the robot arm and moves with the robot arm, and the camera and the robot arm are calibrated by hand and eye using a checkerboard calibration method.

3. The method for detecting irregularly deformed characters of products based on deep learning according to claim 2, characterized in that: In step S1, the test image of the irregularly deformed characters of the product is matched with the standard image input image matching model to extract the position features and structural features of the two images. First, according to the position feature, select the feature point F with common features in the test acquisition image and the standard image and calculate the Euclidean distance d between the feature points F of the two images, compare the Euclidean distance d with the set threshold D, if d>D, convert the feature point coordinates of the test acquisition image to the world coordinates where the robot is located through the intrinsic and extrinsic parameters of the camera, obtain the first movement vector of the feature point F in the test acquisition image and the standard image in the world coordinates, calculate the second movement vector of the robot in the world coordinates through the first movement vector conversion, solve the position and posture parameters of the robot for the test acquisition movement, adjust the position and posture parameters of the robot to move the test acquisition, and ensure that d≤D; Then, for the structural features, the brightness, contrast and structural parameters of the test image and the standard image are used to obtain the SSIM index between the two images through the following formula: SSIM(x,y)=l(x,y) α ·c(x,y) β ·s(x,y) γ l(x,y) represents the brightness parameter, which is obtained by comparing the average brightness of the two images. c(x,y) represents the contrast parameter, which is obtained by comparing the standard deviation of the two images. s(x,y) represents the structure parameter, which is obtained by comparing the covariance between the two images. (x,y) represents the position coordinates of the brightness, contrast and structure parameters extracted from the test image and the standard image. α, β and γ are weight parameters. The value range of the SSIM index is [-1,1]. When the SSIM index approaches 1, it means that the two images are exactly the same. When the SSIM index approaches -1, it means that the similarity between the two images is poor. The SSIM index between the trial image and the standard image is then optimized using the following loss function Loss: Loss=(SSIM current -YES target ) 2 +λ Penalty(x,T) Among them, SSIM current is the current SSIM index between the test image and the standard image, SSIM target is the target SSIM index between the test image and the standard image, SSIM target The value is 0.8~0.9, λ is the weight used to adjust the penalty term, Penalty(x,T) is the penalty function that constrains the current position x of the robot to be within the spherical area T. P If the penalty function is within the spherical area with a radius of 0, then the penalty function is 0. Otherwise, the penalty function is the distance from the robot position x to the spherical area T P The Euclidean distance is calculated, and the position of the robot arm x is adjusted through the gradient descent optimization algorithm so that the current SSIM index between the trial image and the standard image reaches the set target SSIM index, or the optimization is stopped when the loss function Loss is minimized. At this time, the robot arm stops moving, and the current position x of the robot arm is the optimal acquisition posture of the irregularly deformed characters of the product.

4. The method for detecting irregularly deformed characters of products based on deep learning according to claim 1, characterized in that: In the step S2, a non-local mean denoising method is used to perform denoising on the collected character image of the product to be inspected.

5. The method for detecting irregularly deformed characters of products based on deep learning according to claim 1, characterized in that: In step S2, a template matching method based on normalized cross-correlation is used to locate the core area of ​​the characters in the character image of the product to be detected, and a template target image T of the character area is intercepted from the standard image in step S1. m×n , using the template target image T m×n In the product character image I to be detected M×N In the sliding matching, the normalized cross-correlation similarity is used to measure the template target image T during the sliding process. m×n And the character image I of the product to be detected M×N The similarity includes: For the template target image T m×n The average gray value And the character image I of the product to be detected M×N The average gray value Perform cross-correlation calculation to obtain the average grayscale cross-correlation term corr(x,y), and compare the average grayscale cross-correlation term corr(x,y) with the template target image T m×n The standard deviation term σ T And the character image I of the product to be detected M×N The standard deviation term σ I The cross-correlation term is normalized by the following formula to obtain the template target image T m×n And the character image I of the product to be detected M×N NCC similarity: A sliding window with a step size of 1 and a sliding size of Q is selected in the character image of the product to be detected, and the NCC similarity of the template target image in each sliding window is calculated. The area where the NCC similarity is higher than the set similarity threshold is regarded as the matching area, and the area with the largest NCC similarity is found as the matched area of ​​interest. A bounding box is generated according to the position and size of the area of ​​interest to identify the area of ​​interest.

6. The method for detecting irregularly deformed characters of products based on deep learning according to claim 1, characterized in that: In step S3, the deep learning character recognition model adopts the Canny edge segmentation algorithm, which specifically includes the following sub-steps: Performing Gaussian blur on the corrected character image of the region of interest to reduce noise; The blurred and corrected character image is used to calculate the horizontal gradient G using the Sobel operator x and the vertical gradient G y , obtain the gradient amplitude M, perform non-maximum suppression on the gradient amplitude M, compare the gradient amplitude of each pixel of the corrected character image with the gradient amplitudes of its two adjacent pixels along the gradient direction, and retain the local maximum; The double threshold edge connection method is used to threshold the corrected character image after non-maximum suppression, and the high threshold T is set. high , select a value greater than the high threshold T high The strong edge pixels are used for edge tracking to determine the connected edge lines; Finally, the connected edge lines are refined, and the inner area of ​​the edge lines is the character text area of ​​the area of ​​interest.

7. The method for detecting irregularly deformed characters of products based on deep learning according to claim 6, characterized in that: Cluster the character text areas in the region of interest, identify and merge local areas belonging to the same text, filter the clustered character text areas, and retain text character areas that are continuous and larger than a set area size threshold S a The character text area retained by the filter is used to generate a text box using an enclosing rectangle.

8. The method for detecting irregularly deformed characters of products based on deep learning according to claim 5, characterized in that: In step S4, the CRNN text recognition model outputs a text sequence of character lines in the text box through the following sub-steps: The first step is to convert the character image in the text box into the CNN model format, adjust the character image in the text box to a fixed size and normalize it; The second step is to use the VGG16 model to perform convolution and pooling operations on the character image in the input text box to extract the feature map; The third step is to serialize the extracted feature graph to obtain a feature sequence; Step 4: Input the serialized feature sequence into the RNN model, combine the feature sequence recursively with the text character context information, and output a vector at each time step to represent the prediction result of that time step; The fifth step is to decode the prediction result sequence output by the RNN model, and use the CTC loss function to convert the output sequence into the final text sequence and output it. The final text sequence is the text sequence of the character lines in the text box recognized by the CRNN text recognition model.

9. A product irregular deformed character detection device based on deep learning, characterized in that: It includes a character detection robot arm, the execution end of which is equipped with a camera component for capturing images of irregularly deformed characters on products. The character detection robot arm captures images of irregularly deformed characters on products to be detected, and transmits the captured images to a device control host. The device control host determines whether the irregularly deformed characters on products are qualified through the detection method in claims 1-8.

10. The device for detecting irregularly deformed characters of products based on deep learning according to claim 9, characterized in that: It also includes a transport conveyor belt, a product loading module and a product sorting module; The product loading module is located upstream of the transport conveyor belt and includes a loading robot arm that grabs the product to be inspected onto the transport conveyor belt; The product sorting module is located downstream of the transport conveyor belt, and includes a sorting robot arm that takes the inspected products from the transport conveyor belt, and a material tray for placing qualified products and unqualified products by category. The sorting robot arm sorts the inspected products to the corresponding material tray according to the inspection result of the equipment control host on whether the products to be inspected are qualified; The character detection robot arm is located between the feeding robot arm and the sorting robot arm, and performs image acquisition on the deformed characters of the product to be detected which is grabbed by the feeding robot arm and placed on the transport conveyor belt.

Citation Information

Patent Citations

  • Method for detecting package IC (Integrated Circuit) chip defects based on feature template matching and in-depth learning

    CN108982508A

  • Method for detecting quality of jet printing and code spraying on bottle bottom joint line

    CN111598083A

  • Highly reflective metal surface character recognition method based on deep learning

    CN117275010A

  • Scene text recognition method and device

    WO2023083280A1

Cited By

  • Printing quality detection method and system for carton packaging

    CN120339223A

  • Robot hybrid visual servo positioning method, device and equipment

    CN121004614A