CN117975465A - Halcon-based character defect detection method and halcon-based character defect detection system - Google Patents

Halcon-based character defect detection method and halcon-based character defect detection system Download PDF

Info

Publication number
CN117975465A
CN117975465A CN202410249609.6A CN202410249609A CN117975465A CN 117975465 A CN117975465 A CN 117975465A CN 202410249609 A CN202410249609 A CN 202410249609A CN 117975465 A CN117975465 A CN 117975465A
Authority
CN
China
Prior art keywords
image
operator
model
area
standard
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410249609.6A
Other languages
Chinese (zh)
Inventor
殷波
王仁忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Huijiang Intelligent Technology Co ltd
Original Assignee
Shenzhen Huijiang Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Huijiang Intelligent Technology Co ltd filed Critical Shenzhen Huijiang Intelligent Technology Co ltd
Priority to CN202410249609.6A priority Critical patent/CN117975465A/en
Publication of CN117975465A publication Critical patent/CN117975465A/en
Pending legal-status Critical Current

Links

Abstract

The invention provides a method and a system for detecting character defects based on halcon, wherein the method comprises the following steps: collecting images of qualified products as a standard image library; creating a character graphic positioning template; establishing a difference model; carrying out affine transformation alignment on all standard images, and then carrying out mean value smoothing processing to obtain gray average values of characters and backgrounds; carrying out gray scale correction on the smoothed image to be detected according to a standard image gray average value obtained in advance; and comparing the images to be detected after gray scale scaling by using the trained difference model, identifying possible character defects, and judging whether the products to be detected are qualified or not. Aiming at the problem that the characters are judged to be bad due to different thicknesses of the characters caused by the production process of a laser engraving machine or a pad printing machine, the sensitivity of a difference model to the edges of the characters is reduced through the mean value smooth image, and the detection accuracy is improved; and scaling the gray value of the image to be measured to the gray value range of the standard image, and then comparing the gray value range of the standard image with the difference model, so that the problem that the gray value of the image to be measured is large in difference with the gray value of the standard image due to the change of illumination or camera exposure time, and the product is judged to be bad is solved.

Description

