A hardware implementation method for reducing data bandwidth based on image scaling
By configuring the minimum area and sorting position information in the image recognition hardware, and using the interpolation algorithm to calculate pixel values, the problem of high data bandwidth and low processing efficiency in image scaling of integrated circuit hardware is solved, and efficient image scaling processing is achieved.
Patent Information
- Application Number
- CN202010795347.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-10
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-08-10
AI Technical Summary
Due to the large data bandwidth requirements of existing integrated circuit hardware during the image scaling process, hardware design faces high clock frequency and area constraints, and repeated configuration and startup of hardware operations affects processing efficiency, especially in densely distributed image recognition scenarios.
By reading the image to be recognized, configuring the minimum area containing all objects to be recognized, sorting the position information of the objects to be recognized, calculating the position of the target image mapped to the source image, using the interpolation algorithm to calculate the pixel value, and outputting it to the DDR, only once Hardware configuration and startup, reducing data bandwidth and improving processing efficiency.
It achieves efficient processing of large batches of image scaling in the image recognition pre-processing stage, reduces data bandwidth, improves processing efficiency, and avoids the efficiency impact of repeated data reading and hardware startup.
Smart Images

Figure CN114078085B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a hardware implementation method for reducing data bandwidth based on image scaling. Background Art
[0002] In recent years, with the rapid development of science and technology, especially in life, face recognition, license plate recognition, mask recognition, etc., which are often heard, are all in the category of image recognition. Image recognition is one of the most mature directions of artificial intelligence technology. Before the image enters the neural network for recognition, the image needs to be processed to reduce the cost of recognition and improve the accuracy of recognition. Image scaling is a commonly used pre-processing algorithm. In the image pre-processing stage, the image to be recognized is generally scaled, and the image is scaled to a suitable size before being input into the artificial intelligence recognition network. Figure 1 shown.
[0003] Through the image scaling process, we can know that the image scaling process actually describes the correspondence between the target pixel and the source pixel. This correspondence is easy to implement with application software, but recognition efficiency is the biggest bottleneck of software implementation. For example, in public places, there may be hundreds or thousands of faces. At this time, using software to scale hundreds or thousands of faces and then perform face recognition will have a fatal impact on software efficiency. Therefore, it is a general trend to use integrated circuit hardware to implement image face recognition and image scaling.
[0004] However, there are the following defects in the prior art:
[0005] like Figure 2 As shown in the figure, when the integrated circuit hardware implements image scaling, since both the target image and the source image are relatively large, and both the target image and the source image are stored in DDR, the data bandwidth of DDR is the key point of the entire design. Large data bandwidth will add many constraints to the hardware design. For example, the hardware circuit needs to work at a higher clock frequency, and the area needs to be increased to meet the high bandwidth requirements.
[0006] like Figure 3 , 4 As shown in the figure, two application scenarios are listed. Figure 3 The objects to be identified are distributed into 5 boxes, which are called boxes here, and there is no overlap in the distribution of these 5 boxes. Figure 4 It is a large picture distributed into 5 boxes, and the overlap of these 5 boxes is relatively high.
[0007] One way to obtain 5 boxes from these two large images is that the software configures and starts the hardware 5 times respectively. The information of the 5 boxes that need to be configured before starting the hardware 5 times is the source image base address, source image width information and height information.
[0008] like Figure 5 As shown in the figure, for the five boxes with high overlap, the way DDR fetches each box will repeatedly fetch a large amount of data in DDR, which will undoubtedly increase the data bandwidth of DDR. In addition, the way of repeatedly configuring and starting the hardware five times will inevitably have a significant impact on efficiency.
[0009] In order to realize the image scaling function in the image recognition process, the existing integrated circuit implementation scheme has the following limitations:
[0010] (1) In the case of densely distributed boxes, higher requirements are placed on the data bandwidth of DDR, which will inevitably increase the area and clock frequency constraints on the hardware design.
[0011] (2) This repeated configuration and hardware startup operation will inevitably greatly affect the processing efficiency for an image distributed across hundreds or thousands of boxes.
[0012] In addition, the commonly used terms in the prior art are as follows:
[0013] 1) Artificial intelligence.
[0014] 2) Image recognition.
[0015] 3) Image scaling.
[0016] 4) Interpolation algorithm.
[0017] 5) box: represents the object to be identified, such as license plates, faces, etc.
[0018] 6) Integrated circuit hardware design (IC). Summary of the invention
[0019] In order to solve the problems in the prior art, this method aims to provide a hardware implementation method that can greatly reduce data bandwidth and improve processing efficiency for the application scenario of scaling a large number of boxes in the pre-processing stage of image recognition.
[0020] Specifically, the present invention provides a hardware implementation method for reducing data bandwidth based on image scaling, the method comprising the following steps:
[0021] S1, read the image to be identified, the identified image is stored in DDR, assuming that an image contains n objects to be identified, configure a minimum area containing all n objects to be identified according to the image distribution, where n is a natural number;
[0022] S2, sorting the position information of the objects to be identified. According to the information of the objects to be identified, the position information of each target image of the objects to be identified mapped to the original image is calculated, and then sorting is performed to calculate the pixel position of the target image mapped to the source image position that is closest to the front among all the objects to be identified;
[0023] S3, scaling interpolation calculation, according to the position information of the target image of the object to be identified obtained in S2 mapped to the source image, assuming that the position information is (sx, sy), four position information for interpolation calculation can be obtained: (sx, sy), (sx+1, sy), (sx, sy+1), (sx+1, sy+1), and the pixel value of the target point can be obtained by using the interpolation algorithm according to the weight information;
[0024] S4, scaling output, calculates the target image of multiple objects to be identified, and then outputs and stores it in DDR.
[0025] The sorting process of step S2 is divided into the following three steps, where box id represents the number of objects to be identified, and box ids are 0, 1, 2, 3, and 4 respectively:
[0026] Step 1: Group the target image by box id;
[0027] Step 2: Find the point in front of the target point mapped to the source point in each box ID to obtain a horizontal group;
[0028] Step 3: In this horizontal group, sort again to obtain the point that is closest to the source point when the target point is mapped;
[0029] Repeat steps 1 to 3 above until all the points are arranged.
[0030] The position information is actually floating point data, the integer part represents the position information, and the decimal part represents the weight information; the weight information is output to step S3 for scaling interpolation calculation, and the integer part of the position information is used as the position identification information when taking a point in the source map.
[0031] Therefore, the advantages of the present application are: the present method is simple, and only requires the hardware to be configured and started once to batch process the scaling of boxes, and during the processing, a large amount of repeated data does not need to be read, which reduces the data bandwidth and improves the processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0033] Figure 1It is a schematic diagram of the image recognition preprocessing stage including affine transformation in the prior art.
[0034] Figure 2 When the integrated circuit hardware implements affine transformation, both the source image and the target image need to be placed in DDR, corresponding to the schematic diagram of the use of DDR.
[0035] Figure 3 This is a schematic diagram of five boxes of objects to be identified that are distributed without overlap.
[0036] Figure 4 This is a schematic diagram of five overlapping boxes of objects to be identified.
[0037] Figure 5 It is a hardware block diagram of the method implemented by the present invention.
[0038] Figure 6 It is a schematic diagram of configuring the box area of the minimum area including all five boxes in the method of the present invention.
[0039] Figure 7 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0040] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.
[0041] like Figure 5 As shown, the hardware for implementing the method of the present invention is mainly divided into four modules: corresponding to steps S1 of reading the image to be identified, S2 of sorting the position information of the object to be identified, S3 of scaling interpolation calculation, and S4 of scaling output.
[0042] like Figure 7 The present invention relates to a hardware implementation method for reducing data bandwidth based on image scaling, the method comprising the following steps:
[0043] S1, read the image to be recognized, such as Figure 6 As shown in the figure, the recognition image is stored in DDR. Assuming that an image contains 5 objects (boxes) to be recognized, a minimum area containing all 5 objects to be recognized is configured according to the image distribution. The minimum area is the black line frame containing the outermost edges of the 5 boxes in the figure.
[0044] S2, sorting the position information of the objects to be identified. According to the information of the objects to be identified, the position information of each target image of the objects to be identified mapped to the original image is calculated, and then sorting is performed to calculate the pixel position of the target image mapped to the source image position that is closest to the front among all the objects to be identified;
[0045] S3, scaling interpolation calculation, according to the position information of the target image of the object to be identified obtained in S2 mapped to the source image, assuming that the position information is (sx, sy), four position information for interpolation calculation can be obtained: (sx, sy), (sx+1, sy), (sx, sy+1), (sx+1, sy+1), and the pixel value of the target point can be obtained by using the interpolation algorithm according to the weight information;
[0046] S4, scaling output, calculates the target image of multiple objects to be identified, and then outputs and stores it in DDR.
[0047] The sorting process of step S2 is divided into the following three steps, where box id represents the number of objects to be identified, and box ids are 0, 1, 2, 3, and 4 respectively:
[0048] Step 1: Group the target image by box id;
[0049] Step 2: Find the point in front of the target point mapped to the source point in each box ID to obtain a horizontal group;
[0050] Step 3: In this horizontal group, sort again to obtain the point that is closest to the source point when the target point is mapped;
[0051] Repeat steps 1 to 3 above until all the points are arranged.
[0052] The position information is actually floating point data, the integer part represents the position information, and the decimal part represents the weight information; the weight information is output to step S3 for scaling interpolation calculation, and the integer part of the position information is used as the position identification information when taking a point in the source map.
[0053] The step S3 further includes: mapping the target image to the source image, assuming that the size of the target image is dst_w, dst_h, and the position information of the target image is dx, dy; the size of the source image is src_w, src_h; then the scaling factor scale_x in the x direction is src_w / dst_w; the scaling factor scale_y in the y direction is src_h / dst_h; the position information of the target point mapped to the source image can be obtained as sx=dx*scale_x, sy=dy*scale_y. According to the position information, four source and target pixel points (sx, sy), (sx+1, sy), (sx, sy+1), (sx+1, sy+1) are obtained, and the pixel value of the current target pixel point is calculated using a linear interpolation algorithm in combination with the weight information.
[0054] In step S1, the application is used to configure a minimum area containing all n objects to be identified according to the image distribution to reduce the amount of data that the hardware needs to read, thereby reducing the data bandwidth.
[0055] The method is aimed at an application scenario in which a large number of objects to be identified are scaled in the pre-processing stage of image recognition. When implemented in hardware, based on the information of the objects to be identified, the hardware only needs to be configured and started once to batch process the scaling of the objects to be identified, and a large amount of repeated data does not need to be read during the processing.
[0056] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A hardware implementation method for reducing data bandwidth based on image scaling, characterized in that: The method comprises the following steps: S1, read the image to be identified, the identified image is stored in DDR, assuming that an image contains n objects to be identified, configure a minimum area containing all n objects to be identified according to the image distribution, where n is a natural number; S2, sorting the position information of the objects to be identified. According to the information of the objects to be identified, the position information of each target image of the objects to be identified mapped to the original image is calculated, and then sorting is performed to calculate the pixel position of the target image mapped to the source image position that is closest to the front among all the objects to be identified; S3, scaling interpolation calculation, according to the position information of the target image of the object to be identified obtained in S2 mapped to the source image, assuming that the position information is (sx, sy), four position information for interpolation calculation can be obtained: (sx, sy), (sx+1, sy), (sx, sy+1), (sx+1, sy+1), and the pixel value of the target point can be obtained by using the interpolation algorithm according to the weight information; S4, scaling output, calculates the target image of multiple objects to be identified, and then outputs and stores it in DDR.
2. A hardware implementation method for reducing data bandwidth based on image scaling according to claim 1, characterized in that: The sorting process of step S2 is divided into the following three steps, where boxid represents the number of objects to be identified, and box ids are 0, 1, 2, 3, and 4 respectively: Step 1: Group the target image by box id; Step 2: Find the point in front of the target point mapped to the source point in each box ID to obtain a horizontal group; Step 3: In this horizontal group, sort again to obtain the point that is closest to the source point when the target point is mapped; Repeat steps 1 to 3 above until all the points are arranged.
3. The hardware implementation method for reducing data bandwidth based on image scaling according to claim 2, characterized in that: Further including: The position information is actually floating point data, the integer part represents the position information, and the decimal part represents the weight information; The weight information is output to step S3 for scaling interpolation calculation, and the position information of the integer part is used as the position identification information when taking a point in the source image.
4. The method for hardware implementation of reducing data bandwidth based on image scaling according to claim 3, characterized in that: The step S3 further comprises: Map the target image to the source image. Assume that the size of the target image is dst_w, dst_h, and the location information of the target image is dx, dy; the size of the source image is src_w, src_h; then the scaling factor in the x direction is scale_x = src_w / dst_w; the scaling factor in the y direction is scale_y = src_h / dst_h; the location information of the target point mapped to the source image can be obtained as sx = dx*scale_x, sy = dy*scale_y.
5. The method for hardware implementation of reducing data bandwidth based on image scaling according to claim 4, characterized in that: According to the position information, the four source and target pixel points (sx,sy), (sx+1,sy), (sx,sy+1), (sx+1,sy+1) are obtained, and the pixel value of the current target pixel point is calculated using the linear interpolation algorithm in combination with the weight information.
6. The method for hardware implementation of reducing data bandwidth based on image scaling according to claim 1, characterized in that: In step S1, the application is used to configure a minimum area containing all n objects to be identified according to the image distribution to reduce the amount of data that the hardware needs to read, thereby reducing the data bandwidth.
7. The method for hardware implementation of reducing data bandwidth based on image scaling according to claim 1, characterized in that: The method is aimed at an application scenario in which a large number of objects to be identified are scaled in the pre-processing stage of image recognition. When implemented in hardware, based on the information of the objects to be identified, the hardware only needs to be configured and started once to batch process the scaling of the objects to be identified, and a large amount of repeated data does not need to be read during the processing.
