CUDA-accelerated industrial image preprocessing method, system, device, and medium

CN120543499BActive Publication Date: 2026-09-08HANGZHOU QOGORI TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510624899.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2026-09-08
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

[0003]然而,传统CPU串行处理流程存在以下缺陷,包括图像压缩失真:2000×2000高分辨率图像压缩至640×640导致微缺陷(像素级)信息丢失;串行处理延迟:基于Halcon/OpenCV的CPU端切割、极坐标展开、增益、尺寸变换等操作耗时占比过高,存在大量串行操作,各步骤严格顺序执行,导致整体效率低下;内存泄漏风险:多张子图从C#到C++的跨语言传输易引发内存管理问题

Benefits of technology

[0034] The aforementioned CUDA-accelerated industrial image preprocessing method, system, device, and medium transmit the industrial image from the CPU to the GPU by selecting the corresponding transmission mode based on the data type of the industrial image; perform parallel preprocessing based on the detection region type of the industrial image by selecting the corresponding processing strategy to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions; and store the standardized image in a pre-allocated GPU memory pool. This application significantly accelerates the computation speed of the image preprocessing stage and improves the efficiency of industrial image detection by calling CUDA kernel functions to perform parallel computation on the GPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120543499B_ABST
    Figure CN120543499B_ABST
Patent Text Reader

Abstract

The application relates to a CUDA acceleration-based industrial image preprocessing method, system, device and medium, wherein the CUDA acceleration-based industrial image preprocessing method comprises the following steps: based on the data type of an industrial image, a corresponding transmission mode is selected to transmit the industrial image from a CPU end to a GPU end; based on the detection area type of the industrial image, a corresponding processing strategy is selected for parallel preprocessing to obtain a standardized image, wherein the detection area type comprises an arc-shaped area and a rectangular area; and the standardized image is stored in a pre-allocated video memory pool. Through parallel processing, the operation speed of the image preprocessing stage is greatly accelerated, and the efficiency of industrial image detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an industrial image preprocessing method, system, device and medium based on CUDA acceleration. Background Technology

[0002] In industrial defect detection scenarios, industrial images need to be preprocessed. Among the relevant methods, images are preprocessed serially on the CPU.

[0003] However, traditional CPU serial processing has the following drawbacks, including image compression distortion: compressing a 2000×2000 high-resolution image to 640×640 results in the loss of micro-defect (pixel-level) information; serial processing latency: operations such as cutting, polar coordinate expansion, gain, and size transformation on the CPU side based on Halcon / OpenCV consume too much time, with a large number of serial operations. Each step is strictly executed in sequence, resulting in low overall efficiency; and memory leak risk: cross-language transmission of multiple subgraphs from C# to C++ can easily cause memory management problems. Summary of the Invention

[0004] Therefore, it is necessary to provide a CUDA-accelerated industrial image preprocessing method, system, device, and medium to address the aforementioned technical problems.

[0005] In a first aspect, embodiments of this application provide a CUDA-accelerated industrial image preprocessing method applied to a GPU, the method comprising:

[0006] Based on the data type of the industrial image, the corresponding transmission mode is selected to transmit the industrial image from the CPU to the GPU.

[0007] Based on the detection region type of the industrial image, a corresponding processing strategy is selected for parallel preprocessing to obtain a standardized image. The detection region type includes arc-shaped regions and rectangular regions.

[0008] The standardized image is stored in a pre-allocated memory pool.

[0009] In one embodiment, when the detection region type is an arc-shaped region, the parallel preprocessing based on the detection region type of the industrial image, selecting the corresponding processing strategy, to obtain a standardized image includes:

[0010] Based on the dimensions of the arc-shaped region, the number of polar coordinate unfoldings is calculated to determine at least one arc-shaped sub-region to be processed.

[0011] By using parallel polar coordinate expansion operations, each of the arc-shaped sub-regions is expanded into a corresponding rectangular sub-region;

