Keywords

1 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 three-dimensional position of homologous points in a scene, so as to estimate size and weight of live sheep [5]. Bewley et al. 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 et al. used laser scanner to obtain point clouds, in order to reconstruct three dimension pig body [10]. Li et al. captured the point cloud data of a cattle hoof to build the three-dimensional geometrical modeling [11]. Zhang studied the papaya reconstruction to detect feature based on the point cloud data [12]. Obviously, the technology is widely used in agricultural applications with the advantage of accurately and fast obtaining 3D geometrical data.

Sunite sheep, one of the features of Inner Mongolia sheep, was selected as research object. Based on the reverse engineering technology, a large number of points on the sheep body surface were generated by the three-dimension laser scanner, and the pretreatment methods were discussed. 3D surface model of sheep body was reconstructed based on Delaunay triangulation. Subsequently, the parameters were extracted for sheep body size. This way meets the requirement of welfare production in sheep breeding.

The paper is organized as follow: Section 1 introduces the basic principle of laser scanner and collects the point cloud data of sheep. Section 2 predominantly focuses on pretreatment method, including data denoising and reduction, and reconstruction of sheep body. Section 3 describes parameters extraction and discusses results in detail. Section 4 highlights the conclusions.

2 Point Cloud Data Collection of Sheep Body

2.1 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 high-speed 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 980 g. 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 Fig. 1.

Fig. 1.
figure 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 formulas (1) and (2), respectively.

$$ M = f\,tan\,\alpha $$
(1)
$$ S = \frac{L + M}{2\,tan\,\alpha } $$
(2)

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.

2.2 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.txt format.

3 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 3 GB RAM; the codes were written in MATLAB 2011b.

3.1 Point Cloud Data Denoising

The 3D point cloud data of sheep body by the different people acquisition are shown in the Fig. 2, containing 336352 points and 340972 points, respectively. It can be observed that the number of points are nearly equal with different people, but data differ from each other in details. The sophisticated people can obtain the clear sheep hooves.

Fig. 2.
figure 2

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

In Fig. 2, there are a lots of noise data far away from the main body, unlike the normal point data, which are called the outliers [15, 16]. Since the traditional k-nearest neighbor search method has flaws in the aspect of computing speed and efficiency, the improved k-nearest neighbor method based on space block strategy is proposed, so as to eliminate the noise data. The three dimensional scattered point data are projected to the plane, following by the rasterizing. The research field is reduced from the 27 adjacent grids to the 9 grids, significantly decreasing the computation and enhancing the search efficiency.

