Industrial image preprocessing method, system and device based on CUDA acceleration and medium

By adopting CUDA acceleration method on the GPU side, industrial images are preprocessed in parallel, solving the problem of inefficient processing on the CPU side and achieving efficient image compression and detection.

CN120543499AActive Publication Date: 2025-08-26HANGZHOU QOGORI TECH
View PDF 3 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, the industrial image preprocessing method based on the CPU side has the risk of image compression distortion, serial processing delay and memory leakage, resulting in inefficiency.

Method used

Using a CUDA acceleration method, industrial images are transmitted from the CPU side to the GPU side, and corresponding processing strategies are selected according to the image data type and detection area type for parallel pre-processing, including polar coordinate expansion and cutting operations, and finally the standardized image is stored in the pre-allocated video memory pool.

Benefits of technology

Parallel processing greatly accelerates the computing speed of the image preprocessing stage, improves the efficiency of industrial image detection, and reduces latency and memory leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120543499A_ABST
    Figure CN120543499A_ABST
Patent Text Reader

Abstract

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

Description

Technical Field

[0001] The present 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 Art

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

[0003] However, the traditional CPU serial processing flow has the following defects, 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 delay: CPU-side operations such as cutting, polar coordinate expansion, gain, and size conversion based on Halcon / OpenCV take up too much time, involve a large number of serial operations, and each step is strictly executed in sequence, resulting in overall low efficiency; memory leakage risk: the cross-language transmission of multiple sub-images from C# to C++ can easily lead to memory management issues. Summary of the Invention

[0004] Based on this, it is necessary to provide an industrial image preprocessing method, system, device and medium based on CUDA acceleration to address the above technical problems.

[0005] In a first aspect, an embodiment of the present application provides an industrial image preprocessing method based on CUDA acceleration, applied to a GPU side, the method comprising:

[0006] Based on the data type of the industrial image, select a corresponding transmission mode to transmit the industrial image from the CPU side to the GPU side;

[0007] 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 includes an arc area and a rectangular area;

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

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

[0010] Calculating the number of polar coordinate expansions based on the size of the arc-shaped area, and determining at least one arc-shaped sub-area to be processed;

[0011] Expanding each of the arc-shaped sub-regions into a corresponding rectangular sub-region by a parallel polar coordinate expansion operation;

[0012] Calculating the corresponding number of cutting times based on the size of each rectangular sub-region;

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

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

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

[0016] A polar coordinate expansion operation is performed on each of the arc-shaped sub-regions based on each of the polar coordinate parameters to obtain a corresponding rectangular sub-region.

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

[0018] Calculate the corresponding number of cuts based on the size of the rectangular area;

[0019] The rectangular area is cut in parallel to obtain a corresponding standardized image.

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

[0021] resizing each of the rectangular sub-regions or the rectangular region to conform to a size standard of the standardized image; and

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

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

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

[0025] In one embodiment, 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:

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

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

[0028] In a second aspect, an embodiment of the present application further provides an industrial image preprocessing system based on CUDA acceleration, the system comprising:

[0029] A transmission module, configured to select a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU;

[0030] A preprocessing module, configured to select a corresponding processing strategy for parallel preprocessing based on the detection area type of the industrial image to obtain a standardized image, wherein the detection area type includes an arc area and a rectangular area;

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

[0032] In a third aspect, an embodiment of the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method as described in the first aspect above.

[0033] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein when the computer program is executed by a processor, the method described in the first aspect above is implemented.

[0034] The above-mentioned CUDA-accelerated industrial image preprocessing method, system, device, and medium transmit the industrial image from the CPU to the GPU by selecting a corresponding transmission mode based on the data type of the industrial image; select a corresponding processing strategy based on the detection area type of the industrial image for parallel preprocessing to obtain a standardized image, wherein the detection area type includes an arc area and a rectangular area; and store the standardized image in a pre-allocated video memory pool. This application performs parallel calculations on industrial images on the GPU by calling CUDA kernel functions, greatly accelerating the computing speed of the image preprocessing stage through parallel processing, thereby improving the efficiency of industrial image detection.

[0035] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

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