[0012] The number of cuts is calculated based on the dimensions of each rectangular sub-region;

[0013] Each of the rectangular sub-regions is cut in parallel to obtain the corresponding standardized image.

[0014] In one embodiment, the step of expanding each of the arc-shaped sub-regions into corresponding rectangular sub-regions through polar coordinate expansion includes:

[0015] Obtain the polar coordinate parameters of each of the arc-shaped sub-regions;

[0016] Based on the polar coordinate parameters, polar coordinate expansion is performed on each of the arc-shaped sub-regions to obtain the corresponding rectangular sub-regions.

[0017] In one embodiment, when the detection region type is a rectangular region, the step of selecting a corresponding processing strategy based on the detection region type of the industrial image for parallel preprocessing to obtain a standardized image includes:

[0018] The number of cuts is calculated based on the dimensions of the rectangular region.

[0019] The rectangular region is divided into parallel segments to obtain the corresponding standardized image.

[0020] In one embodiment, the method further includes:

[0021] The dimensions of each of the rectangular sub-regions or the rectangular region are adjusted to conform to the size standard of the standardized image; and

[0022] Data augmentation processing is performed on each of the rectangular sub-regions and the rectangular region.

[0023] In one embodiment, the method further includes:

[0024] The number of thread blocks used to perform parallel preprocessing tasks is dynamically adjusted based on the length of each rectangular sub-region or the rectangular region.

[0025] In one embodiment, selecting the corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU includes:

[0026] When the data type of the industrial image is grayscale, the industrial image is transmitted from the CPU to the GPU through CUDA stream, and the grayscale data is copied to the RGB three-channel video memory area through CUDA kernel functions;

[0027] When the data type of the industrial image is RGB image, an independent CUDA stream is created for each channel to asynchronously and in parallel transmit the data of each channel.

[0028] Secondly, embodiments of this application also provide a CUDA-accelerated industrial image preprocessing system, the system comprising:

[0029] The transmission module is used to select the corresponding transmission mode based on the data type of the industrial image and transmit the industrial image from the CPU to the GPU.

[0030] The preprocessing module is used to select the corresponding processing strategy for parallel preprocessing based on the detection region type of the industrial image to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions.

[0031] A storage module is used to store the standardized image into a pre-allocated video memory pool.

[0032] Thirdly, embodiments of this application also provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method described in the first aspect above.

[0033] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method described in the first aspect above.

[0034] The aforementioned CUDA-accelerated industrial image preprocessing method, system, device, and medium transmit the industrial image from the CPU to the GPU by selecting the corresponding transmission mode based on the data type of the industrial image; perform parallel preprocessing based on the detection region type of the industrial image by selecting the corresponding processing strategy to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions; and store the standardized image in a pre-allocated GPU memory pool. This application significantly accelerates the computation speed of the image preprocessing stage and improves the efficiency of industrial image detection by calling CUDA kernel functions to perform parallel computation on the GPU.

[0035] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0036] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0037] Figure 1This is a hardware structure block diagram of a terminal device for an industrial image preprocessing method based on CUDA acceleration in one embodiment.

[0038] Figure 2 This is a flowchart illustrating an industrial image preprocessing method based on CUDA acceleration in one embodiment;

[0039] Figure 3 This is a flowchart illustrating the specific steps involved in preprocessing the arc-shaped region in one embodiment.

[0040] Figure 4 This is a flowchart illustrating the specific steps involved in preprocessing a rectangular region in one embodiment.

[0041] Figure 5 This is a diagram illustrating the effect of cutting a circular area in one embodiment;

[0042] Figure 6 This is a diagram illustrating the cutting effect of the arc-shaped area on the inner wall in one embodiment;

[0043] Figure 7 This is a structural block diagram of an industrial image preprocessing device based on CUDA acceleration in one embodiment. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0045] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.

[0046] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0047] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.

