Camera appearance detection method
Through image acquisition and processing technology, the lens barrel image is cropped and enhanced, and cracks, inner circle, outer circle and dirty are identified and detected, which solves the problems of high error detection and missed detection rates in the appearance detection of existing cameras, achieving more efficient automated detection.
Patent Information
- Application Number
- CN202310611264.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-26
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-05-26
AI Technical Summary
There are problems with high error detection rates and missed detection rates in existing camera appearance detection methods, which mainly rely on artificial visual or microscopic detection, resulting in low detection efficiency and prone to errors.
The image acquisition device is used to obtain the image to be tested, and the image enhancement technology is processed, including binarization and dynamic threshold segmentation, and the outer contour, the inner contour and the light hole profile of the lens barrel are identified, boundary enhancement processing is performed, and whether there are cracks in the lens barrel are detected, and the inner circle, outer circle and dirty are detected.
It improves the accuracy and efficiency of detection, reduces human error, and can more accurately determine whether the appearance of the lens barrel meets preset standards.
Smart Images

Figure CN116506595B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of module appearance detection, and in particular to a camera appearance detection method. Background Art
[0002] With the increasing popularity of mobile electronic devices, the demand for camera modules used in these devices is increasing. In recent years, camera modules have been widely used in a variety of fields, including healthcare, security, and industrial production. During production, module manufacturers need to deploy a large number of personnel to inspect the appearance of each product. However, different appearance inspectors have different understandings of product defects, and inspectors are easily fatigued by long periods of repetitive work. This can lead to missed inspections of module products, resulting in mass returns of module products.
[0003] The existing appearance inspection method of camera modules mainly relies on appearance inspection personnel to inspect the appearance quality of the module through visual inspection or using a microscope. Under high-intensity working pressure, missed inspections are inevitable. Summary of the Invention
[0004] The present invention provides a camera appearance detection method to solve the problems of high false detection rate and missed detection rate in existing camera appearance detection.
[0005] In a first aspect, the present invention provides a camera appearance detection method, the method comprising:
[0006] Acquire an image to be measured, wherein the image to be measured is obtained by a preset image acquisition device through image acquisition of the lens barrel to be measured;
[0007] cropping the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image;
[0008] Performing boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image;
[0009] determining whether there is a crack in the outline of the lens barrel to be tested in the enhanced image;
[0010] If there is no crack in the contour of the lens barrel to be tested in the enhanced image, inner circle detection, outer circle detection and dirt detection are performed on the lens barrel to be tested in the enhanced image to obtain a detection result.
[0011] In a second aspect, the present invention provides a camera appearance detection device, comprising a unit for executing the camera appearance detection method as described in any embodiment of the first aspect.
[0012] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0013] Memory for storing computer programs;
[0014] The processor is used to implement the steps of the camera appearance detection method described in any embodiment of the first aspect when executing the program stored in the memory.
[0015] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the camera appearance detection method as described in any embodiment of the first aspect are implemented.
[0016] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art:
[0017] The method provided by an embodiment of the present invention obtains an image to be tested of the appearance of the lens barrel through an image acquisition device, and performs cropping and boundary enhancement based on the image to be tested, and performs crack detection, inner circle detection, outer circle detection, and dirt detection respectively, so as to more accurately determine whether the appearance of the lens barrel meets the preset detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 A schematic diagram of a flow chart of a camera appearance detection method provided by an embodiment of the present invention;
[0021] Figure 2 A schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention;
[0023] Figure 4 A schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention;
[0024] Figure 5A schematic structural diagram of a camera appearance detection device provided by an embodiment of the present invention;
[0025] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention;
[0026] Figure 7 A schematic diagram of radial distance provided by an embodiment of the present invention;
[0027] Figure 8 An example of a cropped image provided by an embodiment of the present invention;
[0028] Figure 9 An example diagram of a binarized image provided by an embodiment of the present invention;
[0029] Figure 10 An example diagram of an initial threshold segmentation image provided by an embodiment of the present invention;
[0030] Figure 11 An example diagram of a threshold segmented image provided by an embodiment of the present invention;
[0031] Figure 12 An example diagram of an initial enhanced image provided by an embodiment of the present invention;
[0032] Figure 13 This is an example of an enhanced image provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0034] Example 1
[0035] Figure 1 The present invention provides a flow chart of a camera appearance detection method. The present invention provides a camera appearance detection method. Specifically, see Figure 1 The camera appearance detection method includes the following steps S101-S105.
[0036] S101 , obtaining an image to be tested, wherein the image to be tested is obtained by a preset image acquisition device through performing image acquisition on a lens barrel to be tested.
[0037] In a specific implementation, the image acquisition device includes a video camera, a still camera, etc., and is used to capture the lens barrel to be tested, and the image captured by capturing the lens barrel to be tested is used as the image to be tested. Specifically, the image acquisition device captures the image in a direction directly toward the center of the lens barrel to be tested to obtain the image to be tested.
[0038] S102 : cropping the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image.
[0039] In a specific implementation, the image to be tested includes the area occupied by the lens barrel to be tested and the area occupied by the surrounding environment of the lens barrel to be tested. By deleting the area irrelevant to the lens barrel to be tested and retaining the area occupied by the lens barrel to be tested, the image capacity can be reduced, the amount of calculation for subsequent image processing can be reduced, and the characteristics of the lens barrel to be tested can be more prominent, thereby improving processing efficiency and detection accuracy. Figure 8 for the cropped image.
[0040] In one embodiment, see Figure 2 , Figure 2 This is a schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention. The above step S102 includes steps S201-S204:
[0041] S201 , identifying the outer contour, inner contour, and light hole contour of the lens barrel to be tested in the image to be tested.
[0042] In a specific implementation, the aperture contour is a circular contour with stable imaging characteristics. The lens barrel to be tested has an outer contour, an inner contour, and a aperture contour, and these three contours are concentric. Specifically, shape detection of the image to be tested yields three concentric circles, which, from the outermost to the innermost, are the outer contour, the inner contour, and the aperture contour.
[0043] S202: Determine the center of the circle according to the outer contour, inner contour, and light hole contour.
[0044] In a specific implementation, since the outer contour, inner contour, and light hole contour are all approximately circular or circular, and are concentric, the center of the lens barrel to be tested can be calculated based on the centers of the outer contour, inner contour, and light hole contour, respectively. Specifically, the centers of the outer contour, inner contour, and light hole contour are calculated separately. Generally speaking, the centers of the outer contour, inner contour, and light hole contour are the same point, namely, the center of the lens barrel to be tested. If there is a deviation between the centers of the outer contour, inner contour, and light hole contour, and the deviation is less than a preset deviation threshold, the average value of the coordinates of the centers of the outer contour, inner contour, and light hole contour is calculated as the center of the lens barrel to be tested. If the deviation is greater than or equal to the preset deviation threshold, the image to be tested is determined to be unqualified, and the user is prompted to recapture the image.
[0045] S203: Obtain a first distance from the center of the circle to the outer contour, and determine a cropping side length based on the first distance.
[0046] In a specific implementation, a first distance from the center of the circle to the outer contour is calculated, that is, the first distance is the radius of the outer contour, and the area within the outer contour can be cropped according to the radius of the outer contour. In one embodiment, according to the formula: diameter = 2*radius, the diameter of the outer contour is used as the cropping side length.
[0047] S204 , determining a cropping area based on the cropping side length and taking the center of the circle as the center, and cropping the cropping area from the image to be measured to obtain the cropped image.
[0048] In a specific implementation, the area within the outer contour can be cut out according to the center of the circle and the cropping side length. In one embodiment, the diameter of the outer contour is used as the cropping side length, and the center of the circle is used as the center, and the area within the square with the outer contour as the inscribed circle is cropped as the cropping area, that is, the image contained in the area within the square with the outer contour as the inscribed circle is used as the cropped image.
[0049] S103: performing boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image.
[0050] In a specific implementation, one or a combination of technologies such as binarization, dynamic threshold segmentation, grayscale linear transformation, histogram equalization transformation, homomorphic filtering, image sharpening, etc. can be used to perform boundary enhancement processing on the cropped image.
[0051] In one embodiment, see Figure 3 , Figure 3 This is a schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention. The above step S103 includes steps S301-S303:
[0052] S301: Binarize the cropped image to obtain a binarized image.
[0053] In the specific implementation, see Figure 9, which is a binary image. The cropped image contains the outer contour, inner contour, and aperture contour. The aperture contour is unrelated to the appearance of the lens barrel to be inspected. Therefore, only the annular area formed by the outer contour and inner contour needs to be cropped. In this embodiment of the present invention, the inner contour is the inner wall of the lens barrel to be inspected, and the outer contour is the outer wall of the lens barrel to be inspected. Binarization processing can convert a grayscale image into a binary image. The grayscale of pixels greater than a certain critical grayscale value is set to the grayscale maximum value, and the grayscale of pixels less than this value is set to the grayscale minimum value, thereby achieving binarization. Through binarization processing, the corresponding pixels of the outer contour and inner contour in the annular image can be enhanced, making the features of the outer contour and inner contour more distinct. In one embodiment, binarization processing is performed according to the threshold coefficient thres_l to obtain a binary image dst_o, and the formula of the threshold coefficient is: thres_l = m + scale * dev, wherein m is the grayscale mean of the annular image, dev is the grayscale standard deviation, and scale is a preset input coefficient, generally set to 0.5. The value of scale is related to the lighting effect of the material itself. If the target area is obviously lit, the value is usually 0.3-0.5. If the target area is not obviously lit, the value is usually 0.5-0.7.
[0054] S302: Process the cropped image based on a preset dynamic threshold segmentation algorithm to obtain a threshold segmented image.
[0055] In the specific implementation, see Figure 10 , is the initial threshold segmentation image. The dynamic threshold segmentation algorithm can enhance the boundary, and the cropped image is processed by the preset dynamic threshold segmentation algorithm to obtain the initial threshold segmentation image. In one embodiment, the dynamic threshold segmentation includes the formula: S = {(y, x) T ∈R|f y,x -g y,x ≤-g diff}, where f x,y is the grayscale value of the image pixel at position (y,x), g x,y is the grayscale value of the image pixel at position (y, x) after mean filtering, (y, x) T ∈R is the pixel position information, where x is the column information and y is the row information. By calculating the grayscale difference between the two is less than the preset value -g diff , we get the image pixel set S including the boundary points, that is, we get the initial threshold segmentation image. diff If the value is too small, noise or material texture will be filtered out, which will have a great impact on subsequent processing. diffWhen the value is too large, a broken contour fragment is obtained due to too few boundary points. Furthermore, the initial threshold segmentation image is processed by identifying the outer contour and inner contour in the initial threshold segmentation image, removing the pixels outside the outer contour, the pixels inside the inner contour, and the pixels between the inner contour and the outer contour in the initial threshold segmentation image to obtain the threshold segmentation image. The threshold segmentation image is referred to Figure 11 shown.
[0056] S303: Generate the enhanced image using the binarized image and the threshold segmented image.
[0057] In the specific implementation, see Figure 12 The initial enhanced image can be obtained by processing it using the formula dst = dst_o - dst_d, where dst is the final initial enhanced image, dst_o is the binarized image, and dst_d is the threshold segmentation image. Binarization can make the outer and inner contours of the cropped image clearer, while the dynamic threshold segmentation algorithm can make the boundary demarcation in the cropped image more clear. Combining the binarized image and the threshold segmentation image obtained from these two processing steps can produce an initial enhanced image with clearer outer and inner contours and more clearly demarcated boundaries.
[0058] In one embodiment, the outer contour and the inner contour in the initial enhanced image are identified, and the initial enhanced image is processed to remove the pixels outside the outer contour, the pixels inside the inner contour, and the pixels between the inner contour and the outer contour in the initial enhanced image, thereby obtaining a ring image including the outer contour and the inner contour, i.e., the enhanced image. Figure 13 shown.
[0059] The area to be inspected is cropped out to reduce the image capacity, lower the computational effort for subsequent image processing, and highlight the features of the lens barrel to be inspected, thereby improving processing efficiency and detection accuracy.
[0060] S104 , determining whether there are cracks on the outline of the lens barrel to be tested in the enhanced image.
[0061] In a specific implementation, whether there is a crack in the outline of the lens barrel to be tested specifically refers to whether the pixels between the outer outline and the inner outline are continuous (because the crack will connect the pixels between the outer outline and the inner outline). If the pixels between the outer outline and the inner outline are discontinuous, then there is no crack in the outline of the lens barrel to be tested; if the pixels between the outer outline and the inner outline are continuous, then there is a crack in the outline of the lens barrel to be tested.
[0062] In one embodiment, see Figure 4 , Figure 4This is a schematic diagram of a sub-process of a camera appearance detection method provided by an embodiment of the present invention. The above step S104 includes steps S401-S403:
[0063] S401 : In the enhanced image, fill the area enclosed by the inner contour with a preset color to obtain a filled area.
[0064] In a specific implementation, a predetermined color is filled to obtain a filled area, and determining whether the filled area conforms to a predetermined range can be used to determine whether the outline of the lens barrel to be tested has cracks. In one embodiment, the predetermined color is filled into the area enclosed by the inner contour. If the outline of the lens barrel to be tested does not have cracks, the area enclosed by the inner contour is the filled area; if the outline of the lens barrel to be tested has cracks, the area enclosed by the outer contour, the inner contour, and the crack is the filled area.
[0065] S402: Calculate a second distance between the circle center and the inner contour.
[0066] In a specific implementation, the distance between the inner contour and the center of the circle is calculated as the second distance, that is, the radius of the inner contour is calculated as the second distance.
[0067] S403: Determine whether the radius of the filling area is greater than the second distance.
[0068] S404: If the radius of the filling area is not greater than the second distance, determine that there is no crack in the outline of the lens barrel to be tested in the enhanced image.
[0069] In a specific implementation, if the radius of the outermost contour of the filled area (specifically the radius of the circumscribed circle of the filled area) is not greater than the second distance, that is, the filled area does not include the outer contour and the outer contour is discontinuous with the inner contour, then it is determined that there is no crack in the enhanced image.
[0070] S105 : If there is no crack in the contour of the lens barrel to be tested in the enhanced image, perform inner circle detection, outer circle detection, and dirt detection on the lens barrel to be tested in the enhanced image to obtain a detection result.
[0071] In a specific implementation, the lens barrel to be tested without cracks is further subjected to inner circle detection, outer circle detection and dirt detection, and the detection results are obtained, so that the appearance of the lens barrel can be quickly and effectively detected.
[0072] In one embodiment, the inner circle detection includes:
[0073] Perform circle fitting on the inner contour to obtain a first fitting circle; perform an XOR operation on the first fitting circle and the inner contour to obtain a first indentation area; obtain a first radial distance of the first indentation area relative to the center of the circle, and a first area of the first indentation area, and determine whether the first radial distance is greater than a preset first distance threshold, and determine whether the first area is greater than a preset first area threshold; if the first radial distance is not greater than the preset first distance threshold, and the first area is not greater than the preset first area threshold, determine that the inner contour is qualified.
[0074] In specific implementation, the inner circle detection mainly detects whether the inner contour has a crush defect. If the crush defect of the inner contour is smaller than the preset range, the inner circle detection result is that the inner contour is qualified. The inner contour is composed of pixel points. By performing circle fitting on the inner contour, a complete circular contour can be obtained, and the circular contour is used as the first fitting circle. The first fitting circle is XORed with the inner contour to obtain the first crush area. According to the first crush area, the center of the first crush area and the first area of the first crush area can be obtained, and the first radial distance of the first crush area can be calculated. Figure 7 The radial distance refers to the distance in the radial direction of the center of the circle. The first radial distance is the distance occupied by the first crushed area in the radial direction of the center of the circle. Figure 7 The length of k in . In one embodiment, the first radial distance of the first compression area refers to the longest radial distance of the first compression area relative to the center of the circle. Generally speaking, there can be multiple first compression areas, and the first radial distance of each first compression area is judged separately to see whether it is greater than the preset first distance threshold, and the first area of each first compression area is judged separately to see whether the first area is greater than the preset first area threshold. It should be noted that judging each first compression area separately is only an example, and those skilled in the art can also adopt other steps such as judging whether the total area of all first compression areas is greater than the preset first area threshold to determine whether the inner contour is qualified, which does not exceed the scope of protection of the present invention.
[0075] By obtaining data related to the first crush area, the barrel defect is quantified, and it is determined whether the defect value is within the preset fault tolerance range, so as to quickly determine whether the inner contour is qualified.
[0076] In one embodiment, the outer circle detection includes:
[0077] Perform circle fitting on the outer contour to obtain a second fitting circle; perform an XOR operation on the second fitting circle and the outer contour to obtain a second indentation area; obtain a second radial distance of the second indentation area relative to the center of the circle, and a second area of the second indentation area, and determine whether the second radial distance is greater than a preset second distance threshold, and determine whether the second area is greater than a preset second area threshold; if the first radial distance is not greater than the preset second distance threshold, and the second area is not greater than the preset second area threshold, determine that the outer contour is qualified.
[0078] In specific implementation, the outer circle detection mainly detects whether the outer contour has a crush defect. If the crush defect of the outer contour is smaller than the preset range, the detection result of the outer circle detection is that the outer contour is qualified. The outer contour is composed of pixel points. By performing circle fitting on the outer contour, a complete circular contour can be obtained, and the circular contour is used as the second fitting circle. The second fitting circle is XORed with the outer contour to obtain the second crush area. According to the second crush area, the center of the second crush area and the second area of the second crush area can be obtained, and the second radial distance of the second crush area can be calculated. Figure 7 The radial distance refers to the distance in the radial direction of the center of the circle, and the second radial distance is the distance occupied by the second crush area in the radial direction of the center of the circle. Figure 7 The length of k in . In one embodiment, the second radial distance of the second compression area refers to the longest radial distance of the second compression area relative to the center of the circle. Generally speaking, there can be multiple second compression areas, and the second radial distance of each second compression area is judged separately to see whether it is greater than the preset second distance threshold, and the second area of each second compression area is judged separately to see whether the second area is greater than the preset second area threshold. It should be noted that judging each second compression area separately is only an example, and those skilled in the art can also adopt other steps such as judging whether the total area of all second compression areas is greater than the preset second area threshold to determine whether the inner contour is qualified, which does not exceed the scope of protection of the present invention.
[0079] By obtaining data related to the second crush area, the barrel defect is quantified, and it is determined whether the defect value is within the preset tolerance range, so as to quickly determine whether the outer contour is qualified.
[0080] In one embodiment, the dirt detection includes:
[0081] Determining a dirty area of the enhanced image based on a preset grayscale difference; obtaining a third distance between the dirty area and the center of the circle, and a third area of the dirty area; determining whether the third distance is greater than a preset third distance threshold, and determining whether the third area is greater than a preset third area threshold; and determining that the lens barrel to be tested is clean if the third distance is not greater than the preset third distance threshold and the third area is not greater than the preset third area threshold.
[0082] In a specific implementation, generally speaking, dirt and glue appear darker in the grayscale of pixels in an image than normal areas. After binarization and boundary enhancement, the dirty area of the enhanced image can be accurately obtained. In one embodiment, by obtaining the third area of the dirty area and the center of the dirty area, calculating the distance from the center of the dirty area to the center of the circle and using it as the third distance, the dirt and glue are quantified, and determining whether the dirt and glue values are within a preset tolerance range, the lens barrel cleanliness can be quickly determined. There may be multiple dirty areas, and the third distance of each dirty area is determined to be greater than a preset third distance threshold, and the third area of each dirty area is determined to be greater than a preset third area threshold. It should be noted that determining each dirty area separately is merely an example. Those skilled in the art may also use other steps, such as determining whether the total area of all dirty areas is greater than the preset third area threshold, to determine whether the lens barrel cleanliness is qualified. This does not exceed the scope of protection of the present invention.
[0083] The embodiments of the present invention can achieve the following advantages:
[0084] The image acquisition device obtains the image to be tested of the appearance of the lens barrel, and based on the image to be tested, it is cropped and the boundary is enhanced to detect cracks, inner circle detection, outer circle detection and dirt detection respectively, so as to more accurately judge whether the appearance of the lens barrel meets the preset detection results.
[0085] Example 2
[0086] See also Figure 5 An embodiment of the present invention further provides a camera appearance detection device 600 , which includes an acquisition unit 601 , a cropping unit 602 , a processing unit 603 , a judgment unit 604 , and a detection unit 605 .
[0087] The acquisition unit 601 is used to acquire an image to be measured, where the image to be measured is obtained by a preset image acquisition device through performing image acquisition on the lens barrel to be measured.
[0088] The cropping unit 602 is configured to crop the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image.
[0089] In one embodiment, cropping the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image specifically includes:
[0090] Identifying the outer contour, inner contour, and light hole contour of the lens barrel to be tested in the image to be tested;
[0091] Determine the center of the circle by using the outer contour, the inner contour and the light hole contour;
[0092] Obtaining a first distance from the center of the circle to the outer contour, and determining a cropping side length based on the first distance;
[0093] A cropping area is determined based on the cropping side length and the center of the circle, and the cropping area is cropped from the image to be measured to obtain the cropped image.
[0094] The processing unit 603 is used to perform boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image.
[0095] In one embodiment, performing boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image specifically includes:
[0096] performing binarization processing on the cropped image to obtain a binarized image;
[0097] Processing the cropped image based on a preset dynamic threshold segmentation algorithm to obtain a threshold segmented image;
[0098] The enhanced image is generated by using the binarized image and the threshold segmented image.
[0099] The judging unit 604 is used to judge whether there is a crack in the outline of the lens barrel to be tested in the enhanced image.
[0100] In one embodiment, determining whether there is a crack on the outline of the lens barrel to be tested in the enhanced image specifically includes:
[0101] In the enhanced image, filling the area enclosed by the inner contour with a preset color to obtain a filled area;
[0102] Calculating a second distance between the center of the circle and the inner contour;
[0103] Determining whether the radius of the filling area is greater than the second distance;
[0104] If the radius of the filling area is not greater than the second distance, it is determined that there is no crack in the outline of the lens barrel to be tested in the enhanced image.
[0105] The detection unit 605 is configured to, if there is no crack in the outline of the lens barrel to be tested in the enhanced image, perform inner circle detection, outer circle detection, and dirt detection on the lens barrel to be tested in the enhanced image to obtain a detection result.
[0106] In one embodiment, the inner circle detection specifically includes:
[0107] Performing circle fitting on the inner contour to obtain a first fitting circle;
[0108] Performing an XOR operation on the first fitting circle and the inner contour to obtain a first crush area;
[0109] Obtaining a first radial distance of the first crush area relative to the center of the circle and a first area of the first crush area, and determining whether the first radial distance is greater than a preset first distance threshold, and determining whether the first area is greater than a preset first area threshold;
[0110] If the first radial distance is not greater than a preset first distance threshold, and the first area is not greater than a preset first area threshold, it is determined that the inner contour is qualified.
[0111] In one embodiment, the outer circle detection specifically includes:
[0112] Performing circle fitting on the outer contour to obtain a second fitting circle;
[0113] Performing an XOR operation on the second fitting circle and the outer contour to obtain a second crush area;
[0114] Obtaining a second radial distance of the second crush area relative to the center of the circle and a second area of the second crush area, and determining whether the second radial distance is greater than a preset second distance threshold, and determining whether the second area is greater than a preset second area threshold;
[0115] If the first radial distance is not greater than a preset second distance threshold, and the second area is not greater than a preset second area threshold, the outer contour is determined to be qualified.
[0116] In one embodiment, the dirt detection specifically includes:
[0117] determining a dirty area of the enhanced image according to a preset grayscale difference;
[0118] Obtaining a third distance between the dirty area and the center of the circle, and a third area of the dirty area, and determining whether the third distance is greater than a preset third distance threshold, and determining whether the third area is greater than a preset third area threshold;
[0119] If the third distance is not greater than a preset third distance threshold, and the third area is not greater than a preset third area threshold, it is determined that the lens barrel to be tested is clean and qualified.
[0120] like Figure 6 As shown, Figure 6 This is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 can be a terminal or a server. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, personal digital assistant, wearable device, or other electronic device with communication capabilities. The server can be a standalone server or a server cluster consisting of multiple servers.
[0121] The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0122] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 can execute a camera appearance detection method.
[0123] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
[0124] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a camera appearance detection method.
[0125] The network interface 505 is used to communicate with other devices over the network. Those skilled in the art will appreciate that the above structure is merely a block diagram of a portion of the structure related to the present invention and does not limit the computer device 500 to which the present invention is applied. A specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0126] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0127] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.
[0128] Therefore, the present invention further provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program.
[0129] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a magnetic disk, or an optical disk, etc. Any physical storage medium capable of storing program code can be non-volatile or volatile.
[0130] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0131] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0132] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.
[0133] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present invention.
[0134] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0135] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, to the extent such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to encompass such changes and modifications.
[0136] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A camera appearance detection method, characterized in that: The method comprises: Acquire an image to be measured, wherein the image to be measured is obtained by a preset image acquisition device through image acquisition of the lens barrel to be measured; cropping the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image; Performing boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image; determining whether there is a crack in the outline of the lens barrel to be tested in the enhanced image; If there are no cracks in the outline of the lens barrel to be tested in the enhanced image, performing inner circle detection, outer circle detection, and dirt detection on the lens barrel to be tested in the enhanced image to obtain a detection result; The step of cropping the area occupied by the lens barrel to be tested from the image to be tested to obtain a cropped image includes: Identifying the outer contour, inner contour, and light hole contour of the lens barrel to be tested in the image to be tested; Determine the center of the circle by using the outer contour, the inner contour and the light hole contour; Obtaining a first distance from the center of the circle to the outer contour, and determining a cropping side length based on the first distance; Taking the center of the circle as the center, determining a cropping area based on the cropping side length, and cropping the cropping area from the image to be measured to obtain the cropped image; The performing boundary enhancement processing on the cropped image based on a preset image enhancement technology to obtain an enhanced image includes: performing binarization processing on the cropped image to obtain a binarized image; Processing the cropped image based on a preset dynamic threshold segmentation algorithm to obtain a threshold segmented image; generating the enhanced image by using the binarized image and the threshold segmented image; The determining whether there is a crack on the outline of the lens barrel to be tested in the enhanced image includes: In the enhanced image, filling the area enclosed by the inner contour with a preset color to obtain a filled area; Calculating a second distance between the center of the circle and the inner contour; Determining whether the radius of the filling area is greater than the second distance; If the radius of the filling area is not greater than the second distance, it is determined that there is no crack in the outline of the lens barrel to be tested in the enhanced image.
2. The method according to claim 1, characterized in that The inner circle detection includes: Performing circle fitting on the inner contour to obtain a first fitting circle; Performing an XOR operation on the first fitting circle and the inner contour to obtain a first crush area; Obtaining a first radial distance of the first crush area relative to the center of the circle and a first area of the first crush area, and determining whether the first radial distance is greater than a preset first distance threshold, and determining whether the first area is greater than a preset first area threshold; If the first radial distance is not greater than a preset first distance threshold, and the first area is not greater than a preset first area threshold, it is determined that the inner contour is qualified.
3. The method according to claim 1, characterized in that The outer circle detection includes: Performing circle fitting on the outer contour to obtain a second fitting circle; Performing an XOR operation on the second fitting circle and the outer contour to obtain a second crush area; Obtaining a second radial distance of the second crush area relative to the center of the circle and a second area of the second crush area, and determining whether the second radial distance is greater than a preset second distance threshold, and determining whether the second area is greater than a preset second area threshold; If the second radial distance is not greater than a preset second distance threshold, and the second area is not greater than a preset second area threshold, the outer contour is determined to be qualified.
4. The method according to claim 1, wherein The dirt detection includes: determining a dirty area of the enhanced image according to a preset grayscale difference; Obtaining a third distance between the dirty area and the center of the circle, and a third area of the dirty area, and determining whether the third distance is greater than a preset third distance threshold, and determining whether the third area is greater than a preset third area threshold; If the third distance is not greater than a preset third distance threshold, and the third area is not greater than a preset third area threshold, it is determined that the lens barrel to be tested is clean and qualified.
5. A camera appearance detection device, characterized in that: The method comprises means for performing the method according to any one of claims 1 to 4.
6. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; A processor, configured to implement the steps of the method according to any one of claims 1 to 4 when executing a program stored in a memory.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Lens defect detection method
CN111292228A
Glass bottle opening defect detection method, system and device and storage medium
CN112561896A