Halcon-based character defect detection method and halcon-based character defect detection system
Technical Field
The invention relates to the technical field of character defect detection, in particular to a halcon-based character defect detection method and system.
Background
In industrial production, especially in the electronic consumer goods industry, both the product itself and the outer package of the product can contain character and pattern marks, the characters and patterns of the product itself are generally laser carving or pad printing, and the outer package characters and patterns are generally printed; however, the processing and manufacturing environment are limited, and during the production process, some defects of the characters and patterns are unavoidable, such as: incomplete, skewed, sticky, multiple prints, offset, skip, reprint, etc.; currently, character defect detection generally adopts manual visual inspection or utilizes a machine vision system for detection; the manual visual inspection mode is generally to manually compare a standard character pattern printed in advance with the character pattern of the product to be detected one by one; the common method for detecting character defects based on halcon is to compare the images of the character to be detected with the images of the standard character to find out the place (namely the defect) with obvious gray level difference between the images, the standard character images generally adopt images of a plurality of qualified products, the median value or the average value of gray level values of all the images is obtained through training, and the obtained values are compared with the gray level values of the image to be detected, so that the method is called difference model comparison.
However, the manual visual inspection mode has low efficiency, and the human eyes are extremely tired, so that the false detection rate is high; however, the conventional method for comparing the difference models based on halcon has the following disadvantages:
1) The character thickness of the product is different to a certain extent sometimes due to the process reasons of the laser engraving machine or the pad printing machine, but the product can be judged to be qualified, and the edge with difference between the image to be detected and the standard image is judged to be bad when in visual detection, so that the accuracy of visual detection is reduced;
2) The method must ensure that the illumination around the product during detection and the exposure time of the camera must be consistent with that of the standard image of the qualified product, otherwise, the gray level difference between the image to be detected and the standard image becomes large, and the product is judged to be bad.
Accordingly, the prior art has shortcomings and needs further improvement.
Disclosure of Invention
Aiming at the problems existing in the prior art, the invention provides a halcon-based character defect detection method and a halcon-based character defect detection system.
In order to achieve the above object, the present invention is specifically as follows:
The invention provides a character defect detection system based on halcon, which comprises:
the camera module is used for collecting images of qualified products as a standard image library;
The image processing module is used for creating a character and graph positioning template and performing template matching, and comprises marking a character area in an image, dividing the template area image, creating a positioning template and obtaining the center coordinate of the positioning template area;
the difference model generation module is used for creating a difference model by calling a create_variation_model operator;
An image alignment module that aligns all standard images with the positioning template using a find shape model operator, affine transformation, and affine trans image operator;
the smoothing processing module is used for carrying out mean value smoothing processing on the standard images to be aligned by adopting a mean_image operator and adjusting the size of the filter according to the font thickness;
The training module is used for training the smoothed standard image by using a train_variation_model operator and storing a training result into the difference model;
the parameter setting module is used for setting a minimum absolute threshold value and a difference threshold value of the difference model through a preparation_variation_model operator;
the image acquisition module of the product to be measured is used for acquiring the image of the product to be measured and carrying out image pair Ji Heping sliding treatment through the same flow to obtain the image to be measured with smooth mean value;
The gray scale module is used for calculating gray scale and compensation quantity, and then a scale_image operator is applied to carry out gray scale on the image to be measured with the average value being smoothed, so as to obtain the image to be measured with the gray scale;
and the comparison judging module is used for comparing the image to be detected after the gray scale is scaled by combining a compare_ext_variation_model operator with the difference model, and judging whether the product is defective or not according to the comparison result.
Further, the image processing module further includes extracting a character region image from the image using a reduce_domain operator.
Further, the difference model generating module is further configured to obtain average gray values of the standard image character area and the background area, specifically, by using an operator reduce_ domain, binary _ threshold, difference, intensity.
Further, the gray scale method used by the gray scale module, wherein the gray scale Mult and the compensation amount Add are calculated by the following formula :Mult=(ForeGrayValue-BackGrayValue)/(CurrentForeValue-CurrentBackValue),Add=ForeGrayValue-Mult*CurrentForeValue.
The invention also provides a character defect detection method based on halcon, which adopts the system, and comprises the following steps:
S1, acquiring at least one image of a qualified product through a camera, and storing the image as a standard image library;
S2, creating a character graphic positioning template:
s3, creating a difference model, and realizing by using a create_variation_model operator in halcon;
S4, performing alignment processing on all standard images:
S5, carrying out mean smoothing on the aligned standard images by applying a mean image operator, setting the size of a filter to adapt to the thickness change of characters, and marking the smoothed standard images as MEANIMAGE;
s6, training the smoothed standard image MEANIMAGE into a difference model VarModleID by utilizing a train_variation_model operator, and setting a minimum absolute threshold value and a difference threshold value of the difference model;
S7, obtaining a training image TRAINEDIMAGE for the trained difference model and analyzing average gray values ForeGrayValue and BackGrayValue of a character area and a background area in the training image;
S8, acquiring an image of a product to be detected;
s9, carrying out mean value smoothing treatment on the image to be detected after alignment, wherein the size of the filter is consistent with that in the step S5;
S10, obtaining average gray values CurrentForeValue and CurrentBackValue of a character area and a background area of the image to be detected after average smoothing;
S11, calculating gray scale Mult and compensation amount Add of the image to be measured according to known ForeGrayValue, backGrayValue, currentForeValue and CurrentBackValue, and performing gray scale on the image to be measured by using a scale_image operator to obtain SACLEDIMAGE;
And S12, finally, carrying out difference model comparison on the image SACLEDIMAGE to be tested after gray scale scaling by adopting a compare_ext_variation_model operator and combining a difference model VarModleID, judging whether a difference area exceeding a preset range exists according to a comparison result, and if so, judging that the product to be tested is a defective product.
Further, step S2 specifically includes:
S201, selecting an image from a standard image library and displaying the image in an image window;
S202, marking a character area of a product on a window by using a draw_rectangle2 operator as a template area Region;
S203, segmenting a template area Image0 from the Image according to the template area Region by using a reduction_domain operator;
S204, a create_shape_mode operator is applied to create a positioning template ModleID on the template region Image0, and an area_center operator is used to obtain the center line coordinates RowRef, columnRef of the template region.
Further, the step S4 specifically includes the following steps:
s401, reading standard images one by using a read_image operator;
S402, performing template matching on the current standard image by utilizing the find_shape_model and the positioning template ModldID, and determining the center row coordinate and the angle of the character area;
S403, calculating an affine transformation matrix HomMat D by using a vector_angle_to_ rigid operator;
S404, performing translational rotation operation on the current standard image according to the transformation matrix HomMat D by using an affine_trans_image operator to ensure that the character area is aligned with the positioning template area.
Further, the step S8 specifically includes the following steps:
s801, acquiring an image of a product to be detected by using a camera;
s802, matching the acquired image to be detected through the find_shape_model and the positioning template ModldID to acquire the center line coordinate and the angle of the character area;
s803, calculating an affine transformation matrix HomMat D_1 of the image to be detected and applying an affine_trans_image operator to align the character area of the affine transformation matrix with the positioning template.
Further, in step S11, gray scale is performed on the image to be measured, and the gray value of the image to be measured is adjusted by calculating the proportion Mult of the gray difference value of the character area of the standard image and the image to be measured and the compensation amount Add, so that the consistency of the contrast with the difference model is ensured, and the problem of misjudgment caused by illumination or camera exposure time variation is solved.
The technical scheme of the invention has the following beneficial effects:
1. Compared with the traditional manual visual inspection mode, the invention greatly improves the detection efficiency, reduces the misjudgment rate caused by human eye fatigue and other factors, realizes high-efficiency and accurate automatic character defect detection, is beneficial to reducing the production cost and improving the product quality control level.
2. Aiming at the problem that the characters are judged to be bad due to different thicknesses of the characters caused by the production process of a laser engraving machine or a pad printing machine, the sensitivity of a difference model to the edges of the characters is reduced through mean value smoothing of images, and the detection accuracy is improved.
3. And scaling the gray value of the image to be measured to the gray value range of the standard image, and then comparing the gray value range of the standard image with the difference model, so that the problem that the gray value of the image to be measured is large in difference with the gray value of the standard image due to the change of illumination or camera exposure time, and the product is judged to be bad is solved.
4. The adaptability is enhanced, and the detection method has stronger adaptability and robustness by carrying out specific pretreatment (such as alignment, smoothing, gray scale and the like) on the input image, so that the detection method can be better suitable for character defect detection requirements in various complex industrial production scenes.
Drawings
FIG. 1 is a system block diagram of the present invention;
Fig. 2 is an overall flow chart of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples; it is to be understood that the specific embodiments described herein are merely illustrative of the invention and not limiting thereof; it should be further noted that, for convenience of description, only some, but not all of the drawings related to the present invention are shown.
Referring to fig. 1-2, the present invention provides a character defect detection system based on halcon, which is characterized in that the system includes:
the camera module is used for collecting images of qualified products as a standard image library;
The image processing module is used for creating a character and graph positioning template and performing template matching, and comprises marking a character area in an image, dividing the template area image, creating a positioning template and obtaining the center coordinate of the positioning template area;
the difference model generation module is used for creating a difference model by calling a create_variation_model operator;
An image alignment module that aligns all standard images with the positioning template using a find shape model operator, affine transformation, and affine trans image operator;
the smoothing processing module is used for carrying out mean value smoothing processing on the standard images to be aligned by adopting a mean_image operator and adjusting the size of the filter according to the font thickness;
The training module is used for training the smoothed standard image by using a train_variation_model operator and storing a training result into the difference model;
the parameter setting module is used for setting a minimum absolute threshold value and a difference threshold value of the difference model through a preparation_variation_model operator;
the image acquisition module of the product to be measured is used for acquiring the image of the product to be measured and carrying out image pair Ji Heping sliding treatment through the same flow to obtain the image to be measured with smooth mean value;
The gray scale module is used for calculating gray scale and compensation quantity, and then a scale_image operator is applied to carry out gray scale on the image to be measured with the average value being smoothed, so as to obtain the image to be measured with the gray scale;
and the comparison judging module is used for comparing the image to be detected after the gray scale is scaled by combining a compare_ext_variation_model operator with the difference model, and judging whether the product is defective or not according to the comparison result.
The image processing module further includes extracting a character region image from the image using a reduce_domain operator.
The difference model generating module is further used for acquiring average gray values of the standard image character area and the background area, and the average gray values are realized through an operator reduce_ domain, binary _ threshold, difference, intensity.
The gray scale method used by the gray scale module comprises the steps of calculating gray scale Mult and compensation amount Add according to the following formula :Mult=(ForeGrayValue-BackGrayValue)/(CurrentForeValue-CurrentBackValue),Add=ForeGrayValue-Mult*CurrentForeValue.
The invention also provides a character defect detection method based on halcon, which adopts the system, and comprises the following steps:
S1, acquiring at least one image of a qualified product through a camera, and storing the image as a standard image library;
S2, creating a character graphic positioning template:
s3, creating a difference model, and realizing by using a create_variation_model operator in halcon;
S4, performing alignment processing on all standard images:
S5, carrying out mean smoothing on the aligned standard images by applying a mean image operator, setting the size of a filter to adapt to the thickness change of characters, and marking the smoothed standard images as MEANIMAGE;
s6, training the smoothed standard image MEANIMAGE into a difference model VarModleID by utilizing a train_variation_model operator, and setting a minimum absolute threshold value and a difference threshold value of the difference model;
S7, obtaining a training image TRAINEDIMAGE for the trained difference model and analyzing average gray values ForeGrayValue and BackGrayValue of a character area and a background area in the training image;
S8, acquiring an image of a product to be detected;
s9, carrying out mean value smoothing treatment on the image to be detected after alignment, wherein the size of the filter is consistent with that in the step S5;
S10, obtaining average gray values CurrentForeValue and CurrentBackValue of a character area and a background area of the image to be detected after average smoothing;
S11, calculating gray scale Mult and compensation amount Add of the image to be measured according to known ForeGrayValue, backGrayValue, currentForeValue and CurrentBackValue, and performing gray scale on the image to be measured by using a scale_image operator to obtain SACLEDIMAGE;
And S12, finally, carrying out difference model comparison on the image SACLEDIMAGE to be tested after gray scale scaling by adopting a compare_ext_variation_model operator and combining a difference model VarModleID, judging whether a difference area exceeding a preset range exists according to a comparison result, and if so, judging that the product to be tested is a defective product.
The step S2 specifically comprises the following steps:
S201, selecting an image from a standard image library and displaying the image in an image window;
S202, marking a character area of a product on a window by using a draw_rectangle2 operator as a template area Region;
S203, segmenting a template area Image0 from the Image according to the template area Region by using a reduction_domain operator;
S204, a create_shape_mode operator is applied to create a positioning template ModleID on the template region Image0, and an area_center operator is used to obtain the center line coordinates RowRef, columnRef of the template region.
The step S4 specifically comprises the following steps:
s401, reading standard images one by using a read_image operator;
S402, performing template matching on the current standard image by utilizing the find_shape_model and the positioning template ModldID, and determining the center row coordinate and the angle of the character area;
S403, calculating an affine transformation matrix HomMat D by using a vector_angle_to_ rigid operator;
S404, performing translational rotation operation on the current standard image according to the transformation matrix HomMat D by using an affine_trans_image operator to ensure that the character area is aligned with the positioning template area.
The step S8 specifically comprises the following steps:
s801, acquiring an image of a product to be detected by using a camera;
s802, matching the acquired image to be detected through the find_shape_model and the positioning template ModldID to acquire the center line coordinate and the angle of the character area;
s803, calculating an affine transformation matrix HomMat D_1 of the image to be detected and applying an affine_trans_image operator to align the character area of the affine transformation matrix with the positioning template.
In step S11, gray scale is performed on the image to be measured, and the gray value of the image to be measured is adjusted by calculating the proportion Mult of the gray difference value of the character area of the standard image and the image to be measured and the compensation amount Add, so that the consistency of the contrast with the difference model is ensured, and the problem of misjudgment caused by illumination or camera exposure time variation is solved.
Aiming at the defects of the existing difference model comparison detection method, the invention provides a halcon-based character defect detection method; the method comprises the following steps:
1. Collecting images of a plurality of qualified products by using an industrial camera as a standard image library;
2. Creating a character graphic positioning template for aligning the images;
1) Selecting an image from the standard image library at will, and displaying the image in an image window;
2) Drawing a character area of the product on the window by using a draw_rectangle2 operator to serve as a template area Region;
3) Dividing a template area Image0 in the Image according to the template area Region by using a reduction_domain operator;
4) Creating a positioning template ModleID on the template area Image0 using the create_shape_mode operator;
5) The central line and column coordinates of the template Region acquired by using the area_center operator are respectively as follows: rowRef, columnRef;
3. Creating a difference model, and creating a difference model VarModleID by using a create_variation_model operator;
4. Aligning all standard images;
1) Reading all standard images one by using an operator read_image;
2) Performing template matching on the currently read standard image by using an operator find_shape_model and a positioning template ModldID, and obtaining row-column coordinates and angles of the center of a character area of the current standard image, wherein the row-column coordinates and angles are respectively as follows: row, column, angle;
3) Affine transformation is carried out on the line coordinates RowRef, columnRef of the center of the Region of the template and the line coordinates and the angles Row, column, angle of the center of the character Region of the current image by using an operator vector_angle_to_ rigid to obtain a transformation matrix HomMat D;
4) Performing translational rotation on the current standard image by using an operator affine_trans_image and a transformation matrix HomMat D, so that a character area of the current image is aligned with a positioning template area;
5. Smoothing the aligned standard images, carrying out mean smoothing on the aligned standard images by using an operator mean_image, wherein the width and height of a filter in the operator determine the sensitivity to edges during detection, if the font thickness difference during detection is larger, the size of the filter is set to be larger, otherwise, the size of the filter is set to be smaller; the smoothed standard image is noted MEANIMAGE;
6. Training the smoothed standard image MEANIMAGE by using an operator train_variation_model, and saving a training model into the created difference model VarModleID;
7. setting a minimum absolute threshold and a variance threshold of the variance model VarModleID by using an operator preparation_variation_model;
8. acquiring a difference model training image TRAINEDIMAGE by using an operator get_variation_model;
9. Obtaining an average gray value of a character area and an average gray value of a background of the difference model training image TRAINEDIMAGE:
1) Dividing the image ImageReduce at the image TRAINEDIMAGE according to the template Region using the operator reduce_domain;
2) Performing automatic binary threshold segmentation on the image ImageReduce by using an operator binary_threshold to segment a background area BackRegion;
3) Using an operator difference to make difference between the template area and the background area to obtain a character area ForeRegion;
4) Calculating a gray average value of the background area BackRegion by using an operator intensity, and marking the gray average value as BackGrayValue;
5) Calculating a gray average value of the character region ForeRegion by using the operator intensity, and marking the gray average value as ForeGrayValue;
10. collecting an image of a product to be detected and an alignment image;
1) Collecting an image of a product to be detected by using an industrial camera;
2) Matching the image to be detected acquired by the camera by using an operator find_shape_model and a positioning template ModldID, and acquiring row and column coordinates and angles of the center of a character area of the image to be detected, wherein the row and column coordinates and angles are respectively as follows: row1, column1, angle1;
3) Carrying out affine transformation on the line and Column coordinates RowRef, columnRef of the center of the template Region and the line and Column coordinates and angles Row1, column1 and Angle1 of the center of the character Region of the image to be detected by using an operator vector_angle_to_ rigid to obtain a transformation matrix HomMat D_1;
4) Performing translational rotation on the image to be detected by using an operator affine_trans_image and a transformation matrix HomMat D_1, so that a character area of the image to be detected is aligned with a positioning template area;
11. the aligned image to be measured is smoothed by using an operator mean_image mean value, and the filter size is required to be the same as that of the filter in the step 5;
12. And 9, acquiring a character area gray average value CurrentForeValue and a background area gray average value CurrentBackValue of the image to be detected after the average value is smoothed, and referring to the step 9.
13. The image to be measured with the smoothed mean value is subjected to gray scale
1) Calculating gray scale Mult and compensation amount Add
Mult=(ForeGrayValue-BackGrayValue)/
(CurrentForeValue-CurrentBackValue)
Add=ForeGrayValue-Mult*CurrentForeValue
2) And carrying out gray scale on the image to be measured with the average value smoothed by using an operator scale_image, wherein the gray scale and the compensation quantity used in the operator are Mult and Add respectively, and the image after gray scale is recorded as SACLEDIMAGE.
14. The operator compare_ext_variation_model and the difference model VarModleID are used for comparing the difference model of the image SCALEDIMAGE, and a region different from the difference model is obtained; and if the area exceeds the set range, judging that the product to be detected is a defective product, and otherwise, judging that the product to be detected is a good product.
1. Training a difference model and performing mean smoothing on an input image when the difference model is compared;
2. a gray scale scaling method of an image to be measured.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the invention, and all equivalent structural changes made by the description of the present invention and the accompanying drawings or direct/indirect application in other related technical fields are included in the scope of the present invention.

