Adaptive image acquisition method, medium and device
Through adaptive image collection methods, the calculation results of the calibration image and the current image are adjusted to adjust the product posture, solving the problem of poor image collection consistency and low efficiency in the existing technologies, and realized high -quality and efficient image collection.
Patent Information
- Application Number
- CN202411345303.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-26
AI Technical Summary
The prior art relies on manual operations when image acquisition during the manufacturing process of complex aerospace products, resulting in poor image consistency, low acquisition efficiency and low acquisition accuracy.
Using an adaptive image collection method, by obtaining the calibration image and current image of the product to be collected, calculate various grayscale images, clarity and reference coordinates, determine the clarity sensitivity, reference coordinate deviation and angle deviation, and adjust the product posture to ensure Image quality meets set standards.
Improved the consistency and accuracy of image collection, improved the collection efficiency, reduced the dependence of manual operation, and ensured high -quality image collection in the aerospace product manufacturing process.
Smart Images

Figure CN118864469B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image acquisition technology, and in particular to an adaptive image acquisition method, medium and device. Background Art
[0002] In the field of industrial manufacturing, especially in the manufacturing process of complex aerospace products, image acquisition and recording is an important part of the product quality and reliability data package. By applying image acquisition and recording technology, the process control capability is strengthened, and the effective control of key links can be improved. Its intuitive and clear image data provides visual objective evidence for truly and objectively reflecting the product quality status. The existing technology mainly uses a dedicated image acquisition device with a camera and a light source system to take pictures of multiple surfaces of complex products. Aerospace products have the characteristics of complex structure and assembly. When using image acquisition equipment to take pictures of products, in order to ensure the consistency of image quality, the operator needs to observe the product image with the naked eye in the real-time preview mode, and constantly adjust the product to the preset ideal position by referring to the standard image template, and then take the final picture. With the existing image acquisition technology, the image acquisition quality mainly depends on manual labor, which is prone to visual fatigue, poor consistency of the collected images, and no quantitative standards. Therefore, this method is difficult to ensure work efficiency and the accuracy of the collected images.
[0003] Therefore, how to improve it is a technical problem that needs to be solved urgently in this field. Summary of the invention
[0004] Based on this, the purpose of this application is to provide an adaptive image acquisition method, medium and device to solve at least one technical problem mentioned in the above background technology.
[0005] In a first aspect, the present application provides an adaptive image acquisition method, comprising:
[0006] Obtain a calibration image of the product to be collected;
[0007] Calculate the calibration grayscale image, calibration clarity and calibration reference coordinates of the calibration image;
[0008] Get the current image of the product to be captured;
[0009] Calculate the current grayscale image, current definition and current reference coordinates of the current image;
[0010] Determine the clarity sensitivity, the reference coordinate deviation and the angle deviation according to the calibration grayscale image, the calibration clarity, the calibration reference coordinates and the current grayscale image, the current clarity and the current reference coordinates;
[0011] According to the clarity sensitivity, reference coordinate deviation and angle deviation, determine whether the current image is qualified. If so, obtain the current captured image. If not, adjust the product posture and return to the step of obtaining the current image of the product to be captured.
[0012] Furthermore, the steps of calculating a calibration grayscale image and a calibration definition of the calibration image and calculating a current grayscale image and a current definition of the current image include:
[0013] Calculate the grayscale value of each pixel in the calibration image or the current image, and obtain the corresponding grayscale image as the calibration grayscale image or the current grayscale image;
[0014] Performing a convolution operation on the calibration grayscale image or the current grayscale image to obtain an edge contour image of the calibration image or the current image;
[0015] A pixel threshold is set, and pixels above the threshold in the edge contour map of the calibration image or the current image are modified to a first pixel value, and pixels below the threshold are modified to a second pixel value, so as to obtain a contour binary map of the calibration image or the current image;
[0016] According to the pixel value of each pixel point in the contour binary image of the calibration image or the current image, the variance of the contour binary image is calculated to obtain the calibration definition or the current definition.
[0017] Furthermore, the step of calculating the calibration reference coordinates and the current reference coordinates includes:
[0018] Perform edge contour detection on the contour binary image of the calibration image or the current image to obtain several outer contours, and obtain the outer contour with the largest area as the product outer contour of the calibration image or the current image;
[0019] Get the target frame of the product outer contour of the calibration image or the current image, and get the coordinates of its center point, which are the calibration reference coordinates or the current reference coordinates.
[0020] Furthermore, the step of determining the clarity sensitivity includes: obtaining a ratio between the calibrated image clarity and the current image clarity as the clarity sensitivity.
[0021] Furthermore, the step of determining the reference coordinate deviation includes:
[0022] Take any point in the calibration image and the current image as the origin to establish a plane coordinate system, and transform the calibration reference coordinates and the current reference coordinates to the same coordinate system to obtain the distance between the two in the same coordinate system and determine the coordinate deviation value;
[0023] Alternatively, a plane coordinate system is established with any point in the calibration image and the current image as the origin, and the calibration reference coordinates and the current reference coordinates are converted to the corresponding coordinate system to obtain the average value of the distance between the two in each coordinate system and determine the coordinate deviation value.
[0024] Further, the step of determining the angle deviation comprises:
[0025] Extract the key feature points of the calibration grayscale image and the current grayscale image, and calculate the descriptor of each key feature point;
[0026] Match each feature key point according to the descriptor to obtain several feature point pairs;
[0027] The coordinates of each feature point pair are extracted, and the optimal transformation function of the calibration grayscale image and the current grayscale image is constructed to calculate the corresponding homography matrix, and the angle difference between the product angles in the calibration grayscale image and the current grayscale image is obtained as the angle deviation value.
[0028] Furthermore, the step of calculating the descriptor of each feature key point includes:
[0029] Obtain the pixel points within the set area of each feature key point and divide it into several sub-areas;
[0030] Obtain the gradient magnitude and gradient direction of each sub-region;
[0031] The gradient magnitude and gradient direction of each sub-region are summarized to obtain the descriptor of the corresponding feature key point.
[0032] Further, judging whether the current image is qualified according to the clarity sensitivity, reference coordinate deviation and angle deviation includes:
[0033] Set the clarity sensitivity threshold, coordinate deviation threshold, and angle deviation threshold;
[0034] Determine whether the clarity sensitivity is less than the clarity sensitivity threshold, whether the coordinate deviation value is less than the coordinate deviation threshold, and whether the angle deviation value is less than the angle deviation threshold;
[0035] If both are smaller than , the current image is qualified.
[0036] In a second aspect, the present application further provides a computer storage medium storing an executable program code; the executable program code is used to execute the adaptive image acquisition method described in any one of the first aspects.
[0037] In a third aspect, the present application further provides a terminal device, comprising a memory and a processor; the memory stores a program code executable by the processor; the program code is used to execute the adaptive image acquisition method described in any one of the first aspects.
[0038] The present invention provides an adaptive image acquisition method, which obtains a calibration image of a product to be acquired, calculates a calibration grayscale image, a calibration clarity and a calibration reference coordinate of the calibration image, acquires a current image of the product to be acquired, calculates a current grayscale image, a current clarity and a current reference coordinate of the current image, determines the clarity sensitivity, the reference coordinate deviation and the angle deviation according to the calibration grayscale image, the calibration clarity, the calibration reference coordinate and the current grayscale image, the current clarity and the current reference coordinate, determines whether the current image is qualified according to the clarity sensitivity, the reference coordinate deviation and the angle deviation, controls the clarity sensitivity, the reference coordinate deviation and the angle deviation within a set range by setting a deviation threshold, improves the consistency of the acquired image, obtains the current acquired image if it is, adjusts the product posture according to the obtained clarity sensitivity, the reference coordinate deviation and the angle deviation, returns to the step of acquiring the current image of the product to be acquired, and improves the acquisition efficiency and the acquisition accuracy when acquiring the image. The method solves the problems of poor consistency, low acquisition efficiency and low acquisition accuracy when acquiring images in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 The figure is a flow chart of an adaptive image acquisition method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 creative work are within the scope of protection of the present invention.
[0041] It should be noted that if the embodiments of the present invention involve directional indications, such as up, down, left, right, front, back, etc., then the directional indication is only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly. In addition, if the embodiments of the present invention involve descriptions of "first, second", "S1, S2", "step one, step two", etc., then such descriptions are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of indicated technical features or indicating the execution order of the method, etc. Those skilled in the art can understand that anything that does not violate the gist of the invention under the technical concept of the invention should be included in the protection scope of the present invention.
[0042] like Figure 1 As shown, the present invention provides an adaptive image acquisition method:
[0043] S1: Obtain a calibration image of the product to be collected;
[0044] Specifically, it is optional but not limited to placing the product to be inspected within the scanning range of the acquisition device to obtain several surface images of the product, and the images that meet the expected specifications are used as calibration images after manual screening. More specifically, the acquisition device can be optional but not limited to 3D line scan cameras, 3D structured light cameras, TOF cameras, laser scanners, multi-view stereo vision systems, grating projection measuring instruments and other common scanning devices that can be used to obtain three-dimensional data of the surface of an object.
[0045] S2: Calculate the calibration grayscale image, calibration clarity and calibration reference coordinates of the calibration image;
[0046] Specifically, the steps of calculating the calibration grayscale image, the calibration definition and the calibration reference coordinates of the calibration image may optionally include:
[0047] S21: Calculate the grayscale value of each pixel in the calibration image, and obtain the corresponding grayscale image as the calibration grayscale image;
[0048] Specifically, it is optional but not limited to calculating the grayscale value of each pixel in the calibration image through a grayscale calculation formula, and modifying the pixel value of each pixel to a corresponding grayscale value to obtain a grayscale image corresponding to the calibration image, which is a calibration grayscale image.
[0049] Preferably, the grayscale calculation formula can be optionally expressed as Formula 2-1:
[0050] Gray=0.2989×R+0.5870×G+0.1140×B 2-1
[0051] Among them, Gray is the gray value of the pixel, and R, G, and B are the pixel values of each pixel in the red, green, and blue channels respectively.
[0052] S22: performing a convolution operation on the calibration grayscale image to obtain an edge contour image of the calibration image;
[0053] Specifically, it is optional but not limited to performing a convolution operation on the calibration grayscale image according to an edge detection operator to obtain the second-order derivative of each pixel, and modifying the pixel value of the pixel to the corresponding second-order derivative value to obtain the edge contour map corresponding to the calibration image; the edge detection operator may include commonly used operators such as Laplace operator, Sobel operator and Canny operator.
[0054] Preferably, the edge detection operator uses a Laplacian operator, which is a 3x3 centrosymmetric kernel, and can be optionally expressed as Formula 2-2:
[0055] 2-2
[0056] S23: setting a pixel threshold, modifying pixels in the edge contour map of the calibration image that are higher than the threshold to a first pixel value, and modifying pixels that are lower than the threshold to a second pixel value, to obtain a contour binary image corresponding to the edge contour map;
[0057] Specifically, it is optional but not limited to setting a pixel threshold, and the pixel points with pixel values less than the pixel threshold in the edge contour map of the calibrated image are modified to the first pixel value, and the pixel points with pixel values not less than the pixel threshold are modified to the second pixel value, thereby segmenting the image into a foreground area and a background area, and obtaining a binary image corresponding to the surface image; the pixel threshold is arbitrarily set by technicians in this field.
[0058] Preferably, the first pixel value is 0 and the second pixel value is 255.
[0059] S24: Calculate the variance of the contour binary image according to the pixel value of each pixel point in the contour binary image of the calibration image, which is the calibration clarity;
[0060] Specifically, it is optional but not limited to obtaining the pixel value of each pixel point in the contour binary image of the calibration image, substituting it into the variance calculation formula, and calculating the variance of the contour binary image of the calibration image, which is regarded as the calibration clarity.
[0061] For example, the variance calculation formula can be optionally expressed as formula 2-3, 2-4:
[0062] 2-3
[0063] 2-4
[0064] Among them, S is the variance of the edge contour map, N is the total number of pixels in the edge contour map, and I i is the gray value of the i-th pixel in the edge contour map, and u is the average gray value of the edge contour map.
[0065] S25: performing edge contour detection on the contour binary image of the calibration image to obtain a number of outer contours, and obtaining the outer contour with the largest area as the product outer contour of the calibration image;
[0066] S26: Obtain the target frame of the product outer contour of the calibration image, and obtain the coordinates of its center point as the calibration reference coordinates.
[0067] Specifically, it is optional but not limited to performing contour search on the contour binary map of the calibration image according to the image segmentation algorithm to obtain all contours, using a contour extraction algorithm to identify all outer contours in the contour binary map of the calibration image according to the contour hierarchy relationship, and then optionally calculating the area of all outer contours according to the number of pixels in the area covered by each outer contour, obtaining the outer contour with the largest area as the product outer contour, and then calculating the target frame of the product outer contour, and obtaining the center point coordinates of the target frame as the calibration reference coordinates of the calibration image; contour extraction algorithms include but are not limited to common algorithms such as the Canny edge detection algorithm, the Sobel algorithm, graph theory-based algorithms, and region growing and segmentation algorithms.
[0068] Preferably, the target frame may be, but is not limited to, a minimum circumscribed rectangle, a minimum circumscribed circle, or other graphics.
[0069] S3: Acquire the current image of the product to be captured;
[0070] Specifically, similar to step S1, a current image of the product to be captured can be acquired by a capture device.
[0071] Preferably, a current image of the product to be captured is obtained, and the current image is further compressed and preprocessed to obtain an optimized current image to reduce the amount of image data; specifically, the image compression step may optionally include but is not limited to using common methods such as uniform downsampling, nearest neighbor interpolation, and bilinear interpolation.
[0072] S4: Calculate the current grayscale image, current definition and current reference coordinates of the current image;
[0073] Specifically, the current image may be processed in the same manner according to steps S21 to S26 to obtain a current grayscale image, a current definition, and current reference coordinates of the current image.
[0074] S5: Determine the clarity sensitivity, the reference coordinate deviation and the angle deviation according to the calibration grayscale image, the calibration clarity, the calibration reference coordinates and the current grayscale image, the current clarity and the current reference coordinates;
[0075] Specifically, it is optional but not limited to calculating the ratio between the calibrated image clarity and the current image clarity based on the calibrated grayscale image, calibrated clarity, calibrated reference coordinates obtained in step S1 and the current grayscale image, current clarity, current reference coordinates obtained in step S4, determining the clarity sensitivity, and then converting the calibrated reference coordinates and the current reference coordinates to the same coordinate system, calculating the distance between the two, determining the coordinate deviation value, and finally calculating the angle difference between the product angles based on the product images contained in the calibrated grayscale image and the current grayscale image, and determining the angle deviation value.
[0076] Preferably, step S5 may optionally include but is not limited to:
[0077] S51: Obtaining a ratio between the calibrated image clarity and the current image clarity to determine clarity sensitivity;
[0078] Specifically, it is optional but not limited to substituting the calibrated image clarity and the current image clarity into formula 5-1 to calculate the clarity sensitivity between the two:
[0079] IS = S2 / S1 5-1
[0080] Wherein, IS is the clarity sensitivity between the calibrated image clarity and the current image clarity, S1 is the calibrated image clarity, and S2 is the current image clarity.
[0081] S52: Taking any point in the calibration image and the current image as the origin, establishing a plane coordinate system, and converting the calibration reference coordinates and the current reference coordinates to the same coordinate system to obtain the distance between the two in the same coordinate system and determine the coordinate deviation value;
[0082] Specifically, it is optional but not limited to taking the lower left corner point of the calibration image and the current image as the origin, the extending direction from the lower left corner to the upper left corner as the y-axis, and the extending direction from the lower left corner to the lower right corner as the x-axis, respectively establishing a calibration plane coordinate system and a current plane coordinate system, converting the calibration reference coordinates to the current plane coordinate system or converting the current reference coordinates to the calibration reference coordinate system, and calculating the distance between the two to determine the coordinate deviation value.
[0083] Preferably, since only the distance between the calibrated reference coordinates and the current reference coordinates in any same coordinate system is calculated, it is easily affected by external noise and environmental factors, resulting in increased errors. Therefore, step S52 may be optional but not limited to:
[0084] S52': taking any point in the calibration image and the current image as the origin, establishing a plane coordinate system, and converting the calibration reference coordinates and the current reference coordinates to the corresponding coordinate system to obtain the average value of the distance between the two in each coordinate system, and determining the coordinate deviation value;
[0085] Specifically, it is optional but not limited to taking the lower left corner point of the calibration image and the current image as the origin, the extending direction from the lower left corner to the upper left corner as the y-axis, and the extending direction from the lower left corner to the lower right corner as the x-axis, respectively establishing a calibration plane coordinate system and a current plane coordinate system, converting the calibration reference coordinates to the current plane coordinate system and converting the current reference coordinates to the calibration reference coordinate system, and calculating the average distance between the two in each coordinate system to determine the coordinate deviation value.
[0086] S53: Calculate the angle difference between the product angles according to the calibrated grayscale image and the product image included in the current grayscale image, and determine the angle deviation value.
[0087] Specifically, it is optional but not limited to setting a matching threshold, extracting feature key points from the calibrated grayscale image and the current grayscale image according to the feature detection and description algorithm, and calculating the calculation descriptor of each feature key point, and optionally calculating the calculation descriptor according to the feature matching algorithm to obtain a number of feature point pairs in the calibrated grayscale image and the current grayscale image and the distance between each feature point pair, retaining the feature point pairs with a distance greater than the threshold, and then calculating the homography matrix between the feature key points of the calibrated grayscale image and the feature key points of the current grayscale image according to the coordinates of the remaining feature point pairs, so as to calculate the angle difference between the product angles of the product images contained in the calibrated grayscale image and the current grayscale image, and determine the angle deviation value; the matching threshold is arbitrarily set by those skilled in the art; the feature detection and description algorithm may optionally include common algorithms such as the ORB algorithm (Oriented FAST and Rotated BRIEF), the Scale-Invariant Feature Transform algorithm, and the Speeded-Up Robust Features algorithm; the feature matching algorithm may optionally include common feature matching algorithms such as the brute force matching algorithm, the K nearest neighbor matching algorithm, and the graph-based matching algorithm.
[0088] It is worth noting that, depending on the type of descriptor and the application scenario, the type of distance is also different, such as Euclidean distance, Hamming distance, cosine similarity, Manhattan distance, etc.; it is preferred to use the ORB algorithm to obtain the descriptor of the feature key point, and obtain the Hamming distance between the descriptors of each feature key point.
[0089] Further preferably, the specific steps of step S53 may optionally include but are not limited to:
[0090] S531: extracting the key feature points of the calibration grayscale image and the current grayscale image, and calculating the descriptor of each key feature point;
[0091] Specifically, it is optional but not limited to detecting feature key points in the image through the FAST (Features from Accelerated Segment Test) algorithm, and then for each key point, extracting the pixels in the set area around it, and then dividing it into several sub-regions, obtaining the gradient amplitude and gradient direction of each sub-region, and summing them up to obtain the descriptor of the key point.
[0092] Preferably, the step of calculating the descriptor of each feature key point may optionally include but is not limited to:
[0093] S5311: Obtain pixel points within the set area of each feature key point and divide it into several sub-areas;
[0094] For example, it is optional to extract pixels in a 16x16 area centered on each feature key point and divide it into several 4x4 sub-areas.
[0095] S5312: Obtain the gradient magnitude and gradient direction of each sub-region;
[0096] Specifically, it is optional but not limited to calculating the gradient of each sub-region in the set direction through a gradient operator, and finally merging the gradients in each direction to obtain the gradient amplitude of each sub-region, substituting the ratio of the gradients in each direction into the inverse tangent function to obtain the gradient direction; the gradient operator may optionally include common gradient operators such as Sobel operator, Prewitt operator, Roberts operator, Laplace operator, etc.; the set direction may optionally include x direction, y direction, z direction, etc., which may be arbitrarily set by technical personnel in this field according to specific needs.
[0097] For example, the gradient amplitude of each sub-region can be calculated according to Formula 5-6, and the gradient direction of each sub-region can be calculated according to Formula 5-7:
[0098] 5-2
[0099] 5-3
[0100] 5-4
[0101] 5-5
[0102] 5-6
[0103] 5-7
[0104] Among them, Sobelx and Sobely are the kernels of the Sobel operator in the x direction and y direction respectively, G xi and G yi are the gradients of the i-th sub-region in the X and Y directions, Img i is the gradient amplitude of the ith sub-region, is the gradient direction of the i-th sub-region.
[0105] S5313: Summarize the gradient magnitude and gradient direction of each sub-region to obtain the descriptor of the corresponding feature key point.
[0106] Specifically, it is optional but not limited to creating an empty descriptor array according to the size of each sub-region, and then obtaining the histogram of all sub-regions and storing it in the descriptor array, so as to obtain the descriptor corresponding to each feature key point.
[0107] For example, assuming that the histogram size of each sub-region is 8 (representing 8 direction intervals), the final descriptor size is 16×8=12816×8=128.
[0108] S532: Match each feature key point according to the descriptor to obtain a number of feature point pairs;
[0109] Specifically, it is optional but not limited to setting a matching threshold, matching each feature key point according to the descriptor of each feature key point, and if the matching result is less than the matching threshold, the corresponding feature key points form a feature point pair.
[0110] For example, it is optional but not limited to obtaining the matching results of each feature key point according to formula 5-8:
[0111] 5-8
[0112] Among them, d is the matching result of the feature key points corresponding to descriptors A and B, A and B are the descriptors of the feature key points to be matched, n is the number of bits of the descriptor, Ai and Bi are the i-th bits of the descriptors, Represents an exclusive OR operation. A result of 1 indicates that the two bits are different, and a result of 0 indicates that the two bits are the same.
[0113] For example, suppose there are two ORB descriptors as follows (in binary form):
[0114] A=10110011
[0115] B=10010101
[0116] Steps to calculate the Hamming distance:
[0117] Compare each digit:
[0118] No. 1: 1 vs 1 → Same
[0119] 2nd position: 0 vs 0 → Same
[0120] 3rd place: 1 vs 0 → different
[0121] 4th place: 1 vs 1 → Same
[0122] 5th place: 0 vs 0 → same
[0123] 6th position: 0 vs 1 → different
[0124] 7th bit: 1 vs 0 → different
[0125] 8th bit: 1 vs 1 → same
[0126] As can be seen from the above, the number of different bits between the A descriptor and the B descriptor is 3. Therefore, their Hamming distance is 3. Determine whether this distance is less than the matching threshold. If so, the matching is successful and the feature point pair is obtained; if not, the matching fails and it is not a feature point pair.
[0127] S533: Extract the coordinates of each feature point pair, construct the optimal transformation function 5-9 between the calibrated grayscale image and the current grayscale image to calculate the corresponding homography matrix 5-10, and obtain the angular difference between the product angles in the calibrated grayscale image and the current grayscale image, which is the angular deviation value.
[0128] 5-9
[0129] 5-10
[0130] Among them, minf() is the optimal transformation function. 、 are respectively the coordinates of the feature point in the calibrated grayscale image and the feature point in the current grayscale image in the i-th pair of feature point pairs; 0 < i < n; n is the number of groups of feature point pairs; k is the weight of each feature point pair, which can be determined according to the feature saliency such as the position of the feature point pair; Hmin is the homography matrix between the feature points in the calibrated grayscale image and the feature points in the current grayscale image, R is the rotation transformation matrix, and t is the translation transformation matrix; the angular difference is the difference between the rotation transformation matrices. Specifically, optionally, the inverse calculation of the angular difference is Equation 5-11:
[0131] 5-11
[0132] S6: According to the clarity sensitivity, reference coordinate deviation, and angular deviation, determine whether the current image is qualified. If so, obtain the current captured image; if not, adjust the product posture and return to step S3.
[0133] Specifically, optionally but not limited to setting the clarity sensitivity threshold, coordinate deviation threshold, and angular deviation threshold, determine whether the clarity sensitivity is less than the clarity sensitivity threshold, whether the coordinate deviation value is less than the coordinate deviation threshold, and whether the angular deviation value is less than the angular deviation threshold, so as to determine whether it is necessary to adjust the product posture to re-capture the image or obtain the qualified current captured image according to the judgment result.
[0134] Preferably, step S6, optionally but not limited to including:
[0135] S61: Setting a clarity sensitivity threshold, a coordinate deviation threshold, and an angle deviation threshold;
[0136] S62: Determine whether the clarity sensitivity is less than the clarity sensitivity threshold, whether the coordinate deviation value is less than the coordinate deviation threshold, and whether the angle deviation value is less than the angle deviation threshold;
[0137] S63: If both are less than, the current captured image is obtained; otherwise, the product posture is adjusted and the process returns to step S3.
[0138] Specifically, it is optional but not limited to judging whether the clarity sensitivity is less than the clarity sensitivity threshold, whether the coordinate deviation value is less than the coordinate deviation threshold, and whether the angle deviation value is less than the angle deviation threshold. If all of them are less than, the current image obtained in step S2 meets the set image quality requirements and can be used as the current captured image. If any one of the data is less than the corresponding set threshold, it means that when capturing the initial preview image, the current image captured does not meet the set image quality requirements, and it is necessary to further adjust the product posture according to the clarity sensitivity, reference coordinate deviation and angle deviation, and continuously iterate until the clarity sensitivity, reference coordinate deviation and angle deviation between the current image and the calibration image are less than the corresponding set thresholds, and the final current captured image can be obtained.
[0139] In this embodiment, an adaptive image acquisition method of the present invention is provided, by obtaining a calibration image of the product to be acquired, calculating the calibration grayscale image, calibration clarity and calibration reference coordinates of the calibration image, acquiring the current image of the product to be acquired, calculating the current grayscale image, current clarity and current reference coordinates of the current image, determining the clarity sensitivity, reference coordinate deviation and angle deviation according to the calibration grayscale image, calibration clarity, calibration reference coordinates and current grayscale image, current clarity and current reference coordinates, judging whether the current image is qualified according to the clarity sensitivity, reference coordinate deviation and angle deviation, and controlling the clarity sensitivity, reference coordinate deviation and angle deviation within a set range by setting a deviation threshold, improving the consistency of the acquired image, and obtaining the current acquired image if so, and adjusting the product posture according to the obtained clarity sensitivity, reference coordinate deviation and angle deviation, returning to the step of obtaining the current image of the product to be acquired, and improving the acquisition efficiency and acquisition accuracy when acquiring the image. The method solves the problems of poor consistency, low acquisition efficiency and low acquisition accuracy when acquiring images in the prior art.
[0140] On the other hand, the present invention further provides a computer storage medium storing executable program code; the executable program code is used to execute any of the above-mentioned adaptive image acquisition methods.
[0141] On the other hand, the present invention further provides a terminal device, including a memory and a processor; the memory stores program codes that can be executed by the processor; the program codes are used to execute any of the above-mentioned adaptive image acquisition methods.
[0142] Exemplarily, the program code may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the program code in the terminal device.
[0143] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the terminal device may also include an input / output device, a network access device, a bus, etc.
[0144] The processor may be a central processing unit (CPU), or 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. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0145] The memory may be an internal storage unit of the terminal device, such as a hard disk or a memory. The memory may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Furthermore, the memory may include both an internal storage unit of the terminal device and an external storage device. The memory is used to store the program code and other programs and data required by the terminal device. The memory may also be used to temporarily store data that has been output or is to be output.
[0146] The above-mentioned computer storage medium and terminal device are created based on the above-mentioned adaptive image acquisition method, and their technical functions and beneficial effects are no longer repeated here. The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the various technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0147] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. An adaptive image acquisition method, characterized in that: include: Obtain a calibration image of the product to be collected; Calculate the calibration grayscale image, calibration clarity and calibration reference coordinates of the calibration image; Get the current image of the product to be captured; Calculate the current grayscale image, current definition and current reference coordinates of the current image; Determine the clarity sensitivity, the reference coordinate deviation and the angle deviation according to the calibration grayscale image, the calibration clarity, the calibration reference coordinates and the current grayscale image, the current clarity and the current reference coordinates; According to the clarity sensitivity, reference coordinate deviation and angle deviation, determine whether the current image is qualified. If so, obtain the current captured image. If not, adjust the product posture and return to the step of obtaining the current image of the product to be captured. The steps to determine the angle deviation are as follows: Extract the key feature points of the calibration grayscale image and the current grayscale image, and calculate the descriptor of each key feature point; Match each feature key point according to the descriptor to obtain several feature point pairs; Extract the coordinates of each feature point pair, construct the optimal transformation function of the calibration grayscale image and the current grayscale image, calculate the corresponding homography matrix, and obtain the angle difference between the product angles in the calibration grayscale image and the current grayscale image, which is the angle deviation value; the specific formula is: ; ; where, minf() is the optimal transformation function, R is the rotation transformation matrix, and t is the translation transformation matrix; and are the coordinates of the feature points in the calibrated grayscale image and the current grayscale image in the i-th pair of feature point pairs, respectively; 0 < i < n; n is the number of groups of feature point pairs; k is the weight of each feature point pair; Hmin is the homography matrix between the feature points in the calibrated grayscale image and the feature points in the current grayscale image; Inverse angle difference: 。 2. The method according to claim 1, characterized in that The steps of calculating a calibration grayscale image and a calibration definition of a calibration image and calculating a current grayscale image and a current definition of a current image include: Calculate the grayscale value of each pixel in the calibration image or the current image, and obtain the corresponding grayscale image as the calibration grayscale image or the current grayscale image; Performing a convolution operation on the calibration grayscale image or the current grayscale image to obtain an edge contour image of the calibration image or the current image; A pixel threshold is set, and pixels above the threshold in the edge contour map of the calibration image or the current image are modified to a first pixel value, and pixels below the threshold are modified to a second pixel value, so as to obtain a contour binary map of the calibration image or the current image; According to the pixel value of each pixel point in the contour binary image of the calibration image or the current image, the variance of the contour binary image is calculated to obtain the calibration definition or the current definition.
3. The method according to claim 2, characterized in that The steps of calculating the calibration reference coordinates and the current reference coordinates include: Perform edge contour detection on the contour binary image of the calibration image or the current image to obtain several outer contours, and obtain the outer contour with the largest area as the product outer contour of the calibration image or the current image; Get the target frame of the product outer contour of the calibration image or the current image, and get the coordinates of its center point, which are the calibration reference coordinates or the current reference coordinates.
4. The method according to claim 1, characterized in that The step of determining the clarity sensitivity includes: obtaining the ratio between the calibrated image clarity and the current image clarity as the clarity sensitivity.
5. The method according to claim 1, characterized in that The steps for determining the reference coordinate deviation include: Take any point in the calibration image and the current image as the origin to establish a plane coordinate system, and transform the calibration reference coordinates and the current reference coordinates to the same coordinate system to obtain the distance between the two in the same coordinate system and determine the coordinate deviation value; Alternatively, a plane coordinate system is established with any point in the calibration image and the current image as the origin, and the calibration reference coordinates and the current reference coordinates are converted to the corresponding coordinate system to obtain the average value of the distance between the two in each coordinate system and determine the coordinate deviation value.
6. The method according to claim 1, characterized in that The steps of calculating the descriptor of each feature key point include: Obtain the pixel points within the set area of each feature key point and divide it into several sub-areas; Obtain the gradient magnitude and gradient direction of each sub-region; The gradient magnitude and gradient direction of each sub-region are summarized to obtain the descriptor of the corresponding feature key point.
7. The method according to any one of claims 1 to 6, characterized in that: According to the clarity sensitivity, reference coordinate deviation and angle deviation, judge whether the current image is qualified, including: Set the clarity sensitivity threshold, coordinate deviation threshold, and angle deviation threshold; Determine whether the clarity sensitivity is less than the clarity sensitivity threshold, whether the coordinate deviation value is less than the coordinate deviation threshold, and whether the angle deviation value is less than the angle deviation threshold; If both are smaller than , the current image is qualified.
8. A computer storage medium, characterized in that: An executable program code is stored; the executable program code is used to execute the adaptive image acquisition method described in any one of claims 1-7.
9. A terminal device, characterized in that: It comprises a memory and a processor; the memory stores a program code executable by the processor; the program code is used to execute the adaptive image acquisition method described in any one of claims 1-7.
Citation Information
Patent Citations
Visual detection method for appearances
CN111951237A