Object positioning method, device, electronic device and readable storage medium
By obtaining the initial recognition radius and edge point data set to generate the target fitting circle, the problem of accurate positioning of occluded objects is solved, and efficient and accurate object recognition and positioning are achieved, which is suitable for fruit picking.
Patent Information
- Application Number
- CN202210658238.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-10
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-06-10
AI Technical Summary
Existing technologies are unable to accurately and efficiently identify and locate obscured objects, resulting in a low fruit picking rate.
By obtaining the initial recognition radius and edge point data set of the object to be identified, a target fitting circle is generated, and the position of the object is determined based on the target fitting circle, the initial recognition error is eliminated or reduced, and accurate and efficient object recognition and positioning are achieved.
Even when the object contour is incomplete or part of the contour is missing, the initial recognition radius and edge point data can still be accurately obtained, improving the accuracy and efficiency of object recognition and ensuring that the recognition process does not increase the running time.
Smart Images

Figure CN114998274B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method and device for locating an object, an electronic device, and a readable storage medium. Background Art
[0002] With the development of science and technology and the continuous improvement of people's living standards, people's demand for fresh fruit has gradually increased, and the economic benefits brought by fruit have also increased year by year. Because fruit is rich in vitamins and dietary fiber, it is deeply loved by people. However, due to the relatively short ripening cycle of fruit and its high timeliness, the fruit needs to be picked as soon as it matures. Currently, most fruit picking operations still rely on manual labor. This manual fruit picking method is time-consuming and inefficient. Moreover, with the increasingly serious problems of an aging population and labor shortages, manual fruit picking can no longer meet current needs. Therefore, accelerating the process of automated fruit picking is urgent.
[0003] Accurately identifying and locating fruit is a critical step in automated fruit harvesting. However, in natural environments, fruit is often obscured by branches and leaves, resulting in incomplete or missing outlines of the fruit to be identified, posing a significant challenge to fruit identification and positioning. Existing methods for identifying and locating overlapping and obscured fruit increase runtime to improve accuracy, making it impossible to identify and locate the fruit in real time, leading to a slow fruit harvesting rate.
[0004] Therefore, how to accurately and efficiently identify and locate obscured objects is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the Invention
[0005] The present invention provides an object positioning method, device, electronic device and readable storage medium to solve the defect in the prior art that obscured objects cannot be accurately and efficiently identified and positioned, thereby achieving accurate and efficient identification and positioning of obscured objects and improving the automatic extraction rate of obscured objects.
[0006] The present invention provides an object positioning method, comprising: acquiring an original captured image of an object to be identified, and extracting a contour image corresponding to the object to be identified from the original captured image; acquiring an initial recognition radius of the object to be identified in the contour image and an edge point data set of the contour image, wherein the edge point data set includes a plurality of contour edge points; generating a target fitting circle of the object to be identified based on the edge point data set and the initial recognition radius, wherein the target fitting circle is used to fit the shape of the object to be identified; and determining a target position of the object to be identified in the contour image based on the target fitting circle.
[0007] According to a method for positioning an object provided by the present invention, obtaining the initial recognition radius of the object to be identified in the contour image includes: scanning the contour image and obtaining coordinate difference data of two external contour edge points in the same scanning direction in the contour image; generating a coordinate difference curve of the object contour corresponding to the object to be identified based on the coordinate difference data; and determining the initial recognition radius of the object to be identified based on the coordinate difference curve.
[0008] According to a method for positioning an object provided by the present invention, obtaining the initial recognition radius of the object to be identified in the contour image includes: obtaining the number of objects of the object to be identified in the contour image; when the number of objects is one, scanning the contour image in a horizontal scanning direction and a longitudinal scanning direction, and obtaining coordinate difference data of two external contour edge points in the same scanning direction in the contour image; generating a coordinate difference curve of the object contour corresponding to the object to be identified based on the coordinate difference data; obtaining the peak value of the coordinate difference curve, and determining the initial recognition radius of the object to be identified based on a preset first ratio and the peak value.
[0009] According to a method for positioning an object provided by the present invention, obtaining the initial recognition radius of the object to be identified in the contour image includes: obtaining the number of objects of the object to be identified in the contour image; when the number of objects is at least two, obtaining the maximum coordinate difference of the object contour in the contour image; determining the object distribution posture of at least two objects to be identified based on the maximum coordinate difference and a preset coordinate difference threshold, and determining a target scanning direction based on the object distribution posture; scanning the contour image in the target scanning direction, and obtaining coordinate difference data of two external contour edge points in the same scanning direction in the contour image; generating a coordinate difference curve of the object contour corresponding to the object to be identified based on the coordinate difference data; and determining the initial recognition radius of the first object to be identified based on the coordinate difference curve and the object distribution posture.
[0010] According to a method for positioning an object provided by the present invention, the target fitting circle of the object to be identified is generated based on the edge point dataset and the initial recognition radius, including: selecting multiple contour edge points from the edge point dataset as initial fitting edge points, the number of the initial fitting edge points being greater than or equal to three; generating an initial fitting circle of the object to be identified based on the initial fitting edge points, and determining whether the radius of the initial fitting circle is within a first tolerance range of the initial recognition radius; if the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, obtaining all contour edge points within a second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and using the inner points of the initial fitting circle as target fitting edge points; and generating a target fitting circle of the object to be identified based on the target fitting edge points.
[0011] According to a method for positioning an object provided by the present invention, the method generates a target fitting circle of the object to be identified based on the edge point dataset and the initial recognition radius, comprising: when the number of the objects is at least two, generating an initial fitting circle of the first object to be identified based on the initial recognition radius of the first object to be identified and the edge point dataset; obtaining all contour edge points within a second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and obtaining a current remaining edge point dataset; using the inner points of the initial fitting circle as target fitting edge points of the first object to be identified, and generating a target fitting circle of the first object to be identified based on the target fitting edge points; scanning the current remaining edge point dataset to obtain an initial recognition radius of a second object to be identified, and generating a target fitting circle of the second object to be identified based on the initial recognition radius and the current remaining edge point dataset; updating the current remaining edge point dataset, and repeating the steps of obtaining the initial recognition radius and generating the target fitting circle based on the updated current remaining edge point dataset until a target fitting circle of each object to be identified is generated.
[0012] According to a method for locating an object provided by the present invention, extracting a contour image corresponding to the object to be identified from the original acquired image includes: performing morphological opening operation and filtering processing on the original acquired image to obtain a preprocessed image; segmenting the object image area and the background image area in the preprocessed image based on a preset color difference analysis method to extract an object area image from the preprocessed image; performing morphological closing operation and threshold area elimination processing on the object area image to obtain a target binary image; and extracting a contour image corresponding to the original acquired image from the target binary image.
[0013] The present invention also provides an object positioning device, comprising: a contour extraction module, used to obtain an original captured image of an object to be identified, and extract a contour image corresponding to the object to be identified from the original captured image; an initial recognition module, used to obtain an initial recognition radius of the object to be identified in the contour image and an edge point data set of the contour image, wherein the edge point data set includes multiple contour edge points; a target fitting module, used to generate a target fitting circle of the object to be identified based on the edge point data set and the initial recognition radius, wherein the target fitting circle is used to fit the shape of the object to be identified; and a position recognition module, used to determine the target position of the object to be identified in the contour image based on the target fitting circle.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-described object positioning methods is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned object positioning methods when executed by a processor.
[0016] The object positioning method, device, electronic device, and readable storage medium provided by the present invention achieve initial recognition of the object to be identified by obtaining the initial recognition radius of the object to be identified in the contour image, and combine the initial recognition radius with the actual contour edge points of the object contour corresponding to the object to be identified to achieve target recognition of the object to be identified, thereby eliminating or reducing errors generated during the initial object recognition process, obtaining a relatively accurate target object recognition result, and ensuring the accuracy of object recognition. In addition, since the object positioning method adopted in the present invention can still obtain the initial recognition radius and edge point data set when the object contour is incomplete or part of the object contour is missing, and target object recognition is performed based on the initial recognition radius and edge point data set, the recognition process is not affected by the incomplete object contour or the missing part of the object contour. Moreover, the present invention can obtain an accurate target position by combining two object recognition processes, so the running time is not increased to improve the recognition accuracy, the efficiency of object recognition is guaranteed, and the accurate and efficient recognition and positioning of obscured objects is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is one of the flow charts of the object positioning method provided by the present invention;
[0019] Figure 2 This is the second flow chart of the object positioning method provided by the present invention;
[0020] Figure 3a This is the third flow chart of the object positioning method provided by the present invention;
[0021] Figure 3b is a schematic diagram of scanning in a horizontal scanning direction in an embodiment of the present invention;
[0022] Figure 3c is a schematic diagram of scanning in a longitudinal scanning direction in an embodiment of the present invention;
[0023] Figure 3d is a schematic diagram of a transverse coordinate difference curve in an embodiment of the present invention;
[0024] Figure 3e is a schematic diagram of a longitudinal coordinate difference curve in an embodiment of the present invention;
[0025] Figure 4a This is the fourth flow chart of the object positioning method provided by the present invention;
[0026] Figure 4b Schematic diagram of a coordinate difference curve of a lateral distribution posture in an embodiment of the present invention;
[0027] Figure 4c Schematic diagram of a coordinate difference curve of a longitudinal distribution posture in an embodiment of the present invention;
[0028] Figure 4d Schematic diagram of a coordinate difference curve of an oblique distribution posture in an embodiment of the present invention;
[0029] Figure 5 This is the fifth flow chart of the object positioning method provided by the present invention;
[0030] Figure 6 This is the sixth flow chart of the object positioning method provided by the present invention;
[0031] Figure 7 This is the seventh flow chart of the object positioning method provided by the present invention;
[0032] Figure 8a is a schematic diagram of a contour image of a single object to be identified in the second specific embodiment of the present invention;
[0033] Figure 8b is a schematic diagram of a target fitting circle of a single object to be identified in the second specific embodiment of the present invention;
[0034] Figures 8c to 8d is a schematic diagram of target fitting circles of two objects to be identified in the second specific embodiment of the present invention;
[0035] Figure 9 It is a structural schematic diagram of the positioning device of an object provided by the present invention;
[0036] Figure 10 It is a structural schematic diagram of the electronic device provided by the present invention.
[0037] Reference numerals:
[0038] 100: Object positioning device; 10: Contour extraction module; 20: Initial recognition module; 30: Target fitting module; 40: Position recognition module; 1010: Processor; 1020: Communication interface; 1030: Memory; 1040: Communication bus. DETAILED DESCRIPTION
[0039] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0040] The following combination Figure 1-Figure 7 The object positioning method of the present invention is described. Figure 1 As shown, the present invention provides a method for positioning an object, including.
[0041] Step S1: obtaining an original captured image of an object to be identified, and extracting a contour image corresponding to the object to be identified from the original captured image.
[0042] The original captured image represents an image of the object to be identified, captured by an image acquisition device in a natural scene. The shape of the object to be identified in the present invention can be circular, or other shapes similar to a circle, or other shapes that can be enclosed by a circle. The present invention does not impose any specific restrictions on the shape of the object to be identified. The object to be identified in the present invention can be fruit, such as apples, pears, and citrus fruits, or vegetables such as tomatoes; it can also be an object, such as a lantern, etc., without any specific restrictions in the present invention.
[0043] Step S2: obtaining an initial recognition radius of the object to be recognized in the contour image and an edge point dataset of the contour image, wherein the edge point dataset includes a plurality of contour edge points.
[0044] The contour edge points represent the edge points of the object contour in the contour image.
[0045] Step S3: generating a target fitting circle of the object to be identified based on the edge point data set and the initial recognition radius, where the target fitting circle is used to fit the shape of the object to be identified.
[0046] The initial recognition radius represents the initial recognition radius of the object's contour, obtained by recognizing the object's contour in the contour image. This radius is the result of the image recognition algorithm, and there is a certain error between it and the actual radius of the object. The contour edge points represent the actual edge points of the object's contour.
[0047] It should be noted that the object positioning method provided by the present invention does not directly use the initial object recognition result for object positioning, but instead performs target object recognition by combining the initial recognition radius and the edge point data set of the real object contour to eliminate or reduce the errors generated in the initial object recognition process, thereby obtaining a more accurate target object recognition result.
[0048] Step S4: determining the target position of the object to be identified in the contour image based on the target fitting circle.
[0049] Furthermore, the target position of the object to be identified can be determined based on the center coordinates and radius of the target fitting circle.
[0050] Furthermore, if the shape of the object to be identified is similar to a circle, the shape of the object to be identified can be approximated as a circle for processing. If the shape of the object to be identified is other shapes that can be enclosed by a circle, the longest distance from the center point to the edge point of the object contour is used as the initial recognition radius of the object contour, the circumscribed circle of the object contour is used as the target fitting circle of the object to be identified, and the center point and radius of the target fitting circle and the edge points on the target fitting circle that coincide with the edge points of the contour are used to determine the target position of the object to be identified.
[0051] In the above steps S1 to S4, the initial recognition radius of the object to be identified in the contour image is obtained to achieve the initial recognition of the object to be identified, and the initial recognition radius is combined with the actual contour edge points of the object contour corresponding to the object to be identified to achieve the target recognition of the object to be identified, so as to eliminate or reduce the error generated in the initial object recognition process, obtain a relatively accurate target object recognition result, and ensure the accuracy of object recognition. In addition, since the object positioning method adopted in the present invention can still obtain the initial recognition radius and edge point data set when the object contour is incomplete or part of the object contour is missing, and perform target object recognition based on the initial recognition radius and edge point data set, the recognition process is not affected by the incomplete object contour or the missing part of the object contour, and the present invention can obtain an accurate target position by combining the two object recognition processes, so the running time will not be increased to improve the recognition accuracy, the efficiency of object recognition is guaranteed, and the accurate and efficient recognition and positioning of the obscured object is achieved.
[0052] In addition, the present invention fits the shape of the object to be identified by acquiring a target fitting circle, and can accurately acquire the target position of the object to be identified based on the target fitting circle, thereby further improving the accuracy of object recognition.
[0053] In one embodiment, Figure 2 As shown, the above step S2 includes steps S211 to S213, wherein.
[0054] Step S211 : Scan the contour image and obtain coordinate difference data of two external contour edge points in the same scanning direction in the contour image.
[0055] Among them, the coordinate difference data includes multiple sets of coordinate differences. The coordinate difference represents the difference between the coordinates of two external contour edge points in the same scanning direction in the contour image, including the horizontal coordinate difference and the vertical coordinate difference. The coordinate difference can be used to represent the intercept or chord length corresponding to the two external contour edge points in the same scanning direction in the object contour. The external contour edge point represents the edge point of the outer edge of the object contour in the contour image, and the opposite is the internal contour edge point. The internal contour edge point represents the edge point of the inner edge of the object contour in the contour image. Since the object to be identified is easily obscured by other objects, an internal edge line is formed in the object contour. Therefore, the internal contour edge point is the edge point formed in the object contour when other objects obscure the object to be identified, and the external contour edge point is the edge point of the outer contour of the object to be identified itself.
[0056] In addition, the two external contour edge points may also be referred to as the two contour edge points that are farthest apart in the same scanning direction, or as the two contour edge points with the largest and smallest coordinate values in the same scanning direction.
[0057] Step S212: generating a coordinate difference curve corresponding to the object contour of the object to be identified based on the coordinate difference data.
[0058] The coordinate difference curve may be used to represent a curve of changes in the intercepts or chord lengths of two external contour edge points in the same scanning direction in the object contour.
[0059] Step S213: determining an initial recognition radius of the object to be recognized based on the coordinate difference curve.
[0060] Furthermore, the coordinate difference curve is smoothed to eliminate burrs in the coordinate difference curve and improve the smoothness of the coordinate difference curve, so as to facilitate subsequent determination of the initial recognition radius of the object to be recognized based on the coordinate difference curve.
[0061] It should be noted that by intuitively analyzing the coordinate difference curve, the initial recognition radius of the object to be recognized can be determined from the corresponding intercepts or chord lengths of two external contour edge points in the same scanning direction in the object contour.
[0062] In the above steps S211 to S213, by generating a coordinate difference curve corresponding to the object contour of the object to be identified based on the coordinate difference data, the change curve of the corresponding intercept or chord length of multiple sets of external contour edge points in the object contour can be analyzed based on the coordinate difference curve, so that the initial recognition radius of the object to be identified can be determined very conveniently and intuitively from the corresponding intercept or chord length of multiple sets of external contour edge points in the object contour. The entire initial recognition process is simple to operate and easy to implement, and the initial recognition result depends on the actual coordinate difference data obtained based on the scanned contour image and the change curve of the corresponding intercept or chord length in the object contour, which can ensure the reliability of the initial recognition radius. In addition, by selecting external contour edge points to generate the coordinate difference curve, the present invention can avoid the interference of internal contour edge points formed by occlusion of the object to be identified on the recognition process, thereby obtaining a more accurate object recognition result and further improving the accuracy of object recognition.
[0063] In one embodiment, Figure 3a As shown, the above step S2 includes steps S221 to S224, wherein.
[0064] Step S221 , obtaining the number of objects to be identified in the contour image.
[0065] Step S222 : when the number of objects is one, the contour image is scanned in the horizontal scanning direction and the vertical scanning direction, and coordinate difference data of two outer contour edge points in the contour image in the same scanning direction are obtained.
[0066] Further, the identification of apples is taken as an example to illustrate step S222. Figure 3b As shown, the contour image is scanned in the horizontal scanning direction to obtain the horizontal coordinate difference data of two external contour edge points in the same scanning direction in the contour image. Figure 3c As shown, the contour image is scanned in the longitudinal scanning direction to obtain longitudinal coordinate difference data of two external contour edge points in the same scanning direction in the contour image.
[0067] Step S223 : generating a coordinate difference curve of the object contour corresponding to the object to be identified based on the coordinate difference data.
[0068] Further, the identification of apples is taken as an example to illustrate step S223. Figure 3d As shown in FIG, based on the horizontal coordinate difference data, a horizontal coordinate difference curve of the object contour corresponding to the object to be identified is generated. Figure 3e As shown, based on the longitudinal coordinate difference data, a longitudinal coordinate difference curve of the object contour corresponding to the object to be identified is generated.
[0069] Step S224 , obtaining the peak value of the coordinate difference curve, and determining the initial recognition radius of the object to be recognized based on the preset first ratio and the peak value.
[0070] Furthermore, the peak value of the coordinate difference curve is multiplied by the preset first ratio to obtain the initial recognition radius of the object to be identified. The peak value of the coordinate difference curve represents the longest intercept or chord length among the corresponding intercepts or chord lengths of two external contour edge points in the object contour in the same scanning direction. Therefore, the longest intercept or chord length is used as the initial recognition diameter of the object to be identified, and the preset first ratio is multiplied by the peak value of the coordinate difference curve to obtain the initial recognition radius of the object to be identified.
[0071] In the above steps S221 to S224, the number of objects to be identified in the contour image is obtained, and when the number of objects to be identified is one, the target scanning direction is adaptively determined to be the horizontal scanning direction and the vertical scanning direction to scan the contour image, so as to accurately obtain the coordinate difference data of two external contour edge points in the same scanning direction in the contour image, thereby improving the accuracy of the initial recognition result.
[0072] In one embodiment, because the peak of the coordinate difference curve is the initial recognition diameter of the object to be recognized, rather than the actual diameter of the object to be recognized, the initial recognition diameter has a certain error compared to the actual diameter. Therefore, an appropriate preset first ratio can be set based on recognition experience data to minimize the error between the initial recognition diameter and the actual diameter, thereby improving the relative accuracy of the initial recognition radius. The recognition experience data includes the initial recognition diameter, the actual diameter, the preset first ratio, the initial recognition radius, and the actual radius.
[0073] In one embodiment, Figure 4a As shown, the above step S2 includes steps S231 to S236, wherein.
[0074] Step S231 , obtaining the number of objects to be identified in the contour image.
[0075] Step S232 : when the number of objects is at least two, obtaining the maximum coordinate difference of the object contours in the contour image.
[0076] Furthermore, the maximum coordinate difference includes a maximum abscissa difference and a maximum ordinate difference. The maximum abscissa difference represents the coordinate difference between the maximum abscissa and the minimum abscissa of the object contour in the contour image. The maximum ordinate difference represents the coordinate difference between the maximum ordinate and the minimum ordinate of the object contour in the contour image.
[0077] Step S233 determines the object distribution posture of at least two objects to be identified based on the maximum coordinate difference and a preset coordinate difference threshold, and determines a target scanning direction based on the object distribution posture. Specifically, if there are at least two objects to be identified, the maximum coordinate difference of the object contours corresponding to the two objects to be identified is obtained, and the object distribution posture of the two objects to be identified is determined based on the maximum coordinate difference and the preset coordinate difference threshold. The target scanning direction is then determined based on the object distribution posture, and the object contours corresponding to the two objects to be identified are scanned based on the target scanning direction.
[0078] Furthermore, the preset coordinate difference threshold includes an upper coordinate difference threshold and a lower coordinate difference threshold. The object distribution posture includes a horizontal distribution posture, a vertical distribution posture and an oblique distribution posture.
[0079] Step S234 , scanning the contour image in the target scanning direction, and obtaining coordinate difference data of two external contour edge points in the contour image in the same scanning direction.
[0080] Step S235 : generating a coordinate difference curve corresponding to the object contour of the object to be identified based on the coordinate difference data.
[0081] Step S236 : determining an initial recognition radius of the first object to be recognized based on the coordinate difference curve and the object distribution posture.
[0082] In one embodiment, when there are at least three objects, the first two objects to be identified are grouped together, and the maximum coordinate difference of the object contours corresponding to the first two objects to be identified is obtained to determine the object distribution posture of the first two objects to be identified. The object contours corresponding to the first two objects to be identified are scanned to obtain coordinate difference data, and based on the coordinate difference data and the object distribution posture, an initial recognition radius of the first object to be identified is determined. A current remaining edge point dataset is obtained, and the next two objects to be identified are grouped together. The object distribution posture of the next two objects to be identified is determined based on the current remaining edge point dataset, and the object contours corresponding to the next two objects to be identified are scanned. Based on the obtained coordinate difference data and the object distribution posture, an initial recognition radius of the second object to be identified is determined. The current remaining edge point dataset is updated, and the updated current remaining edge point dataset is scanned to obtain the initial recognition radius of the third object to be identified. Furthermore, when there are more than three objects, the identification and positioning method for the three objects to be identified described in the above embodiment may be used, and this invention will not be further described.
[0083] In the above steps S231 to S236, by obtaining the number of objects to be identified in the contour image, and when the number of objects is at least two, obtaining the object distribution postures of multiple objects to be identified, and adaptively determining the target scanning direction based on the object distribution posture to scan the contour image, the coordinate difference data of two external contour edge points in the same scanning direction in the contour image can be accurately obtained, thereby improving the accuracy of the initial recognition result.
[0084] In one embodiment, step S233 includes: obtaining the difference between the maximum horizontal coordinate difference and the maximum vertical coordinate difference; if the difference is greater than an upper coordinate difference threshold, determining that the object distribution posture of the two objects to be identified is a horizontal distribution posture; if the difference is less than a lower coordinate difference threshold, determining that the object distribution posture of the two objects to be identified is a vertical distribution posture; if the difference is greater than the lower coordinate difference threshold and less than the upper coordinate difference threshold, determining that the object distribution posture of the two objects to be identified is an oblique distribution posture. If the object distribution posture is a horizontal distribution posture or an oblique distribution posture, determining the target scanning direction is a horizontal scanning direction; if the object distribution posture is a vertical distribution posture, determining the target scanning direction is a vertical scanning direction.
[0085] In one embodiment, step S236 includes: when the object distribution posture is a horizontal distribution posture or a vertical distribution posture, obtaining a peak value in the coordinate difference curve, and determining an initial recognition radius of the first object to be identified based on a preset second ratio and the peak value. When the object distribution posture is an oblique distribution posture, obtaining a maximum peak value in the coordinate difference curve, obtaining a difference between the maximum peak value and a preset fixed pixel threshold, and determining the initial recognition radius of the first object to be identified based on a preset third ratio and the difference value.
[0086] Furthermore, taking the recognition of apple as an example to illustrate step S236, when the object distribution posture is a horizontal distribution posture or a vertical distribution posture, there are two peaks in the coordinate difference curve, among which the coordinate difference curve corresponding to the horizontal distribution posture (such as Figure 4b As shown), the coordinate difference curve corresponding to the longitudinal distribution posture is as follows Figure 4c As shown, a peak value can be arbitrarily selected and combined with the preset second ratio to obtain the initial recognition radius of the first object to be recognized. In the case where the object distribution posture is an oblique distribution posture, there may be three peaks in the coordinate difference curve (such as Figure 4d As shown), by analyzing the peak value of the coordinate difference curve and determining a suitable preset fixed pixel threshold based on experiments, the initial recognition diameter of the object to be identified can be obtained according to the difference between the maximum peak value and the preset fixed pixel threshold, and the preset third ratio is multiplied by the difference to obtain the initial recognition radius of the first object to be identified.
[0087] Optionally, the preset first ratio, the preset second ratio, and the preset third ratio are set to 0.5.
[0088] In one embodiment, Figure 5 As shown, the above step S3 includes steps S311 to S314, wherein.
[0089] Step S311 : Select multiple contour edge points from the edge point data set as initial fitting edge points, where the number of the initial fitting edge points is greater than or equal to three.
[0090] Step S312: generating an initial fitting circle of the object to be identified based on the initial fitting edge points, and determining whether the radius of the initial fitting circle is within a first tolerance range of the initial identification radius.
[0091] The first tolerance range represents the maximum error range allowed for the initial recognition radius. By controlling the radius of the initial fitting circle within the first tolerance range of the initial recognition radius, the radius of the initial fitting circle is made to match the initial recognition radius as closely as possible, thereby reducing the error of the initial fitting circle.
[0092] It should be noted that, according to the three-point circle determination principle, three non-collinear initial fitting edge points can determine an initial fitting circle, so the number of initial fitting edge points must be at least three. Of course, the number of initial fitting edge points can be greater than three, as long as the initial fitting circle of the object to be identified can be generated based on the selected initial fitting edge points.
[0093] Step S313, when the radius of the initial fitting circle is within the first tolerance range of the initial identification radius, all contour edge points within the second tolerance range of the initial fitting circle are obtained from the edge point dataset as the inner points of the initial fitting circle, and the inner points of the initial fitting circle are used as target fitting edge points.
[0094] Furthermore, when the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, multiple contour edge points are reselected from the edge point data set as initial fitting edge points until the radius of the initial fitting circle generated by the initial fitting edge points is within the first tolerance range of the initial recognition radius.
[0095] The second tolerance range represents the maximum allowable error range for the initial fitting circle. By obtaining all contour edge points within the second tolerance range of the initial fitting circle as the interior points of the initial fitting circle, we can ensure that the selected target fitting edge points fall as much as possible inside the initial fitting circle, thereby improving the reliability of the target fitting edge points and, in turn, the accuracy of the target fitting circle.
[0096] Step S314: generating a target fitting circle of the object to be identified based on the target fitting edge points.
[0097] In steps S311 to S314, the radius of the initial fitting circle is controlled within the first tolerance range of the initial identification radius, so that the radius of the initial fitting circle coincides with the initial identification radius as closely as possible. This reduces the error of the initial fitting circle and improves the accuracy of the initial fitting circle. By obtaining all contour edge points within the second tolerance range of the initial fitting circle as the interior points of the initial fitting circle, it is ensured that the selected target fitting edge points fall as close to the interior of the initial fitting circle as possible, thereby improving the reliability of the target fitting edge points and, consequently, the accuracy of the target fitting circle.
[0098] In one embodiment, the above step S3 includes: in one iteration, traversing all contour edge points in the edge point data set to obtain each contour edge point within the second tolerance range of the initial fitting circle as the inner point of the initial fitting circle, and taking the inner point of the initial fitting circle as the iteration result of this iteration; repeating the above iterative process until a preset number of iterations is reached, stopping the iteration, and determining the iteration with the largest number of inner points of the initial fitting circle based on the iteration results of multiple iterations; and taking the iteration result of the iteration with the largest number of inner points of the initial fitting circle as the target fitting edge point.
[0099] In the above embodiment, the iteration result of the iteration with the largest number of inner points of the initial fitting circle is selected as the target fitting edge point through multiple iterations, which can further improve the reliability of the target fitting edge point and further improve the accuracy of the target fitting circle.
[0100] In one embodiment, Figure 6 As shown, the above step S3 includes steps S321 to S325, wherein.
[0101] Step S321 : When the number of objects is at least two, an initial fitting circle of the first object to be identified is generated based on the initial identification radius and edge point dataset of the first object to be identified.
[0102] Step S322 : acquiring all contour edge points within the second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and acquiring the current remaining edge point dataset.
[0103] Step S323 : taking the inner points of the initial fitting circle as the target fitting edge points of the first object to be identified, and generating the target fitting circle of the first object to be identified based on the target fitting edge points.
[0104] Step S324 : Scan the current remaining edge point dataset to obtain an initial recognition radius of the second object to be recognized, and generate a target fitting circle of the second object to be recognized based on the initial recognition radius and the current remaining edge point dataset.
[0105] Specifically, an initial recognition radius of the second object to be identified is obtained based on the current remaining edge point dataset. Multiple contour edge points are selected from the current remaining edge point dataset as initial fitting edge points. An initial fitting circle for the second object to be identified is generated based on the initial fitting edge points, and a determination is made as to whether the radius of the initial fitting circle is within a first tolerance range of the initial recognition radius. If the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, all contour edge points within the second tolerance range of the initial fitting circle are obtained from the current remaining edge point dataset as inner points of the initial fitting circle. These inner points of the initial fitting circle are then used as target fitting edge points. Based on the target fitting edge points, a target fitting circle for the second object to be identified is generated.
[0106] Step S325 , updating the current remaining edge point dataset, and repeating the above steps of obtaining the initial recognition radius and generating the target fitting circle based on the updated current remaining edge point dataset, until a target fitting circle for each object to be recognized is generated.
[0107] In the above steps S321 to S325, the target fitting circle of the first object to be identified is generated by obtaining the initial fitting circle of the first object to be identified, and obtaining all contour edge points within the second tolerance range of the initial fitting circle from the edge point data set. Then, based on the current remaining edge point data set, similar initial recognition steps and target recognition steps are performed to generate the target fitting circle of each subsequent object to be identified, thereby achieving efficient and accurate recognition and positioning of overlapping objects.
[0108] In one embodiment, Figure 7 As shown, the above step S1 includes steps S11 to S14, wherein.
[0109] Step S11 , performing morphological opening and filtering processing on the original captured image to obtain a pre-processed image.
[0110] The original acquired image is processed by morphological opening operation to reduce the brightness of the original acquired image and eliminate the surface texture information of the object. The original acquired image is filtered to eliminate the system noise of the original acquired image.
[0111] Preferably, median filtering is performed on the original collected image to eliminate system noise of the original collected image.
[0112] Step S12 : segmenting the object image region and the background image region in the pre-processed image based on a preset color difference analysis method to extract the object region image from the pre-processed image.
[0113] Step S13 , performing morphological closing operation and threshold area elimination processing on the object area image to obtain a target binary image.
[0114] The morphological closing operation is performed on the object region image to eliminate holes and spots in the object region image. The threshold area elimination process is performed on the object region image to eliminate distant and small area targets in the object region image to prevent these targets from interfering with the subsequent recognition process.
[0115] Furthermore, the operation formulas of the morphological opening operation and the morphological closing operation are as follows, wherein formula (1) is the morphological opening operation formula, and formula (2) is the morphological closing operation formula.
[0116]
[0117]
[0118] Where f(x, y) represents the input image and b(x, y) represents the structural element.
[0119] Preferably, a morphological opening operation is performed on the original captured image based on a disk-shaped structuring element with a preset first radius, and a morphological closing operation is performed on the object region image based on a disk-shaped structuring element with a preset second radius. Since the purpose of the morphological opening operation is to reduce the brightness of the original captured image and eliminate surface texture information of the object, while the purpose of the morphological closing operation is to eliminate holes and spots in the object region image, disk-shaped structuring elements of different radii are set to achieve different functions.
[0120] Step S14: extracting a contour image corresponding to the original captured image from the target binary image.
[0121] In the above steps S11 to S14, the original acquired image is subjected to morphological opening processing to reduce its brightness and eliminate surface texture information of the object, and the original acquired image is subjected to filtering processing to eliminate system noise in the original acquired image, so as to facilitate segmentation processing of the pre-processed image and obtain a high-quality object region image. The object region image is subjected to morphological closing processing to eliminate holes and spots in the object region image, and the object region image is subjected to threshold area elimination processing to eliminate distant and small targets in the object region image, so as to prevent these targets, holes, and spots from interfering with the subsequent recognition process, thereby obtaining a high-quality contour image and facilitating subsequent object recognition.
[0122] In one embodiment, step S12 includes steps 121 to 125 , wherein.
[0123] Step 121 , obtaining image grayscale feature data based on the preprocessed image, the image grayscale feature data including the grayscale value of each image pixel; based on the image grayscale feature data, obtaining the total number of image pixels and the overall average grayscale value of the image.
[0124] Step 122, based on a preset color difference analysis method, extracts object grayscale feature data corresponding to the object image area and background grayscale feature data corresponding to the background image area from the grayscale feature data, wherein the object grayscale feature data includes the number of object pixels and the average grayscale value of the object image, and the background grayscale feature data includes the number of background pixels and the average grayscale value of the background image.
[0125] Step 123 : obtaining a first ratio corresponding to the object image area based on the number of object pixels and the total number of image pixels; and obtaining a second ratio corresponding to the background image area based on the number of background pixels and the total number of image pixels.
[0126] Preferably, the preset color difference analysis method is the RG color difference analysis method. In one embodiment, an RG component image is extracted from the preprocessed image, and image grayscale feature data of the RG component image is obtained, and the image grayscale feature data includes the grayscale value of each image pixel in the RG component image. Based on the image grayscale feature data, the total number of image pixels and the overall average grayscale value of the image are obtained. Based on the RG color difference analysis method, object grayscale feature data corresponding to the object image area and background grayscale feature data corresponding to the background image area are extracted from the grayscale feature data. Based on the number of object pixels and the total number of image pixels, a first proportion of the object pixels corresponding to the object image area in the RG component image is obtained; and based on the number of background pixels and the total number of image pixels, a second proportion of the background pixels corresponding to the background image area in the RG component image is obtained.
[0127] Step 124 : obtaining a target segmentation threshold based on the overall average grayscale value of the image, the average grayscale value of the object image, the average grayscale value of the background image, the first ratio, and the second ratio.
[0128] Preferably, the Otsu algorithm (i.e., Otsu's algorithm) is selected to calculate the target segmentation threshold. The Otsu algorithm is the best algorithm for threshold selection in image segmentation. Its principle is to divide the image into foreground and background based on its gray features and determine the target segmentation threshold by calculating the maximum inter-class difference. The formula for calculating the target segmentation threshold in the Otsu algorithm is as follows.
[0129] T=max{W0(t)*(u0(t)-u) 2 +W1(t)*(u1(t)-u) 2}
[0130] Wherein, T represents the target segmentation threshold, W0(t) represents the first proportion of the object pixel points in the RG component image, u0(t) represents the average grayscale value of the object image, W1(t) represents the second proportion of the background pixel points in the RG component image, u1(t) represents the average grayscale value of the background image, and u represents the overall average grayscale value of the RG component image.
[0131] Step 125 : Segment the object image region and the background image region in the pre-processed image based on the target segmentation threshold, and obtain the segmented object region image.
[0132] Two specific embodiments are provided below to further illustrate the object positioning method provided by the present invention.
[0133] In a first specific embodiment, the object positioning method provided by the present invention includes the following steps.
[0134] Step 1: Obtain the original image of the object to be identified and extract the corresponding contour image of the object to be identified from the original image. Obtain a dataset of edge points of the contour image, scan the contour image, and obtain the coordinate difference data of two external contour edge points in the contour image in the same scanning direction. Based on the coordinate difference data, generate a coordinate difference curve corresponding to the object contour of the object to be identified. Based on the coordinate difference curve, determine the initial recognition radius of the object to be identified.
[0135] Step 2: Select multiple contour edge points from the edge point dataset as initial fitting edge points, where the number of initial fitting edge points is greater than or equal to three. Generate an initial fitting circle for the object to be identified based on the initial fitting edge points, and determine whether the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius. If the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, obtain all contour edge points within the second tolerance range of the initial fitting circle from the edge point dataset as the inner points of the initial fitting circle, and use the inner points of the initial fitting circle as target fitting edge points. Generate a target fitting circle for the object to be identified based on the target fitting edge points. Determine the target position of the object to be identified in the contour image based on the target fitting circle.
[0136] In the second specific embodiment, the recognition of apples in a close-range target recognition scenario is taken as an example to further illustrate the object positioning method provided by the present invention. In this embodiment, the apple fruit is taken as the object to be identified, that is, the object to be identified is the fruit to be identified, and a camera is used to collect the original image of the fruit to be identified. The camera is installed at the center of the mechanical claw, and the mechanical claw is integrated on a movable telescopic rod. Before the fruit recognition begins, the position of the mechanical claw is adjusted so that the camera is within 50 cm from the fruit to be identified. The specific steps include the following.
[0137] (1) Obtain the original image of the fruit to be identified, perform morphological opening operation of a disk structure element with a radius of 2 and 3*3 median filtering on the original image to obtain a preprocessed image. Segment the fruit image area and the background image area in the preprocessed image based on the RG color difference analysis method and the Otsu algorithm to extract the fruit area image from the preprocessed image. Perform morphological closing operation of a disk structure element with a radius of 5 on the fruit area image, and delete the area with a pixel area less than 5% of the total pixel area in the fruit area image to obtain a target binary image, and extract the contour image corresponding to the fruit contour in the original image from the target binary image based on the Canny operator, for example, Figure 8a Indicates the contour image of the fruit corresponding to the single fruit to be identified when there is a single fruit to be identified in the original captured image.
[0138] (2) Obtaining an edge point data set of a contour image, wherein the edge point data set is composed of a plurality of contour edge points; obtaining the number of fruits to be identified in the contour image; when the number of fruits is one, scanning the contour image in a transverse scanning direction and a longitudinal scanning direction, and obtaining coordinate difference data of two external contour edge points in the same scanning direction in the contour image; generating a coordinate difference curve of the fruit contour corresponding to the fruit to be identified based on the coordinate difference data; obtaining a peak value of the coordinate difference curve, and obtaining half of the peak value as the initial identification radius of the fruit to be identified.
[0139] (3) When there are two fruits, obtain the difference between the maximum horizontal coordinate difference and the maximum vertical coordinate difference of the fruit contour in the contour image, and set the upper coordinate difference threshold to 40 and the lower coordinate difference threshold to 0. When the difference is greater than 40, the fruit distribution posture of the two fruits to be identified is determined to be a horizontal distribution posture; when the difference is less than 0, the fruit distribution posture of the two fruits to be identified is determined to be a vertical distribution posture; when the difference is greater than 0 and less than 40, the fruit distribution posture of the two fruits to be identified is determined to be an oblique distribution posture.
[0140] (4) When the fruit distribution posture is a horizontal distribution posture or an oblique distribution posture, the target scanning direction is determined to be the horizontal scanning direction; when the fruit distribution posture is a vertical distribution posture, the target scanning direction is determined to be the vertical scanning direction. The contour image is scanned in the target scanning direction, and the coordinate difference data of two external contour edge points in the same scanning direction in the contour image are obtained; based on the coordinate difference data, a coordinate difference curve of the fruit contour corresponding to the fruit to be identified is generated; based on the coordinate difference curve and the fruit distribution posture, the initial recognition radius of the first fruit to be identified is determined.
[0141] (5) When the number of fruits is one, multiple contour edge points are selected from the edge point data set as initial fitting edge points, and the number of initial fitting edge points is greater than or equal to three; an initial fitting circle of the fruit to be identified is generated based on the initial fitting edge points, and it is determined whether the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius; when the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, all contour edge points within the second tolerance range of the initial fitting circle are obtained from the edge point data set as inner points of the initial fitting circle, and the inner points of the initial fitting circle are used as target fitting edge points; based on the target fitting edge points, a target fitting circle corresponding to a single fruit to be identified is generated (e.g., Figure 8b fitted circle shown).
[0142] (6) When the number of fruits is two, based on the initial recognition radius and edge point data set of the first fruit to be identified, generate the initial fitting circle of the first fruit to be identified; obtain all the contour edge points within the second tolerance range of the initial fitting circle from the edge point data set as the inner points of the initial fitting circle, and obtain the current remaining edge point data set; use the inner points of the initial fitting circle as the target fitting edge points of the first fruit to be identified, and generate the target fitting circle of the first fruit to be identified based on the target fitting edge points (such as Figure 8c The fitting circle 1 shown in the left circle in the figure is used as the fitting circle, and the target position of the first fruit to be identified is determined based on the target fitting circle. The current remaining edge point dataset is scanned to obtain the initial recognition radius of the second fruit to be identified, and the target fitting circle of the second fruit to be identified is generated based on the initial recognition radius and the current remaining edge point dataset (as shown in the figure). Figure 8d The fitting circle 2 shown in the circle on the right side of the figure is used, and based on the target fitting circle, the target position of the second fruit to be identified is determined.
[0143] The object positioning method provided by the present invention can be applied to the automated picking operation of fruits, does not require a complex modeling process, and has relatively simple experimental equipment and low cost. Taking into account the application needs of actual fruit picking, the present invention proposes a random sampling consensus algorithm based on an adaptive radius selection strategy to fit the fruit shape for the near-field target application scenario, so as to realize a method for identifying and locating fruits that are blocked by branches and leaves and overlap with each other. Compared with the prior art, the object positioning method provided by the present invention has better recognition effect and faster recognition speed, is not affected by the missing or incomplete fruit outline, and is not affected by interference points in complex environments. It can stably identify and locate fruits that are blocked by branches and leaves and overlap with each other under different conditions. The experimental equipment used by the present invention is relatively simple and cheap, and can directly locate the two-dimensional coordinates of the fruit, and obtain parameters such as the running time, the coordinates of the fruit center, and the radius.
[0144] The object positioning device provided by the present invention is described below. The object positioning device described below and the object positioning method described above can be referenced to each other.
[0145] like Figure 9 As shown, the present invention provides an object positioning device, wherein the object positioning device 100 includes a contour extraction module 10, an initial recognition module 20, a target fitting module 30 and a position recognition module 40, wherein.
[0146] The contour extraction module 10 is used to obtain an original captured image of the object to be identified, and extract a contour image corresponding to the object to be identified from the original captured image.
[0147] The initial recognition module 20 is used to obtain an initial recognition radius of an object to be recognized in a contour image and an edge point dataset of the contour image, where the edge point dataset includes a plurality of contour edge points.
[0148] The target fitting module 30 is used to generate a target fitting circle of the object to be identified based on the edge point data set and the initial recognition radius, where the target fitting circle is used to fit the shape of the object to be identified.
[0149] The position recognition module 40 is used to determine the target position of the object to be recognized in the contour image based on the target fitting circle.
[0150] In one embodiment, the initial recognition module 20 includes a first image scanning unit, a first curve generating unit and a first radius determining unit, wherein.
[0151] The first image scanning unit is used to scan the contour image and obtain coordinate difference data of two external contour edge points in the same scanning direction in the contour image.
[0152] The first curve generating unit is configured to generate a coordinate difference curve corresponding to an object contour of the object to be identified based on the coordinate difference data.
[0153] The first radius determination unit is configured to determine an initial recognition radius of the object to be recognized based on the coordinate difference curve.
[0154] In one embodiment, the initial recognition module 20 includes a first quantity determination unit, a second image scanning unit, a second curve generation unit, and a second radius determination unit.
[0155] The first quantity determining unit is configured to obtain the quantity of objects to be identified in the contour image.
[0156] The second image scanning unit is used to scan the contour image in a horizontal scanning direction and a vertical scanning direction when the number of objects is one, and obtain coordinate difference data of two external contour edge points in the contour image in the same scanning direction.
[0157] The second curve generating unit is configured to generate a coordinate difference curve corresponding to an object contour of the object to be identified based on the coordinate difference data.
[0158] The second radius determination unit is configured to obtain a peak value of the coordinate difference curve and determine an initial recognition radius of the object to be recognized based on a preset first ratio and the peak value.
[0159] In one embodiment, the initial recognition module 20 includes a second quantity determination unit, a coordinate difference acquisition unit, a scanning direction determination unit, a third image scanning unit, a third curve generation unit and a third radius determination unit, wherein.
[0160] The second quantity determining unit is configured to obtain the number of objects to be identified in the contour image.
[0161] The coordinate difference acquisition unit is used to acquire the maximum coordinate difference of the object contours in the contour image when the number of the objects is at least two.
[0162] The scanning direction determining unit is used to determine the object distribution postures of at least two objects to be identified based on the maximum coordinate difference and a preset coordinate difference threshold, and to determine the target scanning direction based on the object distribution postures.
[0163] The third image scanning unit is used to scan the contour image in a target scanning direction and obtain coordinate difference data of two external contour edge points in the contour image in the same scanning direction.
[0164] The third curve generating unit is configured to generate a coordinate difference curve corresponding to an object contour of the object to be identified based on the coordinate difference data.
[0165] The third radius determination unit is used to determine an initial recognition radius of the first object to be recognized based on the coordinate difference curve and the object distribution posture.
[0166] In one embodiment, the target fitting module 30 includes a first selection unit, an initial fitting unit, a second selection unit and a target fitting unit, wherein.
[0167] The first selection unit is used to select a plurality of contour edge points from the edge point data set as initial fitting edge points, where the number of the initial fitting edge points is greater than or equal to three.
[0168] The initial fitting unit is used to generate an initial fitting circle of the object to be identified based on the initial fitting edge points, and to determine whether the radius of the initial fitting circle is within a first tolerance range of the initial identification radius.
[0169] The second selection unit is used to obtain all contour edge points within the second tolerance range of the initial fitting circle from the edge point data set as the inner points of the initial fitting circle when the radius of the initial fitting circle is within the first tolerance range of the initial identification radius, and to use the inner points of the initial fitting circle as the target fitting edge points.
[0170] The target fitting unit is used to generate a target fitting circle of the object to be identified based on the target fitting edge points.
[0171] In one embodiment, the initial fitting unit is further configured to generate an initial fitting circle of the first object to be identified based on the initial recognition radius and edge point dataset of the first object to be identified when the number of objects is at least two.
[0172] The second selection unit is further configured to obtain all contour edge points within a second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and obtain the current remaining edge point dataset.
[0173] The target fitting unit is further configured to use the inner point of the initial fitting circle as the target fitting edge point of the first object to be identified, and generate the target fitting circle of the first object to be identified based on the target fitting edge point.
[0174] The target fitting module 30 is also used to scan the current remaining edge point dataset to obtain the initial recognition radius of the second object to be identified, and generate a target fitting circle for the second object to be identified based on the initial recognition radius and the current remaining edge point dataset; update the current remaining edge point dataset, and based on the updated current remaining edge point dataset, repeat the above steps of obtaining the initial recognition radius and generating the target fitting circle until a target fitting circle for each object to be identified is generated.
[0175] In one embodiment, the contour extraction module 10 includes a first processing unit, an image segmentation unit, a second processing unit and a contour extraction unit, wherein.
[0176] The first processing unit is used to perform morphological opening and filtering processing on the original collected image to obtain a preprocessed image.
[0177] The image segmentation unit is used to segment the object image area and the background image area in the preprocessed image based on a preset color difference analysis method to extract the object area image from the preprocessed image.
[0178] The second processing unit is used to perform morphological closing operation processing and threshold area elimination processing on the object area image to obtain a target binary image.
[0179] The contour extraction unit is used to extract the contour image corresponding to the original collected image from the target binary image.
[0180] Figure 10 An example of a physical structure diagram of an electronic device is shown below. Figure 10 As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030, and a communication bus 1040, wherein the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other via the communication bus 1040. The processor 1010 may call logic instructions in the memory 1030 to execute an object positioning method, which includes: acquiring an original captured image of the object to be identified, and extracting a contour image corresponding to the object to be identified from the original captured image; acquiring an initial recognition radius of the object to be identified in the contour image and an edge point dataset of the contour image, the edge point dataset including a plurality of contour edge points; generating a target fitting circle of the object to be identified based on the edge point dataset and the initial recognition radius, the target fitting circle being used to fit the shape of the object to be identified; and determining a target position of the object to be identified in the contour image based on the target fitting circle.
[0181] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0182] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the object positioning method provided by the above methods, which includes: obtaining the original captured image of the object to be identified, and extracting the contour image corresponding to the object to be identified from the original captured image; obtaining the initial recognition radius of the object to be identified in the contour image and the edge point data set of the contour image, the edge point data set including multiple contour edge points; based on the edge point data set and the initial recognition radius, generating a target fitting circle of the object to be identified, the target fitting circle being used to fit the shape of the object to be identified; based on the target fitting circle, determining the target position of the object to be identified in the contour image.
[0183] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the object positioning method provided by the above-mentioned methods, the method comprising: obtaining an original captured image of the object to be identified, and extracting a contour image corresponding to the object to be identified from the original captured image; obtaining an initial recognition radius of the object to be identified in the contour image and an edge point data set of the contour image, the edge point data set comprising a plurality of contour edge points; generating a target fitting circle of the object to be identified based on the edge point data set and the initial recognition radius, the target fitting circle being used to fit the shape of the object to be identified; and determining the target position of the object to be identified in the contour image based on the target fitting circle.
[0184] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. That is, they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0185] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or certain parts of the embodiment.
[0186] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for locating an object, characterized in that: include: Acquire an original captured image of an object to be identified, and extract a contour image corresponding to the object to be identified from the original captured image; Acquire an initial recognition radius of the object to be recognized in the contour image and an edge point dataset of the contour image, wherein the edge point dataset includes a plurality of contour edge points; Selecting a plurality of contour edge points from the edge point data set as initial fitting edge points; According to the three-point circle determination principle, the number of the initial fitting edge points is greater than or equal to three; generating an initial fitting circle of the object to be identified based on the initial fitting edge points, and determining whether a radius of the initial fitting circle is within a first tolerance range of the initial identification radius; When the radius of the initial fitting circle is within a first tolerance range of the initial recognition radius, all contour edge points within a second tolerance range of the initial fitting circle are acquired from the edge point dataset as inner points of the initial fitting circle, and the inner points of the initial fitting circle are used as target fitting edge points; generating a target fitting circle of the object to be identified based on the target fitting edge points, wherein the target fitting circle is used to fit the shape of the object to be identified; Determining a target position of the object to be identified in the contour image based on the target fitting circle; The obtaining of the initial recognition radius of the object to be recognized in the contour image includes: Obtaining the number of objects to be identified in the contour image; When the number of the objects is at least two, obtaining a maximum coordinate difference value of the object contours in the contour image; determining an object distribution posture of at least two objects to be identified based on the maximum coordinate difference and a preset coordinate difference threshold, and determining a target scanning direction based on the object distribution posture; Scanning the contour image in the target scanning direction and obtaining coordinate difference data of two outer contour edge points in the contour image in the same scanning direction; the outer contour edge points correspond to inner contour edge points, and the inner contour edge points represent edge points formed in the contour of the object when other objects occlude the object to be identified; Based on the coordinate difference data, generating a coordinate difference curve corresponding to the object contour of the object to be identified; An initial recognition radius of the first object to be recognized is determined based on the coordinate difference curve and the object distribution posture.
2. The object positioning method according to claim 1, characterized in that: The obtaining of the initial recognition radius of the object to be recognized in the contour image includes: Obtaining the number of objects to be identified in the contour image; When the number of the object is one, scanning the contour image in a horizontal scanning direction and a vertical scanning direction, and obtaining coordinate difference data of two outer contour edge points in the contour image in the same scanning direction; generating a coordinate difference curve corresponding to an object contour of the object to be identified based on the coordinate difference data; A peak value of the coordinate difference curve is obtained, and an initial recognition radius of the object to be recognized is determined based on a preset first ratio and the peak value.
3. The object positioning method according to claim 1, characterized in that: Generating a target fitting circle of the object to be identified includes: When the number of the objects is at least two, generating an initial fitting circle of the first object to be identified based on the initial identification radius of the first object to be identified and the edge point dataset; Acquire all contour edge points within a second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and acquire a current remaining edge point dataset; Using the inner point of the initial fitting circle as the target fitting edge point of the first object to be identified, and generating the target fitting circle of the first object to be identified based on the target fitting edge point; Scanning the current remaining edge point dataset to obtain an initial recognition radius of the second object to be identified, and generating a target fitting circle of the second object to be identified based on the initial recognition radius and the current remaining edge point dataset; The current remaining edge point dataset is updated, and based on the updated current remaining edge point dataset, the steps of obtaining the initial recognition radius and generating the target fitting circle are repeatedly performed until a target fitting circle for each of the objects to be recognized is generated.
4. The object positioning method according to claim 1, characterized in that: The step of extracting a contour image corresponding to the object to be identified from the original collected image includes: Performing morphological opening and filtering processing on the original collected image to obtain a preprocessed image; Segmenting the object image region and the background image region in the pre-processed image based on a preset color difference analysis method to extract the object region image from the pre-processed image; Performing morphological closing operation and threshold area elimination processing on the object area image to obtain a target binary image; A contour image corresponding to the original acquired image is extracted from the target binary image.
5. A positioning device for an object, characterized in that: include: A contour extraction module is used to obtain an original captured image of an object to be identified and extract a contour image corresponding to the object to be identified from the original captured image; An initial recognition module, configured to obtain an initial recognition radius of the object to be recognized in the contour image and an edge point dataset of the contour image, wherein the edge point dataset includes a plurality of contour edge points; The target fitting module includes a first selection unit, an initial fitting unit, a second selection unit, and a target fitting unit, wherein the first selection unit is used to select multiple contour edge points from the edge point data set as initial fitting edge points; according to the three-point circle determination principle, the number of initial fitting edge points is greater than or equal to three; The initial fitting unit is configured to generate an initial fitting circle of the object to be identified based on the initial fitting edge points, and to determine whether the radius of the initial fitting circle is within a first tolerance range of the initial identification radius; The second selection unit is configured to, when the radius of the initial fitting circle is within the first tolerance range of the initial recognition radius, obtain all contour edge points within the second tolerance range of the initial fitting circle from the edge point dataset as inner points of the initial fitting circle, and use the inner points of the initial fitting circle as target fitting edge points; The target fitting unit is used to generate a target fitting circle of the object to be identified based on the target fitting edge points, and the target fitting circle is used to fit the shape of the object to be identified; a position recognition module, configured to determine a target position of the object to be recognized in the contour image based on the target fitting circle; The initial recognition module includes a second quantity determination unit, a coordinate difference acquisition unit, a scanning direction determination unit, a third image scanning unit, a third curve generation unit, and a third radius determination unit; The second number determining unit is configured to obtain the number of objects to be identified in the contour image; The coordinate difference acquisition unit is configured to acquire a maximum coordinate difference of the object contours in the contour image when the number of the objects is at least two; The scanning direction determining unit is configured to determine the object distribution postures of at least two objects to be identified based on the maximum coordinate difference and a preset coordinate difference threshold, and determine a target scanning direction based on the object distribution postures; The third image scanning unit is configured to scan the contour image in the target scanning direction and obtain coordinate difference data of two outer contour edge points in the contour image in the same scanning direction; the outer contour edge points correspond to inner contour edge points, and the inner contour edge points represent edge points formed in the contour of the object to be identified when other objects obstruct the object to be identified; The third curve generating unit is configured to generate a coordinate difference curve corresponding to the object contour of the object to be identified based on the coordinate difference data; The third radius determination unit is configured to determine an initial recognition radius of the first object to be recognized based on the coordinate difference curve and the object distribution posture.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the object positioning method according to any one of claims 1 to 4 is implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the object positioning method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Fruit recognition method and system
CN110309730A