[0048] In related technologies, CPU-based industrial image preprocessing involves numerous sequential operations, resulting in excessive time consumption. For example, in the step of "detection region cutting into smaller image regions," there are many sequential operations. It starts from the "Start" node, calculating the total number of polar coordinate expansions (PolarNum). Then, an outer loop processes each polar coordinate region sequentially (PolarIndex increments from 0 to PolarNum), performing polar coordinate expansion and calculating the number of sub-images to be cut (CutNum) within each loop. Next, the inner loop starts cutting the sub-images one by one from CutIndex=0. If the size is incorrect, the smaller images are resized, and data augmentation is performed until all sub-images are processed (CutIndex≤CutNum). Finally, after processing all regions, the "End" node is reached. The entire process automates multi-region polar coordinate expansion and batch cutting through a double-loop structure. However, the strict sequential execution of each step leads to low overall efficiency, specifically manifested as follows:

[0049] The system suffers from a step-by-step serial bottleneck. All core operations (polar coordinate unwrapping → slicing → resizing → enhancement) must be executed strictly in sequence, making it impossible to utilize the parallel computing capabilities of the GPU / CUDA. For example, slicing cannot begin until all polar coordinate regions have been unwrapped, resulting in idle hardware resources.

[0050] Due to the loop-level serial limitation, both the inner and outer loops (PolarIndex loop for polar coordinate regions and CutIndex loop for subgraph cutting) are executed sequentially in a single thread: each polar coordinate region must wait for the previous one to finish processing (PolarIndex increments sequentially), and each subgraph cut must wait for the previous block to finish processing (CutIndex increments sequentially). For a scenario containing 100 polar coordinate regions, each region is cut into 1000 subgraphs, the total time consumption is as high as 100 × 1000 × single operation latency.

[0051] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal for the CUDA-accelerated industrial image preprocessing method in this embodiment. For example... Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0052] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the CUDA-accelerated industrial image preprocessing method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0053] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module for wireless communication with the Internet.

[0054] This application provides an industrial image preprocessing method based on CUDA acceleration, such as... Figure 2 As shown, the method includes the following steps:

[0055] Step 201: Based on the data type of the industrial image, select the corresponding transmission mode to transmit the industrial image from the CPU to the GPU.

[0056] Specifically, the transmission mode is automatically selected based on the data type (grayscale / RGB) of the industrial image. In grayscale mode, after a single host-to-device (H2D) transmission, the data is copied to the RGB three-channel video memory area through CUDA kernel functions to eliminate the overhead of three H2D transmissions. In RGB mode, independent CUDA streams (stream_r_, stream_g_, stream_b_) are created for the R / G / B channels to achieve asynchronous parallel transmission of the three channels, thereby improving the speed of industrial image transmission from the CPU to the GPU.

[0057] Step 202: Based on the detection region type of the industrial image, select the corresponding processing strategy for parallel preprocessing to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions.

[0058] Specifically, the detection region types of the industrial images include arc-shaped regions (including circles, annular shapes, and arcs, all referred to as arc-shaped regions) and rectangular regions. Therefore, it is necessary to select the corresponding processing steps based on the type of detection region, and use CUDA kernel functions to perform parallel preprocessing on multiple industrial images to obtain standardized images to generate standardized data that conforms to the model input, providing data support for subsequent image detection and other applications.

[0059] Step 203: Store the standardized image in a pre-allocated memory pool.

[0060] Pre-allocated memory pools are a technique used in deep learning frameworks to optimize memory management. By pre-allocating a contiguous block of memory and maintaining its lifecycle, frequent memory allocation / release operations are avoided, thereby improving GPU utilization and training efficiency.

[0061] During parallel preprocessing, multiple processing stages share memory space, avoiding redundant allocation and release. Furthermore, the initial size of the memory pool can be dynamically adjusted according to actual needs, preventing memory waste or insufficiency. Through the memory reuse architecture, pre-allocation and address offset strategies reduce memory management overhead.

[0062] Steps S201 to S203 above involve selecting a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU; selecting a corresponding processing strategy for parallel preprocessing based on the detection region type of the industrial image to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions; and storing the standardized image in a pre-allocated memory pool. This application performs parallel computation on the industrial image on the GPU by calling CUDA kernel functions, without compressing the high-precision industrial image. Parallel processing greatly accelerates the computation speed of the image preprocessing stage and improves the efficiency of industrial image detection.

[0063] In one embodiment, such as Figure 3 As shown, when the detection region type is an arc-shaped region, the process of selecting the corresponding processing strategy based on the detection region type of the industrial image for parallel preprocessing to obtain a standardized image includes the following steps:

[0064] Step 301: Calculate the number of polar coordinate unfoldings based on the size of the arc-shaped region to determine at least one arc-shaped sub-region to be processed.

[0065] Specifically, when the detection region type is an arc-shaped region, the number of polar coordinate unfoldings is calculated based on the size of the arc-shaped region and the size of the standardized image, and the arc-shaped region is divided into multiple arc-shaped sub-regions.

[0066] For example, the standardized image has a size of 100×100. When the radius of the arc-shaped region is 320, the height of the expanded arc-shaped sub-region is first made to match the height of the standardized image. By calculation, the number of polar coordinate expansions is determined to be 4, dividing the arc-shaped region into 4 arc-shaped sub-regions. Adjacent arc-shaped sub-regions may overlap.

[0067] Step 302: Expand each of the arc-shaped sub-regions into corresponding rectangular sub-regions through parallel polar coordinate expansion operation.

[0068] Perform parallel polar coordinate expansion operations on each arc-shaped sub-region to expand each arc-shaped sub-region into a corresponding rectangular sub-region.

[0069] Step 303: Calculate the corresponding number of cuts based on the dimensions of each rectangular sub-region.

[0070] Specifically, in step 301, the height of the expanded arc-shaped sub-region conforms to the height of the standardized image. In order to make the width of the cut image conform to the width of the standardized image, the corresponding number of cuts is determined according to the length of the expanded rectangular sub-region.

[0071] Step 304: Perform parallel cutting on each of the rectangular sub-regions to obtain the corresponding standardized image.

[0072] In this embodiment, image preprocessing processes such as polar coordinate unrolling and small image cutting are performed in parallel, thereby improving the efficiency of image processing.

[0073] In one embodiment, expanding each of the arc-shaped sub-regions into corresponding rectangular sub-regions through polar coordinate expansion includes the following steps:

[0074] Step 401: Obtain the polar coordinate parameters of each of the arc-shaped sub-regions.