[0038] Figure 2 is a flow chart of an industrial image preprocessing method based on CUDA acceleration in one embodiment;

[0039] Figure 3 is a flow chart of specific steps of pre-processing an arc-shaped area in one embodiment;

[0040] Figure 4 is a flowchart of specific steps for pre-processing a rectangular area in one embodiment;

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

[0042] Figure 6 The figure is a diagram showing the effect of cutting the arc-shaped area of ​​the inner wall in one embodiment;

[0043] Figure 7 The figure is a structural block diagram of an industrial image preprocessing device based on CUDA acceleration in one embodiment. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is described and illustrated below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely used to explain this application and are not intended to limit this application. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without making any creative efforts are within the scope of protection of this application.

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

[0046] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.

[0047] Unless otherwise defined, technical or scientific terms used herein shall have the ordinary meaning as understood by persons of ordinary skill in the art to which this application belongs. The terms "a," "an," "an," "the," and similar expressions used herein do not denote quantitative limitations and may refer to either the singular or the plural. The terms "comprise," "include," "have," and any variations thereof, used herein, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising 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 the process, method, product, or apparatus. The terms "connected," "connected," "coupled," and similar expressions used herein are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. As used herein, "plurality" means two or more. "And / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" may mean: A exists alone; A and B exist simultaneously; or B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.

[0048] In the related technology, there are a large number of serial operations in the CPU-based industrial image preprocessing, which results in a large proportion of time consumption. For example, in the step of "cutting small image areas from detection areas", there are a large number of serial operations. First, it starts from the "start" node and calculates the total number of polar coordinate expansions (PolarNum). Then, each polar coordinate area is processed in turn through the outer loop (PolarIndex increases from 0 to PolarNum). The polar coordinate expansion operation is performed in each loop and the number of sub-images to be cut in the area (CutNum) is calculated; then the inner loop is entered, and the sub-images are cut one by one starting from CutIndex=0. If the size does not match, the small image is resized, and then data enhancement is performed until all sub-images are processed (CutIndex≤CutNum); finally, the "end" node is reached after all areas are processed. The entire process realizes the automated processing of multi-region polar coordinate expansion and batch cutting through a double-layer loop structure. However, the steps are strictly executed in sequence, resulting in overall low efficiency, which is specifically manifested as follows:

[0049] A step-level serial bottleneck means all core operations (polar expansion → cutting → resizing → enhancement) must be performed strictly sequentially, preventing the use of GPU / CUDA parallel computing capabilities. For example, cutting must wait until all polar regions are expanded before starting, resulting in idle hardware resources.

[0050] Loop-level serialization restrictions: Both the inner and outer loops (PolarIndex for the polar coordinate region loop and CutIndex for the subgraph cutting loop) are executed sequentially using a single thread: each polar coordinate region must wait for the previous one to be processed (PolarIndex increments sequentially), and each subgraph cut must wait for the previous one to be completed (CutIndex increments). For a scene containing 100 polar coordinate regions and 1000 subgraphs cut from each region, the total time taken is as high as 100 × 1000 × single operation delay.

[0051] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 : is a hardware structure diagram of the terminal of the industrial image preprocessing method based on CUDA acceleration of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0052] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the industrial image preprocessing method based on CUDA acceleration in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a 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 a memory remotely located relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0053] The transmission device 106 is used to receive or send data via a network. The network may include a wireless network provided by the terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0054] The embodiment of the present 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, a corresponding transmission mode is selected to transmit the industrial image from the CPU end to the GPU end.

[0056] Specifically, the transmission mode is automatically selected according to the data type (grayscale / RGB) of the industrial image. When it is in grayscale mode, after a single host-to-device (H2D) transmission, the data is copied to the RGB three-channel video memory area through the CUDA kernel function to eliminate the three H2D transmission overheads; when it is in RGB mode, independent CUDA streams (stream_r_, stream_g_, stream_b_) are created for the R / G / B channels to realize three-channel asynchronous parallel transmission, thereby improving the rate at which industrial images are transmitted from the CPU side to the GPU side.

[0057] Step 202 : 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 includes an arc area and a rectangular area.

[0058] Specifically, the detection area types of the industrial image include arc areas (including circular, annular, and arc-shaped areas are all called arcs) and rectangular areas. Therefore, corresponding processing steps are required according to the selection of the detection area type. The CUDA kernel function is used to perform parallel preprocessing on multiple industrial images to obtain standardized images to generate standardized data that meets the model input, providing data support for subsequent image detection and other applications.

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

[0060] Preallocated memory pool is a technology used in deep learning frameworks to optimize memory management. By preallocating a contiguous block of memory space and maintaining its lifecycle, frequent memory request / release operations are avoided, thereby improving GPU utilization and training efficiency.

[0061] During parallel preprocessing, multiple processing stages share memory space, avoiding repeated allocation and release. The initial size of the memory pool can also be dynamically adjusted based on actual needs, preventing memory waste or shortage. The memory reuse architecture, preallocation, and address offset strategies reduce memory management overhead.

[0062] In the above steps S201 to S203, the industrial image is transmitted from the CPU to the GPU by selecting a corresponding transmission mode based on the data type of the industrial image; 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 includes an arc area and a rectangular area; the standardized image is stored in a pre-allocated video memory pool. This application performs parallel calculations on industrial images on the GPU by calling the CUDA kernel function, and does not compress high-precision industrial images. Through parallel processing, the computing speed of the image preprocessing stage is greatly accelerated, thereby improving the efficiency of industrial image detection.

[0063] In one embodiment, Figure 3 As shown, when the detection area type is an arc area, the corresponding processing strategy is selected based on the detection area type of the industrial image for parallel preprocessing to obtain a standardized image, including the following steps:

[0064] Step 301: Calculate the number of polar coordinate expansions 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 area type is an arc-shaped area, the number of polar coordinate expansions is calculated according to the size of the arc-shaped area and the size of the standardized image, and the arc-shaped area is divided into a plurality of arc-shaped sub-areas.

[0066] For example, if the size of the standardized image is 100×100 and the radius of the arc region is 320, the height of the expanded arc sub-region is first adjusted to match the height of the standardized image. The polar coordinate expansion times are calculated to be 4, and the arc region is divided into 4 arc sub-regions. Adjacent arc sub-regions overlap.

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

[0068] A parallel polar coordinate expansion operation is performed 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 cutting times based on the size of each rectangular sub-region.

[0070] Specifically, through step 301, the height of the expanded arc 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 : performing parallel cutting on each of the rectangular sub-regions to obtain a corresponding standardized image.

[0072] In the embodiment of the present application, image preprocessing processes such as polar coordinate expansion and cutting small images are all parallel operations to improve the efficiency of image processing.

[0073] In one embodiment, the expanding each of the arc-shaped sub-regions into a corresponding rectangular sub-region by a polar coordinate expansion operation comprises the following steps:

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

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

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

[0077] Specifically, the polar coordinate transformation operation is implemented according to the following formula. Through mathematical transformation and interpolation technology, the polar coordinate data is converted into Cartesian coordinates ( , ) form, thereby converting arc-shaped subregions into corresponding rectangular subregions. During the expansion process, an appropriate 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 outside the radius range), cropping or padding with default values ​​can be performed.

[0078]

[0079]

[0080] in, is the starting angle.

[0081] In one embodiment, Figure 4 As shown, when the detection area type is a rectangular area, the corresponding processing strategy is selected based on the detection area type of the industrial image for parallel preprocessing to obtain a standardized image, including the following steps:

[0082] Step 501: Calculate the corresponding number of cutting times based on the size of the rectangular area.

[0083] Step 502: perform parallel cutting on the rectangular area to obtain a corresponding standardized image.

[0084] Specifically, the corresponding number of cutting times is calculated according to the size of the rectangular area, including the number of cutting times in the length direction and the number of cutting times in the width direction, and then the rectangular area is cut in parallel to obtain the corresponding standardized image.

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

