Reconstruction and Body Size Detection of 3D Sheep Body Model Based on Point Cloud Data

. Aiming at the high workload, low precision, strong stress of the traditional manual measurement to obtain the sheep growth parameters, a novel measurement technology was proposed. The specimen of the Sunite sheep about 2~3 years old were chosen for study. By reverse engineering technology, point cloud data of sheep was captured by the 3D laser scanner. Because of noise point cloud data, the improved algorithm of k-nearest neighbor was used to process the data. To improve the subsequent processing time and efficiency, octree coding was employed to reduce data, which can get evenly distribution of point cloud data and retain sheep features. Then, 3D surface model of sheep body was reconstructed using Delaunay triangulation. Some parameters were extracted, including sheep body length, body height, hip height, hip width and chest width. Compared actual parameters values with computing values of two ways, by Geomagic platform and the proposed algorithms on the Matlab, average relative errors of two ways were 1.23% and 1.01%, respectively. So results of the proposed algorithm were with small error range. Using the point clouds can reconstruct sheep surface for computing body size without stress.


Introduction
In recent years, the conformation of animals has garnered close attention by the workers who are engaged in animal husbandry and breeding.It not only reflects production performance and genetic characteristics, but also indicates the shape and yield of different cuts of meat [1].For example, the milk production and breeding of dairy cow are predicted employing linear appraisal of conformation [2].Currently most judgements of animal conformation are executed by eye or hand, and largely depended on the subjective assessment of the stockman or purchaser [3][4].
Body parameters can be estimated from shape measurements, indicating the animal growth development, such as weight body length, chest depth, rump height, body height.These parameters were directly measured by manual and contact operation.The calculation of the body measurements is very difficult especially when sheep is grazing [5].Traditional, The sheep is tied up or hung up on the scale to weight [6].These operations are dangerous for the animal.Meanwhile, it has high workload, low precision and strong stress, leading to the reduction of production quality.Image process and analysis technique have been successfully applied to estimate the animal body size indirectly from its dimensions.Some studies are listed in the following.Schofield estimated non-invasively the measurements from images [7].A low-cost dual web-camera high-resolution system was developed to obtain threedimensional position of homologous points in a scene, so as to estimate size and weight of live sheep [5].Bewley et.used digital images to determine body condition score for lactating dairy cows [8].
Recently, reverse engineering technology, adopting special measuring apparatus to get dimensional data, is used to reconstruct the surface model of animal and plants and measure their parameters with non-contact [9].For example, Liu

Composition and Principle of Three-dimensional Laser Scanner
The captured methods of point cloud data can be divided into two kinds in accordance with sensing mode, which are contact measurement and non-contact measurement.
Although the former is quite accuracy and reliable, it also has some deficiency, such as slow scanning speed and probe abrasion.The later can scan surface with highspeed and avoid of probe radius compensation, which has been widely used in reverse engineering [13].The experiment device REVscan of point cloud acquisition belongs to non-contact measurement method, offered by Canada CreaForm Inc. with weighing only 980g.The laser is safe for eye, the accuracy reaches 50m.The devices mainly contain trigger, two CCD cameras, cross laser transmitter and LED lamp.The function of four LED lamp around the CCD cameras is to shield the interference of light from the outside world.The working principle is the laser triangulation of distance.The laser launching points and CCD receiving points are in the ends of the baseline L, which constitute a triangle with the transmitted light and reflected light all together.The distance S between the baseline L and the measured object is determined by using the triangular geometry method, as shown in Figure 1.

Fig.1. the principle diagram of triangulation
Laser beam are transmitted toward the target according to certain angle.When the laser encounters the object, reflection will be happened, followed with detecting laser beam by CCD detector [14].
The reflected light through the filter appears the offset, whose value is M.Meanwhile, the laser scanning system measures the horizontal scanning angle  of every laser beam.Thus, the offset value M and the target distance S can be calculated by the formula ( 1) and ( 2), respectively.
The baseline L with high precision is generally short in three-dimensional laser scanner based on laser triangulation of distance, which determines the measurement range.

Composition and Principle of Three-dimensional Laser Scanner
The experiment took place in the image processing and pattern recognition laboratory of our college in March 2017.The test object is Sunite sheep specimen about 2~3 years old.The point cloud data were collected by different two people.After calibrating the scanner and adjusting the scanner light supplement rate, the preparation work of the scanner has done.When pressing trigger of REVscan scanner, the scanner starts to scan the surface from one point to another, namely by picking points through scanning the line.The scanning line is an intersection of the scanning plane and the sheep body [9].The points are saved on the computer in the format of .vtx.When the data are operated on MATLAB platform, the data form will be transformed to .txtformat.

Data Pretreatment and 3D Reconstruction of Sheep Body
The scan process is inevitably affected by external factor and instrument itself factor, leading to yielding the noise data among the collected point clouds.At the same time, the captured data are scatted disorderly.With the slow movement of scanner, the data quantity is more and more big, which influences the subsequent storage and processing.Therefore, it is necessary to preprocess the point cloud data.All of the experiments were executed on an Intel Core(TM) 2 Duo E7500 CPU @ 2.93 GHz and 3GB RAM; the codes were written in MATLAB 2011b.

Point Cloud Data Denoising
The Step 1 Three-dimensional point clouds C of sheep body are projected on the twodimensional planes from three directions, respectively.
Step 2 Scatted point cloud data sets on the every plane are divided into the plane mesh.
Step 3 k neighbors of each point pi={xi, yi, zi}(pi∈R 3 , i =1,2,…n) are searched in the any selected plane, then the average distance between point pi and the k neighbors are calculated by equation (3).Where K(pi) is the set of local neighborhood of point pi.
When the point pi has not enough neighbors in rectangular and its adjacent rectangular, the point is viewed as the isolated noise point, and it is deleted.
Step 4 Let D be the threshold.The point pi is regarded as the deleted candidate point if average distance >D.
Step 5 In the rest of two-dimensional plane, the steps (3) and ( 4) are executed, respectively.If the point pi is also deemed to the delete candidate point, this point is removed, otherwise, keep it.Using the proposed method, it is more efficient to recognize and remove the stray noise points.Finally, 325463 points and 339757 points sheep body on the two collection data are remained.

Point Cloud Data Reduction
The goal of data reduction is to employ as few data as possible to represent more information, making sure to improve the processing speed.The classical reduction methods, such as random, curvature, grid and unified, judge all point cloud data, resulting in a large amount of computation [17].Whereas, octree coding is based on the region [18], which splits neighborhood space into many sub-cubes with the specified length, retaining the nearest points closing to the center of every sub-cube.Thereby the data reduction has done.The key steps are listed in the following.a) Determining the number of octree layer according to the formula (4): * 2 ≥ (4) Where, dmax is the maximal length of bounding box of point clouds, d0 is defined as the distance of points.b) Dividing the point cloud data into the octree with n layers and calculating the octree coding of data points.Assuming the data point P(x, y, z), where the spatial index of the sub-cube is (i, j, k), then the index values i, j and k are converted to the binary form, respectively.According to the equation( 7), the octree coding of data point P(x, y, z) is obtained, where octree coding corresponding to the sub-cube is computed by the equation (8).The center point of sub-cube is calculated via the d0 and the spatial index.(5) And, im, jm, km∈{0,1},m∈{0,1,…,n-1}.
c) Restoring the point cloud data according to the order of coding value, at the same time, the point with equal code values are stored in the same chain list.
d) Keeping the point with minimum distance between the center point and data if there are more than one data points on the chain list, so as to reduce the data points.
We compared octree coding with several generic methods, including curvature, grid and unified, as shown in Figure 3 and Table 1.The reduction performance of different methods is evaluated by result pictures and the reduction rate.After many times of experiment, the parameter setting of four methods was specifically stated for getting a better result.The reduction proportion of curvature is set to 30%, the reduction distance of grid and uniform is respectively 6mm and 5mm, the number of octree coding layers is set to 7. Four methods all presented a model of sheep in Figure 3. Curvature method can decrease the number of point when local area was flat.It can be seen that the processing points based on other three methods were almost distributed uniformity on the surface of sheep body.The number of point clouds after octree coding were the least among the four algorithms, whose reduction rate was about 5.77%.Whereas, the number of point clouds after grid method were the largest.Comparatively, the streamline method of octree coding outperformed other methods and achieved the very low point cloud data with retaining sheep feature.When the same algorithm processes different data, the reduction rate remain unchange.Thus, the reduction rate has nothing to do with data.

