A CUDA-based large-scale point cloud 3D reconstruction method
By using the CUDA platform to perform parallel computing on the GPU, the problem of low CPU serial computing efficiency is solved, and efficient large-scale point cloud reconstruction and simple code development are achieved.
Patent Information
- Application Number
- CN202211187005.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-09-28
AI Technical Summary
During large-scale point cloud reconstruction, the CPU serial computing efficiency is low, time-consuming, and code development and migration are difficult, which affects development efficiency.
The CUDA platform is used to perform parallel calculations on the GPU, and three-dimensional images are reconstructed by creating video memory array pointers, setting GPU parameters, calculating pixel coordinates in parallel, and performing decoding and coordinate calculation kernel functions.
It accelerates point cloud reconstruction efficiency, expands the scope of application, overcomes the limitations of CPU serial computing, and improves development efficiency and convenience of code migration.
Smart Images

Figure CN115546403B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to a large-scale point cloud three-dimensional reconstruction method based on CUDA. Background Art
[0002] Currently, with the development of intelligent manufacturing, non-contact structured light vision sensors are increasingly being used in industrial applications. They have been widely used in reverse engineering, workpiece quality inspection, and workpiece dimension measurement. Vision sensors using coded structured light for point cloud reconstruction can meet the requirements of triangulation measurement models. This is a non-contact, fast, and highly accurate measurement method. Coded structured light uses a projector to project a special coded pattern onto the object to be measured. Three-dimensional reconstruction is performed by capturing the deformed coded pattern, which contains depth information about the surface of the object being measured. By decoding and analyzing the captured scene coded image, the decoded value of each pixel is obtained. Based on the triangulated geometric model formed by the camera and projector, the spatial position of the pixel in the image can be calculated, thereby obtaining three-dimensional information about the surface of the object being measured.
[0003] When performing three-dimensional reconstruction of structured light point clouds, it is necessary to decode multiple captured images, calculate coordinates, and perform other operations. Existing technologies use a single CPU for serial calculations during point cloud reconstruction. This method of calculating large-scale point clouds has limitations in efficiency and time. Especially for large-scale point cloud reconstruction, CPU serial calculations will consume a considerable amount of time. In image and point cloud processing, every pixel or three-dimensional point needs to be processed, and the process and method for processing each pixel are very similar. Existing technologies, when using a CPU for image processing, typically require looping through each pixel or point cloud, resulting in insufficient processing speed.
[0004] On the other hand, in the existing technology, when the CPU performs point cloud reconstruction, it often adopts a highly complex algorithm, which requires the construction of a large amount of code programs. It is difficult for developers to complete the development task in a short period of time. When migrating code programs between different platforms, they will also encounter transplantation problems, and it is difficult to ensure that there are no code vulnerabilities. This lack of an efficient and simple processing platform makes it difficult for developers to quickly and easily develop images with different content properties to complete point cloud reconstruction tasks, seriously affecting the development efficiency of developers and easily increasing the difficulty of developers transplanting codes between different platforms. Summary of the Invention
[0005] In order to overcome one or more defects and deficiencies in the prior art, the present invention provides a large-scale point cloud 3D reconstruction method based on CUDA for fast and efficient point cloud reconstruction.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions.
[0007] A large-scale point cloud 3D reconstruction method based on CUDA includes the following steps:
[0008] Execute the CUDA program in a computer with a CUDA platform installed, create a video memory array pointer in the GPU, and copy the image data and calibration data to the GPU's video memory;
[0009] The GPU sets the GPU parameters required for the kernel function of the CUDA platform to run according to the number of pixels in the image to be calculated, including the number of thread blocks and the number of threads in each thread block;
[0010] Calculate the index corresponding to each thread in the GPU, and then perform parallel calculations on the pixels with the same index in the video memory based on the index corresponding to each current thread to obtain the pixel coordinates corresponding to each thread;
[0011] Perform decoding kernel function and coordinate calculation kernel function operations to obtain the three-dimensional coordinates of the point cloud of the image, and reconstruct the three-dimensional image based on the three-dimensional coordinates of the point cloud.
[0012] Preferably, the step of executing the CUDA program includes:
[0013] Use the API interface of the cudaMalloc function in the CUDA platform to create a memory array pointer in the GPU, and use the cudaMemcpy function in the CUDA platform to copy the image data and calibration data from the computer memory to the GPU memory.
[0014] Furthermore, the steps of setting GPU parameters include:
[0015] The GPU calculates the number of pixels N in the image to be calculated. pixel , set the number of thread blocks N when the kernel function of the CUDA platform is running block , the number of threads in each thread block N thread , the calculation relationship is as follows:
[0016] N thread =1024
[0017]
[0018] Furthermore, the steps of obtaining pixel coordinates by parallel calculation include:
[0019] Get the current thread index and the number of columns of pixels in the image. For pixels with the same index in the video memory, calculate the pixel position of the pixel processed by each thread in the image.
[0020] Furthermore, the pixel position processed by each thread is calculated in the image as follows:
[0021] T=blcokDim.x*blockIdx.x+threadIdx.x
[0022]
[0023] col_now=T mod cols
[0024] Where T is the intermediate term, blockDim.x is the dimension of the current thread block, blockIdx.x is the current thread block, threadIdx.x is the index of the current thread, row_now is the row coordinate of the current pixel, col_now is the column coordinate of the current pixel, cols is the total number of columns of image pixels, and blockDim.x, blockDim.x, and blockIdx.x are all obtained through CUDA library functions.
[0025] Furthermore, the steps of decoding kernel function operation include:
[0026] Convert the binary code value of the pixel of the input image to the decimal code value.
[0027] Furthermore, the steps of coordinate calculation kernel function operation include:
[0028] Calculate the three-dimensional coordinates of the point cloud based on the decimal code value of the pixel and the coordinates of the pixel position.
[0029] Furthermore, the steps of denoising the point cloud include:
[0030] Use the denoising kernel function to denoise the point cloud and obtain the denoised point cloud.
[0031] Furthermore, the steps of calculating the center point of the point cloud include:
[0032] Call the CUDA sorting algorithm to calculate the center point of the point cloud.
[0033] Furthermore, the step of reconstructing a three-dimensional image according to the three-dimensional coordinates of the point cloud includes:
[0034] The CUDA library function atomicAdd is used to calculate the number of threads that have completed the calculation, and the three-dimensional coordinate data calculated by a single thread is stored in the computer memory. After the three-dimensional coordinate data calculated by all threads are stored, the CPU calls all the three-dimensional coordinate data from the memory to reconstruct the point cloud and obtain a three-dimensional image.
[0035] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0036] Compared with the existing technology in point cloud reconstruction, the present invention uses the CUDA platform to realize GPU parallel synchronous calculation of large-scale pixels in the image, accelerates the efficiency of point cloud reconstruction, improves the applicability of point cloud reconstruction, and overcomes the limitations and low efficiency of traditional CPU serial calculation in large-scale point cloud reconstruction. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a general flow chart of one of the CUDA-based large-scale point cloud 3D reconstruction methods of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments thereof. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0039] Example
[0040] like Figure 1 As shown, the large-scale point cloud 3D reconstruction method based on CUDA in this embodiment has the following specific steps:
[0041] S1. In a computer with a CUDA platform installed, the CPU starts executing a CUDA program, uses the API interface of the cudaMalloc function in the CUDA platform to create a video memory array pointer in the GPU, and uses the cudaMemcpy function in the CUDA platform to copy the image data and calibration data from the computer memory to the GPU video memory;
[0042] S2, GPU according to the number of pixels N in the image to be calculated pixel , set the GPU parameters required for the kernel function runtime of the CUDA platform, GPU parameters include the number of runtime thread blocks N block , the number of threads in each thread block N thread , the calculation relationship is as follows:
[0043] N thread =1024
[0044]
[0045] This ensures that each pixel in the image can be calculated in parallel by one thread;
[0046] S3. Calculate the index corresponding to each thread in the GPU according to the GPU parameters set in step S2, and then perform parallel calculations on pixels with the same index in the video memory according to the index corresponding to each current thread to obtain the pixel coordinates corresponding to each thread. The step of obtaining pixel coordinates by parallel calculation includes:
[0047] The image pixel position of the current pixel is calculated according to the thread index. Specifically, the current thread index and the number of columns of the input image pixel are obtained, and the pixel position of each thread processed pixel in the image is calculated. Since the parameter passed to the kernel function is in the form of a one-dimensional array, the pixel position processed by each thread and the position coordinates in the image are calculated as follows:
[0048] T=blcokDim.x*blockIdx.x+threadIdx.x
[0049]
[0050] col_now=T mod cols
[0051] Where T is the middle term, blockDim.x is the dimension of the current thread block, blockIdx.x is the current thread block, threadIdx.x is the index of the current thread, row_now is the row coordinate of the current pixel, col_now is the column coordinate of the current pixel, cols is the total number of columns of pixels in the input image, blockDim.x, blockDim.x, and blockIdx.x are all obtained through CUDA library functions;
[0052] S4. Run the kernel function to perform data calculation, including the decoding kernel function and the coordinate calculation kernel function, to obtain the three-dimensional coordinates of the point cloud of the image. The specific steps are as follows:
[0053] S41, performing a decoding kernel function to convert the binary code values of the pixels of the input image into decimal code values to obtain a decoded image;
[0054] S42, performing a coordinate calculation kernel function to calculate the three-dimensional coordinates of the point cloud according to the decimal code value of the pixel in the decoded image and the coordinates of the pixel position;
[0055] S43. After calculating the three-dimensional coordinates of the point cloud, the point cloud is denoised using a denoising kernel function to obtain a denoised point cloud. The CUDA sorting algorithm is then called to calculate the center point of the point cloud, and then the next step is executed.
[0056] S44. Use the CUDA library function atomicAdd to calculate the number of threads that have completed the operation, and store the three-dimensional coordinate data calculated by a single thread into the computer memory. After the three-dimensional coordinate data calculated by all threads are stored, the CPU calls all the three-dimensional coordinate data from the memory to reconstruct the point cloud to obtain a three-dimensional image.
[0057] Compared with the prior art, the CUDA-based large-scale point cloud 3D reconstruction method of this embodiment has the following advantages:
[0058] During point cloud reconstruction, the CUDA platform is used to implement GPU parallel synchronous calculation of large-scale pixels in the image, accelerating the efficiency of point cloud reconstruction and improving the applicability of point cloud reconstruction, overcoming the limitations and low efficiency of traditional CPU serial calculations in large-scale point cloud reconstruction.
[0059] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered as equivalent replacement methods and are included in the scope of protection of the present invention.
Claims
1. A large-scale point cloud 3D reconstruction method based on CUDA, characterized in that: The steps are as follows: Execute the CUDA program in a computer with a CUDA platform installed, create a video memory array pointer in the GPU, and copy the image data and calibration data to the GPU's video memory; The GPU sets the GPU parameters required for the kernel function of the CUDA platform to run according to the number of pixels in the image to be calculated, including the number of thread blocks and the number of threads in each thread block; Calculate the index corresponding to each thread in the GPU, and then perform parallel calculations on the pixels with the same index in the video memory based on the index corresponding to each current thread to obtain the pixel coordinates corresponding to each thread; Perform decoding kernel function and coordinate calculation kernel function operations to obtain the three-dimensional coordinates of the point cloud of the image, then denoise the point cloud and calculate the center point, and then reconstruct the three-dimensional image based on the three-dimensional coordinates of the point cloud; The steps to set GPU parameters include: The GPU calculates the number of pixels N in the image to be calculated. pixel , set the number of thread blocks N when the kernel function of the CUDA platform is running block , the number of threads in each thread block N thread , the calculation relationship is as follows: N thread =1024 The steps of parallel calculation to obtain pixel coordinates include: Get the current thread index and the number of columns of pixels in the image. For pixels with the same index in the video memory, calculate the pixel position of the pixel processed by each thread in the image. The pixel position processed by each thread is calculated in the image as follows: T=blcokDim.x*blockIdx.x+threadIdx.x col_now=T mod cols Where T is the intermediate term, blockDim.x is the dimension of the current thread block, blockIdx.x is the current thread block, threadIdx.x is the index of the current thread, row_now is the row coordinate of the current pixel, col_now is the column coordinate of the current pixel, cols is the total number of columns of image pixels, and blockDim.x, blockDim.x, and blockIdx.x are all obtained through CUDA library functions.
2. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 1, characterized in that: The steps to execute a CUDA program include: Use the API interface of the cudaMalloc function in the CUDA platform to create a memory array pointer in the GPU, and use the cudaMemcpy function in the CUDA platform to copy the image data and calibration data from the computer memory to the GPU memory.
3. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 1, characterized in that: The steps of decoding kernel function operation include: Convert the binary code value of the pixel of the input image to the decimal code value.
4. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 3, characterized in that: The steps of coordinate calculation kernel function operation include: Calculate the three-dimensional coordinates of the point cloud based on the decimal code value of the pixel and the coordinates of the pixel position.
5. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 4, characterized in that: The steps for denoising a point cloud include: Use the denoising kernel function to denoise the point cloud and obtain the denoised point cloud.
6. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 5, characterized in that: The steps to calculate the center point of the point cloud include: Call the CUDA sorting algorithm to calculate the center point of the point cloud.
7. The CUDA-based large-scale point cloud 3D reconstruction method according to claim 6, characterized in that: The steps of reconstructing a 3D image based on the 3D coordinates of the point cloud include: The CUDA library function atomicAdd is used to calculate the number of threads that have completed the calculation, and the three-dimensional coordinate data calculated by a single thread is stored in the computer memory. After the three-dimensional coordinate data calculated by all threads are stored, the CPU calls all the three-dimensional coordinate data from the memory to reconstruct the point cloud and obtain a three-dimensional image.
Citation Information
Patent Citations
Method and device for reconstructing GPU (Graphic Processing Unit) accelerating X-ray image based on CUDA (Compute Unified Device Architecture)
CN103700123A
CUDA architecture parallel optimization three-dimensional deformation measurement method based on novel correlation function constraint
CN113409404A