Obstacle identification method based on machine vision
By determining the warning line area, edge extraction and color feature analysis in machine vision, combined with morphological operations, the problem of low efficiency and low accuracy of warning line recognition in the existing technology is solved, and accurate and efficient identification of the warning line is achieved. Identify.
Patent Information
- Application Number
- CN202410698764.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-05-31
AI Technical Summary
The current obstacle recognition method has low efficiency and low accuracy in identifying warning lines. It is especially difficult to accurately identify when the warning lines are worn, and the image processing method is easily interfered by non-warning line edges, affecting the recognition effect.
Using a method based on machine vision, non-warning line edges are filtered by determining the warning line area, edge extraction, color feature analysis and morphological operations, and the warning line outline is extracted by combining edge and color features to reduce interference and improve recognition accuracy.
It achieves accurate and efficient identification of warning lines, reduces misjudgments and missed judgments, improves identification efficiency, and ensures identification capabilities under complex conditions.
Smart Images

Figure CN118609047A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing methods, and in particular to an obstacle recognition method based on machine vision. Background Art
[0002] With the rapid development of machine vision and artificial intelligence technology, the ability to identify and process specific environmental features has become the key to the system. As an important identification line, the warning line is widely used in roads, factories, public places and other environments to indicate the safe operation area of people or machinery and equipment. At present, most obstacle recognition methods rely on image processing, manual inspections and simple sensor detection. These methods are currently facing not only low efficiency but also low recognition accuracy, and even misjudgment and missed judgment. Among them, the current method of using image processing to identify the warning line usually involves binarization and edge detection of the image captured by the camera to identify the location of the warning line. However, this method does not fully utilize the characteristics of the warning line and cannot accurately and completely identify the warning line, especially when the edge and contour of the warning line are affected by complex conditions such as wear and tear. The recognition ability is greatly reduced.
[0003] In summary, in the recognition of warning lines, the recognition of warning lines based on machine vision currently faces the following problems:
[0004] 1) In addition to the warning lines, there are many objects in the collected images. The distribution of these objects is irregular and complex, which has a great impact on the subsequent extraction of the warning lines.
[0005] 2) In order to obtain more edge information during image edge extraction, the threshold in edge extraction can be reduced, but at the same time, many non-warning line edges will be extracted. These non-warning line edges will make subsequent operations more complicated. Under these influences, it is difficult to extract only the warning lines in the end, and other objects may be extracted together.
[0006] 3) At present, the recognition of warning lines mostly relies on edge detection processing. However, when the edge of the warning line is damaged, the recognition effect of the warning line will be seriously affected. This method is difficult to fully utilize the characteristics of the warning line. The above problems will seriously affect the accurate recognition of the warning line. Summary of the invention
[0007] The technical problem to be solved by the present invention is how to provide a method for accurately and efficiently identifying a warning line.
[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is: a method for obstacle recognition based on machine vision, comprising the following steps:
[0009] S1: determine and extract the warning line area from the acquired image;
[0010] S2: Extract the edge of the warning line area;
[0011] S3: extract the corresponding warning line area according to the color feature;
[0012] S4: Fill the edge-extracted image with the extracted warning line area;
[0013] S5: Extract the outline of the warning line and identify the warning line.
[0014] Furthermore, the method comprises the following steps:
[0015] S1: Extract the warning line area from the collected image. First, determine the area where the warning line is located based on the color feature, then generate a mask for the area and finally extract the area where the warning line is located. This reduces the interference of other content in the image and facilitates subsequent further operations.
[0016] S2: Extract the edge of the warning line area. Use the Canny operator to extract the edge of the extracted warning line area, and then filter the extracted edges to filter out the horizontal and vertical line segments that are not the edges of the warning line, so that the edge of the warning line is more accurate;
[0017] S3: Extract the warning line based on color features. Analyze the color features of the warning line, convert the warning line area into HSV space, and extract the warning line based on color.
[0018] S4: Fill the edge of the warning line extracted in step S2 with the warning line extracted in step S3.
[0019] S5: Extract the outline of the warning line. Perform outline extraction on the warning line image filled in step S4, sort the extracted outlines according to the perimeter of the outline to extract the warning line, and finally identify and mark the warning line.
[0020] The beneficial effects of the above technical solution are as follows: 1) The method of the present invention introduces the area extraction based on "determining the warning line area-generating a mask-extracting the warning line area" to extract the warning line area. The influence of the area outside the warning line on subsequent operations is eliminated, so that the subsequent operations of the image are more focused on the target object, which greatly improves the usability.
[0021] 2) The method described in the present invention introduces a filtering method for edge-extracted images based on "constructing convolution kernels - extracting horizontal and vertical line segments - generating masks - filtering out line segments at the edge of non-warning lines". By constructing a specific convolution kernel according to the height and width of the image and extracting horizontal and vertical line segments at the edge of non-warning lines using morphological operations, performing Hough transform to obtain the position information of the line segments, and then generating masks based on the position information, finally filtering out line segments at the edge of non-warning lines. This overcomes the problem of redundant information affecting subsequent operations in ordinary edge extraction.
[0022] 3) The method of the present invention introduces a method of combining color features with edge features to extract the outline of the warning line. Among them, edge extraction is used to determine the general outline of the warning line, and color feature extraction is used to supplement the details of the warning line. The warning line extracted by color features is used to fill the outline of the warning line obtained by edge feature extraction, and finally a relatively complete outline is obtained. The problem of incomplete extraction of the warning line outline is effectively solved. In summary, the method can accurately and efficiently complete the identification of the warning line. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0024] Figure 1 A flowchart of the method according to an embodiment of the present invention;
[0025] Figure 2 The initial warning line img image in the method described in the embodiment of the present invention;
[0026] Figure 3 The hsv_img image converted into the hsv space in the method of the embodiment of the present invention;
[0027] Figure 4 The mask1 image is obtained by performing threshold processing on the hsv spatial image in the method according to the embodiment of the present invention;
[0028] Figure 5 The canny_img1 image after marginalization in the method described in the embodiment of the present invention;
[0029] Figure 6 The same_img image is initialized in the method described in the embodiment of the present invention;
[0030] Figure 7 The bit_img image obtained after the AND operation in the method described in the embodiment of the present invention;
[0031] Figure 8 The canny_bit image after marginalization in the method described in the embodiment of the present invention;
[0032] Fig. 9 The mask_reh image after the corrosion operation in the method according to the embodiment of the present invention;
[0033] Fig.10 The mask_rev image after the corrosion operation in the method according to the embodiment of the present invention;
[0034] Fig.11 The canny_img image after the AND operation in the method described in the embodiment of the present invention;
[0035] Fig.12 The mask_b image is the image after threshold processing in the method described in the embodiment of the present invention;
[0036] Fig.13 The mask_black image after the AND operation in the method described in the embodiment of the present invention;
[0037] Fig.14 The dilation_mask image after the dilation operation in the method according to the embodiment of the present invention;
[0038] Fig.15 The same_img2 image is initialized in the method described in the embodiment of the present invention;
[0039] Fig.16 It is the img_end image after the outline is drawn in the method described in the embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0042] like Figure 1 As shown, an embodiment of the present invention discloses a method for identifying obstacles based on machine vision, and the method comprises the following steps:
[0043] S1: Extract the warning line area from the collected image. First, determine the area where the warning line is located based on the color feature, then generate a mask for the area and finally extract the area where the warning line is located. This reduces the interference of other content in the image and facilitates subsequent further operations.
[0044] S2: Extract the edge of the warning line area. Use the Canny operator to extract the edge of the extracted warning line area, and then filter the extracted edges to filter out the horizontal and vertical line segments that are not the edges of the warning line, so that the edge of the warning line is more accurate;
[0045] S3: Extract the warning line based on color features. Analyze the color features of the warning line, convert the warning line area into HSV space, and extract the warning line based on color.
[0046] S4: Fill the edge of the warning line extracted in step S2 with the warning line extracted in step S3.
[0047] S5: Extract the outline of the warning line. Perform outline extraction on the warning line image filled in step S4, sort the extracted outlines according to the perimeter of the outline to extract the warning line, and finally identify and mark the warning line.
[0048] The further step S1 specifically includes:
[0049] S11: pre-processing the collected images.
[0050] S12: Determine the area of the warning line according to the color feature.
[0051] S13: Generate a mask for the determined warning line area.
[0052] S14: Extract the warning line area according to the mask generated in step S13.
[0053] In step S11, the image preprocessing includes first performing median filtering on the collected image, and then performing bilateral filtering to remove noise.
[0054] The step S12 specifically includes, firstly, converting the preprocessed warning line image into HSV space; then generating a threshold value according to the color feature of the warning line, and binarizing the warning line image in the HSV space according to the threshold value; then performing Hough transform on the binarized image to find a straight line, sorting all the found straight lines according to the ordinate to obtain the straight line with the smallest ordinate, and obtaining the position information of the straight line in the image to determine the warning line area.
[0055] The step S13 specifically includes, firstly, generating a matrix area including the warning line according to the position information of the straight line found in step S12, then constructing an image with the same width and height as the warning line image, and then initializing the constructed image to set the matrix area to white and other areas to black. Finally, a black and white image is obtained as a mask. The formula for generating the mask is as follows:
[0056]
[0057] Among them, image same_img is an image constructed with the same width and height as the warning line image, y1 is the vertical coordinate of the straight line mentioned above, t1 and t2 are floating values used to generate the matrix area containing the warning line, and h_con is the height of the warning line area.
[0058] The step S14 specifically includes performing an AND operation on the mask generated in step S13 and the collected warning line image to finally achieve the effect of extracting the warning line area.
[0059] Furthermore, the step S2 specifically includes:
[0060] S21: performing edge extraction on the extracted warning line area;
[0061] S22: Obtaining the horizontal line segments of the non-warning line edges in the image after edge extraction;
[0062] S23: Obtaining the longitudinal line segments of the non-warning line edges in the image after edge extraction;
[0063] S24: Generate a mask using the horizontal and vertical line segments extracted in step 22 and step 23;
[0064] S25: Filter out line segments that are not on the edge of the warning line using the mask generated in step 24;
[0065] The step S21 specifically includes first converting the warning line area extracted in step S14 into a grayscale image, and then performing edge extraction on the grayscale image using the Canny operator.
[0066] The step S22 specifically includes first constructing a convolution kernel kernel_hors of hors_k*1, and then using the convolution kernel and the edge-extracted image to perform an erosion operation to obtain a horizontal line segment of the edge of the non-warning line.
[0067]
[0068] Where hors_k is the size of the convolution kernel, width is the width of the warning line image, and kernel_hors is the specific convolution kernel used.
[0069] The step S23 specifically includes first constructing a convolution kernel kernel_vert of 1*vert_k, and then using the convolution kernel and the edge-extracted image to perform an erosion operation to obtain a longitudinal line segment of the non-warning line edge.
[0070]
[0071] Where vert_k is the size of the convolution kernel, height is the width of the warning line image, and kernel_vert is the specific convolution kernel used.
[0072] The step S24 specifically includes performing Hough transform on the horizontal and vertical line segments obtained in step S22 and step S23 to find straight lines to obtain the position information of each line segment, and finally making a mask according to the position information of each line segment, constructing an image with the same width and height as the warning line image, initializing the constructed image, setting the area of the line segment to black, and setting the other areas to white.
[0073] The step S25 specifically includes performing an AND operation on the mask obtained in step S24 and the image extracted by the edge in step S21 to filter out line segments that are not on the edge of the warning line.
[0074] Further, the method is described in detail below with reference to specific data and drawings:
[0075] The specific method of step S1 includes the following steps:
[0076] S11: The collected image img is as follows: Figure 2 The median filtering is performed to obtain an image middle_img;
[0077] S12: perform bilateral filtering and denoising on the image middle_img to obtain the image bilater_img;
[0078] S13: Convert the image bilater_img into an hsv spatial image to obtain hsv_img as Figure 3 As shown;
[0079] S14: Set a threshold value according to the value of yellow in hsv, where the lower limit of the threshold value is low (min_h, min_s, min_v) and the upper limit of the threshold value is high (max_h, max_s, max_v)
[0080]
[0081] Among them, hsv_yellow is the HSV value of yellow in the HSV space, hsv_min is the minimum HSV value that can detect yellow in the HSV space, hsv_max is the maximum HSV value that can detect yellow in the HSV space, (min_h, min_s, min_v) are the specific values of low, which are set to (15, 57, 200) here, and (max_h, max_s, max_v) are the specific values of high, which are set to (30, 255, 255) here.
[0082] S15: Perform threshold processing on the image hsv_img to obtain the image mask1, such as Figure 4 As shown, the lower limit of the threshold is low (min_h, min_s, min_v), and the upper limit of the threshold is high (max_h, max_s, max_v). The image within this range is turned white, and the image outside the range is turned black. The threshold formula here is:
[0083]
[0084] S16: Use a 3*3 convolution kernel to dilate mask1. The number of iterations is itera1 to obtain the image dilation_img. The formula for determining the number of iterations is:
[0085]
[0086] Among them, itera1 is the number of dilation iterations, s_w is the area of the white area, and size_kmax is the size of the convolution kernel, which is set to 10 here;
[0087] S17: Use the Canny operator to perform edgewise operation on dilation_img to obtain image canny_img1, such as Figure 5 As shown;
[0088] S18: Perform Hough transform on the image canny_img1, find straight lines to get all straight lines, and save them in the lines_list list;
[0089] S19: Sort the lines_list list according to the y coordinate to obtain the straight line where the point dot (x1, y1) with the smallest y coordinate value is located;
[0090] S110: Initialize a black and white image same_img with the same width and height as the image img, such as Figure 6 As shown, perform initialization assignment, and the initialization formula is:
[0091]
[0092] Among them, same_img(x,y) is the x and y coordinate values of the image same_img, y1 is the ordinate of the dot point, w_con is the height of the warning line area, t1 and t2 are floating ranges, where t1 is 30 and t2 is 270.
[0093] Furthermore, the step S2 specifically includes the following steps:
[0094] S21: convert the image img into a grayscale image gray;
[0095] S22: Use image same_img as a mask to perform AND operation on grayscale image gray to obtain image bit_img, such as Figure 7 As shown;
[0096]
[0097] Among them, bit_img(x,y) is the value of the x,y coordinates of the bit_img image, same_img(x,y) is the value of the x,y coordinates of the same_img image, and dilate_img(x,y) is the value of the x,y coordinates of the dilate_img image.
[0098] S23: Use the Canny operator to perform edge operation on the image bit_img to obtain the image canny_bit, such as Figure 8 As shown;
[0099] S24: Perform Hough transform on the image canny_bit, find a longer straight line and store the coordinates of the starting point and the end point in the lines list.
[0100] S25: Generate a mask for the coordinates of each line segment in lines to obtain the image mask_reline. The formula is as follows:
[0101]
[0102] Among them, mask_reline(x,y) is the x, y coordinate value of the image mask_reline, and y1 is the ordinate of the starting point of each line segment.
[0103] S26: Construct the convolution kernel kernel_hors of hors_k*1 and perform itera corrosion operations with mask_reline to obtain a shorter horizontal line segment and obtain the image mask_reh, such as Fig. 9 As shown, where:
[0104]
[0105] Among them, width is the width of the image img, kernel_hors is the convolution kernel used, itera is the number of iterations, s_d is the area of the black area, and size_kmin is the size of the convolution kernel, which is set to 1 here.
[0106] S27: Perform Hough transform on the image mask_reh, and store the found straight line into the list list_line1;
[0107] S28: Generate mask_h according to the straight line in list_line1. The formula is as follows:
[0108]
[0109] Among them, mask_h(x,y) is the value of the horizontal and vertical coordinates of the image mask_h, width is the width of the image, and y1 is the vertical coordinate of the line segment in list_line1.
[0110] S29: Construct a 1*vert_k convolution kernel kernel_vert and perform corrosion operation on the image mask_reline to obtain a shorter vertical line segment. The number of iterations is itera2, and the image mask_rev is obtained, such as Fig.10 As shown;
[0111] Among them, itera2 is the number of dilation iterations 1, s_d is the area of the black area, size_kmin is the size of the convolution kernel, which is set to 1 here, height is the height of the image img, and kernel_vert is the specific convolution kernel.
[0112] S210: Perform Hough transform on the image mask_rev, and store the found straight line into the list list_line2;
[0113] S211: Generate mask_v according to the straight line in list_line2. The formula is as follows:
[0114]
[0115] Among them, mask_v(x,y) is the value of the horizontal and vertical coordinates of the image mask_v, height is the width of the image, and x1 is the vertical coordinate of the line segment in list_line2.
[0116] S212: Perform an AND operation on the image mask_h and the image mask_v to obtain the image canny_img, such as Fig.11 shown.
[0117] Furthermore, the step S3 specifically includes the following steps:
[0118] S31: Set a threshold value according to the value of black in hsv, where the lower limit of the threshold value is blacklow (min2_h, min2_s, min2_v) and the upper limit of the threshold value is blackhigh (max2_h, max2_s, max2_v)
[0119]
[0120] Among them, hsv_black is the HSV value of black in the HSV space, hsvblack_min is the minimum HSV value that can detect black in the HSV space, hsvblack_max is the maximum HSV value that can detect black in the HSV space, (min2_h, min2_s, min2_v) are the specific values of blacklow, which are set to (58, 1, 46) here, and (max2_h, max2_s, max2_v) are the specific values of blackhigh, which are set to (174, 40, 136) here.
[0121] S32: Perform threshold processing on the image hsv_img to obtain the image mask_b, such as Fig.12 As shown, the threshold formula here is:
[0122]
[0123] Among them, the lower limit of the threshold is low1 (min2_h, min2_s, min2_v), and the upper limit of the threshold is high1 (max2_h, max2_s, max2_v). The image within this range will be turned white, and the image outside the range will be turned black
[0124] S33: Perform an AND operation on the image mask_b and the image same_img to obtain the image mask_black, such as Fig.13 shown.
[0125]
[0126] Among them, mask_black(x,y) is the value of the x,y coordinates of the mask_black image, same_img(x,y) is the value of the x,y coordinates of the same_img image, and mask_b(x,y) is the value of the x,y coordinates of the mask_b image.
[0127] Furthermore, the step S4 specifically includes the following steps:
[0128] S41: performing an AND operation on the image mask1 and the image canny_img to obtain the image bit_yellow;
[0129]
[0130] Here, bit_yellow(x,y) is the value of the x,y coordinates of the bit_yellow image, canny_img(x,y) is the value of the x,y coordinates of the canny_img image, and mask_1(x,y) is the value of the x,y coordinates of the mask_1 image.
[0131] S42: performing an AND operation on the image mask_b and the image bit_yellow to obtain the image bit_b;
[0132]
[0133] Among them, bit_b(x,y) is the value of the x,y coordinates of the image bit_b, bit_yellow(x,y) is the value of the x,y coordinates of the bit_yellow image, and mask_b(x,y) is the value of the x,y coordinates of the mask_b image.
[0134] S43: Use a 7*7 convolution kernel to dilate bit_b, the number of iterations is itera3, and the image dilation_mask is obtained, as shown in Fig.14 As shown;
[0135]
[0136] Among them, itera3 is the number of dilation iterations, s_w is the area of the white area, and size_kmin is the size of the convolution kernel, which is set to 2 here.
[0137] Furthermore, the step S5 extracts the outline of the warning line, which specifically includes the following steps:
[0138] S51: Search for contours in the image dilation_mask, and save all contours in the contours_list list;
[0139] S52: sort the contours_list list according to the perimeter of the contours to obtain the contour with the largest perimeter;
[0140] S53: Initialize a black and white image same_img2 with the same width and height as the image img, such as Fig.15 As shown, the initialization formula is:
[0141]
[0142] Among them, same_img2(x,y) is the x, y coordinate value of image same_img2, and contour(x,y) is the x, y coordinate value of each point in contour.
[0143] S54: Find the contour of same_img2 and draw the contour to obtain the final image img_end. Fig.16 .
[0144] Through the above steps, the method of the present invention can make fuller use of the color characteristics and edge characteristics of the warning line, more accurately and completely identify and mark the warning line, while reducing labor costs and improving efficiency.
Claims
1. An obstacle recognition method based on machine vision, characterized in that The steps include: S1: determine and extract the warning line area from the acquired image; S2: Extract the edge of the warning line area; S3: extract the corresponding warning line area according to the color feature; S4: Fill the edge-extracted image with the extracted warning line area; S5: Extract the outline of the warning line and identify the warning line.
2. The obstacle recognition method based on machine vision according to claim 1, characterized in that: The S1 specifically includes the following steps: S11: Filter the collected image img to obtain the image middle_img; S12: Filter and denoise the filtered image middle_img to obtain an image bilater_img; S13: convert the image bilater_img into an hsv space image to obtain an image hsv_img; S14: Set a threshold value according to the value of yellow in hsv, where the lower limit of the threshold value is low (min_h, min_s, min_v) and the upper limit of the threshold value is high (max_h, max_s, max_v) Among them, hsv_yellow is the HSV value of yellow in the HSV space, hsv_min is the minimum HSV value that can detect yellow in the HSV space, hsv_max is the maximum HSV value that can detect yellow in the HSV space, (min_h, min_s, min_v) are the specific values of low, and (max_h, max_s, max_v) are the specific values of high; S15: Perform threshold processing on the image hsv_img to obtain the image mask1, where the lower limit of the threshold is low (min_h, min_s, min_v), and the upper limit of the threshold is high (max_h, max_s, max_v). The image within the range is turned white, and the image outside the range is turned black. The threshold formula here is: S16: Use a 3*3 convolution kernel to dilate mask1, the number of iterations is itera1, and the image dilation_img is obtained. The formula for determining the number of iterations is: Where itera1 is the number of dilation iterations, s_w is the area of the white area, and size_kmax is the size of the convolution kernel; S17: Use the Canny operator to perform edge operation on the image dilation_img to obtain the image canny_img1; S18: Perform Hough transform on the image canny_img1 to find all the straight lines and save them in the lines_list list; S19: Sort the lines_list list according to the y coordinate to obtain the straight line where the point dot (x1, y1) with the smallest y coordinate value is located; S110: Initialize a black and white image same_img with the same width and height as the image img. The initialization formula is: Among them, same_img(x,y) is the value of the x and y coordinates of the same_img image, y1 is the ordinate of the dot point, w_con is the height of the warning line area, and t1 and t2 are floating ranges.
3. The obstacle recognition method based on machine vision according to claim 1, characterized in that: The S2 specifically includes the following steps: S21: convert the image img into a grayscale image gray; S22: Use image same_img as a mask to perform AND operation on the grayscale image gray to obtain image bit_img; Among them, bit_img(x,y) is the value of the x,y coordinates of the bit_img image, same_img(x,y) is the value of the x,y coordinates of the same_img image, and dilate_img(x,y) is the value of the x,y coordinates of the dilate_img image; S23: Use the Canny operator to perform edge operation on the image bit_img to obtain the image canny_bit; S24: Perform Hough transform on the image canny_bit to find a longer straight line and store the coordinates of the starting point and the end point in the lines list; S25: Generate a mask for the coordinates of each line segment in the lines list to obtain the image mask_reline formula as follows: Among them, mask_reline(x,y) is the x, y coordinate value of the image mask_reline, and y1 is the ordinate of the starting point of each line segment; S26: Construct the convolution kernel kernel_hors of hors_k*1 and perform itera corrosion operations with mask_reline to obtain a shorter horizontal line segment to obtain the image mask_reh, where: Among them, width is the width of the image img, kernel_hors is the convolution kernel used, itera is the number of iterations, s_d is the area of the black area, and size_kmin is the size of the convolution kernel; S27: Perform Hough transform on the image mask_reh, and store the found straight line into the list list_line1; S28: The formula for generating mask mask_h according to the straight line in list_line1 is as follows: Among them, mask_h(x,y) is the value of the horizontal and vertical coordinates of the image mask_h, width is the width of the image, and y1 is the vertical coordinate of the line segment in list_line1; S29: Construct a 1*vert_k convolution kernel kernel_vert and perform corrosion operation with mask_reline to obtain a shorter vertical line segment. The number of iterations is itera2 to obtain the image mask_rev. Among them, itera2 is the number of dilation iterations 1, s_d is the area of the black area, size_kmin is the size of the convolution kernel, height is the height of the image img, and kernel_vert is the specific convolution kernel; S210: Perform Hough transform on the image mask_rev and store the found straight line in list list_line2 S211: The formula for generating mask mask_v according to the straight line in list_line2 is as follows: Among them, mask_v(x,y) is the value of the horizontal and vertical coordinates of the image mask_v, height is the width of the image, and x1 is the vertical coordinate of the line segment in list_line2; S212: Perform an AND operation on the image mask_h and the image mask_v to obtain the image canny_img.
4. The obstacle recognition method based on machine vision according to claim 1, characterized in that: The S3 specifically includes the following steps: S31: Set a threshold value according to the value of black in hsv, where the lower limit of the threshold value is blacklow (min2_h, min2_s, min2_v) and the upper limit of the threshold value is blackhigh (max2_h, max2_s, max2_v) Among them, hsv_black is the HSV value of black in the HSV space, hsvblack_min is the minimum HSV value that can detect black in the HSV space, hsvblack_max is the maximum HSV value that can detect black in the HSV space, (min2_h, min2_s, min2_v) are the specific values of blacklow, and (max2_h, max2_s, max2_v) are the specific values of blackhigh; S32: Perform threshold processing on the image hsv_img to obtain the image mask_b. The threshold formula is: Among them, the lower limit of the threshold is low1 (min2_h, min2_s, min2_v), and the upper limit of the threshold is high1 (max2_h, max2_s, max2_v). The image within this range will be turned white, and the image outside the range will be turned black; S33: performing an AND operation on the image mask_b and the image same_img to obtain the image mask_black; Among them, mask_black(x,y) is the value of the x,y coordinates of the mask_black image, same_img(x,y) is the value of the x,y coordinates of the same_img image, and mask_b(x,y) is the value of the x,y coordinates of the mask_b image.
5. The obstacle recognition method based on machine vision according to claim 1, characterized in that: The S4 specifically includes the following steps: S41: performing an AND operation on the image mask1 and the image canny_img to obtain the image bit_yellow; Among them, bit_yellow(x,y) is the value of the x,y coordinates of the bit_yellow image, canny_img(x,y) is the value of the x,y coordinates of the canny_img image, and mask_1(x,y) is the value of the x,y coordinates of the mask_1 image; S42: performing an AND operation on the image mask_b and the image bit_yellow to obtain the image bit_b; Among them, bit_b(x,y) is the value of the x,y coordinates of the bit_b image, bit_yellow(x,y) is the value of the x,y coordinates of the bit_yellow image, and mask_b(x,y) is the value of the x,y coordinates of the mask_b image; S43: Use a 7*7 convolution kernel to dilate bit_b, and the number of iterations is itera3 to obtain the image dilation_mask: Among them, itera3 is the number of dilation iterations, s_w is the area of the white area, and size_kmin is the size of the convolution kernel.
6. The obstacle recognition method based on machine vision according to claim 1, characterized in that: The S5 specifically includes the following steps: S51: Search for contours in the image dilation_mask, and save all contours in the contours_list list; S52: sorting the contours_list list according to the perimeter of the contours to obtain the contour with the largest perimeter; S53: Initialize a black and white image same_img2 with the same width and height as the image img. The initialization formula is: Among them, same_img2(x,y) is the x, y coordinate value of the same_img2 image, and contour(x,y) is the x, y coordinate value of each point in contour. S54: Find the contour of the image same_img2 and draw the contour to obtain the final image img_end marked with a warning line.
Citation Information
Patent Citations
Ground warning line identification method and device, computer equipment and storage medium
CN113657332A
Rapid belt deviation detection method based on visual identification
CN117237287A
Warning tape identification method and device, electronic equipment and storage medium
CN117541811A
Automatic marking method for ROI (Region of Interest) of one-way highway tunnel traffic event
CN117876665A
Method, apparatus and system for determining a boundary of an obstacle which occludes an object in an image
US20140119654A1
