3D Reconstruction of Traditional Handicrafts Based on Binocular Vision

As an indispensable and essential material part of China’s traditional culture, traditional handicrafts have played a more important role in modern life. It is not only the crystallization of the wisdom of the Chinese people of all nationalities but also an excellent platform to display China’s long-standing culture. However, the protection and reconstruction of traditional handicrafts are relatively lagging. To realize the reconstruction of traditional handicrafts, this paper proposes an improved AD-Census stereo matching algorithm of a binocular measurement system for object positioning and three-dimensional reconstruction. Methods based on the principle of binocular vision measurement include firstly, histogram equalization, adaptive threshold Canny edge extraction, and expansion are used for image preprocessing; Secondly, the calibration method is used to complete camera calibration, remove camera distortion through stereo correction, and improve the AD-Census stereo matching algorithm based on gradient division of weak texture and edge area. Finally, the parallax map generated by the improved algorithm is used to realize three-dimensional reconstruction. The experimental results show that this method can control the error standard deviation within 0.5mm, can realize the reconstruction of traditional handicrafts, have high accuracy, and can be widely used in practice.


Introduction
Traditional handicrafts are arts and crafts with artistic styles made by human handicrafts. It is the embodiment of the living state of the nation and the integration of life and technology. More and more attention has been paid to the protection and inheritance of traditional handicrafts [1]. With the maturity of virtual reality technology, protectors pay more attention to scienti c and technological means such as digitization and informatization to realize the digital protection and inheritance of traditional handicrafts [2]. Virtual reality technology is to build a virtual scene in the real space with the help of comprehensive information processing technologies such as computer technology, simulation technology, and arti cial intelligence technology, combined with virtual wearable devices, to connect virtual and reality to increase the sensory experience of the audience [3]. e addition of virtual reality technology will provide a new way to protect and disseminate traditional handicrafts.
Machine vision can be divided into monocular vision imaging and binocular vision imaging according to the number of image sensors used. Monocular vision and binocular vision are widely used in di erent elds. Literature [4] used the feature point matching method based on random number classi cation to study the grasping operation of monocular vision and mobile manipulators. Literature [5] uses monocular vision ranging to assist robots in painting. Literature [6] applies monocular vision to a lowcost indoor robot to realize robot azimuth estimation. e most extensive application of binocular vision is measurement. Literature [7] realizes the noncontact measurement of the free-form surface by binocular vision. Literature [8] uses machine learning and binocular vision to measure the size of assembly parts and realizes and guides the robot to complete the intelligent equipment of spaceborne equipment. e classical method of 3D reconstruction in paper 12 is the motion restoration structure SFM (structure from motion) algorithm. Literature [9] restores the 3D point cloud of the target through the same name points of two images and the spatial reference relationship of camera points. Since then, the three-dimensional reconstruction method based on SFM has attracted extensive attention, and relevant scholars have researched it. Literature [10] proposes an incremental SFM (incremental structure from motion) reconstruction method. With the continuous addition of images, this method needs to estimate the camera pose and optimize the adjustment parameters iteratively. erefore, the algorithm's time complexity is high, and the cumulative error is significant. To solve this problem, literature [11] improves and optimizes the incremental SFM algorithm and uses SIFT algorithm to describe and match the feature points of the image. At the same time, a random sampling and consensus (RANSAC) algorithm is introduced to eliminate the wrong matching, which makes the solution of the essential matrix between images more accurate. Literature [12] analyzes the time complexity of each link of the incremental SFM algorithm and adopts different methods to optimize the SFM algorithm for nodes such as feature matching, beam adjustment, and reconstruction. Literature [13] improves the stability of initialization and the parallel computing ability of the algorithm by constructing the relationship graph hierarchically, reorganizing it in the form of a binary tree, and reconstructing it layer by layer. Literature [14] summarizes the previous experience and makes corresponding improvements to the robustness, accuracy, and integrity of the incremental SFM algorithm. However, no matter how the above methods are improved, they are always limited by the incremental SFM algorithm defects, which have high time complexity and low computational efficiency.
In this paper, an improved AD-Census stereo matching algorithm based on a binocular measurement system is proposed for 3D reconstruction, which solves the problem of false matching in the measured scene due to the change of background and illumination. Firstly, in the preprocessing stage, histogram equalization is used to enhance the image contrast.
e Canny adaptive threshold is used for edge extraction, and then, the image boundary is enhanced by edge expansion. Secondly, camera calibration and stereo correction are used to remove distortion. Finally, the improved AD-Census stereo matching algorithm generates a parallax map, which improves the matching accuracy of weak texture areas and realizes the accurate three-dimensional reconstruction of traditional handicrafts.

State of the Art
Binocular stereo vision is to find the pixel parallax between the points with the same name according to two images taken from different angles and simulate the human eye to restore the depth information of the target point. Figure 1 shows the measurement model. e imaging plane is parallel and coplanar in the standard stereo camera model. In Figure 1, O l and O r are the optical centers of the camera, and the K axis is parallel to the optical axis and perpendicular to the imaging plane IOJ .f is the focal length and h is the baseline. U l and U r are the target point's mapping point on the two cameras' imaging plane, and the image coordinate U l � (i l , j l ), U r � (i r , j r ). In the standard stereo model, the optical center is in the same horizontal line, that is, j l � j r , so the parallax d � i l − i r . e target point, two cameras' optical centers, and imaging points form two similar triangles. e depth information can be obtained according to the triangle similarity theorem, as shown in e further known three-dimensional coordinates are expressed as

Methodology
Accurate parallax calculation is the key to the accurate three-dimensional reconstruction of the binocular vision measurement system. e complete binocular vision measurement system mainly includes five steps: image acquisition and preprocessing, camera calibration, stereo correction, stereo matching, and 3D point cloud reconstruction [15].

Image Acquisition and Preprocessing.
e image acquisition device used in the experiment is two high frame rate cameras with an adjustable baseline. e camera can output color and end compressed high-definition images and has the functions of synchronously capturing images and recording videos. e parameters of the left and right cameras are completely consistent. e software environment is VS2019 under the Windows 10 system, including OpenCV library, and PCL library, as well as MATLAB software.
e interference factors such as uneven illumination exposure and background noise in the pictures taken by the actual camera will affect the final reconstruction results. In the experimental preprocessing stage, the effects of image enhancement algorithms such as histogram equalization, gray logarithm transformation, and bilateral filtering are compared. Gray histogram equalization makes the color distribution more uniform by widening the original histogram. After processing the original image, the local contrast is enhanced without affecting the overall difference [16]. Gray logarithm transform stretches the low brightness area through gray value mapping. At the same time, the region with higher brightness is compressed to enhance the dark details of the image, but the overall brightness is increased too much. Bilateral filtering considers the spatial proximity and gray similarity of image pixels at the same time, so as to remove noise and maintain the edge. e brightness is improved, and the details are more prominent. However, due to the smoothing of a large number of pixels in the image, it is unfavorable to the subsequent matching of points with the same name. After a comprehensive comparison, the histogram equalization algorithm is selected for image preprocessing. For the preprocessed image, the Canny adaptive threshold is further used for edge extraction, and then expansion operation is used to fill the holes in the edge area, which is convenient for accurate matching at the boundary.

Camera Calibration.
Camera calibration is to obtain the internal and external parameters of the camera. Calculating the conversion relationship of target points from a twodimensional camera plane to three-dimensional space [17], the matrices R and N are established through rotation and translation, and the external parameter matrix is obtained to determine the relative position of the camera and the target. e pinhole imaging model can approximately represent the perspective projection, and the perspective projection matrix W 2 is obtained according to the principle of triangular similarity. e image coordinates to pixel coordinates are normalized based on the camera imaging plane coordinate system to obtain the conversion matrix W 1 W 1 as shown in In the experiment, MATLAB is used to calibrate the camera. e chess boat images in each scene are captured from different angles, and the corner grid is extracted. Calculate the calibration parameters of forty groups of chessboard images [18]. Experience shows that the error below is the available accuracy, and most of the errors this time are concentrated around, so the expected effect has been achieved.

Stereo Correction.
Stereo correction uses distortion parameters to eliminate lens distortion and compensate for the fisheye effect around the image boundary. e two images with noncoplanar line arrangement are corrected to coplanar line arrangement by epipolar constraint, and the search space of corresponding matching points is reduced from two-dimensional to one-dimensional straight line.

Improvement of Stereo Matching Algorithm.
Stereo matching refers to comparing the similarity between the central pixel of the reference image and the pixel to be matched in another image within the parallax search range. Select the point with the lowest cost and the highest similarity to the same name point to calculate the parallax. Cost aggregation gathers the initial matching costs of adjacent pixels in the window area for addition or mean calculation, which is used for similarity matching to improve the reliability of matching costs. e traditional AD-Census algorithm proposed in the literature [19] uses the window construction of adaptive cross-domain for cost aggregation. Set the color and distance as the constraints of the arm length extension and consider the color difference of adjacent pixels to form a cross arm for calculation. In order to improve the matching accuracy of local stereo matching in weak texture areas, the AD-Census stereo matching algorithm is improved. In the cost aggregation stage, the weak texture and edge area are divided first based on the gradient, and then the cross-domain is aggregated to calculate the parallax and generate the parallax map.
Setting the gradient threshold gives priority to delimiting whether the pixel is in the weak texture area or the edge area. Not only the color and distance constraints but also the gradient difference of adjacent pixels are considered. A looser color and distance threshold is set in the weak texture area, and the restriction is strengthened by reducing the color and distance threshold in the edge area to ensure that the arm length extends only in the areas with similar colors. e arm length constraint condition of the improved weak texture region is shown in e maximum color and distance threshold for the edge region need to be reduced appropriately. Avoid the excessive extension of the arm length in the edge area, increase the wrong matching, and the other conditions remain unchanged as shown in