[0086] Specifically, in actual application scenarios, it is possible that the size (height or width) of the rectangular sub-region or the rectangular region is smaller than the size (height or width) of the standardized image, then the rectangular sub-region or the rectangular region needs to be resized to meet the size standard of the standardized image. For example, the size of the standardized image is 100×100, and the size of the rectangular region is 80×960, then the height of the rectangular region needs to be resized to 100×960, and data enhancement processing is performed to optimize the image quality, and then the number of cuts is calculated to determine the number of sub-graph divisions, and finally standardized data that meets the model input is generated by cutting the small graphs. In this embodiment, the number of sub-graph divisions of the rectangular region is 10, and there are overlapping parts in the divided sub-graphs.

[0087] In one embodiment, the method further comprises: dynamically adjusting the number of thread blocks used to execute parallel preprocessing tasks according to the length of each rectangular sub-region or the rectangular region, so as to improve the speed of image preprocessing.

[0088] In one embodiment, 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 a grayscale image, the industrial image is transmitted from the CPU side to the GPU side through the CUDA stream, and the grayscale data is copied to the RGB three-channel video memory area through the CUDA kernel function.

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

[0091] In an example embodiment, the industrial image preprocessing method based on CUDA acceleration has been tested on an actual production line. When the hardware is NVIDIA GeForce RTX 3050 Laptop GPU, this application achieves the following performance breakthroughs.

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

[0093] As shown in Table 1, the experimental results of the single-image preprocessing delay and memory leakage rate of the present application solution are compared with those of the traditional CPU-side solution. The results show that the present application solution is superior to the traditional solution in both single-image preprocessing delay and memory leakage rate.

[0094] Table 1

[0095] index Traditional solution The present invention Test conditions Single image preprocessing delay 40ms 4ms 2000x2000, NVIDIA RTX 3050 Memory leak rate 1.2% 0% Continuously process 100,000 images

[0096] It should be understood that, although the various steps in the above flow chart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above flow chart may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0097] The present 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 configured to select a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU;

[0099] A preprocessing module 20 is configured to select a corresponding processing strategy for parallel preprocessing based on the detection area type of the industrial image to obtain a standardized image, wherein the detection area type includes an arc area and a rectangular area;

[0100] The storage module 30 is configured to store the standardized image in a pre-allocated video memory pool.

[0101] In one embodiment, when the detection area type is an arc area, the preprocessing module 20 is further used to: calculate the number of polar coordinate expansions based on the size of the arc area to determine at least one arc sub-area to be processed; expand each arc sub-area into a corresponding rectangular sub-area through a parallel polar coordinate expansion operation; calculate the corresponding number of cuttings based on the size of each rectangular sub-area; and perform parallel cutting on each rectangular sub-area to obtain a corresponding standardized image.

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

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

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

[0105] In one embodiment, the pre-processing module 20 is further configured to dynamically adjust the number of thread blocks used to execute the parallel pre-processing tasks according to the length of each rectangular sub-region or the length of the rectangular region.

[0106] In one embodiment, the transmission module 10 is also used to: when the data type of the industrial image is a grayscale image, transmit the industrial image from the CPU side to the GPU side through the CUDA stream, and copy the grayscale data to the RGB three-channel video memory area through the CUDA kernel function; when the data type of the industrial image is an RGB image, create an independent CUDA stream for each channel to perform asynchronous and parallel transmission of the data of each channel.

[0107] Each module in the CUDA-accelerated industrial image preprocessing system can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, 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 a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0109] Based on the data type of the industrial image, select a corresponding transmission mode to transmit the industrial image from the CPU side to the GPU side;

[0110] 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 includes an arc area and a rectangular area;

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

[0112] In one embodiment, the processor further implements the following steps when executing the computer program: when the detection area type is an arc area: calculating the number of polar coordinate expansions based on the size of the arc area, and determining at least one arc sub-area to be processed; expanding each arc sub-area into a corresponding rectangular sub-area through a parallel polar coordinate expansion operation; calculating the corresponding number of cuttings based on the size of each rectangular sub-area; and performing parallel cutting on each rectangular sub-area to obtain a corresponding standardized image.

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

