Summary of the invention
The invention provides and be a kind ofly applied to moving object detection disposal route in straight recording and broadcasting system and equipment, to solve the problem.
The invention provides a kind of moving object detection disposal route be applied in straight recording and broadcasting system.Said method comprises the following steps: graphic process unit obtains image to be detected; Described graphic process unit adopts n parallel thread to perform n group moving object detection flow process respectively, wherein, often organize moving object detection flow process and comprise t moving object detection flow process, t, n be greater than 1 integer, a described moving object detection flow process is the moving object detection processing procedure of carrying out for a pixel in described image to be detected; The execution result of a described n parallel thread is the moving target detected.
The present invention also provides a kind of moving object detection treatment facility be applied in straight recording and broadcasting system, the said equipment comprises: graphic process unit, wherein, described graphic process unit comprises: acquiring unit, storage unit and processing unit, and described acquiring unit is connected with described storage unit respectively with described processing unit; Described image to be detected, for obtaining image to be detected, is sent to described storage unit by described acquiring unit; The image to be detected that described storage unit sends for receiving described image to be detected, described storage unit is also for storing the image described to be detected received; Described processing unit performs n group moving object detection flow process respectively for adopting n parallel thread, wherein, often organize moving object detection flow process and comprise t moving object detection flow process, t, n be greater than 1 integer, described processing unit also for exporting the execution result of a described n parallel thread, obtains the moving target detected.
Compared to prior art, moving object detection disposal route in straight recording and broadcasting system and equipment is applied to according to provided by the invention, described graphic process unit adopts special allocation rule that the thread multiple arranged side by side in graphic process unit is distributed to moving object detection flow process, achieve the two-dimentional reasonable distribution process of thread, taking full advantage of graphic process unit thread can the characteristic of executed in parallel, improve treatment effeciency, and be data cachedly stored in graphic process unit by a large amount of in moving object detection, which reduce the exchanges data between graphic process unit and CPU, thus improve the treatment effeciency of moving object detection.In addition, graphic process unit GPU is high relative to CPU integrated level, and price is low, further reduces cost and the volume of equipment.
Embodiment
Hereinafter also describe the present invention in detail with reference to accompanying drawing in conjunction with the embodiments.It should be noted that, when not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.
Be illustrated in figure 1 the process flow diagram being applied to the moving object detection disposal route in straight recording and broadcasting system that preferred embodiment according to the present invention provides.As shown in Figure 1, what preferred embodiment of the present invention provided the moving object detection disposal route be applied in straight recording and broadcasting system comprises step 101-103.
Step 101: graphic process unit obtains image to be detected;
Step 102: described graphic process unit adopts n parallel thread to perform n group moving object detection flow process respectively, wherein, often organize moving object detection flow process and comprise t moving object detection flow process, t, n be greater than 1 integer, a described moving object detection flow process is the moving object detection processing procedure of carrying out for a pixel in described image to be detected;
Described graphic process unit adopts n parallel thread to perform the process of n group moving object detection flow process respectively, comprising: the size obtaining required thread block according to total pixel number of described image to be detected; Total pixel is divided using t pixel as a pixel group; Described thread block is divided into multiple parallel thread, and make each parallel thread corresponding with each pixel group (i.e. the corresponding t of a parallel thread pixel), obtain the corresponding relation (i.e. pixel group sequence number and parallel thread sequence number one_to_one corresponding) of parallel thread sequence number and pixel group sequence number; According to described corresponding relation, each parallel thread is made to perform the moving object detection flow process of corresponding pixel points group.
The detailed process obtaining the size of required thread block according to total pixel number of described image to be detected is: the total pixel number object 1/t size of described required thread block being set to described image to be detected.
The corresponding relation of described parallel thread sequence number and pixel group sequence number is determined: index=y × width+4x according to following formula;
Wherein, x is the parallel thread sequence number of described parallel thread in x dimension, y is the parallel thread sequence number of described parallel thread in y dimension, and index is the sequence number of pixel group on described image to be detected, and width is the pixel total number in the x dimension of described image to be detected.
Described t is 4.
Described moving object detection flow process be following any one: background difference detecting flow, inter-frame difference testing process, light stream testing process.
Described image to be detected is stored in described graphic process unit.
Step 103: the execution result of a described n parallel thread is the moving target detected.
Technical scheme of the present invention is described in detail hereinafter for background difference detecting flow:
Graphic process unit carries out initialization procedure, carries out contextual establishment, the establishment of command queue and the establishment of buffer memory.
Current frame image is sent to graphic process unit by processor (CPU), this current frame image and previous frame image are preserved in the buffer by graphic process unit respectively, (supposing that the picture size when pre-treatment is the image of 1920 × 1080), the schematic diagram of image slices vegetarian refreshments to be detected, specifically as shown in Figure 2.
In order to improve the treatment effeciency of image processor, in the present embodiment, in x dimension, total pixel is divided using 4 pixels as a pixel group, obtain 480 × 1080 groups of pixel groups, graphic process unit is by the corresponding parallel thread of each group pixel group, the size of thread block required is like this (x, y)=(480, 1080), if 480 × 1080 groups of pixel groups namely will be processed, then need 480 × 1080 parallel threads, each parallel thread performs one group of moving object detection flow process, and one group of moving object detection flow process comprises 4 moving object detection flow processs (namely processing the moving object detection flow process of 4 pixels), make pixel group sequence number and parallel thread sequence number one_to_one corresponding in image to be detected, corresponding relation according to following formula: index=y × width+4x, with parallel thread (0,0) be example, its parallel thread sequence number in x dimension is 0, parallel thread sequence number in y dimension is 0, width is for 1920 the number of the pixel that the transverse direction of image to be detected has (be appreciated that be), therefore the sequence number of pixel group that this parallel thread (0,0) is assigned to is index=0 × 1920+4 × 0=0, and the numbering of its 4 pixels comprised of the pixel group that sequence number is 0 is respectively 0,1,2,3.Continue with parallel thread (0,2) for example below, the sequence number of the pixel group that parallel thread (0,2) is assigned to is index=2 × 1920+4 × 0=3840.Sequence number be the pixel corresponding to pixel group of 3840 be numbered 3840,3841,3842,3843.
This moving object detection flow process is performed below for background difference detecting flow, the check processing of background difference is by the absolute value of the pixel value of the pixel of the pixel value subtracting background two field picture of the pixel of current frame image, obtain background subtraction, i.e. the pixel value ︱ of the pixel of the pixel value-former frame of the pixel of background subtraction=︱ present frame.The preset value of background subtraction is set to 30, if described background subtraction is more than or equal to preset value, then the gray-scale value of current handled pixel is set to 255, if described background subtraction is less than preset value, then the gray-scale value of current handled pixel is set to 0.Parallel thread (0,0) performs the moving object detection flow process that sequence number is the pixel group (being numbered 0,1,2,3 of corresponding pixel) of 0.In former frame (the 3rd frame) image that graphic process unit detects pixel be numbered 0,1,2,3 pixel value and present frame (the 4th frame) image in be numbered the pixel value of the pixel of 0,1,2,3, shown in concrete following table:
|
The pixel value of present frame |
The pixel value of former frame |
Background subtraction |
Pixel be numbered 0 |
156 |
129 |
27 |
Pixel be numbered 1 |
146 |
138 |
8 |
Pixel be numbered 2 |
87 |
135 |
48 |
Pixel be numbered 3 |
144 |
192 |
48 |
The background subtraction being numbered 0 of pixel is less than preset value, output gray level value is the pixel of 0, the background subtraction being numbered 1 of pixel is less than preset value, output gray level value is the pixel of 0, the background subtraction being numbered 2 of pixel is greater than preset value, output gray level value is the pixel of 255, and the background subtraction being numbered 3 of pixel is greater than preset value, output gray level value be 255 pixel (in Output rusults gray-scale value be 255 pixel be moving target).By the pixel of output stored in buffer memory, read by CPU, complete the moving object detection flow process of a two field picture.
Figure 3 shows that the schematic diagram being applied to the moving object detection treatment facility in straight recording and broadcasting system that preferred embodiment according to the present invention provides.As shown in Figure 3, the moving object detection treatment facility that what preferred embodiment of the present invention provided be applied in straight recording and broadcasting system, comprise graphic process unit 300, wherein, described graphic process unit 300 comprises: acquiring unit 302, storage unit 304 and processing unit 306, and described acquiring unit 302 is connected with described storage unit 304 respectively with described processing unit 306; Described image to be detected, for obtaining image to be detected, is sent to described storage unit 304 by described acquiring unit 302; The image to be detected that described storage unit 304 sends for receiving described image to be detected, described storage unit 304 is also for storing the image described to be detected received; Described processing unit performs n group moving object detection flow process respectively for adopting n parallel thread, wherein, often organize moving object detection flow process and comprise t moving object detection flow process, t, n be greater than 1 integer, described processing unit also for exporting the execution result of a described n parallel thread, obtains the moving target detected.
In addition, about the specific operation process of the said equipment with described in said method, therefore repeat no more in this.
In sum, moving object detection disposal route in straight recording and broadcasting system and equipment is applied to according to provided by the invention, described graphic process unit adopts special allocation rule that the thread multiple arranged side by side in graphic process unit is distributed to moving object detection flow process, achieve the two-dimentional reasonable distribution process of thread, taking full advantage of graphic process unit thread can the characteristic of executed in parallel, data cachedly be stored in graphic process unit by a large amount of in moving object detection, which reduce the exchanges data between graphic process unit and CPU, thus improve the treatment effeciency of moving object detection.In addition, graphic process unit GPU is high relative to CPU integrated level, and price is low, further reduces cost and the volume of equipment.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.