Three-dimensional skin model conversion method and device based on 2D image
The skin plane image is acquired through a monocular camera, distortion correction and depth estimation are performed, and a three-dimensional skin model is constructed, which solves the problems of high cost and low accuracy in the existing technology and achieves fast and economical three-dimensional skin model conversion.
Patent Information
- Application Number
- CN202410779627.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, the cost of obtaining 3D skin information based on lidar or binocular cameras is high, the installation conditions are complex, and the maintenance cost is high, resulting in poor ease of use, and surface irregularities and camera angle changes caused by a single measurement reference lead to low measurement accuracy. .
A monocular camera is used to obtain the skin plane image, distortion correction processing and depth estimation are performed, a depth map is generated, and a three-dimensional polygon patch is constructed based on the depth map and the skin plane image to form a three-dimensional skin model.
There is no need for complex 3D image acquisition equipment, which improves the conversion rate of 3D skin models, reduces cost and complexity, and improves measurement accuracy.
Smart Images

Figure CN118735977A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a 2D image-based 3D skin model conversion method in the field of 3D technology, in particular to a 2D image-based 3D skin model conversion method, and also to a 2D image-based 3D skin model conversion device using the method. Background Art
[0002] In dermatology applications, the most common method for recording and diagnosing one or more skin conditions is to take a photograph of the condition with the scale visible in the photograph (typically by taking a photograph of the condition next to the scale). This makes the image acquisition process slow and cumbersome. In addition, because there is only a single measurement reference in the photograph, surface irregularities and camera angle variations can result in low measurement accuracy.
[0003] In traditional technology, the 3D model of the skin is usually based on sensors such as lidar or binocular cameras, which can accurately obtain 3D information and depth distribution of the surrounding environment. However, its cost, installation conditions and subsequent maintenance costs are high, which increases the threshold of related solutions and reduces ease of use. Summary of the invention
[0004] In order to solve the technical problem that in the prior art, sensors such as laser radar or binocular cameras can accurately obtain 3D information and depth distribution of the surrounding environment, but their cost, installation conditions and subsequent maintenance costs are high, the present invention provides a 2D image-based three-dimensional skin model conversion method and device.
[0005] The present invention is implemented by the following technical scheme: a 2D image-based three-dimensional skin model conversion method, which includes the following steps: obtaining a skin plane image output by a monocular camera; performing distortion correction processing on the skin plane image to obtain a first RGB image; performing depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image; based on the depth map and the skin plane image, obtaining a plurality of polygonal patches in a three-dimensional space; using the polygonal patches as basic elements, constructing a three-dimensional skin model corresponding to the skin plane image.
[0006] As a further improvement of the above scheme, the distortion correction processing of the skin plane image to obtain the first RGB image includes the following steps: establishing a first ideal coordinate system based on the plane where the first RGB image is located; obtaining the first pixel coordinates of each pixel point on the first RGB image in the first ideal coordinate system; normalizing and distorting the first pixel coordinates of each pixel point to obtain the second pixel coordinates of each pixel point; denormalizing the second pixel coordinates to obtain the first RGB image after distortion correction.
[0007] As a further improvement of the above scheme, the depth estimation of the first RGB image and the acquisition of the depth map corresponding to the first RGB image include the following steps: obtaining a grayscale image of the first RGB image; and based on the grayscale image, obtaining the grayscale value of each pixel in the first RGB image.
[0008] As a further improvement of the above scheme, the depth estimation of the first RGB image and the acquisition of the depth map corresponding to the first RGB image include the following steps: the depth estimation of the first RGB image and the acquisition of the depth map corresponding to the first RGB image include the following steps: setting a two-dimensional sliding window, the two-dimensional sliding window can cover an odd number of pixels; obtaining the grayscale mean of each pixel covered by the two-dimensional sliding window, and assigning the grayscale mean to the updated grayscale of the center pixel located at the center of the two-dimensional sliding window; using the two-dimensional sliding window to traverse the grayscale map until the updated grayscale of each pixel in the first RGB image is obtained; based on the updated grayscale of each pixel in the first RGB image, the depth map corresponding to the first RGB image is obtained.
[0009] As a further improvement of the above scheme, the obtaining of the depth map corresponding to the first RGB image based on the updated grayscale of each pixel in the first RGB image includes the following steps: assigning the updated grayscale of each pixel in the first RGB image to the depth of each pixel in the first RGB image; and obtaining the depth map corresponding to the first RGB image based on the depth of each pixel in the first RGB image.
[0010] As a further improvement of the above solution, the polygonal patch is a triangular patch.
[0011] As a further improvement of the above scheme, the three-dimensional model corresponding to the skin plane image is constructed with the polygonal facets as basic elements, including the following steps: obtaining a set of vertices constituting each of the polygonal facets, and generating a vertex index based on the storage address of each of the vertex sets in a vertex storage area; obtaining the three-dimensional coordinates of the vertices constituting the polygonal facets from the vertex storage area based on the vertex index; and constructing the three-dimensional model corresponding to the skin plane image based on the three-dimensional coordinates of the vertices.
[0012] The present invention also provides a 2D image-based 3D skin model conversion device, which applies any of the above-mentioned 2D image-based 3D skin model conversion methods, and comprises:
[0013] A plane image acquisition module, which is used to acquire a skin plane image output by a monocular camera;
[0014] An image correction module, used for performing distortion correction processing on the skin plane image to obtain a first RGB image;
[0015] A depth estimation module, configured to perform depth estimation on the first RGB image and obtain a depth map corresponding to the first RGB image;
[0016] An element acquisition module, which is used to acquire a plurality of polygonal patches in a three-dimensional space based on the depth map and the skin plane image;
[0017] A model building module is used to construct a three-dimensional skin model corresponding to the skin plane image using the polygonal surface patch as a basic element.
[0018] Compared with the existing 2D image-based 3D skin model conversion method, the 2D image-based 3D skin model conversion method and device of the present invention have the following beneficial effects: obtaining a skin plane image output by a monocular camera, performing distortion correction processing on the skin plane image, and obtaining a first RGB image; performing depth estimation on the first RGB image, and obtaining a depth map corresponding to the first RGB image; based on the depth map and the skin plane image, obtaining a number of polygonal patches in a three-dimensional space; using the polygonal patches as basic elements, constructing a three-dimensional skin model corresponding to the skin plane image; the present application obtains a skin plane image through a monocular camera, performs depth estimation on a single skin plane image to obtain a depth map, and obtains a three-dimensional skin model corresponding to the skin plane image according to the depth map, without the need to use complex 3D image acquisition equipment, thereby improving the conversion rate of the three-dimensional skin model.
[0019] In one embodiment of the application, a terminal device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor; the steps of a 2D image-based three-dimensional skin model conversion method are implemented when the processor executes the program.
[0020] In one embodiment of the application, this embodiment provides a computer-readable storage medium on which a computer program is stored; when the program is executed by a processor, the steps of a method for converting a 3D skin model based on a 2D image are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 The figure is a flow chart of a method for converting a 2D image into a 3D skin model according to an embodiment of the present invention.
[0022] Figure 2 Flow chart of depth estimation steps according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0024] See also Figure 1 In an embodiment of the present application, a method for converting a 3D skin model based on a 2D image is proposed, and the method comprises the following steps:
[0025] S1, obtaining a skin plane image output by a monocular camera;
[0026] S2, performing distortion correction processing on the skin plane image to obtain a first RGB image;
[0027] Due to the limitations of various installation conditions, the monocular camera may not be installed perpendicular to the target, which will cause perspective distortion of the skin plane image it generates, thus greatly affecting the accuracy of subsequent image processing. Therefore, it is necessary to perform distortion correction on the captured image.
[0028] Specifically, a first ideal coordinate system is established on the plane where the first RGB image is located; the first pixel coordinates of each pixel point on the first RGB image in the first ideal coordinate system are obtained; the first pixel coordinates of each pixel point are normalized and distorted to obtain the second pixel coordinates of each pixel point; the second pixel coordinates are denormalized to obtain the first RGB image after distortion correction.
[0029] S3, performing depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image;
[0030] Among them, the depth map is a map that represents the distance between each pixel of the image and the image acquisition device as the pixel value of each pixel in the image.
[0031] Specifically, a two-dimensional sliding window is set, and the two-dimensional sliding window can cover an odd number of pixels; based on the grayscale image of the first RGB image, the grayscale mean of each pixel covered by the two-dimensional sliding window is obtained, and the grayscale mean is assigned to the updated grayscale of the central pixel located at the center of the two-dimensional sliding window; the grayscale image is traversed by using the two-dimensional sliding window until the updated grayscale of each pixel in the first RGB image is obtained; based on the updated grayscale of each pixel in the first RGB image, a depth map corresponding to the first RGB image is obtained.
[0032] S4, based on the depth map and the skin plane image, obtaining a plurality of polygonal patches in the three-dimensional space;
[0033] It should be noted that a three-dimensional model is usually composed of a group of polygonal facets in a three-dimensional space, and each group of facets includes a plurality of interconnected polygons. A polygon refers to a closed figure composed of three or more line segments connected end to end. Preferably, the polygon in the three-dimensional model is a triangle.
[0034] The three-dimensional model may present a real object or a fictional object, including but not limited to a three-dimensional map, a three-dimensional device, a three-dimensional character, and a three-dimensional game. In the embodiment of the present application, the three-dimensional model refers to a three-dimensional skin model.
[0035] A vertex refers to the connection point of three or more faces in a polyhedron. In a three-dimensional model, the vertex of each polygon is the vertex of the three-dimensional model. The vertex coordinates are three-dimensional coordinates, such as (x, y, z), where z is the depth of each pixel in the first RGB image.
[0036] The polygonal patch may be a triangular patch, which is composed of three vertices.
[0037] Specifically, a second ideal coordinate system is established based on the plane of the first RGB image after distortion correction obtained in step S204, and the horizontal and vertical coordinates of each pixel in the first RGB image are obtained based on the second ideal coordinate system, and the z-axis coordinates of each pixel in the first RGB image are obtained based on the depth map corresponding to the first RGB image, and finally a set of vertex coordinates constituting the polygonal patch is obtained.
[0038] S5, using polygonal patches as basic elements to construct a three-dimensional skin model corresponding to the skin plane image;
[0039] Specifically, the server obtains the vertex sets that constitute each polygonal facet, and generates a vertex index based on the storage address of each vertex in each vertex set; based on the vertex index, loads each vertex set from the vertex storage area to the vertex storage area; based on the vertex storage area, constructs a three-dimensional model corresponding to the skin plane image.
[0040] In an embodiment of the present application, a server obtains a skin plane image output by a monocular camera, performs distortion correction processing on the skin plane image, and obtains a first RGB image; performs depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image; based on the depth map and the skin plane image, a plurality of polygonal patches in a three-dimensional space are obtained; and a three-dimensional skin model corresponding to the skin plane image is constructed using the polygonal patches as basic elements; the present application obtains a skin plane image through a monocular camera, performs depth estimation on a single skin plane image to obtain a depth map, and obtains a three-dimensional skin model corresponding to the skin plane image according to the depth map, without the need to use complex 3D image acquisition equipment, thereby improving the conversion rate of the three-dimensional skin model.
[0041] In one embodiment of the application, step S2 includes:
[0042] S201, establishing a first ideal coordinate system based on the plane where the first RGB image is located;
[0043] S202, obtaining a first pixel coordinate of each pixel point on the first RGB image in a first ideal coordinate system;
[0044] S203, normalizing and distorting the first pixel coordinates of each pixel point to obtain the second pixel coordinates of each pixel point;
[0045] S204: Denormalize the second pixel coordinates to obtain a distortion-corrected first RGB image.
[0046] In an embodiment of the present application, the first pixel coordinates of each pixel point are normalized and distorted to obtain the second pixel coordinates of each pixel point, and then the first pixel coordinates of each pixel point are normalized and distorted to obtain the second pixel coordinates of each pixel point, thereby achieving distortion correction of the skin plane image obtained by the monocular camera and reducing the error caused by lens distortion to the subsequent conversion of the three-dimensional skin model.
[0047] In an application embodiment, please refer to Figure 2 , step S3 comprises:
[0048] S301, setting a two-dimensional sliding window;
[0049] The two-dimensional sliding window is a rectangular window that can cover an odd number of pixels; for example, the rectangular window can be a 3×3 rectangular grid, which can cover 9 pixels.
[0050] S302, obtaining the grayscale mean of each pixel point covered by the two-dimensional sliding window based on the grayscale image of the first RGB image, and assigning the grayscale mean to the updated grayscale of the central pixel point located at the center position of the two-dimensional sliding window;
[0051] When the two-dimensional sliding window covers the first RGB image, the grayscale of each pixel covered by the two-dimensional sliding window is obtained from the grayscale image of the first RGB image, and the grayscale mean of each pixel covered by the two-dimensional sliding window is calculated, and the grayscale mean is assigned to the updated grayscale of the central pixel located at the center of the two-dimensional sliding window.
[0052] S303, traversing the grayscale image using a two-dimensional sliding window until obtaining an updated grayscale of each pixel in the first RGB image;
[0053] Specifically, when the two-dimensional sliding window slides on the first RGB image, the grayscale image of the first RGB image is traversed until the grayscale of each pixel in the first RGB image is updated, thereby obtaining an updated grayscale of each pixel in the first RGB image.
[0054] S304: Obtain a depth map corresponding to the first RGB image based on the updated grayscale of each pixel in the first RGB image.
[0055] Specifically, the updated grayscale of each pixel of the first RGB image is assigned to the depth of each pixel in the first RGB image; based on the depth of each pixel in the first RGB image, a depth map corresponding to the first RGB image is obtained.
[0056] In an embodiment of the present application, the grayscale mean of each pixel point covered by the two-dimensional sliding window is obtained based on the grayscale image of the first RGB image, and the grayscale mean is assigned to the updated grayscale of the central pixel point located at the center of the two-dimensional sliding window, so that the value of a point in the digital image or digital sequence is replaced by the median value of the values of each point in a neighborhood of the point, so that the surrounding pixel values are close to the true value, thereby eliminating isolated noise points; in addition, in an embodiment of the present application, the updated grayscale of each pixel point of the first RGB image is assigned to the depth of each pixel point in the first RGB image. In the case of a small size or a simple changing 2D image scene, it has a good depth estimation capability and can quickly convert the 2D image into a 3D model.
[0057] In one embodiment of the application, step S5 includes:
[0058] S501, obtaining vertex sets constituting each polygonal face, and generating vertex indexes based on storage addresses of each vertex in each vertex set;
[0059] The polygonal face is composed of a plurality of vertices, and the vertex coordinates of the plurality of vertices constitute a vertex set.
[0060] S502, loading each vertex set from the vertex storage area into the vertex storage area based on the vertex index;
[0061] S503: construct a three-dimensional model corresponding to the skin plane image based on the vertex storage area.
[0062] In an embodiment of the present application, the three-dimensional coordinates of the vertex set of the polygonal patch are loaded into the vertex storage area through the vertex index, and based on the vertex storage area, a three-dimensional model corresponding to the skin plane image is constructed, thereby improving the conversion rate of the three-dimensional skin model.
[0063] This embodiment provides a 3D skin model conversion device based on a 2D image, and a 3D skin model conversion method based on a 2D image, which includes:
[0064] A plane image acquisition module, which is used to acquire a skin plane image output by a monocular camera;
[0065] An image correction module, used for performing distortion correction processing on the skin plane image to obtain a first RGB image;
[0066] A depth estimation module, configured to perform depth estimation on the first RGB image and obtain a depth map corresponding to the first RGB image;
[0067] An element acquisition module, which is used to acquire a plurality of polygonal patches in a three-dimensional space based on the depth map and the skin plane image;
[0068] A model building module is used to construct a three-dimensional skin model corresponding to the skin plane image using the polygonal surface patch as a basic element.
[0069] Compared with the prior art, the advantages of the 2D image-based 3D skin model conversion device are the same as those of the 2D image-based 3D skin model conversion method, which will not be described in detail here.
[0070] In one embodiment of the application, a terminal device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The steps of the method for converting a 2D image into a 3D skin model are implemented when the processor executes the program. When the method is applied, it can be applied in the form of software, such as being designed as an independently running program and installed on a computer terminal, which can be a computer, a smart phone, a control system, and other Internet of Things devices. The method can also be designed as an embedded running program and installed on a computer terminal, such as a single-chip microcomputer.
[0071] In one embodiment of the application, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for converting a 3D skin model based on a 2D image are implemented. When the method is applied, it can be applied in the form of software, such as a program designed to be independently run by a computer-readable storage medium. The computer-readable storage medium can be a USB flash drive, designed as a USB shield, and the USB flash drive is designed to start the program of the entire method through an external trigger.
[0072] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for converting a 3D skin model based on a 2D image, the method being applied to an electronic device, characterized in that: The method comprises the following steps: Obtain a skin plane image output by a monocular camera; Performing distortion correction processing on the skin plane image to obtain a first RGB image; Performing depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image; Based on the depth map and the skin plane image, obtaining a plurality of polygonal patches in a three-dimensional space; The polygonal patches are used as basic elements to construct a three-dimensional skin model corresponding to the skin plane image.
2. The method for converting a 2D image into a 3D skin model according to claim 1, wherein: The step of performing distortion correction processing on the skin plane image to obtain a first RGB image comprises the following steps: Establishing a first ideal coordinate system based on the plane where the first RGB image is located; Obtaining a first pixel coordinate of each pixel point on the first RGB image in the first ideal coordinate system; Normalizing and distorting the first pixel coordinates of each pixel point to obtain the second pixel coordinates of each pixel point; Denormalization is performed on the second pixel coordinates to obtain a distortion-corrected first RGB image.
3. The method for converting a 2D image into a 3D skin model according to claim 1, wherein: The performing of depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image comprises the following steps: Obtaining a grayscale image of the first RGB image; Based on the grayscale image, a grayscale value of each pixel in the first RGB image is obtained.
4. The method for converting a 2D image into a 3D skin model according to claim 3, wherein: The performing depth estimation on the first RGB image to obtain a depth map corresponding to the first RGB image comprises the following steps: Setting a two-dimensional sliding window, where the two-dimensional sliding window can cover an odd number of pixels; Obtaining a grayscale mean value of each pixel point covered by the two-dimensional sliding window based on the grayscale image of the first RGB image, and assigning the grayscale mean value to an updated grayscale of a central pixel point located at a central position of the two-dimensional sliding window; Using the two-dimensional sliding window to traverse the grayscale image until an updated grayscale of each pixel in the first RGB image is obtained; Based on the updated grayscale of each pixel in the first RGB image, a depth map corresponding to the first RGB image is obtained.
5. The method for converting a 2D image into a 3D skin model according to claim 4, wherein: The step of obtaining a depth map corresponding to the first RGB image based on the updated grayscale of each pixel in the first RGB image comprises the following steps: Assigning the updated grayscale of each pixel of the first RGB image to the depth of each pixel in the first RGB image; Based on the depth of each pixel in the first RGB image, a depth map corresponding to the first RGB image is obtained.
6. The method for converting a 2D image into a 3D skin model according to claim 1, wherein: The polygonal patch is a triangular patch.
7. The method for converting a 2D image into a 3D skin model according to claim 1, wherein: The method of using the polygonal patch as a basic element to construct a three-dimensional model corresponding to the skin plane image comprises the following steps: Acquire the vertex sets constituting each of the polygonal facets, and generate vertex indexes based on the storage addresses of each vertex in each of the vertex sets; Loading each of the vertex sets into a vertex storage area from the vertex storage area based on the vertex index; Based on the vertex storage area, a three-dimensional model corresponding to the skin plane image is constructed.
8. A 3D skin model conversion device based on a 2D image, the device comprising: A plane image acquisition module, which is used to acquire a skin plane image output by a monocular camera; An image correction module, used for performing distortion correction processing on the skin plane image to obtain a first RGB image; A depth estimation module, configured to perform depth estimation on the first RGB image and obtain a depth map corresponding to the first RGB image; An element acquisition module, which is used to acquire a plurality of polygonal patches in a three-dimensional space based on the depth map and the skin plane image; A model building module is used to construct a three-dimensional skin model corresponding to the skin plane image using the polygonal surface patch as a basic element.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