[0114] In one embodiment, when the processor executes the computer program, the following steps are further implemented: when the detection area type is a rectangular area, the corresponding number of cutting times is calculated based on the size of the rectangular area; and the rectangular area is cut in parallel to obtain a corresponding standardized image.

[0115] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: adjusting the size of each of the rectangular sub-regions or the rectangular region to meet the size standard of the standardized image; and performing data enhancement processing on each of the rectangular sub-regions and the rectangular region.

[0116] In one embodiment, when executing the computer program, the processor further implements the following steps: dynamically adjusting the number of thread blocks used to execute the parallel preprocessing tasks according to the length of each of the rectangular sub-regions or the length of the rectangular region.

[0117] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: when the data type of the industrial image is a grayscale image, transmitting the industrial image from the CPU side to the GPU side through a CUDA stream, and copying the grayscale data to the RGB three-channel video memory area through a CUDA kernel function;

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

[0119] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned industrial image preprocessing method embodiments based on CUDA acceleration are implemented.

[0120] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0121] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned 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 above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. An industrial image preprocessing method based on CUDA acceleration, characterized in that: Applied to the GPU side, the method includes: Based on the data type of the industrial image, select a corresponding transmission mode to transmit the industrial image from the CPU side to the GPU side; 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 includes an arc area and a rectangular area; The normalized image is stored in a pre-allocated video memory pool.

2. The method according to claim 1, characterized in that When the detection area type is an arc area, the selecting a corresponding processing strategy based on the detection area type of the industrial image to perform parallel preprocessing to obtain a standardized image includes: Calculating the number of polar coordinate expansions based on the size of the arc-shaped area, and determining at least one arc-shaped sub-area to be processed; Expanding each of the arc-shaped sub-regions into a corresponding rectangular sub-region by a parallel polar coordinate expansion operation; Calculating the corresponding number of cutting times based on the size of each rectangular sub-region; Each of the rectangular sub-regions is cut in parallel to obtain a corresponding standardized image.

3. The method according to claim 2, characterized in that The step of expanding each of the arc-shaped sub-regions into a corresponding rectangular sub-region by a polar coordinate expansion operation includes: Obtaining polar coordinate parameters of each of the arc-shaped sub-regions; A polar coordinate expansion operation is performed on each of the arc-shaped sub-regions based on each of the polar coordinate parameters to obtain a corresponding rectangular sub-region.

4. The method according to claim 1, wherein When the detection area type is a rectangular area, the step of selecting a corresponding processing strategy based on the detection area type of the industrial image for parallel preprocessing to obtain a standardized image includes: Calculate the corresponding number of cuts based on the size of the rectangular area; The rectangular area is cut in parallel to obtain a corresponding standardized image.

5. The method according to any one of claims 2 or 4, characterized in that The method further comprises: resizing each of the rectangular sub-regions or the rectangular region to conform to a size standard of the standardized image; and Data enhancement processing is performed on each of the rectangular sub-regions and the rectangular region.

6. The method according to claim 5, characterized in that The method further comprises: The number of thread blocks used to execute the parallel preprocessing tasks is dynamically adjusted according to the length of each rectangular sub-region or the length of the rectangular region.

7. The method according to claim 1, characterized in that The selecting a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU side to the GPU side includes: When the data type of the industrial image is a grayscale image, the industrial image is transmitted from the CPU to the GPU through a CUDA stream, and the grayscale data is copied 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, an independent CUDA stream is created for each channel to perform asynchronous and parallel transmission of data of each channel.

8. An industrial image preprocessing system based on CUDA acceleration, characterized in that: The system comprises: A transmission module, configured to select a corresponding transmission mode based on the data type of the industrial image to transmit the industrial image from the CPU to the GPU; A preprocessing module, configured to select a corresponding processing strategy for parallel preprocessing based on the detection area type of the industrial image to obtain a standardized image, wherein the detection area type includes an arc area and a rectangular area; The storage module is used to store the standardized image in a pre-allocated video memory pool.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: 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 having a computer program stored thereon, 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.

Citation Information

Patent Citations

  • Method based on CUDA image fusion parallel computing

    CN106991665A

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

    CN118628415A

  • Apparatus For Air Purifying

    KR1020210138869A