Machine vision-based marking inversion node control method
Patent Information
- Application Number
- CN202610404468.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-30
- Publication Date
- 2026-10-20
AI Technical Summary
[0004]本发明旨在至少在一定程度上解决现有技术中的技术问题之一,获取拐杖支撑管的俯视图像,标记为实时支撑管图像;基于实时支撑管图像获取实时灰度直方图;基于实时灰度直方图获取实时孔洞阈值;基于实时孔洞阈值获取实时孔洞区域;基于实时孔洞区域拟合轮廓拟合函数;基于轮廓拟合函数获取实时偏移值;基于正常打标时拐杖支撑管的俯视图像获取偏移值分布坐标点;基于偏移值分布坐标点获取正常偏移阈值;基于实时偏移值和正常偏移阈值将拐杖支撑管旋转到正常打标位置,以解决现有的打标控制技术无法适应会自身发生旋转的拐杖支撑管,导致打标位置容易发生偏移的问题
[0058]本发明的有益效果:本发明通过获取拐杖支撑管的俯视图像,标记为实时支撑管图像;基于实时支撑管图像获取实时灰度直方图;基于实时灰度直方图获取实时孔洞阈值;基于实时孔洞阈值获取实时孔洞区域;基于实时孔洞区域拟合轮廓拟合函数;基于轮廓拟合函数获取实时偏移值;基于正常打标时拐杖支撑管的俯视图像获取偏移值分布坐标点;基于偏移值分布坐标点获取正常偏移阈值;基于实时偏移值和正常偏移阈值将拐杖支撑管旋转到正常打标位置,优势在于,能够适应会自身发生旋转的拐杖支撑管,提升打标位置的准确性;
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of marking control technology, specifically a marking reversal node control method based on machine vision. Background Technology
[0002] In the field of medical device manufacturing, crutches are important rehabilitation aids. The crutches support tube has a row of holes. The main function of these holes is to adjust and lock the height setting. The height setting is marked on one side of the hole. However, the cylindrical shape of the crutches support tube makes it difficult to directly face the marking position. Therefore, the crutches support tube needs to be rotated to make the marking position correct.
[0003] Existing marking methods place the object to be marked at the marking position. However, when dealing with a cane support tube, the cane support tube itself rotates, causing the marking position to shift. Therefore, traditional marking control cannot adapt to cane support tubes. For example, patent application CN113696639A discloses a marking control method, device, storage medium, processor, and marking equipment. This solution cannot adapt to the cane support tube that rotates itself, resulting in a shift in the marking position. In other words, existing marking control technology cannot adapt to cane support tubes that rotate themselves, making it easy for the marking position to shift. Summary of the Invention
[0004] This invention aims to at least partially solve one of the technical problems in the prior art by acquiring a top-view image of a cane support tube and marking it as a real-time support tube image; acquiring a real-time grayscale histogram based on the real-time support tube image; acquiring a real-time hole threshold based on the real-time grayscale histogram; acquiring a real-time hole region based on the real-time hole threshold; fitting a contour fitting function based on the real-time hole region; acquiring a real-time offset value based on the contour fitting function; acquiring the offset value distribution coordinate points based on the top-view image of the cane support tube during normal marking; acquiring a normal offset threshold based on the offset value distribution coordinate points; and rotating the cane support tube to a normal marking position based on the real-time offset value and the normal offset threshold. This solves the problem that existing marking control technology cannot adapt to cane support tubes that rotate on their own, leading to easy offset of the marking position.
[0005] To achieve the above objectives, this application provides a machine vision-based method for controlling the marking and reversing of nodes, comprising the following steps:
[0006] Obtain a top-view image of the cane support tube and label it as a real-time support tube image;
[0007] Real-time grayscale histogram is obtained based on real-time support tube image;
[0008] Real-time hole threshold is obtained based on real-time grayscale histogram;
[0009] Real-time hole region is obtained based on real-time hole threshold;
[0010] Based on real-time hole region fitting contour fitting function;
[0011] Real-time offset values are obtained based on contour fitting functions;
[0012] The offset value distribution coordinates are obtained based on the top view image of the cane support tube during normal marking.
[0013] Obtain the normal offset threshold based on the coordinate points of the offset value distribution;
[0014] The cane support tube is rotated to the normal marking position based on the real-time offset value and the normal offset threshold.
[0015] Furthermore, obtaining the real-time grayscale histogram based on the real-time support tube image includes the following sub-steps:
[0016] The real-time support tube image is converted to grayscale to obtain a grayscale image, which is then labeled as the real-time support tube grayscale image.
[0017] Mark the grayscale values of the pixels in the real-time support tube grayscale image as the real-time support tube grayscale values;
[0018] Obtain the range of grayscale values of the real-time support tube in the real-time support tube grayscale image and mark it as the real-time grayscale range;
[0019] Divide the real-time grayscale range into a first number of equal range intervals, and mark them as real-time grayscale intervals;
[0020] Obtain the frequency of the grayscale value of the real-time support tube within each real-time grayscale interval and mark it as the real-time grayscale frequency.
[0021] A histogram is drawn with the real-time support tube grayscale value as the X-axis value, the real-time grayscale frequency as the Y-axis value, and the real-time grayscale interval as the histogram interval. This histogram is then marked as the real-time grayscale histogram.
[0022] Furthermore, obtaining the real-time hole threshold based on the real-time grayscale histogram includes the following sub-steps:
[0023] In the real-time grayscale histogram, the real-time grayscale intervals that have a higher real-time grayscale frequency than the left and right sides are marked as peak intervals.
[0024] Find the peak interval with the smallest median value and mark it as the first target interval;
[0025] Find the peak interval with the largest median value and mark it as the second target interval;
[0026] The real-time grayscale interval with the minimum grayscale frequency between the first target interval and the second target interval is identified and marked as the third target interval.
[0027] Obtain the median value of the third target interval and mark it as the real-time hole threshold.
[0028] Furthermore, obtaining the real-time hole region based on the real-time hole threshold includes the following sub-steps:
[0029] Set the gray values of real-time support tubes that are less than the real-time hole threshold in the real-time support tube grayscale image to 0, and set the gray values of real-time support tubes that are greater than or equal to the real-time hole threshold in the real-time support tube grayscale image to 255 to obtain a binarized image of the real-time support tube.
[0030] Pixels with a grayscale value of 0 in the real-time support tube binarization image are marked as hole pixels.
[0031] A continuous region composed of hole pixels is marked as a real-time hole region.
[0032] Furthermore, fitting the contour fitting function based on the real-time hole region includes the following sub-steps:
[0033] Establish a Cartesian coordinate system and label it as the contour extraction coordinate system; place the real-time hole region in the first quadrant of the contour extraction coordinate system;
[0034] Obtain the coordinate points on the real-time hole region outline and mark them as hole outline coordinate points;
[0035] The contour fitting function is set as: (A1-k1) 2 +(A2-k2) 2 =r 2 Where A1 and A2 are the X-axis and Y-axis values of the contour fitting function, respectively, and k1, k2, and r are constants of the contour fitting function;
[0036] All hole contour coordinates are fitted with a contour fitting function to obtain the specific values of k1, k2 and r, which are labeled as ks1, ks2 and rs respectively.
[0037] Furthermore, obtaining the real-time offset value based on the contour fitting function includes the following sub-steps:
[0038] Obtain the distance from all hole outline coordinate points to point (ks1, ks2), and mark it as the actual boundary distance;
[0039] Obtain the absolute value of the difference between all actual boundary distances and rs, and mark it as the boundary offset value;
[0040] Obtain the mean of all boundary offset values and mark it as the real-time offset value;
[0041] Obtain the real-time offset values of all real-time hole regions.
[0042] Furthermore, obtaining the offset value distribution coordinate points based on the top view image of the support tube during normal marking includes the following sub-steps:
[0043] The top view image of the support tube during normal marking is regarded as the real-time offset value obtained from the real-time support tube image and marked as the historical normal offset value.
[0044] Obtain the second number of historical normal offset values;
[0045] If there are identical historical normal offset values, count the number of historical normal offset values and the corresponding number of identical historical normal offset values, and mark them as the number of the same offset value.
[0046] Establish a Cartesian coordinate system with historical normal offset values as the horizontal axis data and the number of identical offset values as the vertical axis data, and mark it as the offset value observation coordinate system;
[0047] The historical normal offset value and the corresponding number of the same offset value are respectively used as the x and y coordinates of the data points and plotted on the offset value observation coordinate system;
[0048] Mark the data points in the offset observation coordinate system as offset value distribution coordinate points.
[0049] Furthermore, obtaining the normal offset threshold based on the offset value distribution coordinate points includes the following sub-steps:
[0050] Obtain the horizontal range length of all historical normal offset values in the offset value observation coordinate system, and label it as D1;
[0051] Create a line segment of length D2 on the horizontal axis of the offset observation coordinate system that can move left and right, and mark it as the distribution judgment line segment;
[0052] The threshold for the number of distributions is calculated as: P = f × (D2 ÷ D1) × C; where P is the threshold for the number of distributions, f is the number adjustment ratio, and C is the second quantity.
[0053] Furthermore, obtaining the normal offset threshold based on the offset value distribution coordinate points also includes the following sub-steps:
[0054] The sum of the number of historical normal offset values corresponding to all offset value distribution coordinate points directly above the distribution judgment line segment is marked as the real-time line segment count;
[0055] On the horizontal axis of the offset observation coordinate system, make the horizontal coordinate of the right endpoint of the distribution judgment line segment equal to the horizontal coordinate of the distribution coordinate point with the largest offset value. Then, move the distribution judgment line segment to the left and compare the real-time number of line segments with the distribution number threshold in real time. When the real-time number of line segments is greater than or equal to the distribution number threshold, stop moving the distribution judgment line segment. Obtain the historical normal offset value corresponding to the horizontal coordinate of the right endpoint of the distribution judgment line segment at this time and mark it as the normal offset threshold.
[0056] Furthermore, rotating the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold includes the following sub-steps:
[0057] If no real-time hole area appears, or if the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, the real-time support tube image and real-time offset value are reacquired while rotating the cane support tube. When the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, the rotation of the cane support tube is stopped, and the cane support tube is transferred to the marking area for marking.
[0058] The beneficial effects of this invention are as follows: This invention acquires a top-view image of the cane support tube and marks it as a real-time support tube image; obtains a real-time grayscale histogram based on the real-time support tube image; obtains a real-time hole threshold based on the real-time grayscale histogram; obtains a real-time hole region based on the real-time hole threshold; fits a contour fitting function based on the real-time hole region; obtains a real-time offset value based on the contour fitting function; obtains the offset value distribution coordinate points based on the top-view image of the cane support tube during normal marking; obtains a normal offset threshold based on the offset value distribution coordinate points; and rotates the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold. The advantage is that it can adapt to cane support tubes that rotate on their own, improving the accuracy of the marking position.
[0059] This invention obtains real-time offset values based on a contour fitting function. Its advantage lies in the ease with which offset judgment values can be set based on the holes in the cane support tube. Based on the offset judgment values, the cane support tube can be rotated to the correct marking position, thereby improving the accuracy of the marking position. Attached Figure Description
[0060] Figure 1 This is a flowchart of the steps of the method of the present invention;
[0061] Figure 2 This is a schematic diagram of the real-time grayscale histogram of the present invention;
[0062] Figure 3 This is a schematic diagram of the real-time hole region of the present invention;
[0063] Figure 4 This is a schematic diagram of the contour fitting function of the present invention;
[0064] Figure 5 This is a schematic diagram of the offset value distribution coordinate points of the present invention. Detailed Implementation
[0065] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0066] Example 1, please refer to Figure 1 As shown, this application provides a machine vision-based method for controlling the marking and reversing of nodes, including the following steps:
[0067] Step S1: Obtain a top view image of the cane support tube and mark it as a real-time support tube image; the real-time support tube image is an image of the cane support tube area after the cane support tube has been perforated.
[0068] Step S2: Obtain the real-time grayscale histogram based on the real-time support tube image; Step S2 includes the following sub-steps:
[0069] Step S201: Perform grayscale processing on the real-time support tube image to obtain a grayscale image, and mark it as the real-time support tube grayscale image;
[0070] Step S202: Mark the gray values of the pixels in the real-time support tube grayscale image as the real-time support tube grayscale values;
[0071] Step S203: Obtain the range of grayscale values of the real-time support tube in the real-time support tube grayscale image and mark it as the real-time grayscale range;
[0072] Step S204: Divide the real-time grayscale range into a first number of equal range intervals and mark them as real-time grayscale intervals.
[0073] Step S205: Obtain the frequency of the gray value of the real-time support tube within each real-time gray-scale interval and mark it as the real-time gray-scale frequency.
[0074] Step S206: Using the real-time support tube grayscale value as the X-axis value, the real-time grayscale frequency as the Y-axis value, and the real-time grayscale interval as the histogram interval, a histogram is drawn and marked as the real-time grayscale histogram; the real-time grayscale histogram is constructed to obtain the real-time hole threshold.
[0075] For practical applications, please refer to Figure 2 As shown, this is the real-time grayscale histogram obtained.
[0076] Step S3: Obtain the real-time hole threshold based on the real-time grayscale histogram; Step S3 includes the following sub-steps:
[0077] Step S301: In the real-time grayscale histogram, the real-time grayscale intervals that are greater than the real-time grayscale frequencies on the left and right sides are marked as peak intervals.
[0078] Step S302: Obtain the peak interval with the smallest median value among the peak intervals and mark it as the first target interval;
[0079] Step S303: Obtain the peak interval with the largest median value among the peak intervals and mark it as the second target interval;
[0080] Step S304: Obtain the real-time grayscale interval with the smallest real-time grayscale frequency between the first target interval and the second target interval, and mark it as the third target interval;
[0081] Step S305: Obtain the median value of the third target interval and mark it as the real-time hole threshold. Because the real-time support tube image only includes the cane support tube, and the hole of the cane support tube will appear black, making the gray values of the cane support tube and the hole different, so there will be two different ranges of gray values. In order to distinguish the two different ranges of gray values, the real-time hole threshold is obtained.
[0082] For practical applications, please refer to Figure 2 As shown, the first target interval is 31 to 63, the second target interval is 191 to 223, the real-time grayscale interval with the smallest grayscale frequency between the first and second target intervals is 95 to 127, then the third target interval is 95 to 127, the median value of the third target interval is 111, then the real-time hole threshold is 111.
[0083] Step S4: Obtain the real-time hole region based on the real-time hole threshold; Step S4 includes the following sub-steps:
[0084] Step S401: Set the gray values of real-time support tubes in the real-time support tube grayscale image that are less than the real-time hole threshold to 0, and set the gray values of real-time support tubes in the real-time support tube grayscale image that are greater than or equal to the real-time hole threshold to 255, to obtain a binarized image of the real-time support tube.
[0085] Step S402: Mark the pixels with a gray value of 0 in the real-time support tube binarization image as hole pixels; while the holes in the cane support tube will appear black, that is, the gray value of the hole area is less than the gray value of the cane support tube area. Therefore, the pixels with a gray value of 0 in the real-time support tube binarization image can be marked as hole pixels.
[0086] Step S403: The continuous area composed of hole pixels is marked as the real-time hole area; the real-time hole area is the location of the hole in the cane support tube.
[0087] For practical applications, please refer to Figure 3 As shown, the grayscale values of real-time support tubes in the real-time support tube grayscale image that are less than the real-time hole threshold 111 are set to 0, and the grayscale values of real-time support tubes that are greater than or equal to the real-time hole threshold 111 are set to 255, thus obtaining a binarized image of the real-time support tube; the real-time hole region is obtained as shown in the figure. Figure 3 As shown.
[0088] Step S5: Fit a contour fitting function based on the real-time hole region; Step S5 includes the following sub-steps:
[0089] Step S501: Establish a Cartesian coordinate system and mark it as the contour extraction coordinate system; place the real-time hole region in the first quadrant of the contour extraction coordinate system;
[0090] Step S502: Obtain the coordinate points on the real-time hole area contour and mark them as hole contour coordinate points;
[0091] Step S503, set the contour fitting function as: (A1-k1) 2 +(A2-k2) 2 =r 2 Where A1 and A2 are the X-axis and Y-axis values of the contour fitting function, respectively, and k1, k2, and r are constants of the contour fitting function;
[0092] Step S504: Fit all the hole contour coordinate points with the contour fitting function to obtain the specific values of k1, k2 and r, which are labeled as ks1, ks2 and rs respectively.
[0093] For practical applications, please refer to Figure 4 As shown, the contour fitting function is: (A1-25) 2 +(A2-25) 2 =4 2 Then we get ks1, ks2 and rs as 25, 25 and 4 respectively.
[0094] Step S6: Obtain the real-time offset value based on the contour fitting function; Step S6 includes the following sub-steps:
[0095] Step S601: Obtain the distance from all hole contour coordinate points to point (ks1, ks2) and mark it as the actual boundary distance;
[0096] Step S602: Obtain the absolute value of the difference between all actual boundary distances and rs, and mark it as the boundary offset value;
[0097] Step S603: Obtain the mean of all boundary offset values and mark it as the real-time offset value;
[0098] Step S604: Obtain the real-time offset values of all real-time hole areas; if the hole is viewed directly from above, the image of the hole appears circular; if the hole is not viewed directly from above, the image of the hole appears elliptical; the closer to the hole, the closer to a circle, that is, the smaller the real-time offset value; and since marking must be done directly in front of the hole, the real-time offset value can be used to determine whether the marking is aligned.
[0099] In practical applications, for example, if the coordinates of a hole outline are (25, 29), and the distance from the hole outline coordinates (25, 29) to the point (25, 25) is 4, and the absolute value of the difference between this actual boundary distance of 4 and rs is 0, then the boundary offset value is 0.
[0100] Step S7: Obtain the offset value distribution coordinate points based on the top view image of the cane support tube during normal marking; Step S7 includes the following sub-steps:
[0101] Step S701: The top view image of the support tube during normal marking is regarded as the real-time offset value obtained from the real-time support tube image and marked as the historical normal offset value.
[0102] Step S702: Obtain a second number of historical normal offset values; in order to obtain the range of historical normal offset values during normal marking, the larger the second number, the better, for example, the second number is 275;
[0103] Step S703: If there are identical historical normal offset values, count the number of historical normal offset values and the corresponding identical historical normal offset values, and mark them as the number of identical offset values;
[0104] Step S704: Establish a Cartesian coordinate system with historical normal offset values as the horizontal axis data and the number of identical offset values as the vertical axis data, and mark it as the offset value observation coordinate system;
[0105] Step S705: Plot the historical normal offset value and the corresponding number of the same offset value as the x and y coordinates of the data points on the offset value observation coordinate system.
[0106] Step S706: Mark the data points in the offset value observation coordinate system as offset value distribution coordinate points; establish offset value distribution coordinate points to observe the distribution of historical normal offset values;
[0107] For practical applications, please refer to Figure 5 As shown, the coordinates of the obtained offset values are distributed.
[0108] Step S8: Obtain the normal offset threshold based on the offset value distribution coordinate points; Step S8 includes the following sub-steps:
[0109] Step S801: Obtain the horizontal range length of all historical normal offset values in the offset value observation coordinate system, and label it as D1; please refer to... Figure 5 As shown, D1 is the length from 0 to 1 mm, i.e., 1 mm;
[0110] Step S802: Create a line segment of length D2 on the horizontal axis of the offset value observation coordinate system, which can move left and right, and mark it as the distribution judgment line segment; in order to judge the distribution of historical normal offset values based on the distribution judgment line segment, D2 is set to be less than D1, for example, D2 is 0.1;
[0111] Step S803, calculate the distribution number threshold as: P = f × (D2 ÷ D1) × C; where P is the distribution number threshold, f is the number adjustment ratio, and C is the second quantity; the distribution number threshold is the number of historical normal offset values with smaller distributions. At the same time, since (D2 ÷ D1) × C is the average number of historical normal offset values under the length of D2 and the length of D1, P must be less than (D2 ÷ D1) × C, that is, f is less than 1, for example, f is 0.2;
[0112] In practical applications, the threshold for the number of distributions is calculated as: P = 0.2 × (0.1 ÷ 1) × 275 = 5.5, so the threshold for the number of distributions is 5.5.
[0113] Step S804: Mark the sum of the number of historical normal offset values corresponding to all offset value distribution coordinate points directly above the distribution judgment line segment as the real-time line segment number;
[0114] Step S805: On the horizontal axis of the offset value observation coordinate system, make the horizontal coordinate of the right endpoint of the distribution judgment line segment equal to the horizontal coordinate of the distribution coordinate point with the largest offset value. Then, move the distribution judgment line segment to the left and continuously compare the real-time number of line segments with the distribution number threshold. When the real-time number of line segments is greater than or equal to the distribution number threshold, stop moving the distribution judgment line segment. Obtain the historical normal offset value corresponding to the horizontal coordinate of the right endpoint of the distribution judgment line segment at this time and mark it as the normal offset threshold. The normal offset threshold is the maximum value of the historical normal offset value after excluding abnormally large historical normal offset values.
[0115] For practical applications, please refer to Figure 5As shown, since the length of the distribution judgment line segment is 0.1, there are two offset value distribution coordinate points above the distribution judgment line segment. On the horizontal axis of the offset value observation coordinate system, the horizontal coordinate of the right endpoint of the distribution judgment line segment is made equal to the horizontal coordinate of the distribution coordinate point with the largest offset value. Then, the distribution judgment line segment is moved to the left, and the real-time number of line segments and the distribution number threshold are compared in real time. When the real-time number of line segments (7) is greater than the distribution number threshold (5.5), the movement of the distribution judgment line segment is stopped. The historical normal offset value corresponding to the horizontal coordinate of the right endpoint of the distribution judgment line segment at this time is obtained, i.e., the right endpoint of the distribution judgment line segment and... Figure 5 If the x-coordinate of the second offset value distribution point from right to left is equal, which is 0.9mm, then the normal offset threshold is 0.9mm.
[0116] Step S9: Rotate the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold; Step S9 includes the following sub-steps:
[0117] Step S901: If no real-time hole area appears, or if the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, re-acquire the real-time support tube image and real-time offset value while rotating the cane support tube. When the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, stop rotating the cane support tube and transfer the cane support tube to the marking area for marking. This is because the closer to the hole, the smaller the real-time offset value. Since marking is set to be directly opposite the hole, that is, when in a qualified marking position, the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold.
[0118] In practical applications, for example, when the real-time offset value is 0.1mm, which is less than the normal offset threshold of 0.9mm, the rotation of the cane support tube is stopped, and the cane support tube is transferred to the marking area for marking, indicating that the marking position is qualified at this time.
[0119] Example 2: This application also provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, steps such as those in the machine vision-based marking reversal node control method are performed to achieve the following functions: acquiring a top view image of the cane support tube and marking it as a real-time support tube image; acquiring a real-time grayscale histogram based on the real-time support tube image; acquiring a real-time hole threshold based on the real-time grayscale histogram; acquiring a real-time hole region based on the real-time hole threshold; fitting a contour fitting function based on the real-time hole region; acquiring a real-time offset value based on the contour fitting function; acquiring the offset value distribution coordinate points based on the top view image of the cane support tube during normal marking; acquiring a normal offset threshold based on the offset value distribution coordinate points; and rotating the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold.
[0120] Furthermore, when the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0121] Example 3: This application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the machine vision-based marking reversal node control method provided by the above methods. The method includes: acquiring a top view image of a cane support tube and marking it as a real-time support tube image; acquiring a real-time grayscale histogram based on the real-time support tube image; acquiring a real-time hole threshold based on the real-time grayscale histogram; acquiring a real-time hole region based on the real-time hole threshold; fitting a contour fitting function based on the real-time hole region; acquiring a real-time offset value based on the contour fitting function; acquiring offset value distribution coordinate points based on the top view image of the cane support tube during normal marking; acquiring a normal offset threshold based on the offset value distribution coordinate points; and rotating the cane support tube to a normal marking position based on the real-time offset value and the normal offset threshold.
[0122] Example 4: This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it performs the steps of the above-described machine vision-based marking reversal node control method to achieve the following functions: acquiring a top-view image of the cane support tube and marking it as a real-time support tube image; acquiring a real-time grayscale histogram based on the real-time support tube image; acquiring a real-time hole threshold based on the real-time grayscale histogram; acquiring a real-time hole region based on the real-time hole threshold; fitting a contour fitting function based on the real-time hole region; acquiring a real-time offset value based on the contour fitting function; acquiring the offset value distribution coordinate points based on the top-view image of the cane support tube during normal marking; acquiring a normal offset threshold based on the offset value distribution coordinate points; and rotating the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold.
[0123] Based on the above description of the embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the above technical solutions, in essence or in terms of their contribution to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or certain parts of the embodiments.
[0124] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces. The indirect coupling or communication connection between systems, modules, and units may be electrical, mechanical, or other forms.
[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A machine vision-based method for controlling marking and reversing nodes, characterized in that, Includes the following steps: Obtain a top-view image of the cane support tube and label it as a real-time support tube image; Real-time grayscale histogram is obtained based on real-time support tube image; Real-time hole threshold is obtained based on real-time grayscale histogram; Real-time hole region is obtained based on real-time hole threshold; Based on real-time hole region fitting contour fitting function; Real-time offset values are obtained based on contour fitting functions; The offset value distribution coordinates are obtained based on the top view image of the cane support tube during normal marking. Obtain the normal offset threshold based on the coordinate points of the offset value distribution; The cane support tube is rotated to the normal marking position based on the real-time offset value and the normal offset threshold.
2. The machine vision-based marking and reversal node control method according to claim 1, characterized in that, Obtaining a real-time grayscale histogram based on a real-time support tube image includes the following sub-steps: The real-time support tube image is converted to grayscale to obtain a grayscale image, which is then labeled as the real-time support tube grayscale image. Mark the grayscale values of the pixels in the real-time support tube grayscale image as the real-time support tube grayscale values; Obtain the range of grayscale values of the real-time support tube in the real-time support tube grayscale image and mark it as the real-time grayscale range; Divide the real-time grayscale range into a first number of equal range intervals, and mark them as real-time grayscale intervals; Obtain the frequency of the grayscale value of the real-time support tube within each real-time grayscale interval and mark it as the real-time grayscale frequency. A histogram is drawn with the real-time support tube grayscale value as the X-axis value, the real-time grayscale frequency as the Y-axis value, and the real-time grayscale interval as the histogram interval. This histogram is then marked as the real-time grayscale histogram.
3. The machine vision-based marking and reversal node control method according to claim 2, characterized in that, Obtaining the real-time hole threshold based on the real-time grayscale histogram includes the following sub-steps: In the real-time grayscale histogram, the real-time grayscale intervals that have a higher real-time grayscale frequency than the left and right sides are marked as peak intervals. Find the peak interval with the smallest median value and mark it as the first target interval; Find the peak interval with the largest median value and mark it as the second target interval; The real-time grayscale interval with the minimum grayscale frequency between the first target interval and the second target interval is identified and marked as the third target interval. Obtain the median value of the third target interval and mark it as the real-time hole threshold.
4. The machine vision-based marking and reversal node control method according to claim 3, characterized in that, Obtaining the real-time hole region based on the real-time hole threshold includes the following sub-steps: Set the gray values of real-time support tubes that are less than the real-time hole threshold in the real-time support tube grayscale image to 0, and set the gray values of real-time support tubes that are greater than or equal to the real-time hole threshold in the real-time support tube grayscale image to 255 to obtain a binarized image of the real-time support tube. Pixels with a grayscale value of 0 in the real-time support tube binarization image are marked as hole pixels. A continuous region composed of hole pixels is marked as a real-time hole region.
5. The machine vision-based marking and reversal node control method according to claim 4, characterized in that, The contour fitting function based on real-time hole region fitting includes the following sub-steps: Establish a Cartesian coordinate system and label it as the contour extraction coordinate system; place the real-time hole region in the first quadrant of the contour extraction coordinate system; Obtain the coordinate points on the real-time hole region outline and mark them as hole outline coordinate points; The contour fitting function is set as: (A1-k1) 2 +(A2-k2) 2 =r 2 Where A1 and A2 are the X-axis and Y-axis values of the contour fitting function, respectively, and k1, k2, and r are constants of the contour fitting function; All hole contour coordinates are fitted with a contour fitting function to obtain the specific values of k1, k2 and r, which are labeled as ks1, ks2 and rs respectively.
6. The machine vision-based marking and reversal node control method according to claim 5, characterized in that, Obtaining real-time offset values based on contour fitting functions includes the following sub-steps: Obtain the distance from all hole outline coordinate points to point (ks1, ks2), and mark it as the actual boundary distance; Obtain the absolute value of the difference between all actual boundary distances and rs, and mark it as the boundary offset value; Obtain the mean of all boundary offset values and mark it as the real-time offset value; Obtain the real-time offset values of all real-time hole regions.
7. The machine vision-based marking and reversal node control method according to claim 6, characterized in that, Obtaining the offset value distribution coordinate points based on the top view image of the support tube during normal marking includes the following sub-steps: The top view image of the support tube during normal marking is regarded as the real-time offset value obtained from the real-time support tube image and marked as the historical normal offset value. Obtain the second number of historical normal offset values; If there are identical historical normal offset values, count the number of historical normal offset values and the corresponding number of identical historical normal offset values, and mark them as the number of the same offset value. Establish a Cartesian coordinate system with historical normal offset values as the horizontal axis data and the number of identical offset values as the vertical axis data, and mark it as the offset value observation coordinate system; The historical normal offset value and the corresponding number of the same offset value are respectively used as the x and y coordinates of the data points and plotted on the offset value observation coordinate system; Mark the data points in the offset observation coordinate system as offset value distribution coordinate points.
8. The machine vision-based marking and reversal node control method according to claim 7, characterized in that, Obtaining the normal offset threshold based on the offset value distribution coordinate points includes the following sub-steps: Obtain the horizontal range length of all historical normal offset values in the offset value observation coordinate system, and label it as D1; Create a line segment of length D2 on the horizontal axis of the offset observation coordinate system that can move left and right, and mark it as the distribution judgment line segment; The threshold for the number of distributions is calculated as: P = f × (D2 ÷ D1) × C; where P is the threshold for the number of distributions, f is the number adjustment ratio, and C is the second quantity.
9. The machine vision-based marking and reversal node control method according to claim 8, characterized in that, Obtaining the normal offset threshold based on the offset value distribution coordinate points also includes the following sub-steps: The sum of the number of historical normal offset values corresponding to all offset value distribution coordinate points directly above the distribution judgment line segment is marked as the real-time line segment count; On the horizontal axis of the offset value observation coordinate system, make the horizontal coordinate of the right endpoint of the distribution judgment line segment equal to the horizontal coordinate of the largest offset value distribution coordinate point. Then move the distribution judgment line segment to the left and judge the size of the real-time line segment count and the distribution count threshold in real time. When the real-time line segment count is greater than or equal to the distribution count threshold, stop moving the distribution judgment line segment. Obtain the historical normal offset value corresponding to the x-coordinate of the right endpoint of the distribution judgment line segment at this time, and mark it as the normal offset threshold.
10. The machine vision-based marking and reversal node control method according to claim 9, characterized in that, Rotating the cane support tube to the normal marking position based on the real-time offset value and the normal offset threshold includes the following sub-steps: If no real-time hole area appears, or if the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, the real-time support tube image and real-time offset value are reacquired while rotating the cane support tube. When the real-time offset value of all real-time hole areas is less than or equal to the normal offset threshold, the rotation of the cane support tube is stopped, and the cane support tube is transferred to the marking area for marking.
Citation Information
Patent Citations
Marking control method and device, storage medium, processor and marking equipment
CN113696639A