Denote n as the number of point clouds. Let \( C \in {\text{R}}^{{{\text{n}} \times 3}} \) be the matrix recording the 3D coordinates of the scattered point clouds of sheep body. The following specific steps are listed:

  • Step 1: Three-dimensional point clouds C of sheep body are projected on the two-dimensional 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 \( p_{i} = \left\{ {x_{i} ,y_{i} ,z_{i} } \right\}(p_{i} \in {\text{R}}^{3} ,i = 1,2, \ldots ,{\text{n}}) \) are searched in the any selected plane, then the average distance \( \bar{d} \) between point pi and the k neighbors are calculated by Eq. (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.

    $$ \bar{d} = \frac{1}{k}\sum\nolimits_{{j \in K\left( {p_{i} } \right)}} {\left\| {p_{i} - p_{j} } \right\|} $$
    (3)
  • Step 4: Let D be the threshold. The point pi is regarded as the deleted candidate point if average distance \( \bar{d} > {\text{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.

3.2 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.

  1. (a)

    Determining the number of octree layer according to the formula (4):

    $$ d_{0} *2^{n} \ge d_{max} $$
    (4)

    Where, dmax is the maximal length of bounding box of point clouds, d0 is defined as the distance of points.

  2. (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 Eq. (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 Eq. (8). The center point of sub-cube is calculated via the d0 and the spatial index.

    $$ \begin{aligned} i = ceil((x - x_{\hbox{min} } )/d_{0} ) \hfill \\ j = ceil((y - y_{\hbox{min} } )/d_{0} ) \hfill \\ k = ceil((z - z_{\hbox{min} } )/d_{0} ) \hfill \\ \end{aligned} $$
    (5)
    $$ \begin{aligned} i = i_{0} 2^{0} + i_{1} 2^{1} + \cdots i_{m} 2^{m} + \cdots i_{n - 1} 2^{n - 1} \hfill \\ j = j_{0} 2^{0} + j_{1} 2^{1} + \cdots j_{m} 2^{m} + \cdots j_{n - 1} 2^{n - 1} \hfill \\ k = k_{0} 2^{0} + k_{1} 2^{1} + \cdots k_{m} 2^{m} + \cdots k_{n - 1} 2^{n - 1} \hfill \\ \end{aligned} $$
    (6)

    And, \( i_{m} ,j_{m} ,k_{m} \in \left\{ {0,1} \right\},m \in \left\{ {0,1, \ldots ,n - 1} \right\} \).

    $$ q_{m} = i_{m} + j_{m} 2^{1} + k_{m} 2^{2} $$
    (7)
    $$ Q = q_{n - 1} \cdots q_{m} \cdots q_{1} q_{0} $$
    (8)
  3. (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.

  4. (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 Fig. 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 6 mm and 5 mm, the number of octree coding layers is set to 7.

Fig. 3.
figure 3

Results of four reduction methods of data two: (a) Curvature; (b) Grid; (c) Uniform; (d) Octree coding

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

Four methods all presented a model of sheep in Fig. 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.

3.3 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 three-dimensional 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 Fig. 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.

Fig. 4.
figure 4

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

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 34 s was obtained when the reduction results of curvature method was used as the input. The construction time based on octree coding was only 5.64 s and 6.09 s, respectively. Therefore, sparse data based on octree coding can yield a better effect.

Table 2. Font sizes of headings. Table captions should always be positioned above the tables.

4 Parameter Extraction and Analysis of Sheep Body

4.1 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 Fig. 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 (9).

Fig. 5.
figure 5

Parameters of sheep body and their locations

$$ L = \sqrt {(x_{i} - x_{j} )^{2} + (y_{i} - y_{j} )^{2} + (z_{i} - z_{j} )^{2} } $$
(9)

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.

$$ d = \frac{{\left| {Ax + {\text{B}}y + {\text{C}}z + {\text{D}}} \right|}}{{\sqrt {A^{2} + B^{2} + C^{2} } }} $$
(10)

Where, (x, y, z) is the measured point coordinate of the height at wither and rump height.

4.2 Results Analysis of Parameters

In this study, body length, height at wither, hip height, hip width and chest width values of sheep are both manually measured and obtained by reconstruction model according to the same point at the same time. Due to existing the error, the average values of several manually measurement were viewed as the finally value. To testify the precision of the three dimension surface reconstruction of sheep, comparative studies were also conducted to between the manually measured values and the obtained measured values, with computation on the three dimensional model in two ways: one was to use Geomagic platform brought by scanner, the other was to apply the mentioned algorithm on MATLAB. Table 2 illustrated the sheep body size values using different data and different computation means, comparing the manually measured values. The relative error of measured values based on Geomagic platform and MATLAB were listed in the parentheses corresponding to the measured values.

It can be observed from Table 2, the obtained values slightly varied with the combination of runtime environment and captured data. The error of parameters based on Geomagic platform altered between −0.82 cm and 1.11 cm, whose rang was larger than that of the proposed algorithm, with the change of −0.55 cm to 0.74 cm. It proved that the proposed algorithm had an effect on the measurement performance. The measured values on Geomagic platform did not reveal a good stable performance with an average relative error of 1.23%, almost 1.01% higher than that of the algorithms in the paper on MATLAB. By comparing the relative error of different data, the measured results of the second collection data was superior to that of the data by first collection, with a little influence of the computation of sheep body size. Also, as can be seen, the measured values of rump width based three dimensional reconstructions exhibited the lowest measurement performance, which was mainly caused by the difficulty of the measured point search. Hence, three dimensional reconstruction of sheep body using proposed algorithm was an effective way to calculate the sheep body size, so as to improve the accuracy and stability.

5 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.