An image positioning method, device, electronic device and storage medium
By acquiring and transforming the template image of the printed circuit board and the pyramid image of the image to be positioned, the position information of the second component on the image to be positioned is solved, and high-precision image positioning is achieved.
Patent Information
- Application Number
- CN202111650898.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2041-12-30
AI Technical Summary
In the process of detecting appearance defects of printed circuit boards, how to improve positioning accuracy is a technical problem that needs to be solved.
By acquiring the first pyramid image corresponding to the template image and the second pyramid image corresponding to the to-local image, transforming and matching, the position information of the second component on the to-local image is determined.
It improves the positioning accuracy of the printed circuit board, avoids positioning failures due to poor selection of feature components, and is suitable for image positioning in more scenarios.
Smart Images

Figure CN114511630B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular, to an image positioning method, apparatus, electronic device, and storage medium. Background Art
[0002] In the process of detecting the appearance defects of printed circuit boards (PCBs), it is necessary to accurately position each component on the PCB; how to improve the positioning accuracy is a technical problem to be solved. Summary of the Invention
[0003] The present application provides an image positioning method, apparatus, electronic device, and storage medium to at least solve the above technical problems existing in the prior art.
[0004] The first aspect of the present application provides an image positioning method, including:
[0005] Obtaining a first pyramid image corresponding to a template image and a second pyramid image corresponding to an image to be positioned;
[0006] Performing a transformation on each layer of the image in the first pyramid image, and determining the transformation coefficient corresponding to the first pyramid image as the target coefficient when the distance between the components of the first shape in the transformed first pyramid image and the components of the first shape in the corresponding layer of the pyramid of the image to be positioned is less than a first threshold;
[0007] Based on the target coefficient and the relative position information between the components of the first shape and the second component on the template image, determining the position information of the second component on the image to be positioned.
[0008] In the above solution, before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be positioned, the method further includes:
[0009] Determining the relative position information between the components of the first shape and the second component on the template image.
[0010] In the above solution, the determining the relative position information between the components of the first shape and the second component on the template image includes:
[0011] Determining the center coordinates and diameter of the components of the first shape on the template image;
[0012] Determining the coordinate information of the second component on the template image;
[0013] Based on the center coordinates and diameter of the component of the first shape on the template image, and the coordinate information of the second component on the template image, confirm the relative position information between the component of the first shape and the second component on the template image.
[0014] In the above solution, before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located, the method further includes:
[0015] Determine the coordinate set of the component of the first shape on the image to be located.
[0016] In the above solution, the determination of the coordinate set of the component of the first shape on the image to be located includes:
[0017] Determine the coordinate information of the centers of at least one circle that meets the first condition on the image to be located;
[0018] Cluster all the circles that meet the first condition on the image to be located to obtain a clustering result;
[0019] Determine the coordinate information corresponding to the clustering result in the clustering result whose difference from the diameter of the component of the first shape on the template image is less than the second threshold as the coordinate set of the component of the first shape on the image to be located.
[0020] In the above solution, before performing a transformation on each layer image of the first pyramid image, the method further includes:
[0021] Determine at least one set of coefficients for performing a transformation on each layer image of the first pyramid image; each set of the coefficients includes a translation coefficient, a scaling coefficient, and a rotation angle coefficient.
[0022] In the above solution, the determination of at least one set of coefficients for performing a transformation on each layer image of the first pyramid image includes:
[0023] Based on the translation amount threshold range and the first step size, determine the translation coefficient in each set of the coefficients;
[0024] Based on the scaling amount threshold range and the second step size, determine the scaling coefficient in each set of the coefficients;
[0025] Based on the rotation angle threshold range and the third step size, determine the rotation angle coefficient in each set of the coefficients.
[0026] In the above solution, performing a transformation on each layer image of the first pyramid image includes:
[0027] Based on at least one set of coefficients, perform transformations on the top layer to the bottom layer of the first pyramid image in sequence;
[0028] Among them, for different serial numbers of the layers of the first pyramid image, the corresponding coefficients are different.
[0029] In the above solution, the determining the position information of the second component on the to-be-located image based on the target coefficient and the relative position information of the first-shaped component and the second component on the template image includes:
[0030] Based on the relative position information of the first-shaped component and the second component on the template image and the coordinate set of the first-shaped component on the to-be-located image, determine the coordinate information of the second component on the to-be-located image;
[0031] Based on the target coefficient, perform a transformation on the coordinate information of the second component on the to-be-located image, and confirm that the transformed coordinate information is the position information of the second component on the to-be-located image.
[0032] A second aspect of the present application provides an image positioning device, including:
[0033] An acquisition unit, configured to acquire a first pyramid image corresponding to a template image and a second pyramid image corresponding to a to-be-located image;
[0034] A processing unit, configured to perform a transformation on each layer image of the first pyramid image, and when the distance between the first-shaped component in the transformed first pyramid image and the first-shaped component in the corresponding layer of the to-be-located image pyramid is less than a first threshold, determine the transformation coefficient corresponding to the first pyramid image as the target coefficient;
[0035] A determination unit, configured to determine the position information of the second component on the to-be-located image based on the target coefficient and the relative position information of the first-shaped component and the second component on the template image.
[0036] A third aspect of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; the memory is used to store a computer program; the processor, when executing the program stored on the memory, implements the method steps described in the above image positioning method.
[0037] A fourth aspect of the present application provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method steps described in the above image positioning method are implemented.
[0038] By using the image positioning method provided in this application, a first pyramid image corresponding to a template image and a second pyramid image corresponding to an image to be positioned are obtained; each layer of the image in the first pyramid image is transformed, and when the distance between the components of the first shape in the transformed first pyramid image and the components of the first shape in the corresponding layer of the pyramid of the image to be positioned is less than a first threshold, the transformation coefficient corresponding to the first pyramid image is determined as the target coefficient; based on the target coefficient and the relative position information between the components of the first shape and the second components on the template image, the position information of the second components on the image to be positioned is determined, which can improve the positioning accuracy of the PCB. Description of the Drawings
[0039] Figure 1 Fig. shows an optional flowchart of the image positioning method provided in an embodiment of this application;
[0040] Figure 2 Fig. shows another optional flowchart of the image positioning method provided in an embodiment of this application;
[0041] Figure 3 Fig. shows a schematic diagram of a template image or an image to be positioned provided in an embodiment of this application;
[0042] Figure 4 Fig. shows a schematic diagram of dot map registration of any layer of the first pyramid and the corresponding layer of the second pyramid;
[0043] Figure 5 Fig. shows a schematic diagram of an optional structure of the image positioning device provided in an embodiment of this application;
[0044] Figure 6 Fig. shows a schematic diagram of the hardware composition structure of an electronic device provided in an embodiment of this application. Detailed Embodiments
[0045] To make the objectives, features, and advantages of this application more obvious and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of this application.
[0046] In the related art, during the process of appearance defect detection and functional testing tasks of a PCB, precise positioning of each component on the PCB is required. Positioning accuracy, positioning speed, and modeling convenience are the key technical indicators for PCB component positioning.
[0047] In the related art, the image of the PCB is located by using components with significant features, such as fiducial points (MARK points), significant texture features, etc. Through the positioning of the feature components, the global position of the PCB to be detected is calculated. However, in the above solution, the solution of using the positioning component with significant features to locate the PCB image requires collecting the template image under the image acquisition conditions similar to the production environment; obtaining the positioning template by manual selection increases the complexity of establishing the template and the difficulty of using the detection equipment, and has relatively high requirements for the operation skills of workers; moreover, some PCBs do not have significant feature components, making it difficult to select the feature components, resulting in difficult operation. In particular, poor selection of the feature components will lead to positioning failure.
[0048] Based on this, the embodiments of the present application provide an image positioning technology using dot pattern matching and calibration. By performing a series of image processing steps on the template image of the PCB product and the image of the PCB to be detected respectively, a template dot pattern and a physical dot pattern are obtained. A method for calculating the dot pattern distance between the template dot pattern and the physical dot pattern is provided, and the image pyramid is used to retrieve the optimal matching parameters, improving the matching speed, so as to quickly and accurately obtain the image positioning of the target position. Using the design data (template data of the PCB product) with standardized markings as the image template avoids the disadvantages of physical modeling occupying production time and being complex in operation.
[0049] Figure 1 Fig. shows an optional flowchart of the image positioning method provided by the embodiments of the present application, which will be described according to each step.
[0050] Step S101, obtain a first pyramid image corresponding to the template image and a second pyramid image corresponding to the image to be located.
[0051] In some embodiments, the image positioning device obtains the template image and / or obtains the image to be located based on an industrial camera; wherein the models of the PCBs corresponding to the template image and the image to be located are the same. The device obtains a first pyramid image corresponding to the template image and a second pyramid image corresponding to the image to be located; wherein, the number of images included in the first pyramid image and the second pyramid image is the same, and the resolution of each corresponding layer is the same (for example, the resolution of the image located at the top layer in the first pyramid is the same as the resolution of the image located at the top layer in the second pyramid).
[0052] In some embodiments, before the device obtains a first pyramid image corresponding to the template image and a second pyramid image corresponding to the image to be located, the relative position information between the component of the first shape and the second component on the template image may also be determined.
[0053] In specific implementation, the device determines the center coordinates and diameter of the component of the first shape on the template image; determines the coordinate information of the second component on the template image; and based on the center coordinates and diameter of the component of the first shape on the template image and the coordinate information of the second component on the template image, confirms the relative position information between the component of the first shape and the second component on the template image. Wherein, the first shape may be a circle; the component of the first shape may be a circular component on the template image; and the second component may be the component corresponding to the component to be located on the image to be located.
[0054] In some embodiments, before the device acquires the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located, it may also determine the coordinate set of the component of the first shape on the image to be located.
[0055] In specific implementation, the device determines the coordinate information of the centers of at least one circle that meets the first condition on the image to be located; performs clustering on all the circles that meet the first condition on the image to be located to obtain a clustering result; and determines the coordinate information corresponding to the clustering result in which the difference from the diameter of the component of the first shape on the template image is less than a second threshold as the coordinate set of the component of the first shape on the image to be located. Wherein, the first condition includes that the absolute value of the difference between the radius of the circular component and the radius of the circular component of the template image is within a first range.
[0056] Step S102, transform each layer of the image in the first pyramid image, and when the distance between the component of the first shape in the transformed first pyramid image and the component of the first shape in the corresponding layer of the pyramid of the image to be located is less than a first threshold, determine the transformation coefficient corresponding to the first pyramid image as the target coefficient.
[0057] In some embodiments, the device transforms each layer of the image in the first pyramid image, and when the distance between the component of the first shape in the transformed first pyramid image and the component of the first shape in the corresponding layer of the pyramid of the image to be located is less than a first threshold, determines the transformation coefficient corresponding to the first pyramid image as the target coefficient.
[0058] In some embodiments, the device determines at least one set of coefficients for transforming each layer of the image in the first pyramid image; each set of the coefficients includes a translation coefficient, a scaling coefficient, and a rotation angle coefficient.
[0059] In specific implementation, the device determines the translation coefficient in each group of coefficients based on a translation amount threshold range and a first step length; determines the scaling coefficient in each group of coefficients based on a scaling amount threshold range and a second step length; and determines the rotation angle coefficient in each group of coefficients based on a rotation angle threshold range and a third step length.
[0060] In some embodiments, the device sequentially transforms the uppermost layer to the lowermost layer of the first pyramid image based on at least one group of coefficients; wherein, for different serial numbers of the layers of the first pyramid image, the corresponding coefficients are different.
[0061] Step S103, determine the position information of the second component on the to-be-located image based on the target coefficient and the relative position information of the first-shaped component and the second component on the template image.
[0062] In some embodiments, the device determines the coordinate information of the second component on the to-be-located image based on the relative position information of the first-shaped component and the second component on the template image and the coordinate set of the first-shaped component on the to-be-located image; and transforms the coordinate information of the second component on the to-be-located image based on the target coefficient, and confirms that the transformed coordinate information is the position information of the second component on the to-be-located image.
[0063] In this way, through the image positioning method provided by the embodiments of the present application, the device obtains the first pyramid image corresponding to the template image and the second pyramid image corresponding to the to-be-located image; transforms each layer of the image in the first pyramid image, and when the distance between the first-shaped component in the transformed first pyramid image and the first-shaped component in the corresponding layer of the to-be-located image pyramid is less than a first threshold, determines the transformation coefficient corresponding to the first pyramid image as the target coefficient; determines the position information of the second component on the to-be-located image based on the target coefficient and the relative position information of the first-shaped component and the second component on the template image. In this way, positioning and registration are performed based on the center coordinates of the first-shaped component, which is feature-stable and has high positioning accuracy without adding additional marking information; the target coefficient is retrieved using an image pyramid, which improves the positioning speed; in addition, the to-be-located image in the present application can be placed randomly, without restricting the placement position and placement angle, and can adapt to more scenarios.
[0064] Figure 2 Another optional flowchart of the image positioning method provided by the embodiments of the present application is shown, and will be described according to each step.
[0065] Step S201, determine the relative position information of the first-shaped component and the second component on the template image.
[0066] In some embodiments, the image positioning device determines the center coordinates and diameter of the component of the first shape on the template image; determines the coordinate information of the second component on the template image; and based on the center coordinates and diameter of the component of the first shape on the template image and the coordinate information of the second component on the template image, confirms the relative position information between the component of the first shape and the second component on the template image. Wherein, the first shape may be a circle; the component of the first shape may be a circular component on the template image; and the second component may be the component corresponding to the component to be positioned on the image to be positioned.
[0067] Specifically, the device acquires a template image (which may be an image file of a PCB template), and based on the method of color retrieval, obtains the center coordinates and diameter of the component of the first shape in the template image; wherein, the component of the first shape may be a circular component. Wherein, the set of the center coordinates of the component of the first shape in the template image represents the position distribution of the component of the first shape in the template image; optionally, the set of the center coordinates of the component of the first shape in the template image is denoted as pts_temp.
[0068] Alternatively, specifically, the device may also acquire the coordinate information of the second component on the template image based on the method of color retrieval; and denote the set of the coordinate information of the second component on the template image as pts_t_roi. The second component is the component to be positioned (target component).
[0069] Figure 3 A schematic diagram of the template image or the image to be positioned provided by an embodiment of the present application is shown. Figure 3 In, the color of the component of the first shape ( Figure 3 the circular component marked in) is different from the colors of other components. Compared with methods such as shape discrimination, the coordinate information of the component of the first shape can be obtained more quickly. Wherein, the coordinate information may refer to the coordinate information in the coordinate system where the industrial camera is located. Figure 3 In, the color of the second component is different from the colors of other components, and the coordinate information of the second component can be obtained by the method of color retrieval.
[0070] In some alternative embodiments, the device stores pts_temp and pts_t_roi in an XML file.
[0071] In some alternative embodiments, step S201 may be executed offline.
[0072] Step S202, determine the coordinate set of the component of the first shape on the image to be positioned.
[0073] In some embodiments, the device determines the coordinate information of the centers of at least one circle that meets the first condition on the image to be located; clusters all the circles that meet the first condition on the image to be located to obtain a clustering result; and determines that the coordinate information corresponding to the clustering result in which the difference from the diameter of the component of the first shape on the template image is less than a second threshold is the coordinate set of the component of the first shape on the image to be located. Wherein, the first condition includes: the difference from the radius of the component of the first shape on the template image is less than a first radius threshold.
[0074] Specifically, the device can obtain the image to be located corresponding to the PCB to be located based on an industrial camera; denote the image to be located as im_ori, detect the circular components (components of the first shape) in the image to be located based on the Hough circle detection algorithm, and denote the components of the first shape whose difference from the radius of the component of the first shape on the template image is less than the first radius threshold as circle_all. The set of circle_all center coordinates of the components of the first shape on the image to be located represents the position distribution of the components of the first shape on the image to be located, denoted as coord_all . The device clusters all the circles that meet the first condition on the image to be located based on the Iterative Self-Organizing Data Analysis Technique (ISODATA) to obtain a clustering result cir_cluster. Based on the prior information of the PCB template, such as the diameter (pixel diameter) of the component of the first shape, at least one component of the first shape with the diameter closest to the prior information is selected from each cluster of cir_cluster, and it is confirmed that in the image to be located, the set composed of the center coordinates of the at least one component of the first shape is the position distribution of the components of the first shape on the image to be located, denoted as coord_test.
[0075] Step S203, obtain the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located.
[0076] In some embodiments, the image positioning device obtains a template image and / or obtains an image to be located based on an industrial camera; wherein the models of the PCBs corresponding to the template image and the image to be located are the same. The device obtains the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located; wherein, the number of images included in the first pyramid image and the second pyramid image is the same, and the resolution of each corresponding layer is the same (for example, the resolution of the image located at the top layer in the first pyramid is the same as the resolution of the image located at the top layer in the second pyramid).
[0077] Specifically, confirm that the size scaling factor of each layer of the pyramid image is py_ration where n is the number of layers of the pyramid image; the set of center coordinates pts_temp of the components of the first shape of the template image and the position distribution of the components of the first shape in the image to be located (the set of center coordinates of the components of the first shape of the image to be located) coord_test are scaled by the size ratio py_ratio of each layer n for scaling to obtain the first pyramid image pts_py n _temp corresponding to the template image and the second pyramid image coord_py n _test corresponding to the image to be located.
[0078] Step S204, determining at least one set of coefficients for transforming each layer of the first pyramid image.
[0079] In some embodiments, the device determines at least one set of coefficients for transforming each layer of the first pyramid image, where each set of coefficients includes a translation coefficient, a scaling coefficient, and a rotation angle coefficient.
[0080] Specifically, the device determines the translation coefficient in each set of coefficients based on the translation amount threshold range and the first step size; determines the scaling coefficient in each set of coefficients based on the scaling amount threshold range and the second step size; and determines the rotation angle coefficient in each set of coefficients based on the rotation angle threshold range and the third step size.
[0081] Step S205, transforming each layer of the first pyramid image.
[0082] In some embodiments, the device sequentially transforms the top layer to the bottom layer of the first pyramid image based on at least one set of coefficients; where the serial numbers of the layers of the first pyramid image are different, and the corresponding coefficients are different.
[0083] Specifically, the device performs translation, scaling, and rotation transformations on each layer of the first pyramid image pts_py n _temp, and the set of center coordinates of the components of the first shape of the transformed template image is denoted as pts_temp_py n _transf. Assuming the translation pixel distance is (x_, y_), the scaling coefficient is ratio, and the rotation angle is angle; then the transformed coordinate information pts_temp_py n _transf can be obtained by the following formula:
[0084]
[0085] Among them, pts_temp_py n _transf i .x is the component in the x-axis direction obtained after transformation of the i-th layer of the first pyramid image; pts_temp_py n _transf i .y is the component in the y-axis direction obtained after transformation of the i-th layer of the first pyramid image; pt_ori.x is the value obtained by scaling the translation amount x_ by ratio; pt_ori.y is the value obtained by scaling the translation amount y_ by ratio; that is, pt_ori is the origin of the coordinate system after translation and scaling transformation, and can be obtained through Equation (2):
[0086]
[0087] radius is the distance between the center coordinate of the component of the first shape and the origin pt_ori of the coordinate system after scaling transformation; angle_0 is the angle between the line connecting the center coordinate of the component of the first shape and the origin pt_ori of the coordinate system and the x-axis after scaling transformation, and can be obtained through Equation (3):
[0088]
[0089] Among them, pt_tmp.x is the coordinate corresponding to the x-axis coordinate of the center of the component of the first shape on the template image after translation and scaling; pt_tmp.y is the coordinate corresponding to the y-axis coordinate of the center of the component of the first shape after translation and scaling, and can be obtained through Equation (4):
[0090]
[0091] Among them, pts_py n _temp i .x is the x-axis coordinate of the center of the component of the first shape on the template image; pts_py n _temp i .y is the y-axis coordinate of the center of the component of the first shape on the template image; n is the number of layers included in the first pyramid image, which can be set according to actual needs.
[0092] Step S206, determine the target coefficient.
[0093] In some embodiments, the device performs transformation on each layer of the first pyramid image, and determines the transformation coefficient corresponding to the first pyramid image as the target coefficient when the distance between the component of the first shape in the transformed first pyramid image and the component of the first shape in the corresponding layer of the image pyramid to be located is less than the first threshold.
[0094] In specific implementation, the device can calculate the coordinates pts-temp_py of the transformed components of the first shape in the first pyramid image n _transf and the coordinates coord_py of the components of the first shape in the image to be located n _test, and record the average distance as pts_dis_average; it can be determined by Equation (5):
[0095]
[0096]
[0097]
[0098] where m is the number of center coordinates that can participate in the calculation of the average distance; thod_dis is the first distance threshold; when the distance between the components of the first shape on the transformed template image and the components of the first shape on the image to be located is greater than the first distance threshold, it is not included in the calculation of the average distance; to avoid interference caused by outliers. x_temp i is the x-axis component of the components of the first shape on the transformed template image; y_temp i is the y-axis component of the components of the first shape on the transformed template image; x_test i is the x-axis component of the components of the first shape on the image to be located; y_test i is the y-axis component of the components of the first shape on the image to be located.
[0099] In some embodiments, the device repeatedly executes step S205 to step S206. When it is determined that the distance between the components of the first shape in the transformed first pyramid image and the components of the first shape in the corresponding layer of the pyramid of the image to be located is less than the first threshold, it is determined that the transformation coefficient corresponding to the first pyramid image is the target coefficient. When it is confirmed that the minimum distance is pts_dis_avg_min and m is greater than the second quantity threshold thod_pt_num, the translation amount corresponding to the target coefficient is (x_min, y_min), the scaling coefficient is ration_min, and the rotation angle is angle_min. Optionally, the device stores the corresponding relationship between the template point map pts_temp_transf obtained after transforming the template image according to the target coefficient and the point map coord_test of the corresponding pyramid layer of the image to be located, and then determines the corresponding relationship (relative position information) between each component of the first shape on the image to be located and each component of the first shape on the template image, so as to determine the corresponding relationship between each component of the first shape on the template image and the image to be located.
[0100] Figure 4 Shows a dot map registration schematic diagram of any layer of the first pyramid corresponding to the corresponding layer of the second pyramid.
[0101] As Figure 4 shown, the ring is a circular component (component of the first shape) of the physical image (image to be located); the circle is the circular positioning component (component of the first shape) obtained after the template image is transformed; the number beside each ring in the figure represents the distance between the circular component of the image to be located and the circular component after the corresponding template image is transformed.
[0102] Step S207, based on the target coefficient and the relative position information of the component of the first shape and the second component on the template image, determine the position information of the second component on the image to be located.
[0103] In some embodiments, the device determines the coordinate information of the second component on the image to be located based on the relative position information of the component of the first shape and the second component on the template image and the coordinate set of the component of the first shape on the image to be located; based on the target coefficient, transform the coordinate information of the second component on the image to be located, and confirm that the transformed coordinate information is the position information of the second component on the image to be located.
[0104] Specifically, the device can determine the coordinate information of the second component in the image to be located corresponding to the second component in the template image based on the following formula:
[0105]
[0106] where pts_temp_transf i .x is the x-axis component of the second component in the image to be located; pts_temp_transf i .y is the y-axis component of the second component in the image to be located; pt_t_ori.x is the value obtained by scaling the translation amount x_min by ratio_min; pt_t_ori.y is the value obtained by scaling the translation amount y_min by ratio_min; that is, pt_t_ori is the origin of the coordinate system after translation and scaling transformation, and can be obtained by formula (9):
[0107]
[0108] The radius is the distance between the center coordinates of the second component in the image to be located after scaling transformation and the origin pt_t_ori of the coordinate system; the angle_t is the angle between the line connecting the center coordinates of the second component in the image to be located after scaling transformation and the origin pt_t_ori of the coordinate system and the x-axis, and can be obtained through Equation (10):
[0109]
[0110] Among them, pt_t_tmp.x is the coordinate corresponding to the x-axis coordinate of the center of the component of the second shape on the template image after translation and scaling; pt_t_tmp.y is the coordinate corresponding to the y-axis coordinate of the center of the component of the second shape after translation and scaling, and can be obtained through Equation (4):
[0111]
[0112] In this way, through the image positioning method provided by the embodiments of the present application, the dot map composed of the center coordinates of the components of a specific shape (circle) is used for positioning and matching, the image features are stable, and the positioning accuracy is high; the data involved in the standardized marking is used as the template image, avoiding the disadvantages of physical modeling occupying production time, causing complex operations, and positioning failures caused by poor selection of specific components; the circular component is used as the positioning feature component, without the need to add additional marking information; the image pyramid is used to retrieve the target parameters (the best matching parameters), improving the positioning speed; for the image positioning method provided by the embodiments of the present application, the image to be located can be placed randomly, without restricting the placement position and angle, and is applicable to more scenarios.
[0113] Figure 5 FIG. shows an optional structural schematic diagram of the image positioning device provided by the embodiments of the present application, and will be described according to each part.
[0114] In some embodiments, the image positioning device 300 includes: an acquisition unit 301, a processing unit 302, and a determination unit 303.
[0115] The acquisition unit 301 is configured to acquire a first pyramid image corresponding to a template image and a second pyramid image corresponding to an image to be located;
[0116] The processing unit 302 is configured to perform transformation on each layer of the image in the first pyramid image, and determine the transformation coefficient corresponding to the first pyramid image as the target coefficient when the distance between the component of the first shape in the transformed first pyramid image and the component of the first shape in the corresponding layer of the image pyramid to be located is less than a first threshold;
[0117] The determining unit 303 is configured to determine the position information of the second component on the image to be located based on the target coefficient and the relative position information between the component of the first shape and the second component on the template image.
[0118] The processing unit 302 is configured to determine the relative position information between the component of the first shape and the second component on the template image before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located.
[0119] Specifically, the processing unit 302 is configured to determine the center coordinates and diameter of the component of the first shape on the template image; determine the coordinate information of the second component on the template image; and confirm the relative position information between the component of the first shape and the second component on the template image based on the center coordinates and diameter of the component of the first shape on the template image and the coordinate information of the second component on the template image.
[0120] The processing unit 302 is configured to determine the coordinate set of the component of the first shape on the image to be located before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be located.
[0121] Specifically, the determining unit 303 is configured to determine the coordinate information of the centers of at least one circle that meets the first condition on the image to be located; perform clustering on all the circles that meet the first condition on the image to be located to obtain a clustering result; and determine the coordinate information corresponding to the clustering result in which the difference from the diameter of the component of the first shape on the template image is less than a second threshold as the coordinate set of the component of the first shape on the image to be located.
[0122] The determining unit 303 is further configured to determine at least one set of coefficients for transforming each layer of the first pyramid image; each set of the coefficients includes a translation coefficient, a scaling coefficient, and a rotation angle coefficient.
[0123] Specifically, the determining unit 303 is configured to determine the translation coefficient in each set of the coefficients based on the translation amount threshold range and the first step size;
[0124] Determine the scaling coefficient in each set of the coefficients based on the scaling amount threshold range and the second step size;
[0125] Determine the rotation angle coefficient in each set of the coefficients based on the rotation angle threshold range and the third step size.
[0126] The processing unit 302 is specifically configured to perform transformations on the top layer to the bottom layer of the first pyramid image in sequence based on at least one set of coefficients; wherein, for different serial numbers of the layers of the first pyramid image, the corresponding coefficients are different.
[0127] The determining unit 303 is specifically configured to determine the coordinate information of the second component on the image to be located based on the relative position information between the first-shaped component and the second component on the template image and the coordinate set of the first-shaped component on the image to be located; and perform transformation on the coordinate information of the second component on the image to be located based on the target coefficient, and confirm that the transformed coordinate information is the position information of the second component on the image to be located.
[0128] Figure 6 FIG. shows a schematic diagram of the hardware composition structure of an electronic device provided in an embodiment of the present application. The electronic device 700 includes: at least one processor 701, a memory 702, and at least one network unit 704. Each component in the electronic device 700 is coupled together through a bus system 705. It can be understood that the bus system 705 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 705 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 6 all kinds of buses are labeled as the bus system 705.
[0129] It can be understood that the memory 702 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be ROM, programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); the magnetic surface memory can be disk memory or tape memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), sync link dynamic random access memory (SLDRAM), direct rambus random access memory (DRRAM). The memory 702 described in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memories.
[0130] In the embodiments of the present application, the memory 702 is used to store various types of data to support the operation of the electronic device 700. Examples of such data include: any computer programs for operating on the electronic device 700, such as the application program 722. The program for implementing the method of the embodiments of the present application may be included in the application program 722.
[0131] The method disclosed in the embodiments of the present application may be applied to or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the method may be completed by the integrated logic circuit in the hardware of the processor 701 or instructions in software form. The processor 701 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 701 may implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. Combining the steps of the method disclosed in the embodiments of the present application, it may be directly embodied as being executed and completed by the hardware decoding processor, or by a combination of the hardware and software modules in the decoding processor. The software module may be located in the storage medium, which is located in the memory 702. The processor 701 reads the information in the memory 702 and combines its hardware to complete the steps of the foregoing method.
[0132] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, MCUs, MPUs, or other electronic components for executing the foregoing method.
[0133] In addition to the foregoing methods and devices, the embodiments of the present application may also be a computer program product, which includes computer program instructions that, when run by a processor, cause the processor to execute the steps in the methods according to the various embodiments of the present application described in the "Exemplary Methods" section of this specification.
[0134] The computer program product may be written in any combination of one or more programming languages for executing the program code of the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0135] In addition, an embodiment of the present application may also be a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are run by a processor, the processor is caused to execute the steps in the methods according to various embodiments of the present application described in the above "Exemplary Method" section of this specification.
[0136] The computer-readable storage medium may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0137] The basic principles of the present application have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, benefits, effects, etc. mentioned in the present application are only examples and not limitations. It cannot be considered that these advantages, benefits, effects, etc. are essential for each embodiment of the present application. Additionally, the above-disclosed specific details are only for illustrative and easy-to-understand purposes and are not limitations. The above details do not limit the present application to necessarily implement using the above specific details.
[0138] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present application are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc. are open-ended terms that mean "including but not limited to" and can be used interchangeably with each other. The word "or" and "and" used herein refer to the phrase "and / or" and can be used interchangeably with it, unless the context clearly indicates otherwise. The phrase "such as" used herein refers to the phrase "such as but not limited to" and can be used interchangeably with it.
[0139] It should also be noted that in the devices, equipment, and methods of the present application, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present application.
[0140] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
[0141] The above description has been given for purposes of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions, and sub-combinations thereof.
Claims
1. An image localization method, characterized in that, the method includes: obtaining a first pyramid image corresponding to a template image and a second pyramid image corresponding to an image to be localized; transforming each layer of the image in the first pyramid image, and when the distance between the components of the first shape in the transformed first pyramid image and the components of the first shape in the corresponding layer of the pyramid image to be localized is less than a first threshold, determining the transformation coefficient corresponding to the first pyramid image as the target coefficient, wherein calculating the average distance between the coordinates of the set of components of the first shape in the transformed first pyramid image and the coordinates of the set of components of the first shape in the image to be localized as the distance; determining the position information of the second component on the image to be localized based on the target coefficient and the relative position information between the first component of the first shape and the second component on the template image.
2. The method according to claim 1, characterized in that, before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be localized, the method further includes: determining the relative position information between the first component of the first shape and the second component on the template image.
3. The method according to claim 2, characterized in that, the determining the relative position information between the first component of the first shape and the second component on the template image includes: determining the center coordinates and diameter of the first component of the first shape on the template image; determining the coordinate information of the second component on the template image; confirming the relative position information between the first component of the first shape and the second component on the template image based on the center coordinates and diameter of the first component of the first shape on the template image and the coordinate information of the second component on the template image.
4. The method according to claim 1, characterized in that, before obtaining the first pyramid image corresponding to the template image and the second pyramid image corresponding to the image to be localized, the method further includes: determining the coordinate set of the first component of the first shape on the image to be localized.
5. The method according to claim 4, characterized in that, the determining the coordinate set of the first component of the first shape on the image to be localized includes: determining the coordinate information of the centers of at least one circle that meets the first condition on the image to be localized; clustering all the circles that meet the first condition on the image to be localized to obtain a clustering result; determining the coordinate information corresponding to the clustering result whose difference from the diameter of the first component of the first shape on the template image is less than a second threshold as the coordinate set of the first component of the first shape on the image to be localized.
6. The method according to claim 1, characterized in that, before transforming each layer of the image in the first pyramid image, the method further includes: determining at least one set of coefficients for transforming each layer of the image in the first pyramid image; each set of the coefficients includes a translation coefficient, a scaling coefficient, and a rotation angle coefficient.
7. The method according to claim 6, characterized in that, Determining at least one set of coefficients for transforming each layer image in the first pyramid image includes: Determining the translation coefficients in each set of coefficients based on a translation amount threshold range and a first step size; Determining the scaling coefficients in each set of coefficients based on a scaling amount threshold range and a second step size; Determining the rotation angle coefficients in each set of coefficients based on a rotation angle threshold range and a third step size.
8. The method according to claim 1, wherein, Transforming each layer image in the first pyramid image includes: Sequentially transforming the top layer to the bottom layer of the first pyramid image based on at least one set of coefficients; wherein, different layer numbers of the first pyramid image correspond to different coefficients.
9. The method according to claim 1, wherein, Determining the position information of the second component on the image to be located based on the target coefficients and the relative position information between the first component and the second component of the first shape on the template image includes: Determining the coordinate information of the second component on the image to be located based on the relative position information between the first component and the second component of the first shape on the template image and the coordinate set of the first component of the first shape on the image to be located; Transforming the coordinate information of the second component on the image to be located based on the target coefficients, and confirming the transformed coordinate information as the position information of the second component on the image to be located.
10. An image positioning device, wherein, The device includes: An acquisition unit, configured to acquire a first pyramid image corresponding to a template image and a second pyramid image corresponding to an image to be located; A processing unit, configured to transform each layer image in the first pyramid image, and determine the transformation coefficients corresponding to the first pyramid image as target coefficients when the distance between the components of the first shape in the transformed first pyramid image and the components of the first shape in the corresponding layer of the pyramid of the image to be located is less than a first threshold, wherein, calculating the average distance between the transformed coordinates of the set of components of the first shape in the first pyramid image and the coordinates of the set of components of the first shape in the image to be located as the distance; A determination unit, configured to determine the position information of the second component on the image to be located based on the target coefficients and the relative position information between the first component and the second component of the first shape on the template image.
11. An electronic device, wherein, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; the memory is used to store a computer program; the processor is configured to implement the method according to any one of claims 1-9 when executing the program stored on the memory.
12. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-9.
Citation Information
Patent Citations
Image registration method and device, electronic equipment and storage medium
CN112396640A