An automatic target reporting method based on machine vision
Through Otsu's binarization and contour approximate fitting processing combined with spot detection algorithms and feature masks, the problems of missed detection, false detection and inaccurate positioning of bullet holes in automatic target reporting technology are solved, and high-accuracy bullet hole identification is achieved. and score calculation, suitable for a variety of shooting training scenarios.
Patent Information
- Application Number
- CN202210678898.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-16
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-06-16
AI Technical Summary
Existing automatic target reporting technology based on machine vision has problems such as missed detection, false detection, inaccurate positioning and inability to detect bullet holes.
Otsu binarization is used to process the original image, the contour approximate fitting method is used to find key feature points, perspective transformation is used for preliminary coordinate correction, and the bullet hole position is detected through spot detection algorithm and feature mask processing, combined with local background subtraction and Euclidean distance Calculation to achieve accurate bullet hole identification and score calculation.
It improves the accuracy of automatic target reporting, solves the problems of missed detection, false detection, inaccurate positioning and inability to detect bullet holes, and realizes accurate and automatic target reporting functions, which is suitable for basic training, assessment and competition events.
Smart Images

Figure CN115131721B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the fields of shooting training and machine vision, and in particular to an automatic target reporting method based on machine vision. Background Art
[0002] The existing live-fire shooting training mainly uses manual target reporting. Manual target reporting is inefficient and unreliable, and there are great safety risks for the target reporting personnel. In addition, the shooter cannot check his or her score in real time and cannot make adjustments in time, which is not conducive to improving the shooting level.
[0003] According to the survey, the existing automatic target reporting technology can be mainly divided into electrode embedding, photoelectric sensing, acoustic and electric positioning and machine vision based on different principles. Among them, the electrode embedding solution is a one-time target judgment, which is relatively expensive. The photoelectric sensing solution requires the installation of various sensor equipment, and the production and maintenance costs are high. The acoustic and electric positioning solution is low in cost and high in precision, but requires professional personnel to operate. A comprehensive comparison shows that the machine vision solution has the advantages of low cost, strong reusability, and can be disassembled at any time, and has great development potential. For example, the invention patent with application number CN201110069211.7 "An embedded wireless automatic target reporting system and its target reporting method" includes a target-side image acquisition and processing system, including a target paper mechanical control system that can automatically install target paper and rotate the target surface, and an image acquisition and processing system for collecting and processing target surface information; the image acquisition and processing system is connected to the output end of the target paper mechanical control system; the shooting-side target reporting system includes a shooter-side user interaction system that can communicate with the corresponding target-side image acquisition and processing system and a referee-side score statistics system that can communicate with all target-side image acquisition and processing systems; the target-side image acquisition and processing system communicates with the shooting-side target reporting system through a wireless transmission system. It can be seen from the patent specification that the existing patent adopts a conventional image binarization process, by constructing and sharpening the mask matrix to correct the initial image, and after the geometric correction of the image is completed, the image is binarized. The mask matrix processing logic and binarization process disclosed in the existing patent are different from the ring target mask preprocessing process and Otsu binarization processing logic explained in the technical solution of this application. The present application performs Otsu binarization processing after the original image is collected, which is different from the image processing technology implementation method of the aforementioned existing patent. At the same time, the existing patent also does not disclose the secondary correction and bullet hole distance calculation logic adopted by this application. Therefore, this application is very different from the technical solution of the existing patent, and the existing application is applied to multi-terminal information interaction and automatic control of target reporting in the shooting range, and cannot solve the technical problems of the existing technology in specific bullet hole detection scenarios such as continuous holes.
[0004] In summary, the real-time automatic target reporting method based on machine vision in the prior art has technical problems such as missed detection of bullet holes, false detection, inaccurate positioning, and inability to detect consecutive bullet holes. Summary of the invention
[0005] The technical problem to be solved by the present invention is how to solve the technical problems of missed detection of bullet holes, false detection, inaccurate positioning, and inability to detect consecutive bullet holes.
[0006] The present invention adopts the following technical solutions to solve the above technical problems: an automatic target reporting method based on machine vision comprises:
[0007] S1. Otsu binarization processes the original image to obtain a binary image, uses a contour approximation fitting method to find key feature points of the binary image, uses perspective transformation to perform preliminary coordinate correction on the original image to obtain a corrected image, adjusts the contrast and brightness of the corrected image, and performs mask processing on the corrected image to obtain a preprocessed image;
[0008] S2, using a spot detection algorithm to detect the bullet hole position coordinate data of the pre-processed image, and performing secondary correction on the coordinates of the pre-processed image according to a bullet hole feature matching algorithm. After the correction is completed, the bullet holes of the identified target paper are processed by feature masking, and then all candidate bullet holes of the current target paper are detected by the spot detection algorithm to obtain bullet hole identification data to be verified;
[0009] S3, extracting the same local area of the bullet hole and the background image, performing local background subtraction, and processing the bullet hole detection data to be verified with a preset logic to obtain an average grayscale difference, and verifying and obtaining a valid bullet hole based on the difference;
[0010] S4. Calculate the Euclidean distance of the effective bullet hole to the bull's-eye using a preset logic, and convert the Euclidean distance to the bull's-eye to a shooting score according to a preset scoring rule.
[0011] The present invention adopts the steps of image preprocessing, bullet hole recognition, bullet hole verification, score calculation, etc., wherein, in the image preprocessing stage, Otsu binarization, contour approximate fitting method and mask processing are adopted to obtain the image to be detected; then, in the bullet hole recognition stage, the data of the candidate bullet hole is obtained by spot detection algorithm and feature mask processing; in the bullet hole verification stage, the same local area of the bullet hole and the background image is taken out, the local background is subtracted, and the bullet hole is verified to be effective by the average grayscale difference; in the score calculation stage, the Euclidean distance of the bullet hole from the center of the target is calculated, and it is converted into a corresponding score according to the scoring rule. The present invention solves the problems of missed detection of bullet holes, false detection, inaccurate positioning of bullet holes, and inability to detect connected bullet holes in traditional target reporting technology, and improves the accuracy of automatic target reporting.
[0012] In a more specific technical solution, step S1 includes:
[0013] S11, acquiring the original target paper image;
[0014] S12, performing the Otsu binarization process on the original image to obtain the binary image;
[0015] S13, removing interference from target paper lines through morphological operations, thereby obtaining a de-interference binary image;
[0016] S14, finding the contour information of the interference-removed binary image, processing the contour information in reverse order according to the contour area to obtain the outer contour, and determining the contour fitting point accordingly;
[0017] S15, sorting the contour fitting points according to the coordinate data of all the contour fitting points to obtain key feature points;
[0018] S16, processing the key feature points with the following logic to obtain the middle points corresponding to the upper midpoint and the lower midpoint:
[0019]
[0020] Among them, x1, x2, y1, y2 are the coordinates of the key feature points, and x and y are the coordinates of the middle point;
[0021] S17, performing perspective transformation according to the upper left point, the upper right point, the lower left point and the lower right point of the key feature points, so as to correct and process the original image to obtain an orthographic image;
[0022] S18, adjusting the brightness and contrast of the orthographic image to a preset brightness range to obtain an optimized image;
[0023] S19, performing logical AND processing on the optimized image and the preset mask to shield the area outside the chest ring target, thereby obtaining the pre-processed image.
[0024] The present invention obtains a total of six key points of the chest ring target, namely the neck, shoulder and bottom, by contour approximation fitting, and respectively finds the center points of the neck, shoulder, shoulder and bottom key points to obtain the four key points finally used for perspective transformation. This method can prevent certain feature points from failing and ensure the accuracy of the coordinates. At the same time, the present invention can shield the area outside the chest ring target by performing logical AND processing on the brightened image and the preset mask to prevent interference caused by this area.
[0025] In a more specific technical solution, step S13 includes:
[0026] S131, removing the ring interference of the target paper in the binary image through the morphological closing operation;
[0027] S132, removing the influence of the peripheral lines of the target paper in the binary image through a morphological opening operation.
[0028] In a more specific technical solution, the method for making the preset mask in step S19 includes:
[0029] S191, create a black mask;
[0030] S192, finding the outer contour of the chest ring target;
[0031] S193, drawing the outer layer contour in the black mask and filling it with white;
[0032] S194: Perform an expansion operation on the black mask to obtain the preset mask.
[0033] In a more specific technical solution, step S2 includes:
[0034] S21, obtaining the filtering parameters of the spot detection algorithm;
[0035] S22, filtering parameters of the spot detection algorithm, and detecting bullet holes in the pre-processed image using the spot detection method;
[0036] S23, obtaining the bullet hole feature value, and correcting the coordinates of the pre-processed image accordingly;
[0037] S24, drawing a mosaic in the corrected image according to the center coordinates and size of the bullet holes according to the previous bullet hole detection result data;
[0038] S25, obtaining data of all the candidate bullet holes through the spot detection algorithm again.
[0039] After the secondary correction is completed, in order to solve the problem that connected holes cannot be detected, the present invention adopts a feature masking method to mosaic the detected bullet holes, so as to facilitate the detection of another bullet hole when connected holes appear, and then detects all possible bullet holes again through the spot detection algorithm. This method effectively improves the recognition rate in the connected hole state.
[0040] In a more specific technical solution, step S23 includes:
[0041] S231, matching the bullet hole position in the current coordinate system with the bullet hole position detected last time to obtain a coordinate correction candidate point;
[0042] S232, selecting from the candidate points for coordinate correction the point closest to the upper left point, the upper right point, the lower left point and the lower right point of the key feature points as a new key feature point;
[0043] S233: When the number of the new key feature points is less than a preset threshold, the key feature points before the selection operation are used as replacements.
[0044] The present invention adopts a spot detection method to solve the problem of missed detection, detects at different thresholds, and detects as many candidate points as possible by setting a relatively loose parameter threshold. This method effectively improves the recall rate of bullet hole recognition.
[0045] The present invention aims at the problem of inaccurate positioning, selects multiple characteristic values, processes according to the characteristic values, obtains preliminary positioning, and then performs secondary correction on the positioning according to the bullet hole characteristic matching, and effectively improves the accuracy of bullet hole positioning through this method.
[0046] In a more specific technical solution, step S3 includes:
[0047] S31, traversing all the bullet holes in the bullet hole identification data to be verified;
[0048] S32, performing local background subtraction on the bullet hole area to obtain a grayscale difference, so as to distinguish the bullet holes according to a preset threshold.
[0049] In a more specific technical solution, step S32 includes:
[0050] S321, obtaining the target paper image detected last time as the background image;
[0051] S322, finding the center coordinates of the bullet hole, intercepting the bullet hole area corresponding to the secondary correction image and the background image according to the size of the bullet, and performing local background subtraction on the bullet hole area image to obtain a grayscale difference image;
[0052] S323, converting the grayscale difference image to obtain a grayscale image, sorting the pixels in the grayscale image according to the grayscale values, removing N maximum values and N minimum values, and calculating the average value to obtain the average grayscale difference.
[0053] To solve the problem of false detection, the present invention uses the grayscale difference between the bullet and the background to filter out invalid candidate points, thereby improving the precision of bullet hole recognition.
[0054] In a more specific technical solution, step S4 includes:
[0055] S41, identifying the center coordinates and radius of the bullet hole of the target paper according to the target paper replacement situation;
[0056] S42, traversing the bullet holes after verification, processing the Euclidean distance between the center coordinates of the bullet holes and the center coordinates of the bullseye with the following logic, and converting it into the shooting score according to the preset scoring rule:
[0057]
[0058] Among them, (P x ,P y ) is the coordinate of the center of the bullet hole, (C x ,C y ) are the coordinates of the bull's eye.
[0059] In a more specific technical solution, step S41 includes:
[0060] S411, judging whether it is the first detection according to the target paper replacement situation;
[0061] S412: If yes, reset the score calculation algorithm, and identify and save the bull's eye coordinates and radius in the image preprocessing stage.
[0062] The present invention realizes an accurate and automatic target reporting function, and can be applied to basic training, assessment, competition projects and other scenarios of relevant departments. It can effectively improve the accuracy of automatic target reporting and improve training efficiency.
[0063] Compared with the prior art, the present invention has the following advantages:
[0064] The present invention adopts the steps of image preprocessing, bullet hole recognition, bullet hole verification, score calculation, etc., wherein, in the image preprocessing stage, Otsu binarization, contour approximate fitting method and mask processing are adopted to obtain the image to be detected; then, in the bullet hole recognition stage, the data of the candidate bullet hole is obtained by spot detection algorithm and feature mask processing; in the bullet hole verification stage, the same local area of the bullet hole and the background image is taken out, the local background is subtracted, and the bullet hole is verified to be effective by the average grayscale difference; in the score calculation stage, the Euclidean distance of the bullet hole from the center of the target is calculated, and it is converted into a corresponding score according to the scoring rule. The present invention solves the problems of missed detection of bullet holes, false detection, inaccurate positioning of bullet holes, and inability to detect connected bullet holes in traditional target reporting technology, and improves the accuracy of automatic target reporting.
[0065] To solve the problem of consecutive holes being unable to be detected, the present invention adopts a feature masking method to mosaic the detected bullet holes, so as to facilitate the detection of another bullet hole when consecutive holes appear, and then detects all possible bullet holes again through a spot detection algorithm. This method effectively improves the bullet hole recognition rate.
[0066] In order to solve the problem of missed detection, the spot detection method is adopted. The present invention detects at different thresholds and detects as many candidate points as possible by setting a relatively loose parameter threshold. This method effectively improves the recall rate of bullet hole recognition.
[0067] In order to solve the problem of inaccurate positioning, the present invention selects multiple characteristic values and processes them according to the characteristic values to obtain preliminary positioning. Then, according to the bullet hole feature matching, the positioning is corrected for a second time. This method effectively improves the accuracy of bullet hole positioning.
[0068] To solve the problem of false detection, invalid candidate points are filtered out by taking advantage of the grayscale difference between bullets and background. This method effectively improves the precision of bullet hole recognition.
[0069] The present invention realizes an accurate and automatic target reporting function, and can be applied to basic training, assessment, competition and other scenarios of relevant departments. It can effectively improve the accuracy of automatic target reporting and improve training efficiency. The present invention solves the technical problems of missed bullet hole detection, false detection, inaccurate positioning, and inability to detect consecutive bullet holes in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 This is a flow chart of an automatic target reporting method based on machine vision according to Embodiment 1 of the present invention;
[0071] Figure 2 is a contour fitting result diagram of Example 2 of the present invention;
[0072] Figure 3 It is the chest ring target Mask of embodiment 2 of the present invention;
[0073] Figure 4 is the ROI image to be detected in Example 2 of the present invention;
[0074] Figure 5 This is a diagram of bullet hole recognition results in Example 2 of the present invention. DETAILED DESCRIPTION
[0075] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are 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.
[0076] Example 1
[0077] like Figure 1 As shown, the present invention discloses an automatic target reporting method based on machine vision, the method comprising:
[0078] S1, Otsu binarization, contour fitting, perspective transformation, image masking, image preprocessing of the target paper image; in this embodiment, in the image preprocessing stage, the original image is subjected to Otsu binarization (OTSU) processing to find the outer contour of the target paper; the key feature points are found through contour approximate fitting, and the image coordinates are preliminarily corrected through perspective transformation (Perspective Transformation); the image contrast is increased and the image brightness is adjusted; the image is masked (Mask) processed to obtain the image to be detected. The original image is subjected to Otsu binarization (OSTU) processing, and then a morphological closing operation is performed on it to remove the internal interference of the ring line; an opening operation is performed on it to eliminate the influence of the surrounding lines of the target paper; the outermost contour is found, and the key feature points are obtained through the contour approximate fitting algorithm. In this embodiment, a total of six key points of the chest ring target neck, shoulder, and bottom can be obtained, and the center points of the neck, shoulder, shoulder, and bottom key points are respectively calculated to obtain the four key points used for perspective transformation. This method can prevent the failure of certain feature points and ensure the accuracy of the coordinates. In this embodiment, the outermost contour is found, a black mask is created, the contour is drawn, and filled with white; an expansion operation is performed on it to obtain the final mask; a logical AND operation is performed on the brightened image and the mask to shield the area outside the chest ring target, thereby obtaining the final ROI area.
[0079] S2. Bullet hole recognition is performed by using blob detection, feature matching, and coordinate correction. In the present embodiment, in the bullet hole recognition stage, the bullet hole positions are first detected by a blob detection algorithm, and the coordinates can be corrected for a second time according to the bullet hole feature matching algorithm. After the correction is completed, the previously identified bullet holes are first feature masked, and then all possible bullet holes are detected again by the blob detection algorithm. In the present embodiment, the bullet hole positions in the current coordinate system are matched with the previously detected bullet hole positions, and the successfully matched ones are used as candidate points for coordinate correction. The bullet holes closest to the four key points of the initial transformation are selected as new key points, and the three key points cannot be on a straight line. If there are less than four bullet holes, the missing positions are still replaced by the initial key points. The current coordinates are corrected for a second time by this method, thereby ensuring the accuracy of the coordinates.
[0080] S3, feature extraction, background subtraction and bullet hole verification; in this embodiment, after the correction is completed, all possible bullet holes are detected again by the spot detection algorithm. In the bullet hole verification stage, the same local area of the bullet hole and the background image is taken out, the background is subtracted, and the bullet hole is verified to be valid by the average grayscale difference. Find the center coordinates of the bullet, draw a circle for the bullet area according to the size of the bullet, and fill the circle with white to cover the identified bullet hole features; this method can effectively identify bullet holes in the case of continuous holes. Find the center coordinates of the bullet, and take out the bullet hole area according to the size of the bullet hole; read the background image saved in the last detection, take the same size area according to the bullet position, and obtain the difference between the two; convert it into a grayscale image, sort the grayscale, remove the n maximum values and n minimum values, calculate the average value, and obtain the final average grayscale difference; by setting a reasonable threshold, it can accurately distinguish whether it is a bullet hole.
[0081] S4, calculating the Euclidean distance between the bullet hole and the bull's eye and converting it into a score, drawing the bullet hole and saving the result; in this embodiment, in the score calculation stage, the Euclidean distance between the bullet hole and the bull's eye is calculated, and it is converted into a corresponding score according to the scoring rule. The present invention solves the problems of missed detection of bullet holes, false detection, inability to detect consecutive holes, inaccurate bullet hole positioning, etc. through the above method, and improves the accuracy of automatic target reporting.
[0082] Example 2
[0083] The present invention provides the following technical solutions:
[0084] An automatic target reporting method based on machine vision includes the steps of image preprocessing, bullet hole recognition, bullet hole verification, score calculation and the like.
[0085] 1. Image preprocessing
[0086] In the image preprocessing stage, the key feature points are found through the contour approximation fitting method, and the image is preliminarily corrected through perspective transformation; the image contrast is increased and the image brightness is adjusted; the image is masked to obtain the image to be detected.
[0087] Furthermore, the contour approximation fitting method in the image preprocessing stage is specifically implemented as follows: the original image is processed by Otsu binarization (OSTU), and then a morphological closing operation is performed on it to remove the internal interference of the loop; an opening operation is performed on it to eliminate the influence of the surrounding lines of the target paper; all contour information is identified and sorted by area. The outermost contour is found, and six key feature points are obtained through the contour approximation fitting algorithm.
[0088] Furthermore, the key feature points in the image preprocessing stage are specifically implemented as follows: a total of six key points of the chest ring target neck, shoulder, and bottom are obtained, and the center points of the neck, shoulder, shoulder, and bottom key points are respectively calculated to obtain the four key points used for perspective transformation. This method can prevent certain feature points from failing and ensure the accuracy of the coordinates.
[0089] Furthermore, the mask processing method in the image preprocessing stage is specifically implemented as follows: find the outermost contour, create a black mask, draw this contour, and fill it with white; perform an expansion operation on it to obtain the final mask; perform a logical AND operation on the brightened image and the mask to shield the area outside the chest ring target, thereby obtaining the final ROI area.
[0090] like Figure 2 As shown, in this embodiment, the morphological closing operation is used to remove the interference of the loop lines in the target paper. Then the opening operation is performed to remove the influence of the surrounding lines of the target paper. All contour information is found and sorted in reverse order according to the contour area. The outermost contour is found and the contour is approximated. The fitting parameter is set to epsilon and set to 0.01. The fitting results are shown in Figure 2 .
[0091] By sorting the y coordinates of all contour fitting points, six key feature points can be found. These six points are recorded as the upper left point (P lt ), left midpoint (P lm ), lower left point (P lb ), upper right point (P rt ), right midpoint (P rm ), lower right point (P rb ). The corresponding midpoints of the upper middle and lower middle points can be found by the following formula.
[0092]
[0093] The 6 points can be transformed into the upper left point required for perspective transformation (T lt ), upper right point (T rt ), lower left point (T Ib ), lower right point (T rb )4 points, and the orthographic image can be obtained through perspective transformation operation. This operation is mainly to prevent the coordinate offset caused by one of the feature points being hit by a bullet. The standard size of the chest ring target paper is 500mm*500mm. For the convenience of calculation, the target paper is mapped to the corresponding 500*500 pixel picture, and a 6-pixel border is added around it. Therefore, the chest ring target area will be mapped to the coordinates of 512*512 pixels, and the preliminary correction of the image coordinate system is completed at this time.
[0094] Calculate the overall brightness of the corrected image, adjust the image brightness to a fixed brightness range, and increase the image contrast. This operation is mainly to solve the problem of bullet holes being difficult to detect when the image is too dark or too bright.
[0095] like Figure 3 As shown, Figure 3 The display shows the chest ring target mask (Mask) that has been pre-processed. By performing a logical AND operation on the brightened image and the mask (Mask), the area outside the chest ring target can be shielded, thereby obtaining the final ROI area.
[0096] like Figure 4 As shown, Figure 4 Displayed as the ROI image to be detected, by Figure 4 It can be seen that only the target paper and its edge are effective areas, and the outer periphery is black. This operation is mainly to shield the bullet holes outside the chest ring target.
[0097] 2. Bullet hole identification
[0098] In the bullet hole recognition stage, the bullet hole positions are first detected using a blob detection algorithm, and the coordinates can be corrected a second time based on the bullet hole feature matching algorithm. After the correction is completed, the previously identified bullet holes are first feature masked, and then all possible bullet holes are detected again using the blob detection algorithm.
[0099] Furthermore, the bullet hole feature matching method in the bullet hole recognition stage is specifically implemented as follows: the bullet hole position in the current coordinate system is matched with the bullet hole position detected previously, and the successfully matched ones are used as candidate points for coordinate correction; the bullet holes closest to the four key points of the initial transformation are respectively selected as new key points, and the three key points cannot be on a straight line; if there are less than four bullet holes, the missing positions are still replaced by the initial key points; through this method, the current coordinates are corrected twice to ensure the accuracy of the coordinates.
[0100] Furthermore, the feature masking method in the bullet hole recognition stage is specifically implemented as follows: find the center coordinates of the bullet, draw a circle for the bullet area according to the size of the bullet, and fill the circle with white to cover the identified bullet hole features; this method can effectively identify bullet holes in the case of continuous holes.
[0101] In this embodiment, the image to be detected is first detected by the blob detection method for all possible bullet holes. At this time, the threshold parameter setting is relatively broad to ensure that there will be no missed detection. The principle of blob detection is to binarize within the gray threshold range (minThreshold ~ maxThreshold) with thresholdStep as the step size, detect black spots multiple times, and filter according to the following parameters. The parameter settings are as follows:
[0102] #Set grayscale threshold
[0103] minThreshold=0
[0104] # Real-time calculation through pictures, no need to set
[0105] #maxThreshold=120
[0106] # Grayscale step length
[0107] thresholdStep=5
[0108] #The point is detected repeatedly. If it is greater than this threshold, it is considered a legal point.
[0109] minRepeatability=2
[0110] #Minimum distance between two points
[0111] minDistBetweenBlobs=2
[0112] #Filter by color
[0113] filterByColor=True
[0114] #0 is for detecting black, 255 is for detecting white
[0115] blobColor=0
[0116] #Set area threshold for filtering
[0117] filterByArea=True
[0118] #Maximum area threshold
[0119] maxArea=60
[0120] #Minimum area threshold
[0121] minArea=15
[0122] #Set the roundness threshold for filtering
[0123] filterByCircularity=True
[0124] #Minimum roundness threshold
[0125] minCircularity=0.3
[0126] #Set the convexity threshold for filtering
[0127] filterByConvexity=True
[0128] #Minimum convexity threshold
[0129] minConvexity=0.3
[0130] #This inertia ratio
[0131] filterByInertia=True
[0132] #Minimum inertia ratio threshold
[0133] minInertiaRatio=0.3
[0134] After the detection is completed, the coordinates are corrected again by matching the bullet hole feature values. The correction principle is as follows: match the bullet hole position in the current coordinate system with the bullet hole position detected previously, and the successfully matched ones will be used as candidate points for coordinate correction. Select the bullet holes closest to the four key points of the initial transformation as new key points respectively, and the three key points cannot be on a straight line. If there are less than four bullet holes, the missing positions are still replaced by the original key points. After the coordinates are corrected, it is guaranteed that the coordinates are the same for each detection. The corrected image will be saved when the detection process is completed and used in the next bullet hole verification stage.
[0135] Based on the corrected image, the bullet hole detection result of the last time is drawn in this image with a mosaic of the size of the bullet hole, and then the detection is performed. This operation is mainly to solve the problem that the bullet holes cannot be detected when there are some overlaps. At this point, all the bullet holes to be checked are obtained, and the problem of missed detection and undetectable consecutive holes is solved.
[0136] 3. Bullet hole verification
[0137] In the bullet hole verification stage, the same local area of the bullet hole and the background image is taken out, the local background is subtracted, and the validity of the bullet hole is verified by the average grayscale difference.
[0138] Furthermore, the local background subtraction method in the bullet hole verification stage is specifically implemented as follows: find the center coordinates of the bullet, and take out the bullet hole area according to the size of the bullet hole; read the background image saved in the last detection, take the same size area according to the bullet position, and obtain the difference between the two; convert it into a grayscale image, and sort the grayscale, remove the n maximum values and the n minimum values, calculate the average value, and obtain the final average grayscale difference; by setting a reasonable threshold, it can be accurately distinguished whether it is a bullet hole.
[0139] In this embodiment, since the spot detection threshold is set relatively widely in the bullet hole identification stage, the detected bullet holes may be misdetected. Therefore, it is necessary to further verify the bullet holes. The verification idea is to use the background subtraction method. There is a large difference in the grayscale difference between the area with bullets minus the background and the area without bullets minus the background. By setting a reasonable threshold, it is easy to distinguish whether it is a bullet. It can be seen from the bullet hole identification stage that a picture will be saved before the end of the last detection process for use in this stage. Traverse all the bullet holes to be verified, take the picture at the same position of the last saved picture according to the coordinates of the bullet holes, subtract the background between the two, and get the grayscale difference picture. Convert it into a grayscale picture, then sort the grayscale, remove the n maximum values and n minimum values, calculate the average value, and get the final grayscale difference. At this point, the verification of the bullet holes is completed, and the problem of false detection is solved.
[0140] 4. Score calculation
[0141] In the score calculation stage, the Euclidean distance from the bullet hole to the center of the bull's eye is calculated and converted into the corresponding score according to the scoring rules.
[0142] In this embodiment, after the target paper is replaced, the algorithm will be reset. When it is recognized that it is the first detection, the center coordinates and radius will be identified and saved in the image preprocessing stage. This operation is mainly to prevent the fitting of the center of the target from being affected when there are too many bullet holes. After traversing the bullet holes after the bullet hole verification, the center coordinates of the bullet holes (P x ,P y ) and the bull's eye coordinates (C x ,C y ) is the Euclidean distance.
[0143]
[0144] Assuming here that the radius of the 10-ring chest ring target is radius, then the 9-ring is 2*radius, the 8-ring is 3*radius, and so on. Divide the distance from the center of the target by radius and round it up. By converting this integer, you can express the score at the current point.
[0145] like Figure 5 As shown in the figure, since the calculation rule in actual use is that the score is higher when the line is pressed, it is necessary to further consider the radius of the bullet and correct the number of rings. From the image preprocessing stage, it can be seen that the length of the target paper is 500mm*500mm, which is converted to a 500*500 pixel image, so one pixel is equal to 1mm. Since the radius of the bullet hole is about 3mm, it is necessary to take the remainder of the distance from the center of the bull's eye. If the remainder is less than or equal to 3, the number of rings is corrected. Finally, draw a red circle to mark the bullet hole in the image to be detected, and display the score and coordinate information of the bullet hole.
[0146] In summary, the present invention adopts steps such as image preprocessing, bullet hole recognition, bullet hole verification, and score calculation, wherein, in the image preprocessing stage, Otsu binarization, contour approximate fitting method, and mask processing are used to obtain the image to be detected; then, in the bullet hole recognition stage, the data of the candidate bullet holes are obtained by spot detection algorithm and feature mask processing; in the bullet hole verification stage, the same local area of the bullet hole and the background image is taken out, the local background is subtracted, and the bullet hole is verified to be effective by the average grayscale difference; in the score calculation stage, the Euclidean distance of the bullet hole from the center of the target is calculated, and it is converted into a corresponding score according to the scoring rule. The present invention solves the problems of false detection, missed detection, inaccurate bullet hole positioning, and inability to detect connected bullet holes in traditional target reporting technology, and improves the accuracy of automatic target reporting.
[0147] To solve the problem of consecutive holes being unable to be detected, the present invention adopts a feature masking method to mosaic the detected bullet holes, so as to facilitate the detection of another bullet hole when consecutive holes appear, and then detects all possible bullet holes again through a spot detection algorithm. This method effectively improves the bullet hole recognition rate.
[0148] In order to solve the problem of missed detection, the spot detection method is adopted. The present invention detects at different thresholds and detects as many candidate points as possible by setting a relatively loose parameter threshold. This method effectively improves the recall rate of bullet hole recognition.
[0149] In order to solve the problem of inaccurate positioning, the present invention selects multiple characteristic values and processes them according to the characteristic values to obtain preliminary positioning. Then, according to the bullet hole feature matching, the positioning is corrected for a second time. This method effectively improves the accuracy of bullet hole positioning.
[0150] To solve the problem of false detection, invalid candidate points are filtered out by taking advantage of the grayscale difference between bullets and background. This method effectively improves the precision of bullet hole recognition.
[0151] The present invention realizes an accurate and automatic target reporting function, and can be applied to basic training, assessment, competition projects and other scenarios of relevant departments, with a large market capacity and high practical value. It can effectively improve the accuracy of automatic target reporting, improve training efficiency, and enhance actual combat level. The present invention solves the technical problems of missed bullet hole detection, false detection, inaccurate positioning, and inability to detect consecutive bullet holes in the prior art.
[0152] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. 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 embodiments of the present invention.
Claims
1. An automatic target reporting method based on machine vision, characterized in that: The method comprises: S1. Otsu binarization processes the original image to obtain a binary image, uses a contour approximation fitting method to find key feature points of the binary image, uses perspective transformation to perform preliminary coordinate correction on the original image to obtain a corrected image, adjusts the contrast and brightness of the corrected image, and performs mask processing on the corrected image to obtain a preprocessed image; S2, using a spot detection algorithm to detect the bullet hole position coordinate data of the pre-processed image, and performing secondary correction on the coordinates of the pre-processed image according to a bullet hole feature matching algorithm. After the correction is completed, the bullet holes of the identified target paper are processed by feature masking, and then all candidate bullet holes of the current target paper are detected by the spot detection algorithm to obtain the bullet hole identification data to be verified; S3, extracting the same local area of the bullet hole and the background image, performing local background subtraction, and processing the bullet hole detection data to be verified with a preset logic to obtain an average grayscale difference, and verifying and obtaining a valid bullet hole based on the difference; S4. Calculate the Euclidean distance of the effective bullet hole to the bull's-eye using a preset logic, and convert the Euclidean distance to the bull's-eye to a shooting score according to a preset scoring rule.
2. The automatic target reporting method based on machine vision according to claim 1, characterized in that: The step S1 comprises: S11, acquiring the original target paper image; S12, performing the Otsu binarization process on the original image to obtain the binary image; S13, removing interference from target paper lines through morphological operations, thereby obtaining a de-interference binary image; S14, finding the contour information of the interference-removed binary image, processing the contour information in reverse order according to the contour area to obtain the outer contour, and determining the contour fitting point accordingly; S15, sorting the contour fitting points according to the coordinate data of all the contour fitting points to obtain key feature points; S16, processing the key feature points with the following logic to obtain the middle points corresponding to the upper midpoint and the lower midpoint: Among them, x1, x2, y1, y2 are the coordinates of the key feature points, and x and y are the coordinates of the middle point; S17, performing perspective transformation according to the upper left point, the upper right point, the lower left point and the lower right point of the key feature points, so as to correct and process the original image to obtain an orthographic image; S18, adjusting the brightness and contrast of the orthographic image to a preset brightness and contrast range to obtain an optimized image; S19, performing a logical AND process on the optimized image and a preset mask to shield the area outside the chest ring target, thereby obtaining the pre-processed image.
3. The automatic target reporting method based on machine vision according to claim 2 is characterized in that: The step S13 comprises: S131, removing the ring interference of the target paper in the binary image through the morphological closing operation; S132, removing the influence of the peripheral lines of the target paper in the binary image through a morphological opening operation.
4. The automatic target reporting method based on machine vision according to claim 2 is characterized in that: The method for manufacturing the preset mask in step S19 includes: S191, create a black mask; S192, finding the outer contour of the chest ring target; S193, drawing the outer layer contour in the black mask and filling it with white; S194: Perform an expansion operation on the black mask to obtain the preset mask.
5. The automatic target reporting method based on machine vision according to claim 1, characterized in that: The step S2 comprises: S21, obtaining the filtering parameters of the spot detection algorithm; S22, filtering parameters of the spot detection algorithm, and detecting bullet holes in the pre-processed image using the spot detection method; S23, obtaining the bullet hole feature value, and correcting the coordinates of the pre-processed image accordingly; S24, drawing a mosaic in the corrected image according to the center coordinates and size of the bullet holes according to the previous bullet hole detection result data; S25, obtaining data of all the candidate bullet holes through the spot detection algorithm again.
6. The automatic target reporting method based on machine vision according to claim 5, characterized in that: The step S23 comprises: S231, matching the bullet hole position in the current coordinate system with the bullet hole position detected last time to obtain a coordinate correction candidate point; S232, selecting from the candidate points for coordinate correction the point closest to the upper left point, the upper right point, the lower left point and the lower right point of the key feature points as a new key feature point; S233: When the number of the new key feature points is less than a preset threshold, the key feature points before the selection operation are used as replacements.
7. The automatic target reporting method based on machine vision according to claim 1, characterized in that: The step S3 comprises: S31, traversing all the bullet holes in the bullet hole identification data to be verified; S32, performing local background subtraction on the bullet hole area to obtain a grayscale difference, so as to distinguish the bullet holes according to a preset threshold.
8. The automatic target reporting method based on machine vision according to claim 7, characterized in that: The step S32 comprises: S321, obtaining the target paper image detected last time as the background image; S322, finding the center coordinates of the bullet hole, intercepting the bullet hole area corresponding to the secondary correction image and the background image according to the size of the bullet, and performing local background subtraction on the bullet hole area image to obtain a grayscale difference image; S323, converting the grayscale difference image to obtain a grayscale image, sorting the pixels in the grayscale image according to the grayscale values, removing N maximum values and N minimum values, and calculating the average value to obtain the average grayscale difference.
9. The automatic target reporting method based on machine vision according to claim 1, characterized in that: The step S4 comprises: S41, identifying the center coordinates and radius of the bullet hole of the target paper according to the target paper replacement situation; S42, traversing the bullet holes after verification, processing the Euclidean distance between the center coordinates of the bullet holes and the center coordinates of the bullseye with the following logic, and converting it into the shooting score according to the preset scoring rule: Among them, (P x ,P y ) is the coordinate of the center of the bullet hole, (C x ,C y ) are the coordinates of the bull's eye.
10. The automatic target reporting method based on machine vision according to claim 9, characterized in that: The step S41 comprises: S411, judging whether it is the first detection according to the target paper replacement situation; S412: If yes, reset the score calculation algorithm, and identify and save the bull's eye coordinates and radius in the image preprocessing stage.
Citation Information
Patent Citations
Embedded wireless automatic scoring system and scoring method thereof
CN102175100A
Automatic target scoring method based on video analysis
CN106408527A
Automatic target scoring system intelligent calibration method based on machine vision
CN109493356A