Advances in Multimedia
where β max is the gradient threshold for dividing weak texture and edge region, taken as 120. Below β max is the weak texture, and vice versa is the edge area. β 1 is the threshold value of the gradient difference between the central pixel and the pixel on the arm, taken as 40. D g (p i ,p), D c (p i ,p), and D d (p i ,p) are, respectively, the gradient difference, color difference, and spatial distance between pixels p and p i. τ max and τ 2 are two different color thresholds, 20 and 10, respectively. L max and L 2 are two different distance thresholds, corresponding to 34 and 17, respectively. e improved arm length constraint extends pixel by pixel with pixel u as the center. Determine the left, right, upper, and lower arm lengths, which are b − u , b + u , q + u , q − u , respectively. When any of the above conditions are not met, stop the extension of the arm length. Construct a cross-region composed of a horizontal line segment B(u) and a vertical line segment Q(u) as the aggregate local support skeleton. e construction process is shown in Figure 2.

3D Point Cloud Reconstruction.
Point cloud registration unifies the pose of the point cloud data from each perspective, and finally, the overlapping areas of each part can be completely coincident. e commonly used algorithm in point cloud registration is the iterative nearest point algorithm. Because the adjacent point clouds are partially coincident, the final iteration fails, and an accurate model cannot be obtained. erefore, this paper first obtains the best change matrix according to the feature points and extracts the feature points, such as NARF (normalized radial feature) algorithm, scale-invariant feature transform (SIFT), FPFH algorithm, and Harris algorithm. en improve the iterative nearest point algorithm to modify the model.

Point Cloud Rough Registration.
is paper aims at the point cloud in the overlapping area of two point clouds, which has the same distribution relationship with the neighborhood. erefore, this paper combines FPFH and RANSAC to eliminate the wrong matching points [20] and then carries out the rough registration of point clouds, so as to obtain a better initial model and improve the basis for fine registration. After the sample rotates every 60°, the point cloud data can be collected from multiple perspectives, and rough registration can be carried out based on frame 1 [21].
Suppose the target point cloud of the reconstructed object is N(n 1 , n 2 , . . . , n t ) and the source point cloud to be registered is S (s 1 , s 2 , . . . , s t ) (6), is used to judge the current model's performance.
where w x is the preset setting value. e change matrix is the optimal solution when the error function is the smallest. e specific process of rough registration is shown in Figure 3.

Precise Registration of Iterative Closest Points Based on
Weight. During rough registration, the point cloud of frame 0 is S 0 and the point cloud of frame i is S i . When S 0 and S 1 are roughly registered, S 1 ′ is obtained. An error exists in point cloud registration of S 1 and S 1 ′ . However, coarse registration of point cloud S 1 ′ and S 2 will transfer and accumulate errors. erefore, when registering to S n in turn, the error will become larger and larger. us, it is necessary to reduce the error accumulated in the registration process of two adjacent frames in the delicate registration stage. e iterative closest point algorithm (ICP) is the most widely used 3D reconstruction algorithm at present. is paper designs an iterative nearest point algorithm based on weight. For two adjacent frames, the point cloud has a good pose after entering the rough registration stage. At this time, the ICP algorithm [22] can be used for the fine registration of point cloud data. e weight is used to reduce the global impact of local error, and the threshold of the normal vector between point clouds is set to remove invalid point pairs. Finally, ICP iterative calculation based on weight is carried out. e specific steps are as follows: (1) Assuming S x is the point cloud to be registered and N y is the target point cloud, the point cloud is constructed into a k-d tree, and the corresponding point pair is found by a fast nearest neighbor search. (2) Calculate the corresponding normal vector according to the corresponding point pair. Assuming that the normal vector of one of the point pairs is t S x and t N x , calculate the angle relationship value between the pair of normal vectors and compare it with the threshold t r . If it is less than the threshold, the point pair will be eliminated.
(3) Calculate the weight according to the point pair, and the weight m xy is calculated as follows: where d xy is the distance between corresponding points. Since 60°is selected each time, the overlapping part is sin 60 ∘ of the previous adjacent data frame. erefore, the function b(x, y) represents whether the selected point belongs to the benchmark.
b(x, y) According to the weight value of the point pair, combined with the least square method, the corresponding spatial transformation parameters R and N are obtained.
(4) e obtained spatial transformation parameters R and N are applied to the source point cloud to obtain a new point cloud set V.
(5) Judge whether the Euclidean distance between the target point cloud and the new point cloud is less than the threshold r. If less, reiterate until convergence.
e speci c ow of the algorithm is shown in Figure 4.

Result Analysis and Discussion
e hardware of the test system includes a six-axis industrial robot, two CCD cameras, a camera mounting bracket, and a light-emitting board. e three-dimensional reconstruction experiments were carried out through three groups of handicrafts of di erent sizes and shapes. e three groups of traditional handicrafts were embroidery ornaments, egg carving, and wood carving square boxes, which are shown in Figure 5.

Camera Calibration.
e single size of the black-andwhite chessboard calibration board is 3 mm × Take 15 units of grids in 3 mm and direction, respectively, and complete the camera calibration with MATLAB software. In this study, the left and right cameras collected 20 calibration plate pictures with di erent angles and positions for monocular and binocular calibration. According to the single target setting, the focal length of the camera, the

Point Circle Fitting and Matching Results.
ree contour lines determine all vertices of the woodcut square box. erefore, the point circle tting method determines the feature points. e schematic diagram of the three-point tting circle is shown in Figure 6.
In Figure 6, point 1, point 2, and point 3, respectively, represent the intersection of three adjacent contour lines of the woodcut square box. e center V is obtained by tting the three points, that is, the feature point. Similarly, the above method is adopted when the vertex of the woodcut square box is greater than 2 contour lines. However, there will be errors in the multipoint tting curve in the calculation process, and there will also be errors in the center of the nal multipoint tting circle. erefore, in the experiment, a feature point of the handicrafts photographed at a speci c position is known and compared with the point circle tting method results. e coordinate values of point 1, point 2, point 3, and the tting circle center are shown in Table 2. It can be seen from Table 2 that the error of point circle tting is within the allowable range.
Because the feature points of egg carving are not obvious, it is impossible to carry out e ective stereo matching of feature points, so only two groups of handicrafts with obvious vertices are matched with the minimum distance of the common vertical line of di erent planes. e matching algorithm can accurately nd the feature points and realize the matching of feature points.   e woodcut square box at two angles photographed by a binocular camera is shown in Figure 7, which is marked with overlapping feature points at two positions.
e coordinate values of point 7 and point 8 in the coordinate system are converted to A in the coordinate system by using the secondary photographing and reconstruction method of overlapping feature points. en, the spatial coordinates of all the remaining feature points of the woodcut square box are converted to coordinate system A to calculate the three-dimensional size of the woodcut square box. In order to verify the effectiveness of this method, the threedimensional reconstruction of five groups of images under different shooting angles is carried out, and the size of 12 sides of the woodblock square box is calculated. Figure 8 shows the error curve between the size calculated by this method and the actual size.
For all crafts with the maximum outline size larger than the camera field of view and the number of surfaces exceeding 4, the same calculation method is used to obtain the full size of the crafts. e 3D reconstructed model of the woodcut square box is shown in Figure 9. Figure 10 shows the measurement error distribution curve of each contour edge of different handicrafts under multiple groups of experiments. It can be seen that the error of the three-dimensional reconstruction results of handicrafts using the research method in this paper is controlled within ±0.5 mm, in which the egg carving error fluctuates the most, and the corresponding error value is also the largest.   is is because the egg carving has rounded corners, which will cause reconstruction deviation.

Conclusion
Taking traditional handicrafts as the research object, this paper studies the three-dimensional reconstruction of handicrafts. An improved AD-Census stereo matching algorithm of the binocular measurement system is proposed for object positioning and 3D reconstruction. e contour fitting algorithm is used to extract the edge contour of handicrafts. According to the intersection of multiple contour lines, the point circle fitting method determines the feature points. e feature point matching of handicrafts is realized using the minimum distance stereo matching algorithm based on the common vertical line of different planes. Aiming at the multisurface and large size of handicrafts, a secondary shooting reconstruction algorithm with overlapping feature points is introduced to realize the complete three-dimensional reconstruction of handicrafts. Finally, the three-dimensional reconstruction experiment is carried out through three groups of handicrafts with different sizes and shapes, which can restore the three-dimensional size and shape of the handicrafts as a whole. e error standard deviation of the main outline dimensions of each handicraft is within ±0.5 mm, reaching a high accuracy. However, when there are rounded corners on the edge of handicrafts, the fitting results of feature points will be biased, and the algorithm in this paper may not be able to accurately 3D reconstruction, which is also the direction of further optimization.

Data Availability
e labeled dataset used to support the findings of this study is available from the corresponding author upon request.

Conflicts of Interest
e authors declare no conflicts of interest.