A method, device, equipment and medium for measuring the bending body size of a pig

The pig body image was obtained through the Kinect camera, and the measurement points were extracted using the contour lines, envelope lines and maximum external moments, which solved the problem of measuring body ruler under the bent posture of the pig body, and achieved efficient and accurate body ruler measurement.

CN113344898BActive Publication Date: 2025-02-14ZHEJIANG FORESTRY UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110708281.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-25
Publication Date
2025-02-14
Estimated Expiration
2041-06-25

AI Technical Summary

Technical Problem

The prior art cannot effectively measure the body ruler of a pig body in a bending posture, resulting in large measurement errors and low production efficiency.

Method used

The Kinect camera is used to obtain the pig body image. By determining the contour line, envelope line and maximum external moment, the head, tail, shoulder, hip and body height measurement points are extracted, and the body height measurement points are restored to the world coordinate system to calculate the pig body bent body. ruler.

Benefits of technology

The measurement of the body ruler in the bent posture of the pig body is realized, reducing the influence of the posture on the measurement, improving the accuracy and efficiency of the measurement, and avoiding hormone stimulation to the pig.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113344898B_ABST
    Figure CN113344898B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of pig body size, and provides a method for measuring the bent body size of a pig. The present invention provides a method for measuring the bent body size of a pig, comprising: acquiring an image of a pig based on a Kinect camera; determining the intersection of the contour line and the envelope line of the pig in the image, and extracting the head measurement point and the tail measurement point of the pig based on the intersection; determining the maximum circumscribed moment of the pig contour in the image, and extracting the shoulder measurement point, the hip measurement point and the body height measurement point of the pig based on the contour line and the maximum circumscribed moment; restoring the head measurement point, the tail measurement point, the shoulder measurement point, the hip measurement point and the body height measurement point to the world coordinate system, and calculating the bent body size of the pig. Through the technical solution of the present application, the body size measurement in a bent posture can be realized, avoiding the requirements for the posture when measuring the body size of the pig, and expanding the scene range of the body size measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of pig body dimensions, and in particular to a method, device, equipment and medium for measuring the bent body dimensions of a pig. Background Art

[0002] Growth and development status need to be paid special attention to in the process of pig farming. Body size is an important indicator to measure the growth status of pigs. It is an important measurement parameter in pig farming and an important reference for breeding, quality estimation, and meat quality evaluation. Traditional body size measurement is carried out directly by manual contact with the pig body. This type of measurement method is difficult, has large errors, is laborious and time-consuming, and will stimulate the pigs to produce hormones that affect their growth and development. As machine vision technology becomes more and more mature, it has been widely studied and paid attention to. Combining machine vision technology to measure pig body size can reduce pigs' stress response and improve production efficiency.

[0003] The measurement of pig body size generally includes three steps: image acquisition, extraction of body size measurement points, and restoration of real body size. In terms of image acquisition, the RGB pig body images captured by traditional cameras are affected by factors such as ambient light, pig body color differences, and ground reflections, which makes the pig body contour extraction inaccurate and leads to large errors in pig body size measurement. However, depth images are insensitive to light and pig body color, so the error of pig body size measurement based on depth images is relatively small; in terms of pig body size measurement point extraction, the existing pig body size point extraction algorithm is only applicable to straight pig body pictures, but in the actual process of collecting pictures, due to the feeding habits and behavioral habits of pigs, the neck or back is usually bent, and it is difficult to collect ideal pictures that meet the requirements, which limits the existing body size measurement point extraction algorithm; in terms of restoring the real body size of pigs, a calibration ruler is usually used to assist in obtaining the proportional relationship between the real world and the image, so as to achieve the purpose of restoring the real body size of pigs. This body size restoration method increases the complexity and restrictions of image acquisition. Summary of the invention

[0004] In view of the defects in the prior art, the present invention provides a method, device, equipment and medium for measuring the body size of a pig in bending, so as to solve the problem that the prior art cannot measure the body size of a pig in bending posture.

[0005] In a first aspect, the present invention provides a method for measuring the bending body size of a pig, comprising:

[0006] Obtain images of the pig body based on the Kinect camera;

[0007] Determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection;

[0008] Determine the maximum circumscribed moment of the pig body contour line in the image, and extract the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body based on the contour line and the maximum circumscribed moment;

[0009] The head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point are restored to the world coordinate system to calculate the bending body size of the pig.

[0010] It can be seen from the above technical scheme that the present invention provides a method for measuring the bending body size of a pig, which obtains a pig image through Kinect, and uses contour lines, envelope lines and maximum circumscribed moments to obtain body size measurement points to achieve the purpose of body size measurement. The body size of a pig in a bent posture can be measured, and the maximum circumscribed moment can obtain the morphological features from the maximum bending degree to the normal posture. Based on this, the corresponding body size measurement points can be extracted to achieve the measurement of the body size of a pig from a bent posture to an ideal straight posture.

[0011] Optionally, before determining the intersection of the contour line and the envelope line of the pig body in the image, the image needs to be preprocessed, including:

[0012] Eliminating background information of the image and enhancing image information of the pig body;

[0013] Performing image segmentation and denoising processing on the image information;

[0014] The boundary of the image information is modified based on morphological operations.

[0015] Optionally, determining the intersection of the contour line and the envelope line of the pig body in the image and extracting the head measurement point and the tail measurement point of the pig body includes:

[0016] Extract the contour of the pig body based on edge detection algorithm;

[0017] Extract the envelope of the pig body based on the envelope algorithm;

[0018] Determining an intersection point between the contour line and the envelope line;

[0019] Determining the maximum distance between the contour line and the envelope line and any point of the intersection;

[0020] The coordinates of the point on the contour line corresponding to the maximum distance are extracted.

[0021] Optionally, determining the maximum circumscribed moment of the pig body in the image and extracting the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body includes:

[0022] Based on the contour line, determining a maximum circumscribed moment of the contour line;

[0023] Acquire a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment;

[0024] A body size measurement point is determined according to the first pixel point and the distance between the first pixel point and the second pixel point.

[0025] Optionally, determining the body size measurement point according to the first pixel point and the distance between the first pixel point and the second pixel point includes:

[0026] Acquire the first pixel point and a difference curve of the distance between the first pixel point and the second pixel point;

[0027] Calculating the curvature of the difference function curve;

[0028] The body measurement points are determined according to the curvature.

[0029] Optionally, restoring the head measurement point, the tail measurement point, the shoulder measurement point, the hip measurement point and the body height measurement point to the world coordinate system includes:

[0030] Convert the measured points from the pixel coordinate system to the world coordinate system, specifically:

[0031] ,

[0032] in,( ) is the coordinate of the measuring point in the world coordinate system, (u,v) is the coordinate of the pixel coordinate system, R is the rotation matrix, T is the translation matrix, f is the focal length of the camera, dx and dy are the actual sizes of the pixels on the photosensitive chip, and is the number of horizontal and vertical pixels that differ between the center pixel coordinates and the origin pixel coordinates of the image.

[0033] Optionally, the image includes a top view and a side view of the pig's body, the top view is used to determine the head measurement point, tail measurement point, shoulder measurement point and hip measurement point, and the side view is used to determine the body height measurement point of the pig's body.

[0034] In a second aspect, the present invention provides a device for measuring the bending size of a pig, comprising:

[0035] An image acquisition module, used to acquire images of the pig body based on a Kinect camera;

[0036] A first determination module is used to determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection;

[0037] A second determination module is used to determine the maximum circumscribed moment of the pig body contour line in the image, and extract the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body based on the contour line and the maximum circumscribed moment;

[0038] The calculation module is used to restore the head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point to the world coordinate system to calculate the bending body size of the pig.

[0039] Optionally, the device further comprises a preprocessing module, specifically configured to:

[0040] Eliminating background information of the image and enhancing image information of the pig body;

[0041] Performing image segmentation and denoising processing on the image information;

[0042] The boundary of the image information is modified based on morphological operations.

[0043] Optionally, the second determining module is specifically configured to:

[0044] Extract the contour of the pig body based on edge detection algorithm;

[0045] Extract the envelope of the pig body based on the envelope algorithm;

[0046] Determining an intersection point between the contour line and the envelope line;

[0047] Determining the maximum distance between the contour line and the envelope line and any point of the intersection;

[0048] The coordinates of the point on the contour line corresponding to the maximum distance are extracted.

[0049] Optionally, the second determining module is specifically configured to:

[0050] Based on the contour line, determining a maximum circumscribed moment of the contour line;

[0051] Acquire a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment;

[0052] A body size measurement point is determined according to the first pixel point and the distance between the first pixel point and the second pixel point.

[0053] Optionally, the second determining module is further configured to:

[0054] Acquire the first pixel point and a difference curve of the distance between the first pixel point and the second pixel point;

[0055] Calculating the curvature of the difference function curve;

[0056] The body measurement points are determined according to the curvature.

[0057] Optionally, the calculation module is specifically used for:

[0058] Convert the measured points from the pixel coordinate system to the world coordinate system, specifically:

[0059] ,

[0060] in,( ) is the coordinate of the measuring point in the world coordinate system, (u,v) is the coordinate of the pixel coordinate system, R is the rotation matrix, T is the translation matrix, f is the focal length of the camera, dx and dy are the actual sizes of the pixels on the photosensitive chip, and is the number of horizontal and vertical pixels that differ between the center pixel coordinates and the origin pixel coordinates of the image.

[0061] Optionally, the image acquired by the image acquisition module includes a top view and a side view of the pig's body, the top view is used to determine the head measurement point, tail measurement point, shoulder measurement point and hip measurement point, and the side view is used to determine the body height measurement point of the pig's body.

[0062] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.

[0063] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer program instructions stored thereon, which implement the steps of any of the above methods when executed by a processor.

[0064] Based on the above technical solution, this application has the following beneficial effects:

[0065] The present application calculates the pig's body size by determining the body size measurement points, and obtains the pig's body size measurement points based on the maximum circumscribed moment, which retains the pig's bending posture characteristics to the greatest extent, so that the body size measurement method of the present application is adaptable to the ideal straight posture to the bending posture of the pig, avoiding the influence of the pig's posture on the body size measurement. The present application uses a method of restoring the world coordinate system to calculate the body size, without the need for a calibration ruler, and can more accurately obtain the body size measurement points to calculate the pig's body size. The body size measurement point extraction method of the present application extracts the measurement points used for body size measurement, so that the body size measurement points in a bending posture can also be obtained, and the measurement point extraction rate is high and meets the requirements of body size calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the specific embodiments or the prior art description. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.

[0067] Figure 1A schematic diagram of a scenario of a method for measuring the bending body dimensions of a pig provided by an embodiment of the present invention is shown;

[0068] Figure 2 A flow chart of a method for measuring the bending body dimensions of a pig provided by an embodiment of the present invention is shown;

[0069] Figure 3 A schematic diagram showing the measuring points of a pig's head provided by an embodiment of the present invention is shown;

[0070] Figure 4 A schematic diagram of world coordinate system restoration provided by an embodiment of the present invention is shown;

[0071] Figure 5a A schematic diagram of a pig body contour line provided by an embodiment of the present invention is shown;

[0072] Figure 5b A schematic diagram of a pig body envelope provided by an embodiment of the present invention is shown;

[0073] Figure 6 A schematic diagram of the maximum circumscribed moment of a pig body provided by an embodiment of the present invention is shown;

[0074] Figure 7 The schematic diagram of the difference function curve provided by the embodiment of the present invention is shown; wherein the horizontal axis is the y value of the first pixel point, and the vertical axis is the contour point difference value ;

[0075] Figure 8 A structural block diagram of a device for measuring the bending size of a pig provided by an embodiment of the present invention is shown;

[0076] Fig. 9 A structural block diagram of an electronic device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0077] The following embodiments of the technical solution of the present invention are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and are therefore only used as examples, and cannot be used to limit the protection scope of the present invention.

[0078] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by those skilled in the art to which the present invention belongs.

[0079] At present, the measurement of pig body size requires the pig to maintain an ideal posture, but in reality this measurement method cannot meet the feeding habits and behavioral habits of pigs. The pig body is often in a bent state, resulting in poor measurement results of the above measurement method. Therefore, this application proposes a method for measuring the main body bending body size. Figure 1 , Figure 1FIG. 1 is a schematic diagram of a scene for obtaining a pig body image in an embodiment of the present invention. Figure 1 As shown, a Kinect camera is respectively arranged above and on the side of the pig body. The Kinect camera obtains a depth image of the pig body, and the control terminal receives and processes the image taken by the camera, obtains the body size measurement points of the pig body through an algorithm, and thus calculates the body size of the pig body.

[0080] The present invention specifically relates to a method for measuring the bending body size of a pig, see Figure 2 ,include:

[0081] S101. Acquire an image of a pig body based on a Kinect camera.

[0082] Specifically, due to the characteristics of the Kinect camera, the acquired image includes the depth information of the pig body. At the same time, the image includes a top view and a side view of the pig body. The top view is used to obtain the measurement points of the head, tail, shoulder and hips, and the side view is used to obtain the height of the pig body. In this application, the measurement point refers to the measurement point used to calculate the length, width and height of the pig body.

[0083] In a possible embodiment, the Kinect camera has 1 million pixels and uses ToF technology to obtain the distance to the pixel point.

[0084] S102: Determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection.

[0085] Specifically, for the body measurement of the pig, the body measurement point of the head and tail of the pig is the largest depression of the head and tail of the contour. Based on this, taking the acquisition of the head measurement point as an example, the image area of ​​the head measurement point of the pig is first determined by the intersection between the contour line and the envelope line of the head area of ​​the pig's back image, such as Figure 3 As shown, this is the point with the maximum distance from the envelope line between points A and B.

[0086] S103, determining the maximum circumscribed moment of the pig body contour line in the image, and extracting the pig body shoulder measurement points, hip measurement points and body height measurement points based on the contour line and the maximum circumscribed moment.

[0087] S104, restore the head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point to the world coordinate system, and calculate the bending body size of the pig.

[0088] Specifically, restore the head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point to the world coordinate system, see Figure 4 , where OW-XwYwZw is the world coordinate system, Oc-XcYcZc is the camera coordinate system, and o-xy is the image plane coordinate system. is the focal length of the camera, uv is the pixel coordinate system, R is the rotation matrix, T is the translation vector, P1 is the point corresponding to the pixel in the image plane, P2 is the corresponding point of P1 in the camera coordinate system, and P3 is the corresponding point of P2 in the world coordinate system.

[0089] In a possible embodiment, after completing the conversion of the body measurement points from the pixel coordinate system to the world coordinate system, the Euclidean distance calculation formula is used to complete the measurement of the real body size of the live pig. The body length is the distance from the midpoint of the ear root along the back spine through the midpoint of the shoulder, the midpoint of the buttocks, to the midpoint of the tail root. The body height is the vertical distance from the top of the shoulder blade to the horizontal bottom surface. The shoulder width is the distance between the tops of the shoulders on both sides, and the hip width is the distance between the tops of the buttocks on both sides.

[0090] The pig image is acquired through Kinect, and the body measurement points are acquired using the contour line, envelope line and maximum circumscribed moment to achieve the purpose of body measurement. The body size of the pig can be measured in a bent posture. The maximum circumscribed moment can obtain the morphological features from the maximum bending degree to the normal posture. Based on this, the corresponding body measurement points can be extracted to achieve the measurement of the pig body size from the bent posture to the ideal straight posture.

[0091] Optionally, before step S102, the image needs to be preprocessed, including:

[0092] Eliminate the background information of the image and enhance the image information of the pig body;

[0093] Perform image segmentation and denoising on image information;

[0094] Modify the boundaries of image information based on morphological operations.

[0095] Specifically, the background information in the image can be removed by using the difference method, and then the image can be denoised to eliminate the noise to the greatest extent, and based on this, the denoised boundary can be modified by morphological operations.

[0096] Optionally, step S102 specifically includes:

[0097] Extract the contour of the pig body based on edge detection algorithm;

[0098] Extract the envelope of the pig body based on the envelope algorithm;

[0099] Determine the intersection of the contour line and the envelope line;

[0100] Determine the maximum distance of any point between the contour and envelope and the intersection point;

[0101] Extract the coordinates of the point on the contour line corresponding to the maximum distance.

[0102] Specifically, based on dynamic threshold segmentation and morphological modification, the canny algorithm is used to extract the pig body contour, and the envelope and maximum circumscribed contour algorithm are used to extract the maximum circumscribed contour and envelope, see Figure 5a and Figure 5b The intersection point is determined by the contour line and the envelope line, and the coordinates of the point on the contour line whose distance from the intersection point to the line connecting the intersection points is the largest are determined.

[0103] In step S102, the intersection of the contour line and the envelope line of the pig body is obtained to obtain the head measurement point and the tail measurement point of the pig body. Taking the head measurement point of the pig body as an example, Figure 3 As shown, the intersection of the contour line and the envelope line is point A and point B. By obtaining the coordinates of point A and point B, and the linear equation of the line where point A and point B are located ax+by+c=0, the distance d from any point on the contour line A to B to the line AB can be obtained, where (x, y) is the coordinate of any point on the contour line AB. Between the contour lines A and B, the coordinates where the maximum value of d is obtained are the head measurement point C. The acquisition of the tail measurement point is based on the same concept as the acquisition method of the head measurement point C, which will not be repeated here.

[0104] Optionally, step S103 specifically includes:

[0105] S1031, based on the contour line, determining the maximum circumscribed moment of the contour line;

[0106] S1032, obtaining a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment;

[0107] S1033: Determine a body size measurement point according to the first pixel point and the distance between the first pixel point and the second pixel point.

[0108] Specifically, after the contour line is determined, the maximum circumscribed moment of the pig's body contour is determined based on the contour line. The maximum circumscribed moment will retain the shape of the pig to the greatest extent, so that the pig can not only obtain the body size in an ideal posture, but also obtain the measurement points for calculating the body size in a bent state. The maximum circumscribed moment is related to the head and tail of the pig's posture. The maximum circumscribed moment can divide the contour line into two parts. Figure 6 For example, the head and tail of the pig body have intersections with the maximum circumscribed moment, and the contour line can be simply divided into left contour points and right contour points. In one possible implementation, any pixel point of the left contour point determines a second pixel point to the left, and any pixel point of the right contour point determines a second pixel point to the right. For the pig body, the length and width of the maximum circumscribed moment are basically parallel to the x-axis or y-axis of the pixel coordinate system. The second pixel point is determined by a straight line parallel to the x-axis from the first pixel point, and the second pixel point is the intersection of this straight line and the maximum circumscribed moment.

[0109] Optionally, step S1033 specifically includes:

[0110] Obtaining a first pixel point and a difference curve of the distance between the first pixel point and the second pixel point;

[0111] Calculate the curvature of the difference function curve;

[0112] Determine the body measurement points based on the curvature.

[0113] The straight-line distance between the second pixel and the first pixel is the contour point difference value , It is obtained by calculating the Euclidean distance formula. The y value of the first pixel on the contour line is used as the independent variable. To plot a difference function curve for the dependent variable, see Figure 7 .

[0114] After determining the difference curve, calculate the curvature K of the curve, ,in, is the second-order derivative of the difference function, is the first-order derivative of the difference function. After obtaining the head and tail measurement points, determine the pixel coordinate system y value interval for obtaining the shoulder measurement point. Within the interval, the coordinate point corresponding to the minimum curvature value is the shoulder measurement point of the subject, such as Figure 7 The hip and body height measurement points are based on the same concept as the shoulder measurement points and will not be described in detail below.

[0115] By establishing a curve, the coordinates of the measuring points can be determined by obtaining the curvature of the curve. This method is suitable for obtaining shoulder measuring points, hip measuring points and body height measuring points, meets the requirements for obtaining measuring points, is not restricted by the ideal posture, and improves the efficiency of obtaining measuring points.

[0116] Optionally, in step S104, the measured points are converted from the pixel coordinate system to the world coordinate system, specifically:

[0117] ,

[0118] in,( ) is the coordinate of the measuring point corresponding to the world coordinate system, (u,v) is the coordinate of the pixel coordinate system, that is, the coordinate of the measuring point obtained for the pixel coordinate system, R is the rotation matrix, T is the translation matrix, f is the focal length of the camera, dx and dy are the actual sizes of the pixels on the photosensitive chip, and It is the number of horizontal and vertical pixels that differ between the center pixel coordinates of the image and the origin pixel coordinates.

[0119] Specifically, the measurement points are converted from the pixel coordinate system to the physical coordinate system, from the physical coordinate system to the camera coordinate system, and finally from the camera coordinate system to the world coordinate system to achieve the measurement of the real body size.

[0120] By converting the body size measurement points into the world coordinate system for calculation, the real body size can be calculated by the real coordinates of the world coordinate system, which is beneficial to the calculation of the body size of live pigs.

[0121] Optionally, the image includes a top view and a side view of the pig's body, the top view is used to determine a head measurement point, a tail measurement point, a shoulder measurement point and a hip measurement point, and the side view is used to determine a body height measurement point of the pig's body.

[0122] Specifically, Kinect cameras are arranged above and to the sides of the pig body, and can be used to obtain top and side views of the pig body. By combining the depth images obtained by the Kinect cameras, the conversion from the pixel coordinate system to the world coordinate system is facilitated.

[0123] In one embodiment, a pig body bending measurement device 20 is provided. Figure 8 ,include:

[0124] An image acquisition module 201 is used to acquire an image of a pig body based on a Kinect camera;

[0125] A first determination module 202 is used to determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection;

[0126] The second determination module 203 is used to determine the maximum circumscribed moment of the pig body contour line in the image, and extract the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body based on the contour line and the maximum circumscribed moment;

[0127] The calculation module 204 is used to restore the head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point to the world coordinate system to calculate the bending body size of the pig.

[0128] Optionally, the device further comprises a preprocessing module, specifically configured to:

[0129] Eliminating background information of the image and enhancing image information of the pig body;

[0130] Performing image segmentation and denoising processing on the image information;

[0131] The boundary of the image information is modified based on morphological operations.

[0132] Optionally, the first determining module 202 is specifically configured to:

[0133] Extract the contour of the pig body based on edge detection algorithm;

[0134] Extract the envelope of the pig body based on the envelope algorithm;

[0135] Determining an intersection point between the contour line and the envelope line;

[0136] Determining the maximum distance between the contour line and the envelope line and any point of the intersection;

[0137] The coordinates of the point on the contour line corresponding to the maximum distance are extracted.

[0138] Optionally, the second determining module 203 is specifically configured to:

[0139] Based on the contour line, determining a maximum circumscribed moment of the contour line;

[0140] Acquire a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment;

[0141] A body size measurement point is determined according to the first pixel point and the distance between the first pixel point and the second pixel point.

[0142] Optionally, the second determining module 203 is further configured to:

[0143] Acquire the first pixel point and a difference curve of the distance between the first pixel point and the second pixel point;

[0144] Calculating the curvature of the difference function curve;

[0145] The body measurement points are determined according to the curvature.

[0146] Optionally, the calculation module 204 is specifically used for:

[0147] Convert the measured points from the pixel coordinate system to the world coordinate system, specifically:

[0148] ,

[0149] in,( ) is the coordinate of the measuring point in the world coordinate system, (u,v) is the coordinate of the pixel coordinate system, R is the rotation matrix, T is the translation matrix, f is the focal length of the camera, dx and dy are the actual sizes of the pixels on the photosensitive chip, and is the number of horizontal and vertical pixels that differ between the center pixel coordinates and the origin pixel coordinates of the image.

[0150] Optionally, the image acquired by the image acquisition module 201 includes a top view and a side view of the pig's body, the top view is used to determine the head measurement point, tail measurement point, shoulder measurement point and hip measurement point, and the side view is used to determine the body height measurement point of the pig's body.

[0151] The pig body bending size measuring device 20 provided in the embodiment of the present application adopts the same inventive concept as the above-mentioned pig body bending size measuring method and can achieve the same beneficial effects, which will not be described in detail here.

[0152] Based on the same inventive concept as the above-mentioned pig body bending body measurement method, the present application embodiment also provides an electronic device 30, such as Fig. 9 As shown, the electronic device 30 may include a processor 301 and a memory 302 .

[0153] The processor 301 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and may implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0154] The memory 302 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic memory, disk, optical disk, etc. The memory is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this. The memory 302 in the embodiment of the present application can also be a circuit or any other device that can realize the storage function, which is used to store program instructions and / or data.

[0155] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; the above computer storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to: mobile storage devices, random access memory (RAM, Random Access Memory), magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor memory (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)) and other media that can store program codes.

[0156] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: mobile storage devices, random access memory (RAM, Random Access Memory), magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)) and other media that can store program codes.

[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.

Claims

1. A method for measuring the bending body size of a pig, characterized in that: include: Obtain images of the pig body based on the Kinect camera; Determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection; Determine the maximum circumscribed moment of the pig body contour line in the image, and extract the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body based on the contour line and the maximum circumscribed moment; comprising: Based on the contour line, determining a maximum circumscribed moment of the contour line; Acquire a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment; Determining a body size measurement point according to the first pixel point and the distance between the first pixel point and the second pixel point; comprising: Obtaining a first pixel point and a difference curve of the distance between the first pixel point and the second pixel point; Calculate the curvature of the difference function curve; Determine the body measurement points based on the curvature; The head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point are restored to the world coordinate system to calculate the bending body size of the pig.

2. The method according to claim 1, characterized in that Before determining the intersection of the contour line and the envelope line of the pig body in the image, the image needs to be preprocessed, including: Eliminating background information of the image and enhancing image information of the pig body; Performing image segmentation and denoising processing on the image information; The boundary of the image information is modified based on morphological operations.

3. The method according to claim 1, characterized in that The step of determining the intersection of the contour line and the envelope line of the pig body in the image, and extracting the head measurement point and the tail measurement point of the pig body based on the intersection, comprises: Extract the contour of the pig body based on edge detection algorithm; Extract the envelope of the pig body based on the envelope algorithm; Determining an intersection point between the contour line and the envelope line; Determining the maximum distance between the contour line and the envelope line and any point of the intersection; The coordinates of the point on the contour line corresponding to the maximum distance are extracted.

4. The method according to claim 1, characterized in that: The restoring of the head measuring point, the tail measuring point, the shoulder measuring point, the hip measuring point and the body height measuring point to the world coordinate system includes: Convert the measured points from the pixel coordinate system to the world coordinate system, specifically: , in,( ) is the coordinate of the measuring point in the world coordinate system, (u,v) is the coordinate of the pixel coordinate system, R is the rotation matrix, T is the translation matrix, f is the focal length of the camera, dx and dy are the actual sizes of the pixels on the photosensitive chip, and is the number of horizontal and vertical pixels that differ between the center pixel coordinates and the origin pixel coordinates of the image.

5. The method according to claim 1, characterized in that The image includes a top view and a side view of the pig's body, the top view is used to determine the head measurement point, the tail measurement point, the shoulder measurement point and the hip measurement point, and the side view is used to determine the body height measurement point of the pig's body.

6. A device for measuring the bending size of a pig, characterized in that: include: An image acquisition module, used to acquire images of the pig body based on a Kinect camera; A first determination module is used to determine the intersection of the contour line and the envelope line of the pig body in the image, and extract the head measurement point and the tail measurement point of the pig body based on the intersection; The second determination module is used to determine the maximum circumscribed moment of the pig body contour line in the image, and extract the shoulder measurement point, the hip measurement point and the body height measurement point of the pig body based on the contour line and the maximum circumscribed moment; and is also used to: Based on the contour line, determining a maximum circumscribed moment of the contour line; Acquire a first pixel point on the contour line and a second pixel point on the maximum circumscribed moment; Determining a body size measurement point according to the first pixel point and the distance between the first pixel point and the second pixel point; comprising: Obtaining a first pixel point and a difference curve of the distance between the first pixel point and the second pixel point; Calculate the curvature of the difference function curve; Determine the body measurement points based on the curvature; The calculation module is used to restore the head measurement point, tail measurement point, shoulder measurement point, hip measurement point and body height measurement point to the world coordinate system to calculate the bending body size of the pig.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Stereo vision-based live pig body size detection method

    CN108230290A