Claims (9)

1. A halcon-based character defect detection system, the system comprising:
the camera module is used for collecting images of qualified products as a standard image library;
The image processing module is used for creating a character and graph positioning template and performing template matching, and comprises marking a character area in an image, dividing the template area image, creating a positioning template and obtaining the center coordinate of the positioning template area;
the difference model generation module is used for creating a difference model by calling a create_variation_model operator;
An image alignment module that aligns all standard images with the positioning template using a find shape model operator, affine transformation, and affine trans image operator;
the smoothing processing module is used for carrying out mean value smoothing processing on the standard images to be aligned by adopting a mean_image operator and adjusting the size of the filter according to the font thickness;
The training module is used for training the smoothed standard image by using a train_variation_model operator and storing a training result into the difference model;
the parameter setting module is used for setting a minimum absolute threshold value and a difference threshold value of the difference model through a preparation_variation_model operator;
the image acquisition module of the product to be measured is used for acquiring the image of the product to be measured and carrying out image pair Ji Heping sliding treatment through the same flow to obtain the image to be measured with smooth mean value;
The gray scale module is used for calculating gray scale and compensation quantity, and then a scale_image operator is applied to carry out gray scale on the image to be measured with the average value being smoothed, so as to obtain the image to be measured with the gray scale;
and the comparison judging module is used for comparing the image to be detected after the gray scale is scaled by combining a compare_ext_variation_model operator with the difference model, and judging whether the product is defective or not according to the comparison result.
2. The system of claim 1, wherein the system further comprises a controller configured to control the controller,
The image processing module further includes extracting a character region image from the image using a reduce_domain operator.
3. The system of claim 1, wherein the system further comprises a controller configured to control the controller,
The difference model generating module is further used for acquiring average gray values of the standard image character area and the background area, and the average gray values are realized through an operator reduce_ domain, binary _ threshold, difference, intensity.
4. The system of claim 1, wherein the system further comprises a controller configured to control the controller,
The gray scale method used by the gray scale module comprises the steps of calculating gray scale Mult and compensation amount Add according to the following formula :Mult=(ForeGrayValue-BackGrayValue)/(CurrentForeValue-CurrentBackValue),Add=ForeGrayValue-Mult*CurrentForeValue.
5. A halcon-based character defect detection method, which is characterized by comprising the following steps:
S1, acquiring at least one image of a qualified product through a camera, and storing the image as a standard image library;
S2, creating a character graphic positioning template:
S3, creating a difference model;
S4, performing alignment processing on all standard images:
S5, carrying out mean smoothing on the aligned standard images by applying a mean image operator, setting the size of a filter to adapt to the thickness change of characters, and marking the smoothed standard images as MEANIMAGE;
s6, training the smoothed standard image MEANIMAGE into a difference model VarModleID by utilizing a train_variation_model operator, and setting a minimum absolute threshold value and a difference threshold value of the difference model;
S7, obtaining a training image TRAINEDIMAGE for the trained difference model and analyzing average gray values ForeGrayValue and BackGrayValue of a character area and a background area in the training image;
S8, acquiring an image of a product to be detected;
s9, carrying out mean value smoothing treatment on the image to be detected after alignment, wherein the size of the filter is consistent with that in the step S5;
S10, obtaining average gray values CurrentForeValue and CurrentBackValue of a character area and a background area of the image to be detected after average smoothing;
S11, calculating gray scale Mult and compensation amount Add of the image to be measured according to known ForeGrayValue, backGrayValue, currentForeValue and CurrentBackValue, and performing gray scale on the image to be measured by using a scale_image operator to obtain SACLEDIMAGE;
S12, carrying out differential model comparison on the image SACLEDIMAGE to be tested after gray scale scaling by adopting a compare_ext_variation_model operator and combining a differential model VarModleID, judging whether a differential area exceeding a preset range exists according to a comparison result, and if so, judging that the product to be tested is a defective product.
6. The method according to claim 5, wherein step S2 specifically comprises:
S201, selecting an image from a standard image library and displaying the image in an image window;
S202, marking a character area of a product on a window by using a draw_rectangle2 operator as a template area Region;
S203, segmenting a template area Image0 from the Image according to the template area Region by using a reduction_domain operator;
S204, a create_shape_mode operator is applied to create a positioning template ModleID on the template region Image0, and an area_center operator is used to obtain the center line coordinates RowRef, columnRef of the template region.
7. The method according to claim 5, wherein step S4 comprises the steps of:
s401, reading standard images one by using a read_image operator;
S402, performing template matching on the current standard image by utilizing the find_shape_model and the positioning template ModldID, and determining the center row coordinate and the angle of the character area;
S403, calculating an affine transformation matrix HomMat D by using a vector_angle_to_ rigid operator;
S404, performing translational rotation operation on the current standard image according to the transformation matrix HomMat D by using an affine_trans_image operator to ensure that the character area is aligned with the positioning template area.
8. The method according to claim 5, wherein step S8 comprises the steps of:
s801, acquiring an image of a product to be detected by using a camera;
s802, matching the acquired image to be detected through the find_shape_model and the positioning template ModldID to acquire the center line coordinate and the angle of the character area;
s803, calculating an affine transformation matrix HomMat D_1 of the image to be detected and applying an affine_trans_image operator to align the character area of the affine transformation matrix with the positioning template.
9. The method of claim 5, wherein the step of determining the position of the probe is performed,
In step S11, gray scale is performed on the image to be measured, and the gray value of the image to be measured is adjusted by calculating the proportion Mult of the gray difference value of the character area of the standard image and the image to be measured and the compensation amount Add, so that the consistency of the contrast with the difference model is ensured, and the problem of misjudgment caused by illumination or camera exposure time variation is solved.
CN202410249609.6A 2024-03-05 2024-03-05 Halcon-based character defect detection method and halcon-based character defect detection system Pending CN117975465A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410249609.6A CN117975465A (en) 2024-03-05 2024-03-05 Halcon-based character defect detection method and halcon-based character defect detection system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410249609.6A CN117975465A (en) 2024-03-05 2024-03-05 Halcon-based character defect detection method and halcon-based character defect detection system

Publications (1)

Publication Number Publication Date
CN117975465A true CN117975465A (en) 2024-05-03

Family

ID=90865804

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410249609.6A Pending CN117975465A (en) 2024-03-05 2024-03-05 Halcon-based character defect detection method and halcon-based character defect detection system

Country Status (1)

Country Link
CN (1) CN117975465A (en)

Similar Documents

Publication Publication Date Title
CN112508826B (en) Printed matter defect detection method
CN111474184B (en) AOI character defect detection method and device based on industrial machine vision
CN109472271B (en) Printed circuit board image contour extraction method and device
CN102496161B (en) Method for extracting contour of image of printed circuit board (PCB)
CN109426814B (en) Method, system and equipment for positioning and identifying specific plate of invoice picture
CN101799434A (en) Printing image defect detection method
CN109540925B (en) Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator
CN109409290B (en) Thermometer verification reading automatic identification system and method
CN106501272B (en) Machine vision soldering tin positioning detection system
CN111062934B (en) Fabric image defect real-time detection method
CN114881915A (en) Symmetry-based mobile phone glass cover plate window area defect detection method
CN113340909B (en) Glue line defect detection method based on machine vision
CN112200776A (en) Chip packaging defect detection method and detection device
CN113034488A (en) Visual detection method of ink-jet printed matter
CN114266764A (en) Character integrity detection method and device for printed label
CN111879777A (en) Soft material fitting defect detection method, device, equipment and storage medium
CN114235837A (en) LED packaging surface defect detection method, device, medium and equipment based on machine vision
CN114549504A (en) Appearance quality detection method based on machine vision
CN115512381A (en) Text recognition method, text recognition device, text recognition equipment, storage medium and working machine
CN111754502A (en) Method for detecting surface defects of magnetic core based on fast-RCNN algorithm of multi-scale feature fusion
CN116091503B (en) Method, device, equipment and medium for discriminating panel foreign matter defects
CN110376211B (en) Wet-process-gummed synthetic leather hemming on-line detection device and method
CN117975465A (en) Halcon-based character defect detection method and halcon-based character defect detection system
CN116337869A (en) Machine vision-based detection system for production of double-sided circuit board
CN115511819A (en) X-ray weld boundary identification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication