A method and system for merging ultra-high-speed rectangular frames
By implementing a pipelined merging and comparison unit chain on the FPGA platform, the problem of slow merging of rectangular frames in the prior art is solved, and the ability to efficiently process hundreds of thousands of rectangular frames in high-speed production lines is realized.
Patent Information
- Application Number
- CN202410755008.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2044-06-12
AI Technical Summary
The existing rectangular box merging algorithm takes several seconds to process hundreds of thousands of detection rectangular boxes, which cannot meet the needs of high-speed production lines.
Using an ultra-high speed rectangular frame merging method and system, a pipelined merger and comparison unit chain is realized on the FPGA platform, and 64 merger and comparison units are used to process rectangular frames at a operating frequency of 300MHz.
A maximum of 262.5 million rectangular boxes are processed within 1 second, and 18.75 million merged independent rectangular boxes are output, fully meeting the needs of hundreds of thousands of rectangular boxes to be merged in high-speed industrial production lines.
Smart Images

Figure CN118552393B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a rectangular frame merging system, in particular to an ultra-high-speed rectangular frame merging method and system, belonging to the technical field of rectangular frame merging systems. Background Art
[0002] The rectangular frame merging algorithm needs to merge hundreds of thousands of overlapping rectangular frames within one second to obtain a unique rectangular frame that is consistent with the target. However, the merging algorithms of existing computing platforms such as CPU and GPU require at least several seconds to process hundreds of thousands of detection rectangular frames. This waiting time greatly affects the efficiency of defective target detection in the production line. Therefore, the existing rectangular frame merging method and system cannot meet the needs of high-speed production lines. Therefore, an ultra-high-speed rectangular frame merging method and system are designed to solve the above problems. Summary of the invention
[0003] The main purpose of the present invention is to provide a method and system for ultra-high-speed rectangular frame merging.
[0004] The purpose of the present invention can be achieved by adopting the following technical solutions:
[0005] A method for ultra-high-speed rectangular frame merging comprises the following steps:
[0006] Step 1: Initialize the system and clear all registers and counter data;
[0007] Step 2: Whenever the merge comparison unit receives an input rectangular frame, check whether the current merge comparison register is empty;
[0008] Step 3: Determine the validity of the input rectangular frame data;
[0009] Step 4: Compare the coordinate size of the received rectangular frame with the coordinate and size of the rectangular frame stored in the register of the merging comparison unit;
[0010] Step 5: Input the rectangular frame outputted by the previous stage to the next stage merging and comparing unit in a pipeline manner, and prepare to compare with the register of the next stage merging and comparing unit;
[0011] Step 6: After the merge comparison process is completed, the output comparison register update operation is executed;
[0012] Step 7: When the system performs an update operation, the valid rectangular frame is transmitted to the first merge comparison unit of the pipeline merge comparison unit chain;
[0013] Step 8: The system performs an output operation and outputs a valid independent unique rectangular frame;
[0014] Step 9: Repeat the transfer of data in the old register to the next level until the output unit is updated.
[0015] Preferably, in step 1, the system needs to be initialized before receiving any rectangular frame data.
[0016] Preferably, if it is empty in step 2, execute step 3;
[0017] Otherwise, go to step 4.
[0018] Preferably, if the data is valid in step three, it is written into the merge comparison register, and the register is marked as empty and non-merged, and then output as an empty rectangular box;
[0019] If the data is invalid, keep the current register empty, output empty, and then execute step five.
[0020] Preferably, in step 4, it is determined whether the merge is possible, and if so, it is marked as a merged state, and the merged rectangular frame is output;
[0021] If the merge is not possible, the input rectangle is directly outputted and then step five is executed.
[0022] Preferably, in step five, if the last rectangular frame received by the merging and comparing unit is the last rectangular frame under the vertical coordinate and the row coordinate, then step six is executed;
[0023] Otherwise, proceed to step 2.
[0024] Preferably, in step six, each level of merging and comparing unit outputs the data of the register to the next level, and receives the output of the previous level and stores it in the register;
[0025] The last stage merging comparison unit outputs the register data to the update output unit;
[0026] If the data received by the update output unit is valid, and the longitudinal coordinate of the rectangular frame is less than the longitudinal distance threshold set by the system, then update operation step seven is executed;
[0027] If the received data is valid, and the vertical coordinate of the rectangular frame is greater than or equal to the vertical distance threshold set by the system, then the output operation step eight is executed;
[0028] Otherwise, output empty data and execute step nine.
[0029] Preferably, in step seven, if the internal register of the merging comparison unit is empty, the value of the register is updated to be the input data;
[0030] Otherwise, the unit outputs the register value to the next-level merging and comparing unit, and updates the value of the unit register as input data. Meanwhile, the next level continues to perform the same operation, and then executes step nine.
[0031] Preferably, in step nine, the new data received in step seven is not transmitted to the next level in this step, and is transmitted to the next level only when an update operation is performed;
[0032] If the data of the registers in all the merge comparison units have been transmitted to the update output unit, then execute step 2;
[0033] Otherwise, go to step 6.
[0034] An ultra-high-speed rectangular frame merging system includes a merging comparison unit, wherein the merging comparison unit has a boundary comparison module, a register control module and a register built in the unit;
[0035] The boundary comparison module is coupled to the register control module, and the boundary comparison module and the register control module are coupled to the register.
[0036] Beneficial technical effects of the present invention:
[0037] The present invention provides a method and system for merging ultra-high-speed rectangular frames. The method is implemented on an FPGA platform and processes at a running frequency of 300 MHz. Figure 7 The system uses 64 merge comparison units to evaluate the running time and rate: the system receives a maximum of 896 rectangles in one row in every 1024 cycles, and outputs a maximum of 64 independent rectangles. Therefore, the system can process a maximum of 262.5 million rectangles in 1 second, and can output 18.75 million merged independent rectangles. It fully meets the needs of hundreds of thousands of rectangles to be merged in high-speed industrial production lines. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A rectangular frame schematic diagram of a preferred embodiment of a method and system for ultra-high-speed rectangular frame merging according to the present invention.
[0039] Figure 2 The figure is a flow comparison unit illustration of a preferred embodiment of a method and system for ultra-high-speed rectangular frame merging according to the present invention.
[0040] Figure 3 The figure is a diagram illustrating the data flow of the pipeline comparison merging rectangular frames according to a preferred embodiment of a method and system for ultra-high-speed rectangular frame merging of the present invention.
[0041] Figure 4 The figure is a diagram illustrating the update merging comparison register according to a preferred embodiment of a method and system for merging ultra-high-speed rectangular frames of the present invention.
[0042] Figure 5 A system diagram illustrating a preferred embodiment of a method and system for ultra-high-speed rectangular frame merging according to the present invention.
[0043] Figure 6 The system flow diagram is a diagram illustrating a preferred embodiment of a method and system for ultra-high-speed rectangular frame merging according to the present invention.
[0044] Figure 7 The figure is a merging effect diagram of a preferred embodiment of a method and system for merging ultra-high-speed rectangular frames according to the present invention. DETAILED DESCRIPTION
[0045] In order to make the technical solution of the present invention more clear and specific to those skilled in the art, the present invention is further described in detail below in conjunction with embodiments and drawings, but the implementation manner of the present invention is not limited thereto.
[0046] Note 1: The system has a constant number of built-in merging and comparison units, and the typical constant value is 64. This constant value can be adjusted according to the rate of detecting rectangular frames required by the system, such as 16, 32, 128, etc.
[0047] Note 2: The horizontal and vertical coordinates as well as the length and width data are considered to be a valid rectangular frame if they are within the valid range set by the user.
[0048] Note 3: The system sets a vertical and horizontal distance threshold. Two rectangular boxes that exceed this threshold are regarded as two independent rectangular boxes, otherwise they need to be merged.
[0049] Note 4: In order to customize the pipeline merging and comparing unit structure required by the algorithm, this method is implemented in FPGA. However, this patent is not limited to the FPGA platform. This ultra-high-speed rectangular frame merging method can be implemented on any hardware platform that can implement or find a similar pipeline merging and comparing unit structure, such as ASIC.
[0050] Note 5: Steps 2 to 5 are as follows Figure 3 As shown: at time 1, input 1 enters merge comparison unit 1, and the inputs of other merge comparison units are empty data. At time 2, input 2 enters merge comparison unit 1, and the merge comparison unit outputs data 1 after operation, which is input into merge comparison unit 2, and the inputs of other merge comparison units are all empty data. Until time N (N is the constant value in description 1), data 1 is input into merge comparison unit N, as shown in the figure. Data enters N merge comparison units in the form of a pipeline, and rectangular frame merge comparison operation is performed.
[0051] Note 6: For a typical constant value of 64 streaming compare registers, the register update operation requires 65 cycles to complete. The update operation traverses 64 streaming compare registers. If the internally stored rectangle is marked as "merged", it is cleared and marked as empty. If there is a non-empty and non-merged rectangle stored internally, it is determined whether its vertical row number exceeds the set vertical threshold. If it exceeds, it is output and regarded as an independent rectangle; if it does not exceed, it is stored in the register of the pipeline merge comparison unit chain in order.
[0052] Step 1: Before receiving any rectangular frame data, the system is initialized and all registers and counter data are cleared.
[0053] Step 2: Whenever the merge comparison unit receives an input rectangle, check whether the current merge comparison register is empty. If it is empty, execute step 3; otherwise, execute step 4. Figure 3 shown.
[0054] Step 3: Check the validity of the input rectangle data. If the data is valid, write it to the merge comparison register, mark the register as "empty" and "non-merge", and then output an empty rectangle. If the data is invalid, keep the current register empty, output empty, and then execute step 5.
[0055] Step 4: Compare the coordinate size of the received rectangular frame with the coordinate and size of the rectangular frame stored in the register of the merge comparison unit. Determine whether it can be merged. If it can be merged, mark it as "merge" state and output the merged rectangular frame. If it cannot be merged, directly output the input rectangular frame. Then execute step 5.
[0056] Step 5: Input the rectangular box output by the previous level to the next level merge comparison unit in a pipeline manner, and prepare to compare with the register of the next level merge comparison unit. If the rectangular box received by the last merge comparison unit is the last rectangular box under this vertical coordinate (row coordinate), execute step 6; otherwise, execute step 2.
[0057] Step six: When the merge comparison process is completed, execute the update output comparison register operation. Each level of the merge comparison unit outputs the register data to the next level, and receives the output of the previous level and stores it in the register. The last level of the merge comparison unit outputs the register data to the update output unit. If the data received by the update output unit is valid, and the longitudinal coordinate of the rectangular box is less than the longitudinal distance threshold set by the system, execute the update operation (step seven); if the received data is valid, and the longitudinal coordinate of the rectangular box is greater than or equal to the longitudinal distance threshold set by the system, execute the output operation (step eight); otherwise, output empty data and execute step nine. Figure 4 shown.
[0058] Step 7: When the system performs an update operation, the valid rectangular frame is transmitted to the first merge comparison unit of the pipeline merge comparison unit chain. If the internal register of the merge comparison unit is empty, the value of the register is updated to the input data; otherwise, the unit outputs the register value to the next level merge comparison unit and updates the value of the unit register to the input data, and the next level continues to perform the same operation. Then execute step 9.
[0059] Step 8: The system performs an output operation and outputs a valid independent unique rectangular frame. Execute step 9.
[0060] Step 9: Repeat the transmission of the data in the old register to the next level until the output unit is updated (the new data received in step 7 is not transmitted to the next level in this step, and is only transmitted to the next level when the update operation is performed). If the data in the registers of all the merged comparison units have been transmitted to the updated output unit, execute step 2; otherwise, execute step 6.
[0061] This method is implemented on an FPGA platform and processes at a running frequency of 300 MHz. Figure 7 The system uses 64 merge comparison units for the test pattern. Run time and rate evaluation: The system receives a maximum of 896 rectangles in one row every 1024 cycles and outputs a maximum of 64 independent rectangles.
[0062] As a result, the system can process up to 262.5 million rectangles in 1 second and output 18.75 million merged independent rectangles, which fully meets the needs of hundreds of thousands of merged rectangles in high-speed industrial production lines.
[0063] Figure 1 Description of the input rectangular frame data;
[0064] x is the horizontal coordinate of the lower left corner of the rectangular box;
[0065] y is the vertical coordinate of the lower left corner of the rectangular box;
[0066] w is the horizontal width of the rectangular frame;
[0067] h is the vertical height of the rectangular frame.
[0068] Figure 2 Description for the streaming comparison unit;
[0069] The figure is a schematic diagram of a single merge comparison unit;
[0070] The rectangular box input is Figure 1 Data format;
[0071] The boundary comparison module is used to compare whether the input rectangular box and the x, y, w and h information stored in the register have overlapping areas, and the output is the coordinates of the merged rectangular box;
[0072] The register control module determines whether the register is empty. If it is empty, the coordinates of the rectangular box are filled into the register, and the value of the "empty" register is updated to 0;
[0073] The register control module also needs to update the value of the "merge" register according to whether the rectangular frame has been merged.
[0074] Figure 3 A diagram illustrating the data flow of the pipeline form comparison and merging rectangular frames;
[0075] According to the parameter N set by the system, a merging comparison unit chain with a length of N is generated, and the data enters the merging comparison unit in sequence in the form of a pipeline to perform a merging rectangle frame operation.
[0076] Figure 4 Update the combined compare register diagram
[0077] The figure illustrates the flow chart for updating the merge compare register
[0078] Initially, cell 1 contains merged rectangular frame data, cell 2 contains unmerged rectangular frame data, cell 3 contains unmerged rectangular frame data, and cell 4 is empty.
[0079] At time T1, unit 1 transfers data to unit 2, unit 2 transfers data to unit 3, and finally unit 4 transfers data to the update output unit.
[0080] At time T2, unit 1 sets the data transmission back to empty, unit 2 stores the data of unit 1 and transmits the data of unit 1, unit 4 stores the data of unit 3 and transmits the data of register 3 to the update output unit. The update output unit processes the data of register 4 received in the previous cycle, and since it is empty, it outputs empty.
[0081] At time T3, the data enters the update output unit in the form of a pipeline as described above. At this time, the update output unit needs to process the data of register 3. Since it is not merged and not empty, it determines whether the difference between the y coordinate of its rectangular box and the y coordinate at the current moment exceeds the threshold set by the system. If it does not exceed, it is transmitted to the front end of the merge comparison unit chain, otherwise it is output.
[0082] At time T4, the value of the output unit processing register 2 is updated, and if it is determined that the difference between its y coordinate and the y coordinate at the current time exceeds the system threshold, an output is performed.
[0083] At time T5, the value of the output unit processing register 1 is updated. Since it has been merged, the output is empty.
[0084] Figure 5 This is a diagram illustrating the system;
[0085] The overall framework of the system is as follows: Figure 5 As shown, the pipelined merging comparison unit chain is formed by connecting N merging comparison units, and the end of the chain is connected to the update output unit.
[0086] Figure 6 It is a diagram to illustrate the system flow;
[0087] System flow chart as follows Figure 6 As shown, when the system starts, the merged register chain is initialized first and all registers are set to empty.
[0088] After receiving the rectangular frame data, the merge comparison operation begins.
[0089] When the last rectangular frame in the same row is received, the update merge comparison register operation starts, and the rectangular frames whose vertical distances are currently stored and are greater than the system threshold are output.
[0090] If the update is completed, a new round of receiving rectangle frames and merging rectangle frame operations will be started.
[0091] Figure 7 This is the merged effect diagram;
[0092] The blue rectangle is a schematic diagram. The left picture only marks part of the rectangle input to the system. The right picture is the output result after merging the rectangles.
[0093] The above description is only a further embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solutions and concepts of the present invention within the scope disclosed by the present invention, which belong to the protection scope of the present invention.
Claims
1. A method for ultra-high-speed rectangular frame merging, characterized in that: The steps include: Step 1: Initialize the system and clear all registers and counter data; Step 2: Whenever the merge comparison unit receives an input rectangular frame, check whether the current merge comparison register is empty; Step 3: Determine the validity of the input rectangular frame data; Step 4: Compare the coordinate size of the received rectangular frame with the coordinate and size of the rectangular frame stored in the register of the merging comparison unit; Step 5: Input the rectangular frame outputted by the previous stage to the next stage merging and comparing unit in a pipeline manner, and prepare to compare with the register of the next stage merging and comparing unit; Step 6: After the merge comparison process is completed, the output comparison register update operation is executed; Specifically, if the data received by the update output unit is valid, and the longitudinal coordinate of the rectangular frame is less than the longitudinal distance threshold set by the system, then update operation step seven is executed; If the received data is valid, and the vertical coordinate of the rectangular frame is greater than or equal to the vertical distance threshold set by the system, then the output operation step eight is executed; Otherwise, output empty data and execute step nine; Step 7: When the system performs an update operation, the valid rectangular frame is transmitted to the first merge comparison unit of the pipeline merge comparison unit chain; Step 8: The system performs an output operation and outputs a valid independent unique rectangular frame; Step 9: Repeat the transmission of the data in the old register to the next level until it is transmitted to the updated output unit.
2. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step one, the system needs to be initialized before receiving any rectangular frame data.
3. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: If it is empty in step 2, execute step 3; Otherwise, go to step 4.
4. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: If the data is valid in step 3, it is written into the merge comparison register, and the register is marked as empty and non-merged, and then output as an empty rectangle; If the data is invalid, keep the current register empty, output empty, and then execute step five.
5. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step 4, it is determined whether the merge is possible. If so, it is marked as a merged state, and the merged rectangular frame is output; If the merge is not possible, directly output the input rectangle and then execute step five.
6. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step 5, if the last rectangular box received by the merging and comparing unit is the last rectangular box in the same row, then step 6 is executed; Otherwise, proceed to step 2.
7. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step six, each level of merging and comparing unit outputs the data of the register to the next level, and receives the output of the previous level and stores it in the register; The last stage merging and comparing unit outputs the register data to the updating output unit.
8. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step 7, if the internal register of the merging comparison unit is empty, the value of the register is updated to the input data; Otherwise, the unit outputs the register value to the next-level merging and comparing unit, and updates the value of the unit register as input data. Meanwhile, the next level continues to perform the same operation, and then executes step nine.
9. The method for ultra-high-speed rectangular frame merging according to claim 1, characterized in that: In step nine, the new data received in step seven is not transmitted to the next level in this step, but is transmitted to the next level only when the update operation is performed; If the data of the registers in all the merge comparison units have been transmitted to the update output unit, then execute step 2; Otherwise, go to step 6.
10. An ultra-high-speed rectangular frame merging system, according to an ultra-high-speed rectangular frame merging method according to any one of claims 1 to 9, characterized in that: It includes a merging comparison unit, which has a boundary comparison module, a register control module and a register built in the merging comparison unit; The boundary comparison module is coupled to the register control module, and the boundary comparison module and the register control module are coupled to the register.
Citation Information
Patent Citations
Rectangular frame merging method and system
CN105447839A
LEF (Library Exchange Format) graph processing method of layout
CN106874543A