Method and apparatus for finding an object in an image
By adding regions of interest to images and adjusting target object parameters, combined with reference objects and error-proofing parameters, the problem of complex parameter adjustments in existing tools is solved. This achieves efficient and accurate target object search and unified output results, improving the tool's operational efficiency and interactivity.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2026-03-24
AI Technical Summary
Existing industrial vision tools involve cumbersome parameter adjustments and complex operations when locating multiple lines and circles in an image, resulting in an inefficient adjustment process.
By adding regions of interest to the image and adjusting the target object parameters according to user instructions, the system can accurately locate the target object using reference objects and error-proofing parameters. Combined with feature detection parameters, the system can output an array or a single element of the target object.
It simplifies the search process, improves adjustment efficiency, ensures accurate acquisition of target objects and uniform output format, and enhances the interactivity of the tool.
Smart Images

Figure CN116309399B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of industrial vision, in particular to a method and device for searching a target object in an image. BACKGROUND
[0002] In the process of vision processing in the field of industrial vision, in order to quickly measure the distance between calipers, the angle and other characteristic values, it is necessary to locate the positions of multiple lines and circles in an image. During the production of equipment, it is often necessary to adjust the parameters of the circle and line searching tool. However, the current tool interface has too many parameters, and the operation is cumbersome. It takes a certain amount of time to be familiar with it before being completely capable of operating, which leads to a cumbersome adjustment process. SUMMARY
[0003] The present application provides a method and device for searching a target object in an image.
[0004] The method for searching a target object in an image according to an embodiment of the present application comprises the following steps.
[0005] In the searching interface, a target image is obtained.
[0006] An area of interest is added in the target image, and the area of interest is moved in the target image according to a user's moving instruction.
[0007] The target object parameters are adjusted in the searching interface.
[0008] According to the target object parameters, the target object is searched in the area of interest, and the target object comprises at least one of a circle and a straight line.
[0009] In the above method, the area of interest is added in the target image in the searching interface, the target object parameters are adjusted in the searching interface, and the target object is searched in the area of interest according to the target object parameters, which can reduce the influence of other function interfaces on the searching operation and improve the efficiency of the adjustment process.
[0010] In some embodiments, according to the target object parameters, the target object is searched in the area of interest, and the target object comprises at least one of a circle and a straight line, which comprises setting one of the multiple undetermined objects found as a reference object according to a user's setting instruction; and screening the remaining undetermined objects according to the target object parameters and the reference object to obtain the target object.
[0011] In this way, the method for searching a target object in an image compares the reference object set by the area of interest with the target object parameters, so as to accurately obtain the target object.
[0012] In some embodiments, the target object parameters comprise a correction type and an allowed deviation between the reference object and the undetermined object.
[0013] Thus, the pending object is compared with the reference object by modifying the type parameter and the allowable deviation parameter to find the determined target object.
[0014] In some embodiments, the finding the target object in the region of interest according to the target object parameter, the target object including at least one of a circle and a straight line includes setting one of the found pending objects as the reference object according to the user's setting instruction; and acquiring the target object in the target image according to the target object parameter and the reference object.
[0015] Thus, the method for finding the target object in the image is adjusted by the reference object set in the region of interest, so as to find the target object matching the reference object to obtain the target object.
[0016] In some embodiments, the target object parameter includes whether the target object is parallelly deviated from the reference object and the amount of deviation.
[0017] Thus, the desired target object can be found.
[0018] In some embodiments, the target object parameter includes a foolproof parameter; and the finding the target object in the region of interest according to the target object parameter includes determining a foolproof range according to the foolproof parameter; and finding the target object in the region of interest according to the foolproof range.
[0019] Thus, the method for finding the target object in the image can find the target object in the region of interest according to the foolproof range determined by the foolproof parameter, so as to ensure that the target object can be accurately acquired when the device for finding the target object in the image fails.
[0020] In some embodiments, the foolproof parameter includes at least one of a centroid foolproof and an angle foolproof.
[0021] Thus, the target object is set by the centroid foolproof and the angle foolproof in the foolproof parameter, so as to ensure the accurate acquisition of the centroid position and the angle of the target object, and then accurately acquire the target object.
[0022] In some embodiments, the target object parameter includes a feature detection item parameter; and the method includes finding a feature item in the target object according to the feature detection item parameter, the feature item including at least one of an intersection, a midpoint and an angle.
[0023] Thus, the method for finding the target object in the image can find at least one of the intersection, the midpoint and the angle feature item, and then the feature item can be acquired.
[0024] In some embodiments, the method includes outputting an array or a single element of the found target object.
[0025] In this way, the target object can output the search result in the form of an array to ensure that the output result format of the target object is consistent with the format of the target object required by subsequent processing, thereby improving the interaction of the device for searching the target object in the image with other tools.
[0026] The present application also provides a device for searching a target object in an image. The device for searching a target object in an image comprises a processor and a memory. The memory stores a computer program which, when executed by the processor, implements the steps of the method for searching a target object in an image according to any one of the above embodiments.
[0027] The device for searching a target object in an image described above can reduce the influence of other function interfaces on the search operation and improve the efficiency of the adjustment process by adding a region of interest to the target image of the search interface, adjusting the target object parameters in the search interface, and searching the target object in the region of interest according to the target object parameters.
[0028] Additional aspects and advantages of the present application will be in part apparent and in part pointed out hereinafter. BRIEF DESCRIPTION OF DRAWINGS
[0029] The above and / or additional aspects and advantages of the present application will become apparent and be readily appreciated from the following description, including the appended drawings and claims.
[0030] Figure 1 is a flowchart of a method for searching a target object in an image according to an embodiment of the present application;
[0031] Figure 2 is a block diagram of a device for searching a target object in an image according to an embodiment of the present application;
[0032] Figure 3 is a schematic diagram of a search interface displayed by a device for searching a target object in an image according to an embodiment of the present application;
[0033] Figure 4 is a flowchart of a method for searching a target object in an image according to an embodiment of the present application;
[0034] Figure 5 is a flowchart of a method for searching a target object in an image according to an embodiment of the present application;
[0035] Figure 6 is a flowchart of a method for searching a target object in an image according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] Embodiments of the present application are described below in the accompanying drawings, wherein like numbers refer to like elements throughout. The embodiments described below are exemplary in nature, and are not intended to limit the present application, and configurational changes can be made that do not depart from the spirit of the present application.
[0037] In the description of the present application, it is to be understood that the terms "first", "second", "third" and the like, merely mean different instances and do not imply or connote relative importance or a number of the indicated technical features. Thus, a feature defined with "first", "second", "third" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "plurality" is two or more, unless otherwise explicitly and specifically defined.
[0038] In the description of the present application, it is to be understood that, unless otherwise explicitly and specifically defined, the terms "mounting", "connection", "connecting" should be understood in a broad sense, for example, can be fixed connection, can be detachable connection, or integral connection; can be mechanical connection, or electrical connection or can communicate with each other; can be directly connected, or indirectly connected through an intermediate medium, or the internal communication of two elements or the interaction relationship between two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0039] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present application. For the purpose of simplifying the present application, the components and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeatedly refer to numbers and / or letters in different examples, and such repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0040] Embodiments of the present application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar numbers represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary, only for explaining the present application, and cannot be understood as limiting the present application.
[0041] Please refer to Figure 1 and Figure 3 The embodiments of the present application provide a method for searching a target object in an image. The method for searching a target object in an image comprises:
[0042] 01: In a search interface, an image is acquired;
[0043] 03: Add a region of interest 20 to the target image, and move the region of interest 20 in the target image according to the user's movement instructions;
[0044] 05: Adjust the target object parameters in the search interface;
[0045] 07: Based on the target object parameters, locate the target object in the region of interest 20. The target object includes at least one of the circle 40 and the straight line 30.
[0046] Please combine Figure 2 This invention also provides an apparatus 10 for locating a target object in an image. The apparatus 10 includes a processor 11 and a memory 12. The memory 12 stores a computer program 121, which, when executed by the processor 11, implements the steps of the method for locating a target object in an image according to this invention.
[0047] In the above-described method for finding a target object in an image and the apparatus 10 for finding a target object in an image, a region of interest 20 is added to the target image in the search interface, the target object parameters are adjusted in the search interface, and the target object is searched in the region of interest 20 according to the target object parameters. This can reduce the impact of other functional interfaces on the search operation and improve the efficiency of the adjustment process.
[0048] Specifically, please combine Figure 3 In step 01, the target image is acquired in the search interface. In one embodiment, the target image can be acquired by a camera device, which is an image obtained by photographing the workpiece. The camera device can be, for example, an industrial camera, or other devices, without limitation. The camera device can input the image through the image-finding device 10, and then obtain the target image in the search interface.
[0049] In step 03, a region of interest (ROI) 20 is added to the target image, and the ROI 20 is moved within the target image according to the user's movement commands. Specifically, the ROI 20 can be added automatically or manually upon acquiring the target image. In one embodiment, the ROI 20 can be, for example, a line ROI, a circle ROI, or the ROI of a target object; no specific limitation is made here. Furthermore, the ROI 20 in this embodiment can be moved according to the user's movement commands. For example, the user can drag the ROI with the mouse to adjust its position, thus quickly locating the target object, such as a line 30 and / or a circle 40.
[0050] In step 05, the target object parameters are adjusted in the search interface. In one embodiment, please refer to... Figure 3The target object parameters can include attribute parameters and advanced attribute parameters. Further, attribute parameters can be, for example, contrast and edge parameters. Advanced attribute parameters can be, for example, angle limits, maximum deviation, parallel offset, correction type, allowable deviation, reference distance, and centroid settings. That is, by adjusting the target object parameters, the region of interest 20 can more accurately locate the target object. It is understood that this invention does not specifically limit the target object parameters.
[0051] In step 07, based on the target object parameters, a target object is located in the region of interest 20. The target object includes at least one of a circle 40 and a straight line 30. In one embodiment, the number of target objects found can be one, two, or more than two; no specific limitation is made here. Correspondingly, the region of interest 20 can be one, two, or more than two; no specific limitation is made here. Figure 3 As shown, there are six regions of interest (ROIs) 20, including four square regions used to locate line 30 and two circular regions used to locate circle 40. That is, the target objects that can be found within the six ROIs 20 include circle 40 and line 30. It should be noted that image processing techniques can be used to locate line 30 and / or circle 40 in the image; specific methods can be found in relevant image processing techniques, which will not be elaborated upon here.
[0052] Please see Figure 4 In some implementations, step 07 includes:
[0053] 071: Based on the user's settings, set one of the multiple undetermined objects found as the reference object;
[0054] 072: Based on the target object parameters and reference objects, the remaining undetermined objects are screened to obtain the target object.
[0055] Thus, the method of finding the target object in the image compares the parameters of the reference object set in the region of interest 20 with those of the target object, thereby accurately obtaining the target object.
[0056] Specifically, in step 071, according to the user's setting instructions, one of the multiple objects to be determined is set as a reference object. In one embodiment, the multiple objects to be determined can be, for example, four straight lines 30: top, bottom, left, and right. According to the user's setting instructions, the rightmost straight line 30 can be set as the reference object, and the other three straight lines 30 can be set as lines to be determined. It is understood that in other embodiments, according to the user's setting instructions, any one or more of the other three straight lines 30 can be set as the reference object; no specific limitation is made here. Similarly, the object to be determined can also be, for example, a circle 40. The method for setting the reference object is the same as the method for setting the reference line 30, and to avoid redundancy, it will not be described again here.
[0057] In step 072, the remaining objects to be determined can be screened based on the target object parameters and reference objects to obtain the target object. For example, in Figure 3 In the process, the line 30 among the three undetermined lines 30 (upper, lower, and left) whose relationship with the reference object conforms to the parameters of the target object is determined as the target line 30, and thus the target line 30 can be obtained.
[0058] In some implementations, the target parameters include the type of correction and permissible deviation between the reference object and the object to be determined.
[0059] In this way, the object to be determined is compared with the reference object by adjusting the type parameters and allowable deviation parameters, so as to find the definite target object.
[0060] Specifically, in one embodiment, the correction type can be parallel or inclined (including vertical and non-vertical cases), or other types, without specific limitations. The allowable deviation can be set to, for example, 0.50. That is, if the correction type parameter is parallel and the allowable deviation is 0.50, and the relationship between the object to be determined and the reference object is parallel, and the allowable deviation is less than or equal to 0.50, the object to be determined can be identified as the target object. For example, in... Figure 3 In the process of determining the three undetermined straight lines 30 (upper, lower, and left), if the relationship between the left straight line 30 and the reference object (right straight line 30) is parallel and the allowable deviation is less than or equal to 0.50, then the left straight line 30 is determined as the target straight line 30 (target object).
[0061] Please see Figure 5 In some implementations, step 07 includes:
[0062] 073: Based on the user's settings, set one of the multiple undetermined objects found as the reference object;
[0063] 074: Obtain the target object from the target image based on the target object parameters and the reference object.
[0064] Thus, the method of finding the target object in the image is adjusted by setting the reference object parameters in the region of interest 20, thereby finding the target object that matches the reference object and obtaining the target object.
[0065] Specifically, please combine Figure 3 In step 073, according to the user's setting instructions, one of the multiple undetermined objects is set as a reference object. In one embodiment, the multiple undetermined objects can be, for example, four undetermined straight lines 30 found in the ROI (top, bottom, left, and right). In one embodiment, according to the user's setting instructions, the rightmost straight line 30 can be set as the reference object. It is understood that in other embodiments, the other three straight lines 30 can also be used as reference objects (reference lines 30) according to the user's setting instructions; no specific limitation is made here. Similarly, the undetermined object can also be, for example, a circle 40. The method for setting the reference object is the same as the method for setting the reference line 30, and to avoid redundancy, it will not be described again here.
[0066] In step 074, the target object is acquired in the target image based on the target object parameters and the reference object. In one embodiment, the reference object can be the selected right-hand straight line 30. The target object can be acquired based on the relationship between the target object and the reference object. For example, in a Region of Interest (ROI), undetermined objects whose relationship with the reference object satisfies the target object parameters are found, and these undetermined objects are identified as the target objects. In one embodiment, the target object can exist in the region of interest (ROI) 20, or it can exist in other image locations outside the ROI 20.
[0067] In some implementations, the target parameters include whether the target and the reference object are parallel and offset, and the amount of offset.
[0068] In this way, you can find the target you want.
[0069] Specifically, such as Figure 3 As shown, the maximum deviation of the parallel offset is 10.0. In one embodiment, the target object parameters include a parallel offset relationship between the target object and the reference object, with an offset amount of 0.20. Figure 3 In the process, the right straight line 30 can be used as a reference object (reference line 30). Based on the above target object parameters, and using the reference object as a reference, a target object parallel to the reference object and offset by 0.2 can be found in the image.
[0070] Please see Figure 6 In some implementations, the target object parameters include mistake-proofing parameters. Step 07 includes:
[0071] 075: Determine a mistake-proof range based on the mistake-proof parameters;
[0072] 076: Based on the error prevention range, search for the target object in region of interest 20.
[0073] Thus, the method for finding a target object in an image can search for the target object in the region of interest 20 according to the error-proof range determined by the error-proof parameters, so as to ensure that the target object can be accurately obtained through the error-proof parameters when the device 10 for finding a target object in the image fails.
[0074] Specifically, in step 075, a mistake-proofing range is determined based on the mistake-proofing parameters. In one embodiment, the mistake-proofing parameters are used to minimize the possibility of errors occurring during the target object search process. The mistake-proofing parameters may include centroid mistake-proofing parameters and angle mistake-proofing parameters. That is, the centroid mistake-proofing parameters can reduce the probability of centroid anomalies during the target object search process. The angle mistake-proofing parameters can reduce the probability of angular anomalies during the target object search process. For example... Figure 3 As shown, the angle of the right-hand straight line 30 can be, for example, 85.906, and the allowable deviation is 0.50. Then the error-proof range of the angle of the right-hand straight line 30 is 85.406 to 86.406. The calculation of other error-proof parameter ranges is the same, and will not be repeated here.
[0075] In step 076, the target object is located in the region of interest 20 according to the error prevention range. In one embodiment, assuming that a straight line 30 in the region of interest 20 is in the range of 85.406 to 86.406, the straight line 30 can be identified as the target object in the region of interest 20.
[0076] In some implementations, the error prevention parameters include at least one of centroid error prevention and angle error prevention.
[0077] In this way, by setting the centroid error prevention and angle error prevention parameters, the target object's centroid position and angle can be accurately obtained, thereby accurately acquiring the target object.
[0078] Specifically, the centroid error-proof parameter can be used to determine the position of the centroid to prevent inaccurate location of the target centroid when the search tool malfunctions, thereby affecting the acquisition of the target object.
[0079] Similarly, the angle error-proof parameter can be used to determine the angle of the target object to prevent inaccurate angle finding when the search tool malfunctions, thus affecting the acquisition of the target object.
[0080] In other words, the error prevention parameters can include the centroid error prevention parameter alone, the angle error prevention parameter alone, or both the centroid error prevention parameter and the angle error prevention parameter at the same time, in order to ensure the accurate acquisition of the target object.
[0081] In some implementations, the target object parameters include feature detection term parameters. Methods for locating targets in an image include:
[0082] Based on the feature detection parameters, feature items are searched for on the target object. Feature items include at least one of intersection point, midpoint, and angle.
[0083] Thus, the method for finding a target object in an image can obtain the feature by finding at least one of the features of intersection, midpoint, and angle.
[0084] Specifically, in one implementation, the feature terms are a set of edges of the target object, and the feature terms include basic attributes such as the type and value of the target object. The method for finding the feature terms of the target object can be, for example, an edge-based extraction algorithm.
[0085] In detail, edge-based extraction algorithms can use endpoints of the target object, or points on the edges of the target object with significant curvature changes, as feature terms. In embodiments of this invention, feature terms can be, for example, intersections, midpoints, or angles. Because feature terms are a set of target object edges, edge extraction algorithms require high precision. Therefore, edge extraction algorithms can accurately locate feature terms, thereby ensuring the accuracy of the detection results.
[0086] In other words, edge-based extraction algorithms can find at least one of the following features: intersection, midpoint, and angle. The feature to be found depends on the feature detection parameters and the user's search requirements. For example, based on the user's instructions, it can search for any one of the intersection, midpoint, and angle features individually, or it can search for any two of the intersection, midpoint, and angle features, or it can search for the intersection, midpoint, and angle features simultaneously.
[0087] In some implementations, the method for locating a target object in an image includes:
[0088] Output an array or a single element of the found target objects.
[0089] In this way, the target object can be output as an array to ensure that the output format of the target object is consistent with the format of the target object required for subsequent processing, thereby improving the interactivity of the device 10 for finding target objects in the image with other tools.
[0090] Specifically, in one implementation, the array of targets can be, for example, an array of lines, an array of line segments, and an array of points, or a single element can be output.
[0091] In detail, the line array can include multiple target lines 30. In each line segment array, multiple target lines are connected end to end to form a single line.
[0092] Point arrays can include intersection arrays and midpoint arrays, etc. That is, the intersections of feature terms can be output as a one-dimensional array using the intersection array. The midpoints of feature terms can be output as a one-dimensional array using the midpoint array.
[0093] In addition, a single element can also be output. A single element can be, for example, a straight line (30) or a circle (40).
[0094] In summary, the method of the present invention can diversify the output results of the target object, and the corresponding output format can be selected according to the user's needs, so that the device 10 for finding the target object in the image can match the format of the target object required by the subsequent processing tools, thereby improving interactivity.
[0095] In one implementation, such as Figure 3 As shown, Figure 3 This is the search interface for the multi-circle, multi-line search tool.
[0096] The multi-circle, multi-line search tool integrates advanced line-finding tools, circle-finding tools, geometric positioning tools, and feature detection tools. With high integration and comprehensive functionality, it not only simplifies the operation process but also allows users to customize whether to associate the multi-circle, multi-line search tool with the geometric positioning tool. In other words, this flexible association can solve more on-site application problems, thereby improving the tool's operational efficiency.
[0097] In addition, the output results of the multi-circle and multi-line search tool are unified. For example, it can flexibly select one of the result formats, such as line array, line segment array, point array, and single element, to output the result uniformly. This facilitates the interaction of the output results of the target object with other tools and makes it more convenient for users.
[0098] Specifically, the device 10 for locating target objects in an image can be applied to industrial vision equipment. Industrial vision equipment includes, but is not limited to, industrial cameras, vision robots, etc. Industrial vision equipment is widely used in visual positioning, product measurement, and equipment inspection.
[0099] Understandably, the computer-readable storage medium in the embodiments of this application may include a USB flash drive, a portable hard drive, a recording medium, a magnetic disk, an optical disk, and a computer memory, etc. That is, the computer-readable storage medium in the embodiments of this application stores target image data in the form of a computer program, which is executed by a processor to implement the aforementioned method for finding the target object in an image.
[0100] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.
Claims
1. A method for locating a target object in an image, characterized in that, include: In the search interface, retrieve the target image; Add a region of interest to the target image, and move the region of interest in the target image according to the user's movement instructions; Adjust the target object parameters on the search interface; Based on the target object parameters, the target object is located in the region of interest, wherein the target object includes at least one of a circle and a straight line; The step of locating the target object in the region of interest based on the target object parameters, wherein the target object includes at least one of a circle and a straight line, includes: Based on the user's settings, one of the multiple undetermined objects found is set as the reference object; The remaining objects to be determined are screened based on the target object parameters and the reference object to obtain the target object; The target object parameters include the correction type and allowable deviation between the reference object and the object to be determined; The target object parameters include error-proofing parameters; The step of searching for the target object in the region of interest based on the target object parameters includes: Based on the aforementioned error prevention parameters, a error prevention range is determined; Based on the error prevention range, locate the target object in the region of interest.
2. The method for locating a target object in an image according to claim 1, characterized in that, The step of locating the target object in the region of interest based on the target object parameters, wherein the target object includes at least one of a circle and a straight line, includes: Based on the user's settings, one of the multiple undetermined objects found is set as the reference object; The target object is obtained from the target image based on the target object parameters and the reference object.
3. The method for finding a target object in an image according to claim 2, characterized in that, The target object parameters include whether the target object and the reference object are parallel and offset, and the amount of offset. Based on the error prevention range, locate the target object in the region of interest.
4. The method for finding a target object in an image according to claim 1, characterized in that, The error prevention parameters include at least one of centroid error prevention and angle error prevention.
5. The method for locating a target object in an image according to claim 1, characterized in that, The target object parameters include feature detection item parameters; The method includes: Based on the feature detection parameters, feature items are searched on the target object, and the feature items include at least one of intersection point, midpoint and angle.
6. The method for locating a target object in an image according to claim 1, characterized in that, The method includes: Output an array or a single element of the found target objects.
7. A device for locating a target object in an image, characterized in that, include: Processor, and; A memory storing a computer program that, when executed by the processor, implements the steps of the method for finding a target object in an image as described in any one of claims 1-6.
Citation Information
Patent Citations
Automatic visual detection method and device for display screen
CN110987938A
Mold state monitoring method and device, industrial personal computer, storage medium and system
CN112837302A