Sheep Body Three-dimensional Reconstruction
The three-dimensional reconstruction is to fulfill the process of sheep point clouds from points to surfaces.Using the sheep surface model, it is convenient to obtain and analyze the parameters of sheep.The definition of triangulation is to transform the scatted point into the triangle mesh [19].The triangle is the simplest polygons, which can consist of the arbitrary polygons.The common way to construct the threedimensional surface is to use the triangulation.In this study, the Delaunay triangulation was chosen to reconstruct the sheep body.After the data captured by different people employed the octree coding to eliminate, the results were view as the input data.The reconstruction results with 28518 and 39196 triangles were displayed in Figure 4, on which the ear of sheep can be clearly seen.Whereas the edge of sheep hoof was slightly rough.This was because of the touching the ground to make the edge points difficult.Particularly, the reconstruction time after of four reduction methods were compared in the Table 2.It can be found that the number of point after simplification were proportional to the reconstruction time with the almost same ratio about 3200.The top reconstruction time of about 34s was obtained when the reduction results of curvature method was used as the input.The construction time based on octree coding was only 5.64s and 6.09s, respectively.Therefore, sparse data based on octree coding can yield a better effect.

Method of Parameter Extraction
From the three-dimensional surface reconstruction, some body size measurements can be acquired.Traditional body measurements are carried out by the use of measuring tape calibrated in centimeters after restraining and holding the animals in an unforced position, including body length, height at wither, hip height, hip width and chest width.Height at withers is obtained as the highest point over the scapulae vertical to the ground.Rump height is obtained as the highest point over the sacrum vertical to the ground.Body length is obtained as the distance from the shoulder end to the distal end of the ischial tuberosity.Chest width refers to the back width just behind the foreleg.Rump width is determined as the back width over the sacrum [20,21].Measurement locations were displayed in the Figure 5, which are searched on the three dimensional model.The body length, rump width and chest width are achieved by the Euclidean distance employing the formula (8).
Where, (xi, yi, zi) and (xj, yj, zj) is the corresponding measured points coordinates of parameters, respectively.Supposing the ground equation containing the baseline is denoted as Ax+By+Cz+D=0, Height at wither and rump height are calculated in the following formula.
Where, (x,y,z) is the measured point coordinate of the height at wither and rump height.

Conclusions
In the study, we presented the three dimensional reconstruction system of sheep body based on point cloud data.The process comprises four steps: point clouds acquisition, preprocessing, three dimensional reconstruction and body size measurement.In the data preprocessing stage, the improved k-nearest neighbor was used for data denoising, and the octree coding was employed in the reduction data to enhance the research speed and decrease the number of the point clouds while preserving the intrinsic feature points, for it divided the data points into spatial neighbor.Three dimensional reconstruction of sheep body was built using the Delaunay triangulation.
The novelty of the system of the algorithm was to calculate sheep body size based on point clouds.The measurement results made a comparison with the real values, which indicated that the proposed algorithm slightly outperformed Geomagic platform in the stability and accuracy.The paper provided a new method for the sheep body measurement, and three dimensional model can evaluate the sheep body shape, all of which are of significant importance to the sheep production and breeding.In addition, the new technology can be extended the other fields.

Fig. 2 .
Fig.2. the point cloud data of sheep body: (a) the first collection data, (b) the second collection data

Fig. 4 .
Fig. 4. Three dimensional reconstruction results based on octree coding:(a)first collection data,(b)second collection data

Fig. 5 .
Fig.5.Parameters of sheep body and their locations

Table 1 .
Comparison of data points number and rate after reduction of different algorithms