CN115546403A - CUDA-based large-scale point cloud three-dimensional reconstruction method - Google Patents
CUDA-based large-scale point cloud three-dimensional reconstruction method Download PDFInfo
- Publication number
- CN115546403A CN115546403A CN202211187005.0A CN202211187005A CN115546403A CN 115546403 A CN115546403 A CN 115546403A CN 202211187005 A CN202211187005 A CN 202211187005A CN 115546403 A CN115546403 A CN 115546403A
- Authority
- CN
- China
- Prior art keywords
- point cloud
- cuda
- thread
- image
- gpu
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Generation (AREA)
Abstract
The invention discloses a large-scale point cloud three-dimensional reconstruction method based on CUDA. The method of the invention comprises the following steps: executing a CUDA program, creating a video memory array pointer in the GPU, and copying image data and calibration data into a video memory of the GPU; the GPU sets GPU parameters required by the kernel function operation of the CUDA platform according to the number of pixels in the image required to be calculated; calculating the index corresponding to each thread in the GPU, and according to the index corresponding to each current thread, performing parallel calculation on pixels with the same index in the video memory to obtain the pixel coordinate corresponding to each thread; and performing decoding kernel function and coordinate calculation kernel function operation to obtain a point cloud three-dimensional coordinate of the image, and reconstructing the three-dimensional image according to the point cloud three-dimensional coordinate. Compared with the prior art, the method has the advantages of accelerating the efficiency of point cloud reconstruction, improving the application range of point cloud reconstruction and overcoming the problems of limitation and low efficiency of the traditional CPU serial calculation in the aspect of large-scale point cloud reconstruction.
Description
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a large-scale point cloud three-dimensional reconstruction method based on CUDA.
Background
At present, with the development of intelligent manufacturing, non-contact structured light vision sensors in industrial application are more and more widely applied, and the structured light vision sensors are widely applied in the fields of reverse engineering, workpiece quality detection, workpiece dimension measurement and the like. The point cloud reconstruction is carried out by adopting the visual sensor in a coded structured light mode, the requirement of a triangulation method measurement model can be met, and the method is a non-contact measurement mode with high measurement speed and high precision. The coding structure light adopts a projector to project a special coding pattern on an object to be measured, three-dimensional reconstruction is carried out by collecting a deformed coding pattern, and the change comprises depth information of the surface of the object to be measured. The collected scene coding image is decoded and analyzed to obtain the decoding value of each pixel, and the spatial position of the pixel points in the image can be calculated according to a triangular geometric model formed by a camera and a projector, so that the three-dimensional information of the surface of the measured object is obtained.
When point cloud three-dimensional reconstruction of structured light is performed, operations such as decoding and coordinate calculation of a plurality of shot images are required. In the prior art, when point cloud is reconstructed, a CPU is independently used for serial calculation, the calculation of large-scale point cloud in the mode has limitations on efficiency and time, and particularly for the reconstruction of large-scale point cloud, the CPU serial calculation consumes more time. In image and point cloud processing, each pixel point or three-dimensional point has the need of being processed, and the processing process and mode of each pixel point are very similar, and when a CPU is used for image processing in the prior art, each pixel point or point cloud is usually required to be traversed in a circulating mode, so that the problem of low processing speed is caused.
On the other hand, in the prior art, when the CPU performs point cloud reconstruction, an algorithm with higher complexity is often adopted, a large number of code programs need to be built, a developer is difficult to complete a development task in a short time, the code programs are migrated between different platforms, and it is difficult to guarantee that no code leak occurs, which is a situation that an efficient and simple processing platform is lacking, so that the developer is difficult to rapidly and simply develop images with different content properties to complete the point cloud reconstruction task, the development efficiency of the developer is seriously affected, and the difficulty of code transplantation of the developer on different platforms is easily increased.
Disclosure of Invention
In order to overcome one or more defects and shortcomings in the prior art, the invention provides a large-scale point cloud three-dimensional reconstruction method based on CUDA (compute unified device architecture), which is used for quickly and efficiently reconstructing point cloud.
In order to achieve the above object, the present invention adopts the following technical means.
A large-scale point cloud three-dimensional reconstruction method based on CUDA comprises the following steps:
executing a CUDA program in a computer provided with a CUDA platform, creating a memory array pointer in a GPU, and copying image data and calibration data into a memory of the GPU;
the GPU sets GPU parameters required by kernel function operation of the CUDA platform according to the number of pixels in the image required to be calculated, wherein the GPU parameters comprise the number of thread blocks and the number of threads in each thread block;
calculating the index corresponding to each thread in the GPU, and then performing parallel calculation on pixels with the same index in the video memory according to the index corresponding to each current thread to obtain the pixel coordinate corresponding to each thread;
and performing decoding kernel function and coordinate calculation kernel function operation to obtain a point cloud three-dimensional coordinate of the image, and reconstructing the three-dimensional image according to the point cloud three-dimensional coordinate.
Preferably, the step of executing the CUDA program comprises:
and creating a display memory array pointer in the GPU by using an API (application programming interface) of a cudaMalloc function in the CUDA platform, and copying the image data and the calibration data from the computer memory to the display memory of the GPU by using a cudaMemcpy function in the CUDA platform.
Further, the step of setting the GPU parameters includes:
the GPU calculates the number N of pixels in the image according to the requirement pixel Setting the number N of thread blocks when a kernel function of a CUDA platform runs block Number of threads in each thread block N thread The relationship is calculated as follows:
N thread =1024
further, the step of parallel computing to obtain pixel coordinates includes:
and acquiring the current thread index and the number of columns of pixels in the image, and calculating the pixel position of the pixel processed by each thread in the image for the pixels with the same index in the video memory.
Further, the pixel position processed by each thread in the image is calculated as follows:
T=blcokDim.x*blockIdx.x+threadIdx.x
col_now=T mod cols
the method comprises the steps of obtaining a current thread block, determining a block index, determining row coordinates of a current pixel, obtaining column coordinates of the current pixel, obtaining total column number of image pixels, and obtaining the block index, the block dim.x and the block idx.x through a CUDA library function.
Further, the step of decoding the kernel function operation comprises:
binary code values of pixels of an input image are converted into decimal code values.
Further, the step of the coordinate calculation kernel function operation includes:
and calculating the three-dimensional coordinates of the point cloud according to the decimal code value of the pixel and the coordinates of the pixel position.
Further, the step of denoising the point cloud comprises:
and denoising the point cloud by using a denoising kernel function to obtain a denoised point cloud.
Further, the step of calculating the point cloud center point comprises:
and calling a CUDA sorting algorithm to calculate the center point of the point cloud.
Further, the step of reconstructing a three-dimensional image from the point cloud three-dimensional coordinates comprises:
and calculating the number of the threads which finish the operation by using a CUDA library function atomic Add, storing the three-dimensional coordinate data calculated by a single thread into a memory of the computer, and calling all the three-dimensional coordinate data from the memory by the CPU to perform point cloud reconstruction to obtain a three-dimensional image after the three-dimensional coordinate data calculated by all the threads are stored.
Compared with the prior art, the technical scheme of the invention has the following beneficial effects:
compared with the prior art, when point cloud reconstruction is carried out, the method and the device have the advantages that the GPU is used for carrying out synchronous calculation on large-scale pixels in the image in parallel, the point cloud reconstruction efficiency is accelerated, the application range of the point cloud reconstruction is widened, and the problems of limitation and low efficiency of traditional CPU serial calculation in the aspect of large-scale point cloud reconstruction are solved.
Drawings
Fig. 1 is a general flowchart of a large-scale point cloud three-dimensional reconstruction method based on CUDA according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings and embodiments thereof. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Examples
As shown in fig. 1, the method for three-dimensional reconstruction of large-scale point cloud based on CUDA of this embodiment includes the following specific steps:
s1, in a computer provided with a CUDA platform, a CPU starts to execute a CUDA program, a memory array pointer is created in a GPU through an API (application program interface) of a cudaMalloc function in the CUDA platform, and image data and calibration data are copied into a memory of the GPU from a computer memory through a cudaMemcpy function in the CUDA platform;
s2, the GPU calculates the number N of pixels in the image according to the requirement pixel Setting GPU parameters required by kernel function operation of a CUDA platform, wherein the GPU parameters comprise the number N of thread blocks in operation block Number of threads in each thread block N thread The relationship is calculated as follows:
N thread =1024
thereby ensuring that each pixel in the image can be computed in parallel by one thread;
s3, calculating indexes corresponding to each thread in the GPU according to the GPU parameters set in the step S2, and then performing parallel calculation on pixels with the same indexes in the video memory according to the indexes corresponding to each current thread to obtain pixel coordinates corresponding to each thread; the step of parallel computing to obtain pixel coordinates comprises:
calculating the image pixel position of the current pixel according to the thread index, specifically: acquiring the current thread index and the number of columns of input image pixels, and calculating the pixel position of the pixel processed by each thread in the image; since the parameters introduced into the kernel function are in the form of a one-dimensional array, the pixel position processed by each thread, and the position coordinate in the image, are calculated as follows:
T=blcokDim.x*blockIdx.x+threadIdx.x
col_now=T mod cols
wherein T is a middle item, blockDim.x is the dimension of the current thread block, blockIdx.x is the current thread block, threadadIdx.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 column number of the pixels of the input image, and blockDim.x, blockDim.x and blockIdx.x are all obtained through a CUDA library function;
s4, operating a kernel function to perform data calculation, including decoding the kernel function and calculating the kernel function by coordinates to obtain a point cloud three-dimensional coordinate of the image; the method comprises the following specific steps:
s41, performing a decoding kernel function, and converting the binary code value of the pixel of the input image into a decimal code value to obtain a decoded image;
s42, performing a coordinate calculation kernel function, and calculating the three-dimensional coordinates of the point cloud according to the decimal code value of the pixels in the decoded image and the coordinates of the pixel positions;
s43, after the three-dimensional coordinates of the point cloud are calculated, denoising the point cloud by using a denoising kernel function to obtain a denoised point cloud, then calling a CUDA (compute unified device architecture) sorting algorithm to calculate the central point of the point cloud, and then executing the next step;
s44, calculating the number of the threads which finish the operation by using a CUDA library function atomic Add, storing the three-dimensional coordinate data calculated by a single thread into a memory of the computer, and calling all the three-dimensional coordinate data from the memory by the CPU to perform point cloud reconstruction to obtain a three-dimensional image after the three-dimensional coordinate data calculated by all the threads are stored.
Compared with the prior art, the large-scale point cloud three-dimensional reconstruction method based on the CUDA has the advantages that:
when point cloud is reconstructed, the CUDA platform is used for realizing that the GPU is used for carrying out parallel synchronous calculation on large-scale pixels in an image, the efficiency of point cloud reconstruction is accelerated, the application range of point cloud reconstruction is improved, and the problems of limitation and low efficiency of traditional CPU serial calculation in the aspect of large-scale point cloud reconstruction are solved.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.
Claims (10)
1. A large-scale point cloud three-dimensional reconstruction method based on CUDA is characterized by comprising the following steps:
executing a CUDA program in a computer provided with a CUDA platform, creating a video memory array pointer in a GPU, and copying image data and calibration data into a video memory of the GPU;
the GPU sets GPU parameters required by kernel function operation of the CUDA platform according to the number of pixels in the image required to be calculated, wherein the GPU parameters comprise the number of thread blocks and the number of threads in each thread block;
calculating the index corresponding to each thread in the GPU, and then performing parallel calculation on the pixels with the same index in the video memory according to the index corresponding to each current thread to obtain the pixel coordinate corresponding to each thread;
and performing decoding kernel function and coordinate calculation kernel function operation to obtain a point cloud three-dimensional coordinate of the image, denoising the point cloud and calculating a central point, and reconstructing the three-dimensional image according to the point cloud three-dimensional coordinate.
2. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 1, wherein the step of executing the CUDA program comprises:
and creating a display memory array pointer in the GPU by using an API (application programming interface) of a cudaMalloc function in the CUDA platform, and copying the image data and the calibration data from the computer memory to the display memory of the GPU by using a cudaMemcpy function in the CUDA platform.
3. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 2, wherein the step of setting GPU parameters comprises:
the GPU calculates the number N of pixels in the image according to the requirement pixel Setting the number N of thread blocks when the kernel function of the CUDA platform runs block Number of threads in each thread block N thread The relationship is calculated as follows:
N thread =1024
4. the CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 3, wherein the step of parallel computing to obtain pixel coordinates comprises:
and acquiring the current thread index and the number of columns of pixels in the image, and calculating the pixel position of the pixel processed by each thread in the image for the pixels with the same index in the video memory.
5. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 4, wherein the pixel position processed by each thread in the image is calculated according to the following formula:
T=blcokDim.x*blockIdx.x+threadIdx.x
col_now=T mod cols
the method comprises the steps of obtaining a current thread block, determining a block index, determining row coordinates of a current pixel, obtaining column coordinates of the current pixel, obtaining total column number of image pixels, and obtaining the block index, the block dim.x and the block idx.x through a CUDA library function.
6. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 5, wherein the step of decoding the kernel function operation comprises:
binary code values of pixels of an input image are converted into decimal code values.
7. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 6, wherein the step of computing a kernel function by coordinates comprises:
and calculating the three-dimensional coordinates of the point cloud according to the decimal code value of the pixel and the coordinates of the pixel position.
8. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 7, wherein the step of denoising the point cloud comprises:
and denoising the point cloud by using a denoising kernel function to obtain a denoised point cloud.
9. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 8, wherein the step of calculating the point cloud center point comprises:
and calling a CUDA sorting algorithm to calculate the center point of the point cloud.
10. The CUDA-based large-scale point cloud three-dimensional reconstruction method of claim 9, wherein the step of reconstructing a three-dimensional image from the three-dimensional coordinates of the point cloud comprises:
and calculating the number of the threads which finish the operation by using a CUDA library function atomic Add, storing the three-dimensional coordinate data calculated by a single thread into a memory of the computer, and calling all the three-dimensional coordinate data from the memory by the CPU to perform point cloud reconstruction to obtain a three-dimensional image after the three-dimensional coordinate data calculated by all the threads are stored.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211187005.0A CN115546403A (en) | 2022-09-28 | 2022-09-28 | CUDA-based large-scale point cloud three-dimensional reconstruction method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211187005.0A CN115546403A (en) | 2022-09-28 | 2022-09-28 | CUDA-based large-scale point cloud three-dimensional reconstruction method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115546403A true CN115546403A (en) | 2022-12-30 |
Family
ID=84728868
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211187005.0A Pending CN115546403A (en) | 2022-09-28 | 2022-09-28 | CUDA-based large-scale point cloud three-dimensional reconstruction method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115546403A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116260975A (en) * | 2023-01-17 | 2023-06-13 | 成都曾自科技有限公司 | Video compression method, device and storage medium based on CUDA |
-
2022
- 2022-09-28 CN CN202211187005.0A patent/CN115546403A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116260975A (en) * | 2023-01-17 | 2023-06-13 | 成都曾自科技有限公司 | Video compression method, device and storage medium based on CUDA |
CN116260975B (en) * | 2023-01-17 | 2024-01-23 | 成都曾自科技有限公司 | Video compression method, device and storage medium based on CUDA |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110490919B (en) | Monocular vision depth estimation method based on deep neural network | |
Ernst et al. | Mutual information based semi-global stereo matching on the GPU | |
US9117267B2 (en) | Systems and methods for marking images for three-dimensional image generation | |
CN111207692B (en) | Improved segmented step phase coding three-dimensional measurement method | |
CN111174730B (en) | Rapid phase unwrapping method based on phase encoding | |
CN112801047B (en) | Defect detection method and device, electronic equipment and readable storage medium | |
CN115546403A (en) | CUDA-based large-scale point cloud three-dimensional reconstruction method | |
KR20160123871A (en) | Method and apparatus for estimating image optical flow | |
CN113607085A (en) | Binary defocus three-dimensional measurement method and device based on half-broken sine stripes | |
CN115451860A (en) | Phase shift three-dimensional measurement method based on gray level multiplexing Gray code | |
CN106840038A (en) | A kind of double frequency phase shift closes method with Gray's code character | |
CN114612318B (en) | Three-dimensional modeling method, system and equipment based on cultural relic CT image contour line | |
CN111951377A (en) | Three-dimensional object reconstruction method and terminal equipment | |
Liu et al. | Multi-modal neural radiance field for monocular dense slam with a light-weight tof sensor | |
Dong et al. | Lightweight and edge-preserving speckle matching network for precise single-shot 3D shape measurement | |
CN110289861B (en) | Semi-precision compressed sensing sampling method | |
CN117132704A (en) | Three-dimensional reconstruction method of dynamic structured light, system and computing equipment thereof | |
CN115393172B (en) | Method and equipment for extracting light stripe center in real time based on GPU | |
CN116740375A (en) | Image feature extraction method, system and medium | |
CN113610856B (en) | Method and device for training image segmentation model and image segmentation | |
CN114943761A (en) | Method and device for extracting center of light stripe of central line structure of FPGA (field programmable Gate array) | |
Mateo et al. | Hierarchical, Dense and Dynamic 3D Reconstruction Based on VDB Data Structure for Robotic Manipulation Tasks | |
CN114862866A (en) | Calibration plate detection method and device, computer equipment and storage medium | |
CN112232372B (en) | Monocular stereo matching and accelerating method based on OPENCL | |
CN114279356A (en) | Gray scale stripe pattern design method for three-dimensional measurement |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |