Horse-viewing method, device, electronic device and medium based on machine vision
Through machine vision technology, the characteristics of horses are identified and the body ruler index is calculated, which solves the problems of high labor costs and low efficiency in horse appearance assessment, and achieves rapid, accurate assessment and precise selection of horse quality.
Patent Information
- Application Number
- CN202210487114.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-06
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2042-05-06
AI Technical Summary
The prior art has problems such as high labor cost, low efficiency and lack of quantitative analysis in horse appearance assessment, and it is impossible to accurately select excellent individuals.
Using machine vision-based horse-photographic method, through image processing and neural network technology, the contours of the horse's head, eyes, ears and nostrils are identified, their proportion of the head area is calculated, and the horse's face is combined with the body ruler index. Comprehensive ratings and grading.
It realizes rapid and accurate measurement of horse quality, reduces artificial interference, improves the accuracy and efficiency of appearance assessment, and solves the problem of insufficient qualitative analysis of traditional methods.
Smart Images

Figure CN115035544B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine vision, and in particular relates to a horse-viewing method, device, electronic equipment and medium based on machine vision. Background Art
[0002] With the continuous exploration and research of horse breeding science and technology, horse physiognomy has also been comprehensively developed. Horses are a unified whole. We should not only pay attention to the physique of horses, but also pay attention to their external appearance. The two complement each other. The quality of horses in most parts of my country is cultivated for a long time under specific ecological conditions. They have the advantages of being strong and adaptable, but the appearance and body size of the group are uneven. In order to ensure that the excellent characteristics of the breed can be inherited and overcome genetic defects, it is necessary to adopt a selective breeding method to carry out planned selection and strengthen the cultivation of future generations.
[0003] At present, breeders still use traditional appearance assessment methods, which have high labor costs, large human subjective factors, low evaluation efficiency, lack of unified visual assessment standards, and cannot conduct quantitative analysis. Summary of the invention
[0004] The technical problem to be solved by the present invention is that in view of the deficiencies of the above-mentioned prior art, a method, device, electronic device and readable storage medium for horse judging based on machine vision are provided. The method is a horse judging method based on visual technology, which can eliminate the interference of human factors, reduce labor costs, improve the efficiency of horse judging, accurately measure the quality of horses, and greatly improve the accuracy of selecting excellent individuals through appearance assessment.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: a horse-matching method based on machine vision, characterized in that the method comprises:
[0006] obtaining images of the horse, the images including front and side views of the horse;
[0007] Based on the collected images of horses, the outlines of the head, eyes, ears and nostrils are identified;
[0008] Based on the identified contours of the head, eyes, ears and nostrils, calculate the proportion of the eyes, ears and nostrils to the head area;
[0009] Obtaining the body size index of the horse based on the collected images of the horse;
[0010] The horse's appearance is comprehensively scored based on the proportion of the eyes, ears, and nostrils to the head area in the image, as well as the body size index, and finally the horse's appearance is graded based on the scoring result.
[0011] Preferably, the body size index includes body length index, chest diameter index, tube circumference index and limb length index, the body length index is the ratio of body length to body height; the chest diameter index is the ratio of chest diameter to body height; the tube circumference index is the ratio of tube circumference to body height; the limb length index is the ratio of forelimb length to body height.
[0012] Preferably, the horse image is obtained by: collecting the horse image, analyzing the collected image, removing the image not containing the horse, and then performing noise reduction and enhancement processing on the image.
[0013] Preferably, the Faster-RCNN neural network is used to analyze the collected images and remove images that do not contain horses.
[0014] Preferably, the contours of the head, eyes, ears and nostrils are identified based on the collected image of the horse, and the specific process is as follows:
[0015] The front picture of the horse is input into the Mask-RCNN neural network model to obtain the outlines of the horse's head and left and right nostrils in the front picture. The side picture of the horse is input into the Mask-RCNN neural network model to obtain the outlines of the horse's ears, eyes, and head in the side picture, and then the pixel coordinate values of constructing the outline of each part are recorded respectively.
[0016] Preferably, the body size index of the horse is obtained according to the collected image of the horse, and the specific process is: inputting the side image of the horse into the DeepLabCut neural network model, predicting the coordinate values of the pixel points of the withers apex, the bottom of the hoof, the shoulder end, the hip end, the left side of the tube circumference, the right side of the tube circumference, the rear edge of the shoulder blade, the front chest, and the elbow end of the horse in the side image, and measuring the 2D body size length of the horse by calculating the straight-line distance between the two points, and the body size length includes body height, body length, tube circumference, breast diameter, and limb length;
[0017] The body height is the vertical distance from the top of the withers to the ground, measured by the vertical distance from the top of the withers to the bottom of the hoof;
[0018] The body length is the straight-line distance from the shoulder end to the hip end;
[0019] The tube circumference is the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone;
[0020] The chest diameter is the vertical distance between the rear edge of the scapula and the front chest;
[0021] The limb length is the vertical distance from the highest point of the elbow to the ground, measured by the vertical distance between the elbow and the bottom of the horseshoe.
[0022] The present invention also provides a sports horse judging device, comprising:
[0023] An image module, used for obtaining images of the horse, the images including front and side pictures of the horse;
[0024] A contour recognition module, used to recognize the contours of the head, eyes, ears and nostrils based on the collected horse images;
[0025] A calculation module, used to calculate the proportion of the eye, ear, and nostril to the head area according to the identified contours of the head, eye, ear, and nostril; and also used to obtain the body size index of the horse according to the collected image of the horse;
[0026] The evaluation module is used to score the appearance of the horse according to the proportion of the eyes, ears, and nostrils to the head area in the image and the body size index, and finally grade the appearance of the horse according to the scoring values.
[0027] Preferably,
[0028] The present invention further provides an electronic device, characterized in that the electronic device comprises:
[0029] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned machine vision-based horse-matching method.
[0030] Compared with the prior art, the present invention has the following advantages:
[0031] 1. The present invention provides a method for judging horse appearance based on machine vision. On the basis of traditional appearance assessment, the method combines machine vision technology for quantitative analysis, and can quickly and accurately measure the appearance of horses, greatly improving the accuracy of selecting excellent individuals through appearance assessment. It has largely changed the disadvantages of traditional horse appearance assessment that it is mainly qualitative, difficult to conduct quantitative analysis and has low accuracy. It is a development and supplement to the theory of horse appearance assessment, and has important practical significance in horse breeding production practice.
[0032] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The present invention is a flow chart of a method for judging a horse by its movement disclosed in Embodiment 1 of the present invention.
[0034] Figure 2 This is a schematic diagram of the structure of a horse-viewing device disclosed in Example 2 of the present invention.
[0035] Figure 3 This is an example diagram of horse body measurement points according to Example 1 of the present invention.
[0036] Figure 4 This is an effect diagram of extracting the nostrils and head contour from the front view of a horse in Example 1 of the present invention.
[0037] Figure 5 This is a rendering of the horse side view of Example 1 of the present invention, in which the contours of the head, eyes, and ears are extracted.
[0038] Figure 6 This is a flow chart of using the DeepLabCut neural network to train and predict horse body measurement points in Example 1 of the present invention. DETAILED DESCRIPTION
[0039] Example 1
[0040] like Figure 1 As shown, a method for horse selection based on machine vision in an embodiment of the present invention comprises:
[0041] S1, collecting images of horses, the images including front and side pictures of the horses;
[0042] Specifically, you can install image acquisition software on your mobile phone and use the mobile phone to take pictures of the horse from the front and side angles;
[0043] S2. According to the horse image, the outlines of the head, eyes, ears, and nostrils are identified, and the proportion of the eyes, ears, and nostrils to the head area is calculated; at the same time, the body length index, chest diameter index, tube circumference index, and limb length index of the horse are calculated according to the horse image;
[0044] S3. Score the horse's appearance based on the proportion of the eyes, ears, and nostrils to the head area in the image, as well as the body length index, chest diameter index, tube circumference index, and limb length index. Finally, grade the horse's appearance based on the scoring results.
[0045] In this embodiment, in order to improve the detection accuracy of subsequent targets such as the horse's head, eyes, ears, and nostrils, the horse image collected in S1 is analyzed using the Faster-RCNN neural network model. If a horse object is detected in the image, the image is denoised and enhanced, otherwise it is required to be re-collected; the specific training steps of the Faster-RCNN neural network model are as follows:
[0046] S101, the central server Ubuntu20.04 builds the Faster-RCNN algorithm environment;
[0047] S102, prepare a training data set, collect front and side pictures of horses (more than 5000 pictures), and use the LabelImg image annotation tool to select the area where the horse is located with a rectangular box;
[0048] S103, inputting a training data set into the Faster-RCNN neural network, repeatedly iterating the training, and obtaining an optimal Faster-RCNN neural network, that is, a preset Faster-RCNN neural network.
[0049] In this embodiment, in S2, a Mask-RCNN neural network is trained to identify the contour range of the head, eyes, ears, and nostrils in the horse picture. The specific steps of training the Mask-RCNN neural network are as follows:
[0050] S201, the central server Ubuntu20.04 builds the Mask-RCNN algorithm environment;
[0051] S202, prepare a training data set, collect front and side pictures of horses (more than 5000 pictures), use LabelMe image annotation tool to mark the head and left and right nostril contours of the horse's front picture, and mark the head, ears, and eye contours of the horse's side picture;
[0052] S203, generating a mask file from the marked data and adjusting it to the COCO dataset format;
[0053] S204, adjusting key parameters such as the number of GPUs, number of iterations, learning rate, and training sample path;
[0054] S205, loading the pre-trained model, inputting the training data set into the Mask-RCNN neural network, and repeatedly iterating the training to obtain the optimal neural network, namely the Mask-RCNN neural network model.
[0055] In this embodiment, the specific process of the proportion of the eyes, ears, and nostrils to the head area in S2 is as follows:
[0056] Input the front picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's head and left and right nostrils in the front picture; input the side picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's ears, eyes, and head in the side picture, and then record the pixel coordinate values of the contours of each part;
[0057] Since the outlines of the ears, eyes, nostrils, and head are irregular polygons, the image is first binarized when calculating the outline area. Obtain the length and width of the horse's front image and the pixel coordinate values of the head and nostril outlines in the front image, generate three black background images with the same length and width as the horse's front image, and draw the head outline, left nostril outline, and right nostril outline in the newly created image according to the pixel coordinate values of the head and nostril outlines, and fill the outlines with white (such as Figure 4As shown), after generating the binary image, use the Python script cv2.findCountor to find the contour value, use cv2.drawCountors to draw the image contour, take out the contour value cnt through the index, and use cv2.ContourArea() to calculate the area of the contour, where:
[0058] imgurl is the binary image path;
[0059] area is the calculation result.
[0060] The specific algorithm is as follows:
[0061] import cv2
[0062] imgurl="head.png"
[0063] img = cv2.imread(imgurl)
[0064] gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
[0065] ret,thresh=cv2.threshold(gray,127,255,cv2.THRESH_BINARY)
[0066] binary,contours,h=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
[0067] draw_img = img.copy()
[0068] ret=cv2.drawContours(draw_img,contours,0,(0,0,255),2)
[0069] cnt=contours[0]
[0070] area = cv2.contourArea(cnt)
[0071] After the above algorithm is used to obtain the areas of the left and right nostril regions and the head region, the ratio between the two can be calculated. Suppose the area of the left nostril region is S1, the area of the right nostril region is S2, the area of the front head region is S3, and the ratio of the nostril to the front head is M1. The calculation formula is:
[0072]
[0073] Through the side view of the horse, the proportion of the ears and eyes to the head can be calculated, the length and width of the side view of the horse and the pixel coordinate values of the head, eyes and ears in the side view can be obtained, and three black background images with the same length and width as the side view of the horse are generated. The head, eyes and ears are drawn in the newly created images according to the pixel coordinate values of the head, eyes and ears in the side view, and the outlines are filled with white (such as Figure 5 As shown), then use the above method to calculate the area of the side head, eyes, and ears, and then calculate the ratio of eyes to side head, and the ratio of ears to side head. Suppose the area of the eye area is S4, the area of the ear area is S5, the area of the side head area is S3, the ratio of eyes to side head is M2, and the ratio of ears to side head is M3. The calculation formula is:
[0074]
[0075]
[0076] In this embodiment, the body length index, chest diameter index, tube circumference index, and limb length index in S2 are specifically defined as:
[0077] Body length index: also known as body length rate, which is the ratio of body length to body height. Body length / body height × 100 = body length rate, which can explain the economic type of the horse and the embryonic development.
[0078] Diameter at breast height index: Diameter at breast height ratio, which is the ratio of diameter at breast height to height. Diameter at breast height / height × 100 = diameter at breast height ratio, which indicates the development of the body, also known as the body width index. A large diameter at breast height ratio indicates a large chest, good heart and lung development, and a large body weight, which is conducive to the development of pulling power and endurance.
[0079] Tube circumference index: Tube circumference ratio, which is the ratio of tube circumference to body height. Tube circumference / body height×100=tube circumference ratio. It indicates the development of bones and is also called bone mass index.
[0080] Limb length index: also known as limb length ratio, which is the ratio of forelimb length to body height. Forelimb length / body height × 100 = limb length ratio. Limb length index is related to speed, also known as speed index.
[0081] In addition to judging the quality of sports horses by the size of their body parts, you can also judge by body size index, which includes body length index, chest diameter index, tube circumference index and limb length index. Before calculating the above body size index, you need to obtain the 2D plane horse body length, body height, limb length, chest diameter, tube circumference data, such as Figure 3 The measurement criteria are as follows:
[0082] Body height: the vertical distance from the top of the withers to the ground;
[0083] Body length: the straight-line distance from the shoulder to the hip;
[0084] Tube circumference: the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone;
[0085] Diameter of chest: the vertical distance between the back edge of the shoulder blade and the front chest;
[0086] Limb length: the vertical distance from the highest point of the elbow to the ground.
[0087] The DeepLabCut neural network can estimate the posture of user-defined body parts. If you want to obtain the horse's body size data based on the picture, you need to train the DeepLabCut neural network model to obtain the positions of the horse's withers, hoof bottom, shoulder, hip, left side of the tube, right side of the tube, rear edge of the shoulder blade, forechest, and elbow in the picture. By calculating the distance between pixel points, you can get the horse's body length, height, limb length, chest diameter, and tube circumference based on the 2D plane. Figure 6 As shown, the specific steps for training the DeepLabCut neural network are as follows:
[0088] S2-1. Build DeepLabCut environment on central server Ubuntu20.04;
[0089] S2-2. Prepare training videos, shoot horse videos from side angles, classify the 120 video files, and classify them into 80 training sets and 40 test sets. Input the training sets into the DeepLabCut neural network for model training. After each round of training, input the test set into the neural network for model evaluation.
[0090] S2-3. Create a project and import 80 training set videos into the project;
[0091] S2-4, create key frames, use clustering algorithm to extract frames, DeepLabCut automatically loads key frame images, and marks the withers apex, hoof bottom, shoulder end, hip end, left side of the tube girth, right side of the tube girth, rear edge of the shoulder blade, front chest, and elbow end of the horse in the key frame image;
[0092] S2-5, model training, select resnet_50 residual network, imgaug data enhancement method, single training maximum iteration 20,000 times, start model training;
[0093] S2-6, video analysis, after a single training session, some test videos are imported into the video analysis function, and the DeepLabCut neural network automatically predicts the horse body measurement points in the video;
[0094] S2-7, adjust the abnormal frames and manually correct the labels with large prediction errors;
[0095] S2-8. Repeat S2-5 to S2-7, and iterate the training to obtain the optimal neural network model, that is, the DeepLabCut neural network model.
[0096] Input the side view of the sports horse into the DeepLabCut neural network model to predict the pixel coordinates of the withers apex, hoof bottom, shoulder, hip, left side of the girth, right side of the girth, rear edge of the shoulder blade, front chest, and elbow in the side view. The 2D body length of the horse can be measured by calculating the straight-line distance between the two points.
[0097] The body height is the vertical distance from the withers apex to the ground. The pixel value of the body height can be calculated by measuring the vertical distance between the withers apex and the bottom of the hoof. Assuming the coordinate value of the withers apex is (x1, y1), the coordinate value of the bottom of the hoof is (x2, y2), and the body height is K1, the calculation formula is:
[0098] K1=|y2-y1|
[0099] The body length is the straight-line distance from the shoulder to the hip. Assume that the coordinates of the shoulder are (x3, y3), the coordinates of the hip are (x4, y4), and the body length is K2. The calculation formula is:
[0100]
[0101] The tube circumference is the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone. Let the left point of the tube circumference be (x5, y5), the right point of the tube circumference be (x6, y6), and the tube circumference be K3. The calculation formula is:
[0102]
[0103] The diameter at chest is the vertical distance between the rear edge of the scapula and the front chest. Assuming the coordinates of the rear edge of the scapula are (x7, y7), the coordinates of the front chest are (x8, y8), and the diameter at chest is K4, the calculation formula is:
[0104] K4=|y8-y7|
[0105] The limb length is the vertical distance from the highest point of the elbow to the ground. The pixel value of the limb length can be calculated by measuring the vertical distance between the elbow and the bottom of the horseshoe. Assuming the coordinate value of the elbow is (x9, y9), the limb length is K5, and the calculation formula is:
[0106] K5=|y9-y2|
[0107] The above body size data can be used to calculate the horse's body length index, chest diameter index, tube circumference index, and limb length index.
[0108] The body length index is the ratio of body length to body height. Assuming the body length ratio is S1, the calculation formula is:
[0109] S1=K2 / K1;
[0110] The breast diameter index is the ratio of breast diameter to body height. Suppose the breast diameter ratio is S2, the calculation formula is:
[0111] S2=K4 / K1;
[0112] The tube circumference index is the ratio of tube circumference to body height. Let the tube circumference index be S3, and the calculation formula is:
[0113] S3=K3 / K1;
[0114] The limb length index is the ratio of the forelimb length to the body height. Let the limb length index be S4, and the calculation formula is:
[0115] S4=K5 / K1.
[0116] In this embodiment, the standards used for comprehensive scoring in S3 are shown in Table 1 below:
[0117] Table 1 Horse selection index range and scoring criteria
[0118]
[0119]
[0120] The ranges and scoring criteria for each horse-appraising index in Table 1 were obtained by statistically analyzing 50 special-grade, 50 first-grade, 50 second-grade, and 50 other-grade sport horses.
[0121] In this embodiment, the scoring criteria in S3 are shown in Table 2 below:
[0122] Table 2 Grading table
[0123] Points Grading 9.1-10 Special 8.4-9.0 Level 1 7.3-8.3 Level 2 ≤7.2 substandard
[0124] Example 2
[0125] like Figure 2 As shown, this embodiment also provides a sports horse judging device, comprising:
[0126] An image module 1 is used to obtain an image of a horse, wherein the image includes a front view and a side view of the horse;
[0127] Contour recognition module 2; used to identify the contours of the head, eyes, ears and nostrils based on the collected horse image;
[0128] The calculation module 3 is used to calculate the proportion of the eye, ear and nostril to the head area according to the identified contours of the head, eye, ear and nostril; and is also used to obtain the body size index of the horse according to the collected image of the horse;
[0129] Evaluation module 4 is used to score the appearance of the horse according to the proportion of the eyes, ears, and nostrils to the head area in the image and the body size index, and finally grade the appearance of the horse according to the scoring values.
[0130] In this embodiment, in order to improve the detection accuracy of subsequent targets such as the horse's head, eyes, ears, and nostrils, the horse image is collected and analyzed by using the Faster-RCNN neural network model. If a horse object is detected in the image, the image is denoised and enhanced, otherwise it is required to be re-collected; the specific training steps of the Faster-RCNN neural network model are as follows:
[0131] S101, the central server Ubuntu20.04 builds the Faster-RCNN algorithm environment;
[0132] S102, prepare a training data set, collect front and side pictures of horses (more than 5000 pictures), and use the LabelImg image annotation tool to select the area where the horse is located with a rectangular box;
[0133] S103, inputting a training data set into the Faster-RCNN neural network, repeatedly iterating the training, and obtaining an optimal Faster-RCNN neural network, that is, a preset Faster-RCNN neural network.
[0134] In this embodiment, the Mask-RCNN neural network is trained to identify the contour range of the head, eyes, ears, and nostrils in the horse picture. The specific steps of training the Mask-RCNN neural network are as follows:
[0135] S201, the central server Ubuntu20.04 builds the Mask-RCNN algorithm environment;
[0136] S202, prepare a training data set, collect front and side pictures of horses (more than 5000 pictures), use LabelMe image annotation tool to mark the head and left and right nostril contours of the horse's front picture, and mark the head, ears, and eye contours of the horse's side picture;
[0137] S203, generating a mask file from the marked data and adjusting it to the COCO dataset format;
[0138] S204, adjusting key parameters such as the number of GPUs, number of iterations, learning rate, and training sample path;
[0139] S205, loading the pre-trained model, inputting the training data set into the Mask-RCNN neural network, and repeatedly iterating the training to obtain the optimal neural network, namely the Mask-RCNN neural network model.
[0140] In this embodiment, the specific process of the proportion of the eyes, ears, and nostrils to the head area is as follows:
[0141] Input the front picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's head and left and right nostrils in the front picture; input the side picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's ears, eyes, and head in the side picture, and then record the pixel coordinate values of the contours of each part;
[0142] Since the outlines of the ears, eyes, nostrils, and head are irregular polygons, the image is first binarized when calculating the outline area. Obtain the length and width of the horse's front image and the pixel coordinate values of the head and nostril outlines in the front image, generate three black background images with the same length and width as the horse's front image, and draw the head outline, left nostril outline, and right nostril outline in the newly created image according to the pixel coordinate values of the head and nostril outlines, and fill the outlines with white (such as Figure 4 As shown), after generating the binary image, use the Python script cv2.findCountor to find the contour value, use cv2.drawCountors to draw the image contour, take out the contour value cnt through the index, and use cv2.ContourArea() to calculate the area of the contour, where:
[0143] imgurl is the binary image path;
[0144] area is the calculation result.
[0145] The specific algorithm is as follows:
[0146] import cv2
[0147] imgurl="head.png"
[0148] img = cv2.imread(imgurl)
[0149] gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
[0150] ret,thresh=cv2.threshold(gray,127,255,cv2.THRESH_BINARY)
[0151] binary,contours,h=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
[0152] draw_img = img.copy()
[0153] ret=cv2.drawContours(draw_img,contours,0,(0,0,255),2)
[0154] cnt=contours[0]
[0155] area = cv2.contourArea(cnt)
[0156] After the above algorithm is used to obtain the areas of the left and right nostril regions and the head region, the ratio between the two can be calculated. Suppose the area of the left nostril region is S1, the area of the right nostril region is S2, the area of the front head region is S3, and the ratio of the nostril to the front head is M1. The calculation formula is:
[0157]
[0158] Through the side view of the horse, the proportion of the ears and eyes to the head can be calculated, the length and width of the side view of the horse and the pixel coordinate values of the head, eyes and ears in the side view can be obtained, and three black background images with the same length and width as the side view of the horse are generated. The head, eyes and ears are drawn in the newly created images according to the pixel coordinate values of the head, eyes and ears in the side view, and the outlines are filled with white (such as Figure 5 As shown), then use the above method to calculate the area of the side head, eyes, and ears, and then calculate the ratio of eyes to side head, and the ratio of ears to side head. Suppose the area of the eye area is S4, the area of the ear area is S5, the area of the side head area is S3, the ratio of eyes to side head is M2, and the ratio of ears to side head is M3. The calculation formula is:
[0159]
[0160]
[0161] In this embodiment, the body length index, chest diameter index, tube circumference index, and limb length index are specifically defined as:
[0162] Body length index: also known as body length rate, which is the ratio of body length to body height. Body length / body height × 100 = body length rate, which can explain the economic type of the horse and the embryonic development.
[0163] Diameter at breast height index: Diameter at breast height ratio, which is the ratio of diameter at breast height to height. Diameter at breast height / height × 100 = diameter at breast height ratio, which indicates the development of the body, also known as the body width index. A large diameter at breast height ratio indicates a large chest, good heart and lung development, and a large body weight, which is conducive to the development of pulling power and endurance.
[0164] Tube circumference index: Tube circumference ratio, which is the ratio of tube circumference to body height. Tube circumference / body height×100=tube circumference ratio. It indicates the development of bones and is also called bone mass index.
[0165] Limb length index: also known as limb length ratio, which is the ratio of forelimb length to body height. Forelimb length / body height × 100 = limb length ratio. Limb length index is related to speed, also known as speed index.
[0166] In addition to judging the quality of sports horses by the size of their body parts, you can also judge by body size index, which includes body length index, chest diameter index, tube circumference index and limb length index. Before calculating the above body size index, you need to obtain the 2D plane horse body length, body height, limb length, chest diameter, tube circumference data, such as Figure 3 The measurement criteria are as follows:
[0167] Body height: the vertical distance from the top of the withers to the ground;
[0168] Body length: the straight-line distance from the shoulder to the hip;
[0169] Tube circumference: the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone;
[0170] Diameter of chest: the vertical distance between the back edge of the shoulder blade and the front chest;
[0171] Limb length: the vertical distance from the highest point of the elbow to the ground.
[0172] The DeepLabCut neural network can estimate the posture of user-defined body parts. If you want to obtain the horse's body size data based on the picture, you need to train the DeepLabCut neural network model to obtain the positions of the horse's withers, hoof bottom, shoulder, hip, left side of the tube, right side of the tube, rear edge of the shoulder blade, forechest, and elbow in the picture. By calculating the distance between pixel points, you can get the horse's body length, height, limb length, chest diameter, and tube circumference based on the 2D plane. Figure 6 As shown, the specific steps for training the DeepLabCut neural network are as follows:
[0173] S2-1. Build DeepLabCut environment on central server Ubuntu20.04;
[0174] S2-2. Prepare training videos, shoot horse videos from side angles, classify the 120 video files, and classify them into 80 training sets and 40 test sets. Input the training sets into the DeepLabCut neural network for model training. After each round of training, input the test set into the neural network for model evaluation.
[0175] S2-3. Create a project and import 80 training set videos into the project;
[0176] S2-4, create key frames, use clustering algorithm to extract frames, DeepLabCut automatically loads key frame images, and marks the withers apex, hoof bottom, shoulder end, hip end, left side of the tube girth, right side of the tube girth, rear edge of the shoulder blade, front chest, and elbow end of the horse in the key frame image;
[0177] S2-5, model training, select resnet_50 residual network, imgaug data enhancement method, single training maximum iteration 20,000 times, start model training;
[0178] S2-6, video analysis, after a single training session, some test videos are imported into the video analysis function, and the DeepLabCut neural network automatically predicts the horse body measurement points in the video;
[0179] S2-7, adjust the abnormal frames and manually correct the labels with large prediction errors;
[0180] S2-8. Repeat S2-5 to S2-7, and iterate the training to obtain the optimal neural network model, that is, the DeepLabCut neural network model.
[0181] Input the side view of the sports horse into the DeepLabCut neural network model to predict the pixel coordinates of the withers apex, hoof bottom, shoulder, hip, left side of the girth, right side of the girth, rear edge of the shoulder blade, front chest, and elbow in the side view. The 2D body length of the horse can be measured by calculating the straight-line distance between the two points.
[0182] The body height is the vertical distance from the withers apex to the ground. The pixel value of the body height can be calculated by measuring the vertical distance between the withers apex and the bottom of the hoof. Assuming the coordinate value of the withers apex is (x1, y1), the coordinate value of the bottom of the hoof is (x2, y2), and the body height is K1, the calculation formula is:
[0183] K1=|y2-y1|
[0184] The body length is the straight-line distance from the shoulder to the hip. Assume that the coordinates of the shoulder are (x3, y3), the coordinates of the hip are (x4, y4), and the body length is K2. The calculation formula is:
[0185]
[0186] The tube circumference is the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone. Let the left point of the tube circumference be (x5, y5), the right point of the tube circumference be (x6, y6), and the tube circumference be K3. The calculation formula is:
[0187]
[0188] The diameter at chest is the vertical distance between the rear edge of the scapula and the front chest. Assuming the coordinates of the rear edge of the scapula are (x7, y7), the coordinates of the front chest are (x8, y8), and the diameter at chest is K4, the calculation formula is:
[0189] K4=|y8-y7|
[0190] The limb length is the vertical distance from the highest point of the elbow to the ground. The pixel value of the limb length can be calculated by measuring the vertical distance between the elbow and the bottom of the horseshoe. Assuming the coordinate value of the elbow is (x9, y9), the limb length is K5, and the calculation formula is:
[0191] K5=|y9-y2|
[0192] The above body size data can be used to calculate the horse's body length index, chest diameter index, tube circumference index, and limb length index.
[0193] The body length index is the ratio of body length to body height. Assuming the body length ratio is S1, the calculation formula is:
[0194] S1=K2 / K1;
[0195] The breast diameter index is the ratio of breast diameter to body height. Suppose the breast diameter ratio is S2, the calculation formula is:
[0196] S2=K4 / K1;
[0197] The tube circumference index is the ratio of tube circumference to body height. Let the tube circumference index be S3, and the calculation formula is:
[0198] S3=K3 / K1;
[0199] The limb length index is the ratio of the forelimb length to the body height. Let the limb length index be S4, and the calculation formula is:
[0200] S4=K5 / K1.
[0201] In this embodiment, the scoring criteria are shown in Table 1 below:
[0202] Table 1 Horse selection index range and scoring criteria
[0203]
[0204]
[0205]
[0206] The ranges and scoring criteria for each horse-appraising index in Table 1 were obtained by statistically analyzing 50 special-grade, 50 first-grade, 50 second-grade, and 50 other-grade sport horses.
[0207] In this embodiment, the scoring criteria are shown in Table 2 below:
[0208] Table 2 Grading table
[0209] Points Grading 9.1-10 Special 8.4-9.0 Level 1 7.3-8.3 Level 2 ≤7.2 substandard
[0210] Example 3
[0211] This embodiment provides an electronic device, the electronic device comprising:
[0212] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can execute the Souma method described in Example 1.
[0213] Example 4
[0214] This embodiment provides a computer-readable storage medium storing computer instructions, wherein the computer instructions are operated to execute the horse-matching method described in Embodiment 1.
[0215] The above is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent change made to the above embodiment according to the technical essence of the invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A horse-matching method based on machine vision, characterized in that: The method includes: obtaining images of the horse, the images including front and side views of the horse; Based on the collected images of horses, the outlines of the head, eyes, ears and nostrils are identified; Based on the identified contours of the head, eyes, ears and nostrils, calculate the proportion of the eyes, ears and nostrils to the head area; Obtaining the body size index of the horse based on the collected images of the horse; Comprehensively scoring the appearance of the horse based on the proportion of the eyes, ears, and nostrils to the head area in the image and the body size index, and finally grading the appearance of the horse based on the scoring result; Based on the collected horse images, the outlines of the head, eyes, ears and nostrils are identified. The specific process is as follows: Input the front picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's head and left and right nostrils in the front picture; input the side picture of the horse into the Mask-RCNN neural network model to obtain the outlines of the horse's ears, eyes, and head in the side picture, and then record the pixel coordinate values of the contours of each part; The body size index of the horse is obtained according to the collected horse images. The specific process is as follows: the side image of the horse is input into the DeepLabCut neural network model, and the coordinate values of the pixel points of the withers apex, the bottom of the hoof, the shoulder end, the hip end, the left side of the tube circumference, the right side of the tube circumference, the rear edge of the shoulder blade, the front chest, and the elbow end in the side image are predicted. The 2D body size length of the horse can be measured by calculating the straight-line distance between the two points. The body size length includes body height, body length, tube circumference, chest diameter, and limb length; The body height is the vertical distance from the top of the withers to the ground, measured by the vertical distance from the top of the withers to the bottom of the hoof; The body length is the straight-line distance from the shoulder end to the hip end; The tube circumference is the thinnest part of the lower end of the upper 1 / 3 of the left anterior tube bone; The chest diameter is the vertical distance between the rear edge of the scapula and the front chest; The limb length is the vertical distance from the highest point of the elbow to the ground, measured by the vertical distance between the elbow and the bottom of the horseshoe.
2. The method for horse selection based on machine vision according to claim 1, characterized in that: The body size index includes body length index, chest diameter index, tube circumference index and limb length index. The body length index is the ratio of body length to body height; the chest diameter index is the ratio of chest diameter to body height; the tube circumference index is the ratio of tube circumference to body height; and the limb length index is the ratio of forelimb length to body height.
3. A method for horse selection based on machine vision according to claim 1 or 2, characterized in that: The horse images are obtained by collecting the horse images, analyzing the collected images, removing the images not containing the horses, and then performing noise reduction and enhancement processing on the images.
4. The method for horse selection based on machine vision according to claim 3, characterized in that: The Faster-RCNN neural network model was used to analyze the collected images and remove images that did not contain horses.
5. A device suitable for the method of horse matching based on machine vision as claimed in claim 1, characterized in that: include: An image module, used for obtaining images of the horse, the images including front and side pictures of the horse; A contour recognition module, used to recognize the contours of the head, eyes, ears and nostrils based on the collected horse images; A calculation module, used to calculate the proportion of the eye, ear, and nostril to the head area according to the identified contours of the head, eye, ear, and nostril; and also used to obtain the body size index of the horse according to the collected image of the horse; The evaluation module is used to score the appearance of the horse according to the proportion of the eyes, ears, and nostrils to the head area in the image and the body size index, and finally grade the appearance of the horse according to the scoring values.
6. An electronic device, characterized in that: The electronic device comprises: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can execute the machine vision-based method as described in any one of claims 1-4.
7. A computer-readable storage medium storing computer instructions, wherein the computer instructions are operated to execute the horse-matching method based on machine vision according to any one of claims 1 to 4.