[0075] Specifically, the polar coordinate parameters include the center point ( , ),radius( ), Angle range ( The polar coordinate parameters are batch processed, and the polar coordinate parameters of multiple arc-shaped sub-regions are packaged and transferred to the display memory.

[0076] Step 402: Perform polar coordinate expansion on each of the arc-shaped sub-regions based on the polar coordinate parameters to obtain the corresponding rectangular sub-regions.

[0077] Specifically, the polar coordinate transformation operation is performed according to the following formula, which uses mathematical transformation and interpolation techniques to convert polar coordinate data into Cartesian coordinates. , This allows for the transformation of arc-shaped sub-regions into corresponding rectangular sub-regions. During the unfolding process, a suitable interpolation method (such as nearest neighbor, bilinear, or cubic spline) is selected to balance processing speed and quality. When processing the boundaries of polar coordinate images (such as data exceeding the radius range), default values ​​can be cropped or filled.

[0078]

[0079]

[0080] in, This is the starting angle.

[0081] In one embodiment, such as Figure 4 As shown, when the detection region type is a rectangular region, the process of selecting the corresponding processing strategy based on the detection region type of the industrial image for parallel preprocessing to obtain a standardized image includes the following steps:

[0082] Step 501: Calculate the corresponding number of cuts based on the dimensions of the rectangular region.

[0083] Step 502: Perform parallel segmentation on the rectangular region to obtain the corresponding standardized image.

[0084] Specifically, the number of cuts is calculated based on the size of the rectangular region, including the number of cuts in the length direction and the number of cuts in the width direction. Then, the rectangular region is cut in parallel to obtain the corresponding standardized image.

[0085] In one embodiment, the method further includes: adjusting the size of each of the rectangular sub-regions or the rectangular region to conform to the size standard of the standardized image; and performing data augmentation processing on each of the rectangular sub-regions and the rectangular region to improve the performance of subsequent target detection.

[0086] Specifically, in practical applications, the size (height or width) of the rectangular sub-region or the rectangular region may be smaller than the size (height or width) of the standardized image. In such cases, the size of the rectangular sub-region or the rectangular region needs to be adjusted to conform to the size standard of the standardized image. For example, if the size of the standardized image is 100×100 and the size of the rectangular region is 80×960, the height of the rectangular region needs to be adjusted to 100×960. Data augmentation processing is then performed to optimize image quality. Next, the number of cuts is calculated to determine the number of sub-image divisions. Finally, standardized data conforming to the model input is generated by cutting smaller images. In this embodiment, the rectangular region is divided into 10 sub-image divisions, and the divided sub-images have overlapping parts.

[0087] In one embodiment, the method further includes: dynamically adjusting the number of thread blocks used to perform parallel preprocessing tasks based on the length of each of the rectangular sub-regions or the rectangular region, in order to improve the speed of image preprocessing.

[0088] In one embodiment, the step of selecting a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU includes the following:

[0089] When the data type of the industrial image is grayscale, the industrial image is transmitted from the CPU to the GPU via CUDA stream, and the grayscale data is copied to the RGB three-channel video memory area via CUDA kernel functions.

[0090] When the data type of the industrial image is RGB image, an independent CUDA stream is created for each channel to asynchronously and in parallel transmit the data of each channel.

[0091] In one example embodiment, the CUDA-accelerated industrial image preprocessing method was tested on an actual production line with an NVIDIA GeForce RTX 3050 Laptop GPU, and the application achieved the following performance breakthroughs.

[0092] like Figure 5 As shown, when cutting this circular region, the traditional CPU solution takes 40ms, while the solution in this application only takes 4ms. Figure 6 As shown, when cutting the arc-shaped area, the traditional CPU solution takes 10ms, while the solution in this application only takes 2ms.

[0093] As shown in Table 1, the experimental results of the proposed solution and the traditional CPU-based solution in terms of single-image preprocessing latency and memory leak rate are compared. The results show that the proposed solution is superior to the traditional solution in terms of both single-image preprocessing latency and memory leak rate.

[0094] Table 1

[0095] Single image preprocessing delay 40ms 4ms 2000x2000, NVIDIA RTX 3050 Memory leak rate 1.2% 0% Continuous processing of 100,000 images

[0096] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

[0097] This application also provides an industrial image preprocessing system based on CUDA acceleration, such as... Figure 7 As shown, the system includes:

[0098] The transmission module 10 is used to select the corresponding transmission mode based on the data type of the industrial image and transmit the industrial image from the CPU to the GPU.

[0099] The preprocessing module 20 is used to select a corresponding processing strategy for parallel preprocessing based on the detection region type of the industrial image to obtain a standardized image, wherein the detection region type includes arc-shaped regions and rectangular regions.

[0100] Storage module 30 is used to store the standardized image into a pre-allocated video memory pool.

[0101] In one embodiment, when the detection region type is an arc-shaped region, the preprocessing module 20 is further configured to: calculate the number of polar coordinate unfolding operations based on the size of the arc-shaped region, and determine at least one arc-shaped sub-region to be processed; unfold each arc-shaped sub-region into a corresponding rectangular sub-region through parallel polar coordinate unfolding operations; calculate the corresponding number of cutting operations based on the size of each rectangular sub-region; and perform parallel cutting on each rectangular sub-region to obtain a corresponding standardized image.

[0102] In one embodiment, the preprocessing module 20 is further configured to: obtain polar coordinate parameters of each of the arc-shaped sub-regions; and perform polar coordinate expansion operation on each of the arc-shaped sub-regions based on the polar coordinate parameters to obtain the corresponding rectangular sub-regions.

[0103] In one embodiment, when the detection region type is a rectangular region, the preprocessing module 20 is further configured to: calculate the corresponding number of cuts based on the size of the rectangular region; and perform parallel cuts on the rectangular region to obtain the corresponding standardized image.

[0104] In one embodiment, the preprocessing module 20 is further configured to: adjust the size of each of the rectangular sub-regions or the rectangular region to conform to the size standard of the standardized image; and perform data augmentation processing on each of the rectangular sub-regions and the rectangular region.

[0105] In one embodiment, the preprocessing module 20 is further configured to: dynamically adjust the number of thread blocks used to perform parallel preprocessing tasks based on the length of each of the rectangular sub-regions or the rectangular region.

[0106] In one embodiment, the transmission module 10 is further configured to: when the data type of the industrial image is a grayscale image, transmit the industrial image from the CPU to the GPU via a CUDA stream, and copy the grayscale data to the RGB three-channel video memory area via a CUDA kernel function; when the data type of the industrial image is an RGB image, create an independent CUDA stream for each channel to asynchronously and parallelly transmit the data of each channel.

[0107] The modules in the aforementioned CUDA-accelerated industrial image preprocessing system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.

[0108] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0109] Based on the data type of the industrial image, the corresponding transmission mode is selected to transmit the industrial image from the CPU to the GPU.

[0110] Based on the detection region type of the industrial image, a corresponding processing strategy is selected for parallel preprocessing to obtain a standardized image. The detection region type includes arc-shaped regions and rectangular regions.

[0111] The standardized image is stored in a pre-allocated memory pool.

[0112] In one embodiment, when the processor executes the computer program, it further implements the following steps: when the detection region type is an arc-shaped region: calculate the number of polar coordinate unfoldings based on the size of the arc-shaped region to determine at least one arc-shaped sub-region to be processed; unfold each arc-shaped sub-region into a corresponding rectangular sub-region through parallel polar coordinate unfolding operations; calculate the corresponding number of cuts based on the size of each rectangular sub-region; and perform parallel cuts on each rectangular sub-region to obtain a corresponding standardized image.

[0113] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining the polar coordinate parameters of each of the arc-shaped sub-regions; and performing a polar coordinate expansion operation on each of the arc-shaped sub-regions based on the polar coordinate parameters to obtain the corresponding rectangular sub-regions.

[0114] In one embodiment, when the processor executes the computer program, it further implements the following steps: when the detection region type is a rectangular region, it calculates the corresponding number of cuts based on the size of the rectangular region; and performs parallel cuts on the rectangular region to obtain the corresponding standardized image.

[0115] In one embodiment, the processor, when executing a computer program, further performs the following steps: resizing each of the rectangular sub-regions or the rectangular region to conform to the size standard of the standardized image; and performing data augmentation processing on each of the rectangular sub-regions and the rectangular region.

[0116] In one embodiment, when the processor executes a computer program, it further performs the following steps: dynamically adjusting the number of thread blocks used to perform parallel preprocessing tasks based on the length of each of the rectangular sub-regions or the rectangular region.

[0117] In one embodiment, when the processor executes the computer program, it further performs the following steps: when the data type of the industrial image is a grayscale image, the industrial image is transmitted from the CPU to the GPU via a CUDA stream, and the grayscale data is copied to the RGB three-channel video memory area via a CUDA kernel function.

[0118] When the data type of the industrial image is RGB image, an independent CUDA stream is created for each channel to asynchronously and in parallel transmit the data of each channel.

[0119] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above embodiments of the CUDA-accelerated industrial image preprocessing method.

[0120] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0121] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0122] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A CUDA-accelerated industrial image preprocessing method, characterized in that, When applied to the GPU, the method includes: Based on the data type of the industrial image, the corresponding transmission mode is selected to transmit the industrial image from the CPU to the GPU. Specifically, this includes: when the data type of the industrial image is a grayscale image, the industrial image is transmitted from the CPU to the GPU via a CUDA stream, and the grayscale data is copied to the RGB three-channel video memory area via a CUDA kernel function; when the data type of the industrial image is an RGB image, an independent CUDA stream is created for each channel to perform asynchronous parallel transmission of the data in each channel. Based on the detection region type of the industrial image, a corresponding processing strategy is selected for parallel preprocessing to obtain a standardized image. The detection region type includes arc-shaped regions and rectangular regions. Specifically, the process includes: when the detection region type is an arc-shaped region, calculating the number of polar coordinate unfolding operations based on the size of the arc-shaped region to determine at least one arc-shaped sub-region to be processed; obtaining the polar coordinate parameters of each arc-shaped sub-region; performing polar coordinate unfolding operations on each arc-shaped sub-region based on the polar coordinate parameters to obtain a corresponding rectangular sub-region; calculating the corresponding number of cuts based on the size of each rectangular sub-region; performing parallel cuts on each rectangular sub-region to obtain a corresponding standardized image; and when the detection region type is a rectangular region, calculating the corresponding number of cuts based on the size of the rectangular region; performing parallel cuts on the rectangular region to obtain a corresponding standardized image. The standardized image is stored in a pre-allocated memory pool.

2. The method according to claim 1, characterized in that, The method further includes: The dimensions of each of the rectangular sub-regions or the rectangular region are adjusted to conform to the size standard of the standardized image; and Data augmentation processing is performed on each of the rectangular sub-regions and the rectangular region.

3. The method according to claim 2, characterized in that, The method further includes: The number of thread blocks used to perform parallel preprocessing tasks is dynamically adjusted based on the length of each rectangular sub-region or the rectangular region.

4. A CUDA-accelerated industrial image preprocessing system, characterized in that, The system includes: The transmission module is used to select the corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU. Specifically, it includes: when the data type of the industrial image is a grayscale image, transmitting the industrial image from the CPU to the GPU through a CUDA stream, and copying the grayscale data to the RGB three-channel video memory area through a CUDA kernel function; when the data type of the industrial image is an RGB image, creating an independent CUDA stream for each channel to perform asynchronous parallel transmission of the data in each channel. The preprocessing module is used to select a corresponding processing strategy for parallel preprocessing based on the detection region type of the industrial image to obtain a standardized image. The detection region type includes arc-shaped regions and rectangular regions. Specifically, it includes: when the detection region type is an arc-shaped region, calculating the number of polar coordinate unfolding operations based on the size of the arc-shaped region to determine at least one arc-shaped sub-region to be processed; obtaining the polar coordinate parameters of each arc-shaped sub-region; performing polar coordinate unfolding operations on each arc-shaped sub-region based on the polar coordinate parameters to obtain a corresponding rectangular sub-region; calculating the corresponding number of cuts based on the size of each rectangular sub-region; performing parallel cuts on each rectangular sub-region to obtain a corresponding standardized image; and when the detection region type is a rectangular region, calculating the corresponding number of cuts based on the size of the rectangular region; performing parallel cuts on the rectangular region to obtain a corresponding standardized image. A storage module is used to store the standardized image into a pre-allocated video memory pool.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method based on CUDA image fusion parallel computing

    CN106991665A

  • Multi-projector projection malformation correction method, medium and system

    CN118628415A