Method and device for extracting fine contour lines of three-dimensional digital models
By calculating the internal and external parameters of the virtual camera based on virtual viewpoints and camera parameters, and screening and merging the contours of the three-dimensional digital model, the problems of low efficiency and insufficient accuracy in contour extraction of large models in the existing technology are solved, and efficient and fine contour extraction of complex objects is achieved.
Patent Information
- Application Number
- CN202210669535.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-14
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-06-14
AI Technical Summary
Existing technologies make it difficult to efficiently extract fine contour lines from large three-dimensional digital models, especially in the field of cultural relics research. Existing methods have low processing efficiency and are unable to finely extract detailed contours, and do not consider the impact of different viewpoints on the extracted contour lines.
A method based on virtual viewpoint and virtual camera parameters is used to calculate the internal and external parameters of the virtual camera, extract the outer contour line of the three-dimensional digital model, screen the visible faces, and filter the face contour lines and line of sight contour lines through the cosine values of the normal angle and the line of sight angle, and merge them to obtain the fine contour line.
It realizes efficient and fine contour line extraction of large three-dimensional digital models, can extract rich internal contour information, improve the extraction accuracy and details of contour lines, and is suitable for the study of complex objects.
Smart Images

Figure CN116012599B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method and device for extracting fine contour lines of a three-dimensional digital model. Background Art
[0002] 3D digital models have become a mainstream method for designing and displaying high-tech products in industry and commerce. Their intuitive effects and natural interaction have led to a booming development in 3D manufacturing and 3D visual processing. The contours of a 3D digital model are a key feature of the model. These not only include the boundary between the object and the background, known as the outer contour, but also, for complex 3D digital models, the features within the outer contour require inner contours.
[0003] The contour lines of three-dimensional digital models play a vital role in graphic interaction, especially in the field of cultural relic protection. After obtaining the three-dimensional digital model of a cultural relic using non-contact three-dimensional measurement technology, it is generally difficult to view the detailed appearance of the cultural relic. Therefore, using the projected contour lines of the cultural relic can quickly and intuitively study the details of the cultural relic.
[0004] Among existing technologies for cultural relic research, some extract line drawings of artifact models based on displayed ridges. However, due to complex algorithms and low processing efficiency, this technology can only handle models with fewer than 500,000 facets. However, today's large models often have hundreds of millions of facets, and extracting fine contour lines for these 3D digital models is a critical challenge. Other existing technologies extract the outer contours of 3D digital models while also extracting internal lines based on facet relationships. However, these solutions fail to account for the impact of different viewpoints on the extracted contours, as changes in viewing angle can also lead to deviations in contour extraction. Furthermore, if applied to cultural relic research, these solutions fail to accurately extract the detailed contours of 3D digital models. However, for cultural relic research, more detail is beneficial, and fine structures are crucial for restoration. Therefore, the demand for accurate contour extraction of 3D digital models is increasing, especially in the field of archaeological artifacts. Summary of the Invention
[0005] Based on the above situation, the main purpose of the present invention is to provide a fine contour line extraction method based on virtual viewpoints and virtual camera parameters, which can extract enough details.
[0006] To achieve the above object, the technical solution adopted by the present invention is as follows:
[0007] A method for extracting fine contour lines of a three-dimensional digital model, comprising:
[0008] S1: Calculate the intrinsic parameters of the virtual camera, determine the virtual viewpoint, and calculate the extrinsic parameters of the virtual camera according to the virtual viewpoint;
[0009] S2: extracting the outer contour line of the three-dimensional digital model at the virtual viewpoint position;
[0010] S3: Filter out all visible patches under the virtual viewpoint, where the visible patches are patches that are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates;
[0011] S4: Calculate the cosine value of the angle between the normal directions of adjacent facets in all the visible facets. If the cosine value is within a first preset range, convert the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of the two adjacent facets into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the facet contour lines of the three-dimensional digital model.
[0012] S5: Calculate the cosine value of the angle between the normal of all visible facets and the vector pointing from the facet mass center to the virtual viewpoint; if the cosine value is within a second preset range, convert the three-dimensional coordinates of the facet vertices, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the facet mass center into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the sightline contour line of the three-dimensional digital model;
[0013] S6: merging the outer contour line, the patch contour line and the sight contour line to obtain a fine contour line of the three-dimensional digital model.
[0014] Preferably, the calculation of the intrinsic parameters and extrinsic parameters of the virtual camera in S1 includes:
[0015] Calculating the internal parameters of a preset real camera as the internal parameters of the virtual camera;
[0016] The external parameters of the virtual camera are calculated according to the position relationship between the virtual viewpoint and the three-dimensional digital model, and the external parameters include a rotation matrix and a translation vector.
[0017] Preferably, determining the virtual viewpoint in S1 includes:
[0018] Establishing a spherical coordinate system with the geometric center of the bounding box of the three-dimensional digital model as the sphere center, wherein the spherical coordinate system encloses the three-dimensional digital model;
[0019] The virtual viewpoint is determined on the spherical coordinate system.
[0020] Preferably, extracting the outer contour line of the three-dimensional digital model based on the virtual viewpoint in step S2 includes:
[0021] Receiving vertex coordinates of each facet in the three-dimensional digital model, converting the vertex coordinates into a pixel coordinate system using the external and internal parameters, and obtaining pixel coordinates and corresponding depth values;
[0022] Performing debinarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain a debinarization effect image;
[0023] The debinarized effect image is subjected to morphological dilation processing, and the image before processing is subtracted from the image after processing to obtain the outer contour line.
[0024] Preferably, performing debinarization calculation on the pixel value at the pixel coordinate according to the depth value includes: debinarizing the pixel value at the pixel coordinate whose depth value is greater than 0 to 0, and debinarizing the pixel value at the pixel coordinate whose depth value is equal to 0 to 255.
[0025] Preferably, the step S3 of screening out all visible photos under the virtual viewpoint includes:
[0026] Selecting patches that are within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, and labeling the selected patches;
[0027] From the labeled patches, the patch with the smallest depth value at the same pixel coordinate is selected to obtain all the visible patches.
[0028] Preferably, the first preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
[0029] Preferably, the binarization calculation of the pixel value of the converted coordinate in step S4 includes: setting the pixel value at the converted coordinate to 255.
[0030] Preferably, the second preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
[0031] Preferably, the binarization calculation of the pixel value of the converted coordinate in step S5 includes: setting the pixel value at the converted coordinate to 255.
[0032] Preferably, the step S6 further includes:
[0033] The pixel value of 255 in the fine contour line image is de-binarized to 0, and the pixel value of 0 is de-binarized to 255, to obtain an updated fine contour line.
[0034] The present invention also provides a three-dimensional digital model fine contour line extraction device, including a parameter calculation module, an outer contour line extraction module, a visible face screening module, a face contour line extraction module, a sight line contour line extraction module and a contour line merging module:
[0035] The parameter calculation module is used to calculate the intrinsic parameters of the virtual camera, determine the virtual viewpoint, and calculate the extrinsic parameters of the virtual camera according to the virtual viewpoint;
[0036] The outer contour line extraction module is used to extract the outer contour line of the three-dimensional digital model at the virtual viewpoint position;
[0037] The visible face screening module is used to screen out all visible faces under the virtual viewpoint, wherein the visible faces are faces that are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates;
[0038] The face contour extraction module is used to calculate the cosine value of the angle between the normal directions of adjacent facets in all the visible facets. If the cosine value is within a first preset range, the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of two adjacent facets are converted into a pixel coordinate system using the external and internal parameters, and the pixel values of the converted coordinates are binarized to obtain the face contour of the three-dimensional digital model.
[0039] The sight line contour extraction module is used to calculate the cosine value of the angle between the normal of all visible facets and the vector pointing from the facet mass center to the virtual viewpoint. If the cosine value is within a second preset range, the three-dimensional coordinates of the facet vertices, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the facet mass center are converted into a pixel coordinate system using the external and internal parameters, and the pixel values of the converted coordinates are binarized to obtain the sight line contour of the three-dimensional digital model.
[0040] The contour line merging module is used to merge the outer contour line, the patch contour line and the sight line contour line to obtain a fine contour line of the three-dimensional digital model.
[0041] Preferably, the parameter calculation module includes an intrinsic parameter calculation unit and an extrinsic parameter calculation unit, the intrinsic parameter calculation unit is used to calculate the intrinsic parameters of a preset real camera as the intrinsic parameters of the virtual camera, and the extrinsic parameter calculation unit is used to calculate the extrinsic parameters of the virtual camera based on the posture relationship between the virtual viewpoint and the three-dimensional digital model, and the extrinsic parameters include a rotation matrix and a translation vector.
[0042] Preferably, the parameter calculation module establishes a spherical coordinate system with the geometric center of the bounding box of the three-dimensional digital model as the sphere center, and the spherical coordinate system surrounds the three-dimensional digital model; and determines the virtual viewpoint on the surface of the spherical coordinate system.
[0043] Preferably, the outer contour line extraction module includes a coordinate conversion unit, a debinarization calculation unit and an outer contour line calculation unit.
[0044] The coordinate conversion unit is used to receive the vertex coordinates of each facet in the three-dimensional digital model, convert the vertex coordinates into the pixel coordinate system through the external parameters and the internal parameters, and obtain the pixel coordinates and the corresponding depth value;
[0045] The debinarization calculation unit is used to perform debinarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain a debinarization effect image;
[0046] The outer contour line calculation unit is used to perform morphological dilation processing on the debinarized effect image, and subtract the image before processing from the processed image to obtain the outer contour line.
[0047] Preferably, the debinarization calculation unit debinarizes the pixel value at the pixel coordinate whose depth value is greater than 0 to 0, and debinarizes the pixel value at the pixel coordinate whose depth value is equal to 0 to 255, so as to complete the debinarization calculation of the pixel value at the pixel coordinate.
[0048] Preferably, the visible face screening module selects faces that are within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, and labels the selected faces; from the labeled faces, the face with the smallest depth value at the same pixel coordinates is selected to obtain all the visible faces.
[0049] Preferably, the first preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
[0050] Preferably, the patch contour extraction module includes a binarization calculation unit,
[0051] The binarization calculation unit is used to set the pixel value at the converted coordinate to 255.
[0052] Preferably, the second preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
[0053] Preferably, the sight line contour extraction module includes a binarization calculation unit,
[0054] The binarization calculation unit is used to set the pixel value at the converted coordinate to 255.
[0055] Preferably, the contour line merging module includes an inverse binarization calculation unit,
[0056] The debinarization calculation unit is used to debinarize the pixel value of 255 in the fine contour line image into 0, and debinarize the pixel value of 0 into 255, so as to obtain an updated fine contour line.
[0057] The present invention also provides a computer-readable storage medium having a computer program stored thereon. The computer program stored in the storage medium is used to be executed to implement the three-dimensional digital model fine contour line extraction method of the present invention.
[0058] The present invention also provides a three-dimensional digital model fine contour line extraction device, comprising: a processor for implementing the three-dimensional digital model fine contour line extraction method of the present invention.
[0059] The present invention also provides a face recognition technology method, including the three-dimensional digital model fine contour line extraction method of the present invention, so as to extract the fine contour line of the face.
[0060] The present invention also provides a face recognition device, which uses the three-dimensional digital model fine contour line extraction device of the present invention to extract the fine contour line of the face.
[0061] The present invention fully takes into account that the contour line extraction in the real scene is based on a certain viewpoint, and the extracted contour lines are different at different viewpoint positions. Therefore, a contour line extraction method based on a virtual viewpoint is adopted, and the parameters of the real camera are used as the parameters of the virtual camera in the contour line extraction process. A method for extracting the fine contour line of the three-dimensional model by a combination method is proposed. First, the internal and external parameters of the virtual camera are calculated, and the virtual viewpoint is determined. The outer contour of the object is first extracted based on the virtual viewpoint, and then the visible faces of the three-dimensional digital model under the virtual viewpoint are screened out. Then, according to the cosine value of the angle between the normal direction of adjacent faces in the visible face, the faces that meet the face contour line requirements are screened out, and the face contour line is extracted. Then, according to the cosine value of the angle between the normal direction of the face in the visible face and the specified line of sight direction, the faces that meet the line of sight contour line requirements are screened out, and the line of sight contour line is extracted. Finally, the outer contour line, the face contour line and the line of sight contour line are combined together to form the fine contour line of the present invention.
[0062] The present invention can not only extract ordinary outer contour information, but also extract very rich inner contour information for extremely complex objects. The inner contour information includes not only patch contour lines but also sight contour lines. By making full use of the complementary advantages of the three different contours, a very perfect and detailed fine contour line can be obtained.
[0063] At the same time, by using the intrinsic and extrinsic parameters of the real camera as the intrinsic and extrinsic parameters of the virtual camera and selecting a virtual viewpoint, it is equivalent to using the real camera parameters as the input parameters for contour extraction of the three-dimensional digital model, which greatly improves the practicality of the extracted contour information in future expansion experiments.
[0064] Other beneficial effects of the present invention will be explained through the introduction of specific technical features and technical solutions in the specific implementation methods. Those skilled in the art should be able to understand the beneficial technical effects brought about by the introduction of these technical features and technical solutions. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The following describes a preferred embodiment of the method and apparatus for extracting fine contour lines of a three-dimensional digital model according to the present invention with reference to the accompanying drawings.
[0066] Figure 1 A flow chart of a method for extracting fine contour lines from a three-dimensional digital model according to a preferred embodiment of the present invention;
[0067] Figure 2 A schematic diagram of determining a virtual viewpoint according to a preferred embodiment of the present invention;
[0068] Figure 3 A schematic diagram of a three-dimensional digital model according to a preferred embodiment of the present invention;
[0069] Figure 4 From a virtual perspective Figure 3 Debinarization effect diagram of the depth map of the three-dimensional digital model;
[0070] Figure 5 According to a preferred embodiment of the present invention Figure 3 Outer contour line drawing of the three-dimensional digital model;
[0071] Figure 6 Contour comparison chart obtained by screening visible faces in advance;
[0072] Figure 7 A schematic diagram of extracting facet contour lines according to a preferred embodiment of the present invention;
[0073] Figure 8 According to a preferred embodiment of the present invention Figure 3 Surface contour extraction diagram of 3D digital model;
[0074] Figure 9 A schematic diagram of extracting sight line contour lines according to a preferred embodiment of the present invention;
[0075] Figure 10 According to a preferred embodiment of the present invention Figure 3 Sight line extraction diagram of 3D digital model;
[0076] Figure 11 According to a preferred embodiment of the present invention Figure 3 Fine contour line extraction map of 3D digital model;
[0077] Figure 12 A three-dimensional digital model fine contour line extraction device according to a preferred embodiment of the present invention;
[0078] Figure 13 is a structural diagram of a parameter calculation module according to a preferred embodiment of the present invention;
[0079] Figure 14 Schematic diagram of an outer contour line extraction module according to a preferred embodiment of the present invention;
[0080] Figure 15 This is a facial fine contour line extraction diagram according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0081] Figure 1 This is a flow chart of a method for extracting fine contour lines from a three-dimensional digital model according to a preferred embodiment of the present invention, comprising:
[0082] S1: Calculate the intrinsic parameters of the virtual camera, determine the virtual viewpoint, and calculate the extrinsic parameters of the virtual camera based on the virtual viewpoint.
[0083] In one embodiment, a preset real camera is selected and calibrated to obtain its intrinsic parameters, which are then used as the intrinsic parameters of the virtual camera. After determining the virtual viewpoint, the virtual camera's extrinsic parameters are calculated based on the pose relationship between the virtual viewpoint and the model coordinate system of the 3D digital model. These extrinsic parameters typically include a rotation matrix and a translation vector. The calibration calculations for the real camera can be performed using existing methods. In the present invention, the model coordinate system can be defined as a world coordinate system.
[0084] The camera external parameters include the rotation matrix and translation vector, which are used to transform the three-dimensional points in the model coordinate system into the camera coordinate system.
[0085] The intrinsic parameter matrix of the camera can be expressed as formula 1:
[0086]
[0087] The internal parameter matrix includes the equivalent focal length (f x ,f y ) and the camera principal point (u0, v0), the role of the intrinsic parameter matrix is to transform the point in the camera coordinate system into the pixel coordinate system.
[0088] In one embodiment, the method for determining the virtual viewpoint may include: Figure 2 As shown, a spherical coordinate system is established with the geometric center of the bounding box of the three-dimensional digital model of the measured object as the sphere center, and a suitable distance is selected as the radius. The spherical coordinate system encloses the three-dimensional digital model, and points a to j in the sphere of the spherical coordinate system can be selected as virtual viewpoints.
[0089] By using the internal parameters of the real camera as the internal parameters of the virtual camera and determining the external parameters of the virtual camera based on the virtual viewpoint, it is equivalent to using the parameters of the real camera when extracting the contour lines under the virtual viewpoint. Therefore, the obtained contour lines have very high practical value.
[0090] S2: Extracting the outer contour line of the three-dimensional digital model at the virtual viewpoint position.
[0091] For example Figure 3 In one embodiment, the three-dimensional digital model shown in FIG. 1 may include extracting the outer contour line of the three-dimensional digital model at the virtual viewpoint position by receiving the vertex coordinates of each facet in the three-dimensional digital model, converting the vertex coordinates into a pixel coordinate system using external and internal parameters, and obtaining pixel coordinates and corresponding depth values, where the depth value is the converted value of the vertex coordinates in the virtual camera coordinate system; and then performing debinarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain a debinarization effect image, such as Figure 4 As shown; then the debinarized effect image is subjected to morphological dilation processing, and the image before processing is subtracted from the image after processing to obtain the outer contour line of the three-dimensional digital model with a black background and white lines. In order to facilitate reading and understanding of the solution, the outer contour line is expressed by black lines on a white background in the present invention, as shown Figure 5 In a specific embodiment, by setting different expansion parameters, outer contours with different line widths can also be obtained.
[0092] In a specific embodiment, the process of converting three-dimensional vertex coordinates to pixel coordinates can be: multiplying the three-dimensional vertex coordinates by the external parameter to convert the three-dimensional vertex coordinates from the model coordinate system to the virtual camera coordinate system, and then multiplying them by the internal parameter to convert them to the pixel coordinate system to obtain the pixel coordinates.
[0093] In one embodiment, performing debinarization calculation on the pixel values at the pixel coordinates according to the depth value may include: debinarizing the pixel values at the pixel coordinates having a depth value greater than 0 to 0, and debinarizing the pixel values at the pixel coordinates having a depth value equal to 0 to 255. In a specific embodiment, the pixel values may also be binarized to a suitable value between 0 and 255, which can be set according to requirements.
[0094] S3: Filter out all visible patches under the virtual viewpoint, where the visible patches are patches that are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates.
[0095] In one embodiment, patches within the virtual viewpoint's viewing frustum and with pixel coordinates within the legal pixel coordinate system of the virtual camera can be screened and labeled. In a specific embodiment, the label can be 1. After converting 3D coordinates to pixel coordinates, patches that exceed the virtual camera's resolution range are defined as illegal. From these labeled patches, the patch with the smallest depth value at the same pixel coordinates is selected to obtain all visible patches.
[0096] In a specific embodiment, when filtering all the faces within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, not only the faces facing the virtual viewpoint will be filtered out, but also the faces facing away from the virtual viewpoint. However, the faces facing away from the virtual viewpoint are not visible from the viewpoint position and need to be removed. For example, Figure 6 As shown in the figure, the right side shows the contour extraction effect without removal, and the left side shows the contour extraction effect with removal. Without removal, the contour extraction will be incorrect. Since the depth value of the 3D vertex coordinates of the facets facing away from the virtual viewpoint is larger when converted to the virtual camera pixel coordinates, the difference in depth values at the same pixel coordinates is used to further filter all visible faces.
[0097] S4: Calculate the cosine value of the angle between the normal directions of adjacent facets in all visible facets screened out in step S3. If the cosine value is within a first preset range, convert the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of the two adjacent facets into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the facet contour lines of the three-dimensional digital model.
[0098] In one embodiment, if Figure 7 The figure shows the principle diagram of extracting the facet contour line. The triangles in the figure represent two different adjacent facets. The arrows n1 and n2 at their centroids represent the normal lines corresponding to the two facets. The figure also shows the two end points and the midpoint on the common edge of the two facets. The facet contour line can be extracted by screening the cosine value of the angle between the normal directions of adjacent facets. If the cosine value of the angle between the normal directions of any two adjacent facets meets the first preset range, it can be considered that the adjacent facets meet the requirements for facet contour extraction. Figure 7The three-dimensional coordinates of the three points are converted to the two-dimensional image plane, that is, converted to the pixel coordinate system. After performing the above processing on all visible faces, the face contour lines with black background and white lines can be obtained. For the convenience of reading and understanding, the present invention uses white background and black lines to express the face contour lines, such as Figure 8 shown.
[0099] In one embodiment, the first preset range may be greater than or equal to cos(90°) and less than or equal to cos(80°). If the normal angles of adjacent facets are within the first preset range, it means that a contour is formed. In other embodiments, the first preset range may be relaxed. In this case, more facet contours are extracted, but a lot of noise, that is, unnecessary contours, will be introduced. Black spots will appear on the image, affecting the extraction effect of the facet contours. Greater than or equal to cos(90°) and less than or equal to cos(80°) is the preferred range, which can ensure that enough facet contours are extracted and that as few unnecessary contours as possible are introduced.
[0100] In one embodiment, converting the three-dimensional coordinates of the two endpoints and the three-dimensional coordinates of the midpoint on the common edge of two adjacent facets into the virtual camera coordinate system using the external parameters and the internal parameters may include: multiplying the three-dimensional coordinates by the external parameters to convert the three-dimensional coordinates from the model coordinate system to the virtual camera coordinate system, and then multiplying them by the internal parameters to convert them into the pixel coordinate system.
[0101] In one embodiment, binarizing the pixel value at the converted coordinate in step S4 may be performed by setting the pixel value at the converted coordinate to 255.
[0102] S5: Calculate the cosine value of the angle between the normal of all visible facets and the vector pointing to the virtual viewpoint from the facet centroid. If the cosine value is within a second preset range, convert the three-dimensional coordinates of the facet vertices, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the facet centroid into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the sightline contour line of the three-dimensional digital model.
[0103] In one embodiment, if Figure 9 The figure shows the principle diagram of extracting the sight line contour line. In the figure, n1 and n2 are the normal of the patch and the vector of the patch mass pointing to the viewpoint, respectively. The figure also shows the position of the vertex of the patch and the midpoint of each edge. By calculating the cosine value of the angle between the two vectors n1 and n2, if the cosine value is within the second preset range, the patch meets the requirements of sight line contour extraction. Figure 9The 3D coordinates of the vertices and midpoints of each edge, as well as the 3D coordinates of the center of mass of the patch, a total of 7 3D points are converted to the 2D image plane, that is, converted to the pixel coordinate system, and the pixel values at the converted coordinate points are binarized. After performing the above processing on all visible patches, the sight line contour line with white lines on a black background can be obtained. For the sake of ease of reading and understanding, the present invention uses black lines on a white background to express the sight line contour line, such as Figure 10 shown.
[0104] For a 3D digital model, if a facet is smooth relative to its surrounding faces—that is, the angle between its normal and the normals of the surrounding faces is not very large, thus not meeting the requirements for facet contour extraction—but at a certain viewing angle, if the angle between the facet normal and the line of sight meets the requirements for a line of sight contour, the corresponding line of sight contour can be extracted. By adding the extraction of line of sight contours based on a virtual viewpoint, the present invention significantly increases the detail of the internal contours of the 3D model.
[0105] In one embodiment, the second preset range may be greater than or equal to cos(90°) and less than or equal to cos(80°). It can be seen that the angle between the normal of the face and the vector pointing to the virtual viewpoint from the face centroid is within the second preset range, indicating that a contour has been formed. In other embodiments, the second preset range may also be relaxed. In this case, more sight contour lines are extracted, but a lot of noise, that is, unnecessary contours, will be introduced. For example, black spots will appear on the image, affecting the sight contour lines. Greater than or equal to cos(90°) and less than or equal to cos(80°) is the preferred range, which can ensure that enough sight contour lines are extracted and that as few unnecessary contours as possible are introduced.
[0106] In one embodiment, converting the three-dimensional coordinates of the vertices of the facet, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the center of mass of the facet into the virtual camera coordinate system through the external parameters and the internal parameters may include: multiplying the three-dimensional coordinates by the external parameters to convert the three-dimensional coordinates from the model coordinate system to the virtual camera coordinate system, and then multiplying them by the internal parameters to convert them into the pixel coordinate system.
[0107] In one embodiment, performing binarization calculation on the pixel value of the converted coordinate in step S5 may include: setting the pixel value at the converted coordinate to 255.
[0108] S6: Merge the outer contour line extracted in step S2, the surface contour line extracted in step S4, and the sight contour line extracted in step S5 to obtain the fine contour line of the three-dimensional digital model with a black background and white lines. For the convenience of reading and understanding, the present invention uses a white background and black lines to express the fine contour line, such as Figure 11 shown.
[0109] In one embodiment, the pixel value of 255 in the extracted fine contour line image can be further debinarized to 0, and the pixel value of 0 can be further debinarized to 255 to obtain an updated fine contour line, that is, a fine contour line with a white background and a black outline can be generated, which is more in line with the user's visual experience and enhances the user experience.
[0110] In one embodiment, the above-mentioned debinarization calculation can be performed after the outer contour line is extracted in S2, the patch contour line is extracted in S4, and the sight contour line is extracted in S5, respectively, to obtain the following: Figure 5 、 8 The outer contour line, the face contour line and the sight contour line of the white background and the black outline shown in 10 can be directly synthesized as shown in FIG. Figure 11 The fine outline of the black outline on a white background that conforms to the user's visual experience is shown.
[0111] The present invention fully takes into account that the contour line extraction in the real scene is based on a certain viewpoint, and the extracted contour lines are different at different viewpoint positions. Therefore, a contour line extraction method based on a virtual viewpoint is adopted, and the parameters of the real camera are used as the parameters of the virtual camera in the contour line extraction process. A method for extracting the fine contour line of the three-dimensional model by a combination method is proposed. First, the internal and external parameters of the virtual camera are calculated, and the virtual viewpoint is determined. The outer contour of the object is first extracted based on the virtual viewpoint, and then the visible faces of the three-dimensional digital model under the virtual viewpoint are screened out. Then, according to the cosine value of the angle between the normal direction of adjacent faces in the visible face, the faces that meet the face contour line requirements are screened out, and the face contour line is extracted. Then, according to the cosine value of the angle between the normal direction of the face in the visible face and the specified line of sight direction, the faces that meet the line of sight contour line requirements are screened out, and the line of sight contour line is extracted. Finally, the outer contour line, the face contour line and the line of sight contour line are combined together to form the fine contour line of the present invention.
[0112] The present invention can not only extract ordinary outer contour information, but also extract very rich inner contour information for extremely complex objects. The inner contour information includes not only patch contour lines but also sight contour lines. By making full use of the complementary advantages of the three different contours, a very perfect and detailed fine contour line can be obtained.
[0113] At the same time, by using the intrinsic and extrinsic parameters of a real camera as those of a virtual camera and selecting a virtual viewpoint, the real camera parameters are used as input parameters for extracting the contour lines of a 3D digital model, greatly improving the practicality of the extracted contour information in future extended experiments. For example, in the field of cultural relic research, if the surface structure of an unearthed cultural relic is very complex and the color is dark, it is difficult to judge the details of the cultural relic with the naked eye. In this case, if 3D scanning technology is used to obtain a 3D digital model of the cultural relic, and the technology of the present invention is used to extract a fine contour map of a certain viewpoint, and then a real camera is used to take a photo at the above viewpoint, and finally the extracted contour map is plotted on the photo, the detailed contour of the cultural relic can be clearly displayed, thereby helping cultural relic researchers better understand the fine structure of the cultural relic.
[0114] The present invention also provides a device for extracting fine contour lines of a three-dimensional digital model, such as Figure 12 As shown, it includes a parameter calculation module 10, an outer contour extraction module 20, a visible face screening module 30, a face contour extraction module 40, a sight contour extraction module 50 and a contour merging module 60. Among them, the parameter calculation module 10 is used to calculate the internal parameters of the virtual camera, determine the virtual viewpoint, and calculate the external parameters of the virtual camera according to the virtual viewpoint; the outer contour extraction module 20 is used to extract the outer contour of the three-dimensional digital model at the virtual viewpoint position; the visible face screening module 30 is used to filter out all visible faces under the virtual viewpoint, and the visible faces are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates; the face contour extraction module 40 is used to calculate the cosine value of the angle between the normal directions of adjacent faces in all visible faces. If the cosine value is within a first preset range, the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of the two adjacent faces are converted to pixels through the external and internal parameters. The pixel values of the converted coordinates are binarized to obtain the face contour of the three-dimensional digital model; the sight contour extraction module 50 calculates the cosine value of the angle between the normal of all visible faces and the vector pointing from the face centroid to the virtual viewpoint. If the cosine value is within a second preset range, the three-dimensional coordinates of the vertices of the face, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the face centroid are converted into the pixel coordinate system through the external and internal parameters, and the pixel values of the converted coordinates are binarized to obtain the sight contour of the three-dimensional digital model; the contour merging module 60 is used to merge the outer contour, the face contour, and the sight contour to obtain the fine contour of the three-dimensional digital model.
[0115] The present invention can not only extract ordinary outer contour information, but also extract very rich inner contour information for extremely complex objects. The inner contour information includes not only patch contour lines but also sight contour lines. By making full use of the complementary advantages of the three different contours, a very perfect and detailed fine contour line can be obtained.
[0116] In one embodiment, if Figure 13 As shown, the parameter calculation module 10 includes an intrinsic parameter calculation unit 101 and an extrinsic parameter calculation unit 102. The intrinsic parameter calculation unit 101 is used to calculate the internal parameters of a preset real camera as the internal parameters of the virtual camera. The extrinsic parameter calculation unit 102 is used to calculate the extrinsic parameters of the virtual camera based on the pose relationship between the virtual viewpoint and the model coordinate system of the 3D digital model. The extrinsic parameters may include a rotation matrix and a translation vector. By using the intrinsic parameters of the real camera as the internal parameters of the virtual camera and determining the extrinsic parameters of the virtual camera based on the virtual viewpoint, the real camera parameters are used as input parameters for 3D digital model contour extraction, greatly improving the practicality of the extracted contour information in future expansion experiments.
[0117] In one embodiment, the parameter calculation module 10 may establish a spherical coordinate system with the geometric center of the bounding box of the 3D digital model as the sphere center. The spherical coordinate system encompasses most of the 3D digital model, and the virtual viewpoint may be determined on the surface of the spherical coordinate system.
[0118] In one embodiment, if Figure 14 As shown, the outer contour line extraction module 20 may include a coordinate conversion unit 201, an inverse binarization calculation unit 202 and an outer contour line calculation unit 203. The coordinate conversion unit 201 is used to receive the vertex coordinates of each facet in the three-dimensional digital model, and convert the vertex coordinates into the pixel coordinate system through external parameters and internal parameters to obtain pixel coordinates and corresponding depth values; the inverse binarization calculation unit 202 is used to perform inverse binarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain an inverse binarization effect image; the outer contour line calculation unit 203 is used to perform morphological dilation processing on the inverse binarization effect image, and subtract the image before processing from the processed image to obtain the outer contour line.
[0119] In one embodiment, the debinarization calculation unit 202 may debinarize the pixel values at the pixel coordinates whose depth values are greater than 0 to 0, and debinarize the pixel values at the pixel coordinates whose depth values are equal to 0 to 255, so as to complete the debinarization calculation of the pixel values at the pixel coordinates.
[0120] In one embodiment, the visible face screening module 30 may select faces that are within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, and label the selected faces. In a specific embodiment, the label may be 1. Then, from the labeled faces, the face with the smallest depth value at the same pixel coordinates is selected to obtain all visible faces.
[0121] In one embodiment, the first preset range may be greater than or equal to cos(90°) and less than or equal to cos(80°). If the normal angle of adjacent facets is within the first preset range, it means that a contour has been formed. In other embodiments, the first preset range may be relaxed, but a lot of noise will be introduced, black spots will appear on the image, and the effect of extracting the facet contour line will be affected. Greater than or equal to cos(90°) and less than or equal to cos(80°) is the preferred range, which can ensure that enough facet contour lines are extracted while minimizing the introduction of unnecessary contours.
[0122] In one embodiment, the patch contour extraction module 40 may further include a binarization calculation unit configured to set the pixel value at the converted coordinate to 255.
[0123] In one embodiment, the second preset range may be greater than or equal to cos(90°) and less than or equal to cos(80°). The angle between the normals of adjacent facets is within the second preset range, indicating that a contour has been formed. In other embodiments, the first preset range may be relaxed.
[0124] In one embodiment, the sight line contour extraction module 50 may further include a binarization calculation unit configured to set the pixel value at the converted coordinate to 255.
[0125] In one embodiment, the contour line merging module 60 may include an inverse binarization calculation unit for inverse binarizing the pixel value of 255 in the fine contour line image to 0, and the pixel value of 0 to 255, to obtain an updated fine contour line, thereby forming a fine contour line with a white background and a black outline, which can better meet user needs and enhance user experience.
[0126] In one embodiment, the above-mentioned debinarization calculation can also be performed after the outer contour extraction module 20, the patch contour extraction module 40 and the sight contour extraction module 50 are completed, and the following can be obtained respectively: Figure 5 、 8 The outer contour line, the face contour line and the sight contour line shown in FIG10 can be directly synthesized by the contour line merging module 60. Figure 11 The fine outline of the black outline on a white background that conforms to the user's visual experience is shown.
[0127] The present invention also provides a computer-readable storage medium having a computer program stored thereon. The computer program stored in the storage medium is used to be executed to implement the three-dimensional digital model fine contour line extraction method of the present invention.
[0128] The present invention also provides a three-dimensional digital model fine contour line extraction device, comprising: a processor for implementing the three-dimensional digital model fine contour line extraction method of the present invention.
[0129] The present invention also provides a face recognition method, which includes the three-dimensional digital model fine contour line extraction method of the present invention to extract fine contour lines of the face, so that the face can be recognized through the fine contour line line. Figure 15 As shown, the fine contour lines of the face are extracted using the technical solution of the present invention.
[0130] The present invention also provides a face recognition device, which uses the three-dimensional digital model fine contour line extraction device of the present invention to extract the fine contour line of the face.
[0131] It should be noted that the use of step numbers (letters or numbers) to refer to certain specific method steps in the present invention is solely for the purpose of convenience and brevity, and is in no way intended to limit the order of these method steps. Those skilled in the art will appreciate that the order of the relevant method steps is determined by the technology itself and should not be unduly limited by the use of step numbers.
[0132] Those skilled in the art will appreciate that, provided there is no conflict, the above preferred solutions can be freely combined and superimposed.
[0133] It should be understood that the above-mentioned embodiments are merely illustrative and non-restrictive. Without departing from the basic principles of the present invention, various obvious or equivalent modifications or substitutions that can be made by those skilled in the art to the above-mentioned details will be included in the scope of the claims of the present invention.
Claims
1. A method for extracting fine contour lines of a three-dimensional digital model, characterized in that: include: S1: Calculate the intrinsic parameters of the virtual camera, determine the virtual viewpoint, and calculate the extrinsic parameters of the virtual camera according to the virtual viewpoint; S2: extracting the outer contour line of the three-dimensional digital model at the virtual viewpoint position; S3: Filter out all visible patches under the virtual viewpoint, where the visible patches are patches that are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates; S4: Calculate the cosine value of the angle between the normal directions of adjacent facets in all the visible facets. If the cosine value is within a first preset range, convert the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of the two adjacent facets into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the facet contour lines of the three-dimensional digital model. S5: Calculate the cosine value of the angle between the normal of all visible facets and the vector pointing from the facet mass center to the virtual viewpoint; if the cosine value is within a second preset range, convert the three-dimensional coordinates of the facet vertices, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the facet mass center into a pixel coordinate system using the external and internal parameters, and perform binarization calculation on the pixel values of the converted coordinates to obtain the sightline contour line of the three-dimensional digital model; S6: merging the outer contour line, the patch contour line and the sight contour line to obtain a fine contour line of the three-dimensional digital model.
2. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: The calculation of the intrinsic and extrinsic parameters of the virtual camera in S1 includes: Calculating the internal parameters of a preset real camera as the internal parameters of the virtual camera; The external parameters of the virtual camera are calculated according to the position relationship between the virtual viewpoint and the three-dimensional digital model, and the external parameters include a rotation matrix and a translation vector.
3. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: Determining the virtual viewpoint in S1 includes: Establishing a spherical coordinate system with the geometric center of the bounding box of the three-dimensional digital model as the sphere center, wherein the spherical coordinate system encloses the three-dimensional digital model; The virtual viewpoint is determined on the spherical coordinate system.
4. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: Extracting the outer contour line of the three-dimensional digital model based on the virtual viewpoint in step S2 includes: Receiving vertex coordinates of each facet in the three-dimensional digital model, converting the vertex coordinates into a pixel coordinate system using the external and internal parameters, and obtaining pixel coordinates and corresponding depth values; Performing debinarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain a debinarization effect image; The debinarized effect image is subjected to morphological dilation processing, and the image before processing is subtracted from the image after processing to obtain the outer contour line.
5. The method for extracting fine contour lines of a three-dimensional digital model according to claim 4, characterized in that: Debinarizing the pixel value at the pixel coordinate according to the depth value includes: debinarizing the pixel value at the pixel coordinate whose depth value is greater than 0 to 0, and debinarizing the pixel value at the pixel coordinate whose depth value is equal to 0 to 255.
6. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: All visible photos under the virtual viewpoint screened out in step S3 include: Selecting patches that are within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, and labeling the selected patches; From the labeled patches, the patch with the smallest depth value at the same pixel coordinate is selected to obtain all the visible patches.
7. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: The first preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
8. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, characterized in that: The binarization calculation of the pixel value of the converted coordinate in step S4 includes: setting the pixel value at the converted coordinate to 255.
9. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, wherein: The second preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
10. The method for extracting fine contour lines of a three-dimensional digital model according to claim 1, wherein: The binarization calculation of the pixel value of the converted coordinate in step S5 includes: setting the pixel value at the converted coordinate to 255.
11. The method for extracting fine contour lines of a three-dimensional digital model according to any one of claims 1 to 10, characterized in that: The step S6 further includes: The pixel value of 255 in the fine contour line image is de-binarized to 0, and the pixel value of 0 is de-binarized to 255, to obtain an updated fine contour line.
12. A device for extracting fine contour lines of a three-dimensional digital model, characterized in that: It includes parameter calculation module, outer contour extraction module, visible face screening module, face contour extraction module, sight contour extraction module and contour merging module: The parameter calculation module is used to calculate the intrinsic parameters of the virtual camera, determine the virtual viewpoint, and calculate the extrinsic parameters of the virtual camera according to the virtual viewpoint; The outer contour line extraction module is used to extract the outer contour line of the three-dimensional digital model at the virtual viewpoint position; The visible face screening module is used to screen out all visible faces under the virtual viewpoint, wherein the visible faces are faces that are visible under the virtual viewpoint and have the smallest depth value at the same pixel coordinates; The face contour extraction module is used to calculate the cosine value of the angle between the normal directions of adjacent facets in all the visible facets. If the cosine value is within a first preset range, the three-dimensional coordinates of the two end points and the three-dimensional coordinates of the midpoint on the common edge of two adjacent facets are converted into a pixel coordinate system using the external and internal parameters, and the pixel values of the converted coordinates are binarized to obtain the face contour of the three-dimensional digital model. The sight line contour extraction module is used to calculate the cosine value of the angle between the normal of all visible facets and the vector pointing from the facet mass center to the virtual viewpoint. If the cosine value is within a second preset range, the three-dimensional coordinates of the facet vertices, the three-dimensional coordinates of the midpoints of each edge, and the three-dimensional coordinates of the facet mass center are converted into a pixel coordinate system using the external and internal parameters, and the pixel values of the converted coordinates are binarized to obtain the sight line contour of the three-dimensional digital model. The contour line merging module is used to merge the outer contour line, the patch contour line and the sight line contour line to obtain a fine contour line of the three-dimensional digital model.
13. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The parameter calculation module includes an internal parameter calculation unit and an external parameter calculation unit. The internal parameter calculation unit is used to calculate the internal parameters of the preset real camera as the internal parameters of the virtual camera; The extrinsic parameter calculation unit is used to calculate the extrinsic parameters of the virtual camera according to the position relationship between the virtual viewpoint and the three-dimensional digital model, and the extrinsic parameters include a rotation matrix and a translation vector.
14. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The parameter calculation module establishes a spherical coordinate system with the geometric center of the bounding box of the three-dimensional digital model as the sphere center, and the spherical coordinate system surrounds the three-dimensional digital model; and determines the virtual viewpoint on the surface of the spherical coordinate system.
15. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The outer contour line extraction module includes a coordinate conversion unit, an inverse binarization calculation unit and an outer contour line calculation unit. The coordinate conversion unit is used to receive the vertex coordinates of each facet in the three-dimensional digital model, convert the vertex coordinates into the pixel coordinate system through the external parameters and the internal parameters, and obtain the pixel coordinates and the corresponding depth value; The debinarization calculation unit is used to perform debinarization calculation on the pixel value at the pixel coordinate according to the depth value to obtain a debinarization effect image; The outer contour line calculation unit is used to perform morphological dilation processing on the debinarized effect image, and subtract the image before processing from the processed image to obtain the outer contour line.
16. The device for extracting fine contour lines of a three-dimensional digital model according to claim 15, characterized in that: The debinarization calculation unit debinarizes the pixel values at the pixel coordinates whose depth values are greater than 0 to 0, and debinarizes the pixel values at the pixel coordinates whose depth values are equal to 0 to 255, so as to complete the debinarization calculation of the pixel values at the pixel coordinates.
17. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The visible face screening module selects faces that are within the viewing cone of the virtual viewpoint and whose pixel coordinates are within the legal pixel coordinate system of the virtual camera, and labels the selected faces; from the labeled faces, selects the face with the smallest depth value at the same pixel coordinates to obtain all the visible faces.
18. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The first preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
19. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The patch contour line extraction module includes a binarization calculation unit, The binarization calculation unit is used to set the pixel value at the converted coordinate to 255.
20. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The second preset range is: greater than or equal to cos(90°) and less than or equal to cos(80°).
21. The device for extracting fine contour lines of a three-dimensional digital model according to claim 12, characterized in that: The sight line contour extraction module includes a binarization calculation unit, The binarization calculation unit is used to set the pixel value at the converted coordinate to 255.
22. The device for extracting fine contour lines from a three-dimensional digital model according to any one of claims 12 to 21, characterized in that: The contour line merging module includes an inverse binarization calculation unit, The debinarization calculation unit is used to debinarize the pixel value of 255 in the fine contour line image into 0, and debinarize the pixel value of 0 into 255, so as to obtain an updated fine contour line.
23. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program stored in the storage medium is used to be executed to implement the method according to any one of claims 1 to 11.
24. A device for extracting fine contour lines from a three-dimensional digital model, characterized in that: include: A processor, configured to implement the method according to any one of claims 1 to 11.
25. A face recognition method, characterized in that: The method comprises the method as described in any one of claims 1 to 11, so as to extract fine contour lines of a human face.
26. A face recognition device, characterized in that: The three-dimensional digital model fine contour line extraction device as described in any one of claims 12 to 22 is used to extract fine contour lines of a human face.
Citation Information
Patent Citations
Fisheye camera and multiple plane mirror devices-based three-dimensional reconstruction method
CN101923730A
Three-dimensional blind watermark embedding and extraction detection method and device in local spherical coordinate system
CN108335256A