A parallel detection method for image targets based on multi-core DSP
Through the parallel processing and data structure optimization of multi-core DSP, the real-time and resource efficiency problems of target detection in complex scenes are solved, and efficient and accurate image target detection is achieved.
Patent Information
- Application Number
- CN202111315928.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-08
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-11-08
AI Technical Summary
The existing technology has insufficient real-time performance and resource efficiency for target detection in complex scenarios. The traditional method has a high rate of false detection and missed detection. The method based on the convolutional neural network consumes a lot of computing resources and has serious interference in redundant areas. It is difficult to meet the requirements of high real-time performance and high efficiency. Low resource storage requirements.
The image target parallel detection method based on multi-core DSP is adopted, and the main core and auxiliary core are used to process image data in parallel. Through data structures such as grayscale related statistics, sequence group information, adjacency lists and mapping tables, the processing efficiency and accuracy are improved, and the processing efficiency is reduced. Storage requirements.
It achieves high real-time target detection in complex scenarios, reduces false detection and missed detection rates and computing resource consumption, improves detection accuracy and processing efficiency, and is suitable for multi-target detection scenarios.
Smart Images

Figure CN114266899B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing, and in particular relates to an image target parallel detection method based on multi-core DSP. Background Art
[0002] Detecting objects in images is an important and basic part of image processing technology. It usually involves determining whether an image contains one or more objects of interest and locating the detected objects in the image. At present, object detection technology for images has penetrated into all aspects of human social life. For example, scanning codes to identify objects in daily life and augmented reality technology that has not yet been fully implemented all require object detection. The current object detection methods are mainly divided into the following two types:
[0003] The first is a target detection method based on artificially set features. This method of target detection based on artificially set features belongs to the traditional target detection method, which can generally be divided into three types: detection method based on template matching, detection method based on prior knowledge, and detection method that divides the object area first and then classifies it. Traditional target detection methods are more suitable for detection environments with simple image backgrounds and large target sizes. In the face of complex scenes with low contrast between the target and the image background and target occlusion, traditional target detection methods have a high probability of false detection and missed detection. In complex scenes, in order to improve detection accuracy, traditional target detection methods often need to increase the complexity of the algorithm, but the complexity is too high to meet the real-time scene requirements.
[0004] The second is a target detection method based on convolutional neural networks. This method of target detection based on convolutional neural networks is a target detection method that has gradually emerged with the development and application of computer vision and deep learning technologies. It often has more accurate target detection effects than traditional target detection methods. However, this target detection method has high requirements for computing resources and has some obvious defects in the relationship between computing efficiency and occupied space. Especially in the case of complex image scenes or a large number of regional redundancies, the introduction of a large amount of scene noise will cause the image feature information to be interfered with or even submerged, and the redundant areas are not conducive to the suppression of non-maxima, thus affecting the accuracy of target detection.
[0005] In recent years, with the continuous upgrading of image sensor components, the image resolution is getting higher and higher, the frame rate is getting faster and faster, the demand for target detection in more complex environments is becoming increasingly obvious, and the real-time requirements for target detection are also getting higher and higher. However, the serial computing method is widely used in the existing technology, and its data processing rate and data exchange rate cannot meet the requirements of high real-time performance and low resource storage. Summary of the invention
[0006] In order to solve the above problems existing in the prior art, the present invention provides an image target parallel detection method based on multi-core DSP. The technical problem to be solved by the present invention is achieved by the following technical solutions:
[0007] A multi-core DSP-based image target parallel detection method is applied to a digital signal processor DSP with eight cores, wherein the eight cores include a main core and seven auxiliary cores; in each step of the method: the main core determines the number of working cores including the main core according to the amount of data to be processed in the step, divides the data to be processed in the step into multiple copies according to the number of working cores, and distributes a different copy of the copies to each working core as task data, each working core independently processes its own task data, and after the main core determines that all working cores have completed processing, the main core summarizes the processing results of all working cores; wherein the steps of the method include:
[0008] Step 1: Each working core calculates the grayscale correlation statistics for its respective task data in this step; the main core obtains the grayscale mean of the image to be tested using the grayscale correlation statistics of all working cores; in step 1, the data to be processed is a frame of the image to be tested acquired by the DSP;
[0009] Step 2: Each working core extracts information of sequence groups from the respective task data in step 1; the main core summarizes and updates the information of all sequence groups in the image to be tested as the data to be processed in the next step; a sequence group refers to a sequence composed of at least one pixel in a row of image data that continuously falls within the image segmentation threshold range; the information of the sequence group includes the sequence number of the sequence group;
[0010] Step 3: Each working core generates a corresponding adjacency list using its own task data in this step, and updates the serial number of its own original sequence group; the main core obtains the adjacency list of the image to be tested as the data to be processed in the next step; wherein an adjacency list contains information on the adjacent overlapping relationship between rows of each sequence group in the corresponding image data;
[0011] Step 4: Each working core generates a corresponding mapping table using its own task data in this step, and uses the mapping table to update the serial number of its own original sequence group; the main core obtains the mapping table of the image to be tested by summarizing, and obtains the information of the updated sequence group of the image to be tested as the data to be processed in the next step; the data in a mapping table represents the updated serial number of each sequence group in the corresponding image data, and adjacent sequence groups with overlapping areas have the same data in the mapping table;
[0012] Step 5: Each working core obtains feature data information of a sequence group as the same connected domain from the respective task data in this step according to the same sequence number; the main core summarizes and updates the feature data information of all connected domains in the image to be tested as the data to be processed in the next step;
[0013] Step 6: Each working core determines whether each connected domain in the task data in the step is a target; the main core summarizes the target judgment results of each working core to obtain feature data information of all targets in the image to be tested.
[0014] In one embodiment of the present invention, for any working core, the grayscale related statistics include the number of pixels belonging to the first grayscale class and the second grayscale class in the image data of the working core, and the sum of the grayscales of the pixels in each grayscale class; wherein, if the grayscale value of a pixel is less than a preset grayscale decision threshold, it belongs to the first grayscale class, otherwise it belongs to the second grayscale class;
[0015] Correspondingly, in step 1, the main core uses the grayscale correlation statistics of all working cores to obtain the grayscale mean of the image to be tested, including:
[0016] Calculate the sum of the number of pixels in the first grayscale class of all working cores to obtain the sum of the number of pixels in the first grayscale class, and calculate the sum of the number of pixels in the second grayscale class of all working cores to obtain the sum of the number of pixels in the second grayscale class;
[0017] Determine the grayscale class corresponding to the larger of the sum of the number of pixels of the first grayscale class and the sum of the number of pixels of the second grayscale class as the target grayscale class;
[0018] The sum of the grayscale values of all working cores under the target grayscale class is calculated to obtain the target pixel grayscale sum, and the sum of the number of pixels of all working cores under the target grayscale class is calculated to obtain the target pixel number sum;
[0019] The quotient of the grayscale sum of the target pixels and the total number of the target pixels is calculated to obtain the grayscale mean of the image to be tested.
[0020] In one embodiment of the present invention, in step 2, each worker checks the task data extracted from the step 1 to extract the information of the sequence group, including:
[0021] For each working core, the working core performs pixel traversal row by row from left to right on the image data as task data. In the traversal of each row, pixels falling within the image segmentation threshold range are determined as valid pixels, and individual valid pixels and sequences consisting of two or more adjacent valid pixels are determined as sequence clusters. For each determined sequence cluster, information of the sequence cluster is determined, and the information of the sequence cluster includes a sequence number of the sequence cluster, a row position of the sequence cluster, a start column position of the sequence cluster, an end column position of the sequence cluster, a peak grayscale of the sequence cluster, and an accumulated grayscale of the sequence cluster.
[0022] After the traversal of each row is completed, the working core proceeds to the traversal of the next row until the working core completes the traversal of all rows of the corresponding image data; wherein the sequence numbers of the sequence groups successively determined during the traversal of all rows are incremented in sequence.
[0023] In one embodiment of the present invention, in step 3, the main core determines the number of working cores including the main core according to the amount of data to be processed in this step, including:
[0024] The main core determines the total number of different row numbers occupied by all sequence groups of the image to be tested;
[0025] The main core determines whether the total number of the different row numbers is greater than or equal to a preset working core decision threshold, and if so, determines that the number of working cores is eight; if not, selects a number of working cores less than eight according to the total number of the different row numbers and a preset selection relationship;
[0026] Correspondingly, in step 3, the task data of each working core is obtained by dividing the data to be processed in this step according to the total number of different row numbers.
[0027] In one embodiment of the present invention, before step 3, the initial state of the adjacency list is a blank table with two rows and several columns;
[0028] In step 3, each working core generates a corresponding adjacency table using its own task data in this step, and updates the sequence number of its own original sequence group, including:
[0029] For each working core, the working core uses the information of the partial sequence group of the image to be tested as task data to traverse the sequence group row by row, and for the current sequence group traversed,
[0030] If the current sequence group has no overlapping area with the sequence group in the previous row, the sequence number of the current sequence group is incrementally updated by the maximum sequence number of the previously determined sequence group, and the upper and lower rows of the column corresponding to the current sequence group in the adjacency table are filled with the updated sequence number of the current sequence group;
[0031] If the current sequence group has only an overlapping area with one sequence group in the previous row, the sequence number of the current sequence group is updated to the sequence number of the overlapping sequence group in the previous row, and the adjacency table is not updated;
[0032] If the current sequence group has an overlapping area with the m sequence groups in the previous row, the sequence number of the current sequence group is updated to the sequence number of the first sequence group overlapping with it in the previous row, and the m-1 columns corresponding to the current sequence group in the adjacency table are filled with the updated sequence number of the current sequence group in the upper row, and the sequence numbers of the remaining sequence groups overlapping with the current sequence group in the previous row are filled in the lower row in sequence; where m≥2.
[0033] In one embodiment of the present invention, before step 4, the initial state of the mapping table is a blank table with several columns;
[0034] In step 4, each working core generates a corresponding mapping table using its own task data in this step, including:
[0035] For each working core, the working core traverses the adjacency list of task data from left to right, and for the current column traversed,
[0036] If the current column is a first category column, wherein the first category column satisfies that the uplink and downlink data are the same, non-zero, and the data has not been traversed before; the current column is processed as follows: the data of the current column in the adjacency table is cleared, the number of connected domains is increased by 1, and the obtained number of connected domains is filled into the column corresponding to the current column in the mapping table to update the mapping table; and after judging the current column in the adjacency table, whether there are some second category columns, wherein the second category columns satisfy that the uplink and downlink data are different and the uplink data is the same as the data of the current column; if there are no some second category columns, continue to traverse the columns to the right of the original current column of the first category column; if there are some second category columns Category columns, update each second category column in turn to the current column for respective processing, and after each second category column is processed, determine whether there is a partial third category column in the adjacency list, wherein the third category column satisfies that the data is the same as the downstream data of the previously processed column, and the previously processed column is the second category column; if there is no partial third category column, continue to traverse the column to the right with the original current column of the first category column; if there is a partial third category column, according to the reverse order of each second category column, update the corresponding third category column in turn to the current column for respective processing, and after all third category columns are processed, continue to traverse the column to the right with the original current column of the first category column;
[0037] If the current column is a column of the second category, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the data updated in the previous current column in the mapping table is repeated to update the column of the mapping table, and the number of connected domains is kept unchanged;
[0038] If the current column is a third category column, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the mapping table and the number of connected domains are not updated;
[0039] After the adjacency list is completely traversed, the mapping table of the working core is generated, wherein the number of columns is the maximum value of the sequence number of the sequence group before the mapping table is generated, and each data is the sequence number that each sequence group should update in turn.
[0040] In one embodiment of the present invention, in step 5, the characteristic data information of the sequence group of the same connected domain includes:
[0041] The accumulated grayscale of the connected domain, the peak grayscale of the connected domain, the area of the connected domain, the accumulated row number of the connected domain, the accumulated column number of the connected domain, the row position of the centroid of the connected domain, the column position of the centroid of the connected domain, the mean grayscale of the connected domain, the maximum width of the connected domain, and the maximum height of the connected domain;
[0042] Among them, the same connected domain is composed of multiple sequence groups with the same sequence number; the cumulative grayscale of the connected domain is the sum of the cumulative grayscales of the sequence groups constituting the connected domain, minus the difference between the product of the area of the connected domain and the grayscale mean of the image to be tested; the peak grayscale of the connected domain is the difference between the maximum value of the peak grayscale of the sequence groups constituting the connected domain and the grayscale mean of the image to be tested; the area of the connected domain is the cumulative sum of the differences between the end column position and the start column position of each sequence group constituting the connected domain; the cumulative row number and the cumulative column number of the connected domain are respectively the number of the sequence groups constituting the connected domain. The sum of the row numbers and the column numbers of all pixels in the sequence cluster of the connected domain; the centroid row position of the connected domain is the quotient of the accumulated row number of the connected domain and the area of the connected domain; the centroid column position of the connected domain is the quotient of the accumulated column number of the connected domain and the area of the connected domain; the mean grayscale of the connected domain is the quotient of the accumulated grayscale of the connected domain and the area of the connected domain; the maximum width of the connected domain is the difference between the maximum end column number and the minimum start column number of the sequence cluster in the connected domain; the maximum height of the connected domain is the difference between the maximum row number and the minimum row number of the sequence cluster in the connected domain.
[0043] In one embodiment of the present invention, in step 6, each work checks the task data of the step to determine whether each connected domain is a target, including:
[0044] For each working core, the working core performs target feature legitimacy judgment and image bad pixel judgment on each connected domain in its task data. If the connected domain has the target feature legitimacy and is not an image bad pixel, the connected domain is determined to be a target;
[0045] The process of judging the legitimacy of target features and image bad pixels for a connected domain and a working core includes:
[0046] The working core determines whether the centroid row position and centroid column position of the connected domain are within the image data range corresponding to the working core, determines whether the maximum width and maximum height of the connected domain are both within the corresponding threshold range, and determines whether the ratio of the maximum width and maximum height of the connected domain is within the corresponding threshold range. If all of them are yes, it is determined that the connected domain has the legitimacy of the target feature;
[0047] The working core determines whether the area of the connected domain is greater than or equal to 1, and whether the accumulated grayscale of the connected domain is greater than or equal to the corresponding threshold. If all are yes, it is determined that the connected domain is not a bad pixel of the image.
[0048] In one embodiment of the present invention, when the multi-core DSP-based image target parallel detection method is used to process multiple frames of images to be detected, in step 1, for any working core, the grayscale related statistics also include the grayscale square sum under each grayscale class in the image data of the working core;
[0049] Correspondingly, in step 1, after the main core obtains the grayscale mean of the image to be tested using the grayscale related statistics of all working cores, the method further includes:
[0050] The master core calculates the sum of the grayscale squares of all working cores under the target grayscale class to obtain a target grayscale square sum;
[0051] The main core uses the target grayscale square sum, the target pixel quantity sum and the grayscale mean of the image to be tested to calculate the grayscale mean square error of the image to be tested, so as to determine the image segmentation threshold range of the next frame of the image to be tested.
[0052] In one embodiment of the present invention, the master core aggregates the processing results of all the working cores, including:
[0053] The master core moves the data stored in the double data rate synchronous dynamic random access memory DDR of each working core to the shared storage area for aggregation.
[0054] In the solution provided by the embodiment of the present invention, the architectural characteristics of DSP are fully utilized, the advantages and processing speed of parallel execution of multi-core DSP are brought into play, and the processing tasks of each core are reasonably allocated so that each core of DSP can process data in parallel at the same time, which can improve the processing efficiency. In addition, the embodiment of the present invention scans the image data once to obtain the information of the sequence group, and the subsequent processing is based on the information of the sequence group rather than the image data. Therefore, compared with the region marking method in the prior art that scans the image twice, the embodiment of the present invention only scans once, is not limited by the number of gray levels of the image, and can reduce the scanning time. Compared with the traditional target detection method that uses the method of saving an image to extract image information, the embodiment of the present invention extracts sequence groups from the image data to carry key image information, and then generates an adjacency table and a mapping table. The storage required for this information is much smaller than the entire image. Therefore, the embodiment of the present invention can reduce the resource storage amount and improve the processing efficiency by extracting sequence groups; at the same time, by using sequence groups to represent image information, it is easier to extract features such as target area and target centroid, which can improve the processing efficiency of subsequent images and the accuracy of target detection. The embodiments of the present invention have low computational complexity and are easy to implement in engineering. They can solve the problems of low data processing rate and slow data exchange rate. While meeting the real-time requirement, they can simultaneously ensure high detection accuracy and have more obvious advantages in multi-target detection scenarios.
[0055] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A schematic diagram of a flow chart of a multi-core DSP-based parallel detection method for image targets provided by an embodiment of the present invention;
[0057] Figure 2 A schematic diagram of sequence cluster distribution of image data provided by an embodiment of the present invention;
[0058] Figure 3 For the embodiment of the present invention Figure 2 Schematic diagram of the generation process of the adjacency list;
[0059] Figure 4 For the embodiment of the present invention Figure 2 Schematic diagram of sequence cluster distribution after the adjacency list is generated.
[0060] Figure 5 A schematic diagram of a change process of an adjacency table according to an embodiment of the present invention;
[0061] Figure 6 A schematic diagram of a change process of a mapping table according to an embodiment of the present invention;
[0062] Figure 7 A schematic diagram of a stack change process according to an embodiment of the present invention;
[0063] Figure 8 For the embodiment of the present invention Figure 4 Schematic diagram of sequence cluster distribution after updating using the mapping table.
[0064] Fig. 9 This is a schematic diagram of multi-core synchronous processing interaction according to an embodiment of the present invention;
[0065] Fig.10 Schematic diagram of target detection results of a frame of image to be detected in an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0067] In order to meet the requirements of high real-time performance and low resource storage in target detection, an embodiment of the present invention provides an image target parallel detection method based on a multi-core DSP (Digital Signal Processing). It is applied to a digital signal processor DSP with eight cores, and the eight cores include a main core and seven auxiliary cores; in each step of the method: the main core determines the number of working cores including the main core according to the amount of data to be processed in this step, divides the data to be processed in this step into multiple copies according to the number of working cores, and distributes a different copy of the data to each working core as task data. Each working core processes its own task data independently. After the main core determines that all working cores have completed processing, the main core summarizes the processing results of all working cores. Among them, the steps of this method are shown in Figure 1 understand, Figure 1 The following is a flow chart of a method for parallel detection of image targets based on a multi-core DSP according to an embodiment of the present invention. It should be noted that steps 1 to 6 are Figure 1 In each step, the number of working cores is determined by the main core according to the amount of data to be processed in the step, that is, the workload. When the workload is large, the number of working cores is eight; when the workload is small, the number of working cores is less than eight, which is selected according to the needs of each step. Among the eight cores, the auxiliary cores that are not working cores are in a waiting state. Figure 1 As shown, the steps of the method include:
[0068] Step 1: Each working core calculates the grayscale correlation statistics for its own task data in this step; the main core uses the grayscale correlation statistics of all working cores to obtain the grayscale mean of the image to be tested.
[0069] In step 1, the data to be processed is a frame of image to be tested acquired by the DSP. In the embodiment of the present invention, the image to be tested may be an infrared image or a visible light image.
[0070] The embodiment of the present invention determines the number of working cores in this step according to the size of the image to be tested. In an optional implementation, the corresponding image size threshold range can be used in advance to determine different levels of the number of working cores. When a test image meets the image size threshold range of one level, the number of working cores of that level is determined. For example, when a test image is smaller than 5*5, the number of its working cores is determined to be 4, and so on.
[0071] After determining the number of working cores, the main core divides the image to be tested into the number of copies corresponding to the number of working cores by row, and distributes each copy to each working core as their respective task data. For each working core, its task data is the image data of the portion of the image to be tested. For the sake of simplicity, in an optional implementation, when dividing the task data, the image to be tested is divided equally by row. Of course, it is also possible to divide the task data of different data sizes for each working core. In subsequent steps, the method of dividing the data to be processed into each task data can be handled similarly.
[0072] In step 1, the task of each working core is to calculate the grayscale correlation statistics, and the main core also needs to obtain the grayscale mean of the image to be tested. The process of obtaining the grayscale correlation statistics and the grayscale mean of the image to be tested is as follows:
[0073] In the first optional implementation:
[0074] For any working core, the grayscale-related statistics include the number of all pixels and the grayscale sum of all pixels in the image data of the working core.
[0075] Correspondingly, in step 1, the main core uses the grayscale correlation statistics of all working cores to obtain the grayscale mean of the image to be tested, including:
[0076] The sum of the pixel grayscale sums of all working cores is calculated to obtain the pixel grayscale sum of the image to be tested, where the pixel grayscale sum is the sum of the pixel grayscale values.
[0077] Calculate the sum of the number of pixels of all working cores to obtain the number of pixels of the image to be tested.
[0078] The quotient of the pixel grayscale sum of the image to be tested and the number of pixels of the image to be tested is calculated to obtain the grayscale mean value of the image to be tested.
[0079] In the first implementation, the grayscale mean of the image to be measured is obtained by averaging the grayscale values of all pixels, which can ensure the accuracy of calculation.
[0080] In the optional second implementation:
[0081] For any working core, the grayscale related statistics include the number of pixels belonging to the first grayscale class and the second grayscale class in the image data of the working core, and the grayscale sum of the pixels in each grayscale class.
[0082] Among them, if the grayscale value of a pixel is less than the preset grayscale decision threshold, it belongs to the first grayscale class, otherwise it belongs to the second grayscale class; for a single frame of the image to be tested, the grayscale decision threshold is a fixed value, which can be pre-set according to experience, such as 65.
[0083] Correspondingly, in step 1, the main core uses the grayscale correlation statistics of all working cores to obtain the grayscale mean of the image to be tested, including:
[0084] The sum of the number of pixels in the first gray class of all working cores is calculated to obtain the sum of the number of pixels in the first gray class, and the sum of the number of pixels in the second gray class of all working cores is calculated to obtain the sum of the number of pixels in the second gray class.
[0085] The grayscale class corresponding to the larger one of the sum of the number of pixels of the first grayscale class and the sum of the number of pixels of the second grayscale class is determined as the target grayscale class.
[0086] The target pixel grayscale sum is obtained by summing up the pixel grayscale sum of all working cores under the target grayscale class, and the target pixel quantity sum is obtained by summing up the pixel quantity of all working cores under the target grayscale class.
[0087] The quotient of the grayscale sum of the target pixels and the total number of target pixels is calculated to obtain the grayscale mean of the image to be tested.
[0088] In the second implementation, by comparing the number of pixels in the two grayscale classes, and considering the grayscale class part with a large number of pixels as normal image information, and the grayscale class part with a small number of pixels as abnormal image information, the main kernel uses the grayscale class part with a large number of pixels to represent the entire image to calculate the grayscale mean of the image to be tested. Therefore, the grayscale mean of the image to be tested can be obtained more easily and quickly.
[0089] The grayscale mean of the image to be tested is used to calculate part of the characteristic data information of the sequence group of the same connected domain in step 5, which will be specifically introduced later.
[0090] Step 2: Each working core extracts the information of the sequence cluster from its respective task data in step 1; the main core summarizes and updates the information of all sequence clusters in the image to be tested as the data to be processed in the next step.
[0091] A sequence group refers to a sequence consisting of at least one pixel in a row of image data that continuously falls within the image segmentation threshold range. The information of the sequence group includes the sequence number of the sequence group.
[0092] In the embodiment of the present invention, step 1 and step 2 can be completed at the same time. In order to facilitate the understanding of the solution, two steps are presented here according to different processing results. In essence, both step 1 and step 2 process the image to be tested, and together complete a scanning process of the image to be tested. Therefore, in step 2, the main core does not need to redivide the task data, and the task data of each working core is still the corresponding task data in step 1.
[0093] In step 2, the task of each working core is to extract the information of the sequence cluster, and the main core also needs to summarize the information of the sequence clusters extracted by all the working cores to obtain the information of the sequence clusters of the image to be tested.
[0094] In an optional implementation manner, in step 2, each task checks the task data extracted from step 1 to extract information of the sequence group, including:
[0095] For each working core, the working core traverses the image data as task data row by row from left to right. In the traversal of each row, the pixels falling within the image segmentation threshold are determined as valid pixels, and the sequences consisting of single valid pixels and two or more adjacent valid pixels are determined as sequence clusters. For each determined sequence cluster, the information of the sequence cluster is determined, and the information of the sequence cluster includes the sequence number of the sequence cluster, the row position of the sequence cluster, the starting column position of the sequence cluster, the ending column position of the sequence cluster, the peak grayscale of the sequence cluster, and the accumulated grayscale of the sequence cluster.
[0096] After the traversal of each row is completed, the working core proceeds to the traversal of the next row until the working core completes the traversal of all rows of the corresponding image data; wherein the sequence numbers of the sequence groups successively determined during the traversal of all rows are incremented in sequence.
[0097] In the embodiment of the present invention, the image segmentation threshold range is a pixel grayscale range, which can be preset according to empirical values for a single frame of the image to be tested, such as [150, 230], etc. The serial number of the sequence group is used to distinguish each sequence group, and can be represented by a number or other symbols; the row position of the sequence group refers to the row number of the row where the sequence group is located; the starting column position of the sequence group and the ending column position of the sequence group refer to the column number of the starting column and the column number of the ending column of the sequence group respectively; the peak grayscale of the sequence group refers to the maximum pixel grayscale value among multiple pixels in the sequence group; the accumulated grayscale of the sequence group refers to the sum of the grayscale values of multiple pixels in the sequence group.
[0098] Specifically, in the process of traversing row by row from left to right, in the same row, for the current pixel, it is determined whether it falls within the image segmentation threshold range. If so, the current pixel is determined to be a valid pixel, and it is determined to be a sequence group. It is assigned a sequence group number, and the row position of the sequence group, the starting column position of the sequence group, the ending column position of the sequence group, the peak grayscale of the sequence group, and the accumulated grayscale of the sequence group are recorded as the sequence group information.
[0099] Continue to determine whether the pixel adjacent to the original current pixel on the right is a valid pixel. If so, the two pixels are determined as a sequence group, and the information of the sequence group composed of the two pixels is updated.
[0100] Continue to traverse to the right. When the right adjacent pixel is a valid pixel, continue to update the information of the sequence group composed of multiple pixels. If a pixel appears to be an invalid pixel, the previous sequence group ends.
[0101] Continue to traverse to the right in the row until the column number of the current pixel traversed reaches the maximum column number of the image data, then the row traversal is completed, and the traversal of the next row continues. Until the row number of the current pixel traversed reaches the maximum row number of the image data, and the column number of the current pixel traversed reaches the maximum column number of the image data, the traversal of the entire image data is completed.
[0102] For easier understanding, see Figure 2 , Figure 2 A schematic diagram of sequence cluster distribution of image data provided by an embodiment of the present invention.
[0103] exist Figure 2 In the figure, the numbers on the horizontal axis represent the column number; the numbers on the vertical axis represent the row number; the black area is the sequence group, and the sequence number of each sequence group is represented by a white number within the sequence group. It can be seen that a total of 15 sequence groups are extracted from the image data through step 2. Figure 2 Only the sequence number of the sequence group is shown in the figure. For other information about the sequence group, please refer to Figure 2 Understand, for example, sequence group 2, its sequence group row position is 1, the sequence group start column position is 7, and the sequence group end column position is 9.
[0104] Step 3: Each working core generates a corresponding adjacency list using its own task data in this step, and updates the sequence number of its own original sequence group. The main core summarizes the adjacency list of the image to be tested as the data to be processed in the next step.
[0105] An adjacency list contains information on adjacent overlapping relationships between rows of each sequence group in the corresponding image data.
[0106] The data to be processed in step 3 is the information of all sequence groups in the image to be tested. In step 3, the main core determines the number of working cores including the main core according to the amount of data to be processed in this step, including:
[0107] 1) The main core determines the total number of different row numbers occupied by all sequence groups of the image to be tested.
[0108] For ease of understanding, Figure 2 Taking the 15 sequence groups in as examples, the sequence numbers of the sequence groups (referred to as sequence numbers in Table 1) and the row numbers where the sequence groups are located (referred to as row numbers in Table 1) are shown in Table 1.
[0109] Table 1
[0110]
[0111] It can be seen that the different row numbers occupied by the 15 sequence groups are 1, 3, 4, 6, 7, 9, and 10, so the total number of different row numbers occupied by all sequence groups is 7.
[0112] 2) The main core determines whether the total number of different row numbers is greater than or equal to the preset working core decision threshold. If so, the number of working cores is determined to be eight; if not, a number of working cores less than eight is selected based on the total number of different row numbers and the preset selection relationship.
[0113] In an embodiment of the present invention, the preset working core decision threshold may be 9. If the total number of different row numbers is greater than or equal to 9, the number of working cores is determined to be eight. If the total number of different row numbers is less than 9, the number of working cores less than eight may be selected according to a preset selection relationship. For example, in the selection relationship, the total number of different row numbers less than 9 may be divided into a plurality of different levels, each level corresponding to a number of working cores. For example, when the total number of different row numbers is 1, the number of working cores is 1; when the total number of different row numbers ∈[2,9), the number of working cores is the total number of different row numbers minus 1.
[0114] Then, taking Table 1 as an example, according to the above selection relationship, the number of working cores is determined to be 7-1=6, that is, in addition to the main core, there are 5 auxiliary cores as working cores.
[0115] In step 3, the data to be processed is the information of all sequence groups of the image to be tested, and the task data of each working core is obtained by dividing the data to be processed in this step according to the total number of different row numbers.
[0116] In an optional implementation, the number of different row numbers of the sequence groups included in the task data of each working core is Where l represents the total number of different row numbers occupied by all sequence groups of the image to be tested, which is a natural number greater than 0. Indicates rounding up.
[0117] Continuing with the above example, the total number of different row numbers occupied by all sequence groups is 7. According to the above formula, the number of different row numbers of sequence groups included in the task data of each working core is 2. Therefore, the row numbers of the sequence groups included in the task data of each of the six working cores are shown in Table 2.
[0118] Table 2
[0119]
[0120] In step 3, after each working core obtains the corresponding task data, the task of each working core is to generate an adjacency list. The main core also needs to summarize the adjacency lists of all working cores and update the adjacency list of the image to be tested.
[0121] It should be noted that, before step 3, the initial state of the adjacency list is a blank table with two rows and several columns.
[0122] In an optional implementation manner, in step 3, each working core generates a corresponding adjacency list using its own task data in this step, and updates the sequence number of its own original sequence group, including:
[0123] For each working core, the working core uses the information of the partial sequence group of the image to be tested as the task data to traverse the sequence group row by row, and for the current sequence group traversed,
[0124] If the current sequence group has no overlapping area with the sequence group in the previous row, the sequence number of the current sequence group is incremented by the maximum sequence number of the previously determined sequence group, and the updated sequence number of the current sequence group is filled in the upper and lower rows of the column corresponding to the current sequence group in the adjacency table.
[0125] If the current sequence group has only an overlapping area with one sequence group in the previous row, the sequence number of the current sequence group is updated to the sequence number of the overlapping sequence group in the previous row, and the adjacency table is not updated.
[0126] If the current sequence cluster has an overlapping area with the m sequence clusters in the previous row, the sequence number of the current sequence cluster is updated to the sequence number of the first sequence cluster that overlaps with it in the previous row, and the m-1 columns corresponding to the current sequence cluster in the adjacency table are filled with the updated sequence number of the current sequence cluster in the upper row, and the sequence numbers of the remaining sequence clusters that overlap with the current sequence cluster in the lower row are filled in sequence; where m≥2.
[0127] Specifically Figure 2 For example, the adjacency table generation process is described in detail in Figure 3 , Figure 3 For the embodiment of the present invention Figure 2Schematic diagram of the generation process of the adjacency list; the numbers under each adjacency list represent the corresponding step number. Figure 2 For each sequence group in , there are the following steps:
[0128] 1) Sequence group 1 has no overlap with the sequence group in the previous row. 1 is filled in the first column of the existing adjacency table, and the sequence number of the sequence group is updated to 1.
[0129] 2) Sequence group 2 has no overlap with the sequence group in the previous row, and 2 is filled in the second column of the existing adjacency table, and the sequence number of the sequence group is updated to 2.
[0130] 3) Sequence group 3 does not overlap with the sequence group in the previous row. 3 is filled in the third column of the existing adjacency table, and the sequence number of the sequence group is updated to 3.
[0131] 4) Sequence group 4 does not overlap with the sequence group in the previous row. 4 is filled in the 4th column of the existing adjacency table, and the sequence number of the sequence group is updated to 4.
[0132] 5) Sequence group 5 has no overlap with the sequence group in the previous row. 5 is filled in the 5th column of the existing adjacency table, and the sequence number of the sequence group is updated to 5.
[0133] 6) Sequence group 6 only overlaps with sequence group 3 in the previous row, so the sequence number of this sequence group is updated to the sequence number 3 of the sequence group in the previous row that overlaps with it; the adjacency list is not updated.
[0134] 7) Sequence cluster 7 has no overlap with the sequence cluster in the previous row. Following the previously determined maximum sequence cluster number 5, 6 is filled in the 6th column of the existing adjacency table, and the sequence cluster number is updated to 6.
[0135] 8) Sequence group 8 has no overlap with the sequence group in the previous row, so 7 is filled in the 7th column of the existing adjacency table, and the sequence number of the sequence group is updated to 7.
[0136] 9) Sequence group 9 does not overlap with the sequence group in the previous row, so 8 is filled in the 8th column of the existing adjacency table, and the sequence number of the sequence group is updated to 8;
[0137] 10) Sequence cluster 10 overlaps with sequence clusters 6 and 7 (updated sequence numbers) in the previous row. The sequence number of this sequence cluster is updated to the sequence number 6 of the first sequence cluster that overlaps with it in the previous row. The updated sequence number 6 of the sequence cluster is filled in the upper row of the 9th column of the existing adjacency table, and the sequence number 7 of another sequence cluster that overlaps with it is filled in the lower row.
[0138] 11) Sequence group 11 has no overlap with the sequence group in the previous row, and 9 is filled in the 10th column of the existing adjacency table, and the sequence number of the sequence group is updated to 9.
[0139] 12) Sequence group 12 has no overlap with the sequence group in the previous row, and 10 is filled in the 11th column of the existing adjacency table, and the sequence number of the sequence group is updated to 10.
[0140] 13) Sequence group 13 has no overlap with the sequence group in the previous row, and 11 is filled in the 12th column of the existing adjacency table, and the sequence number of the sequence group is updated to 11.
[0141] 14) Sequence group 14 does not overlap with the sequence group in the previous row, and 12 is filled in the 13th column of the existing adjacency table, and the sequence number of the sequence group is updated to 12.
[0142] 15) Sequence group 15 overlaps with sequence groups 9, 10, and 11 (updated sequence numbers) in the previous row. The sequence number of this sequence group is updated to 9. In the existing adjacency table, fill in 9 and 10 in the upper and lower rows of the 14th column, and fill in 9 and 11 in the upper and lower rows of the 15th column, respectively.
[0143] The final adjacency table is as follows Figure 3 The adjacency list of step 15. The distribution of sequence groups after updating the serial numbers of the original sequence groups is as follows Figure 4 As shown, Figure 4 For the embodiment of the present invention Figure 2 Schematic diagram of sequence cluster distribution after the adjacency list is generated. Figure 3 The adjacency table in step 15 reflects the independence and connectivity of the sequence clusters in the entire data image. For example, the column (1, 1) represents an independent sequence cluster, while the column (6, 7) represents a sequence cluster that is adjacent to and overlaps with the sequence cluster 6 in the previous row, and is adjacent to and overlaps with the sequence cluster 7 in the previous row. The columns (9, 10) and (9, 11) represent a sequence cluster that is adjacent to and overlaps with the sequence clusters 9 to 11 in the previous row. Figure 4 , compared to Figure 2 , Figure 4 The sequence number of the sequence group that overlaps with the previous row has been updated to the sequence number of the first sequence group that overlaps with it in the previous row.
[0144] Step 4: Each working core generates a corresponding mapping table using its own task data in this step, and uses the mapping table to update the serial number of its own original sequence group; the main core summarizes the mapping table of the image to be tested, and obtains the information of the updated sequence group of the image to be tested as the data to be processed in the next step.
[0145] The data in a mapping table represent updated serial numbers of each sequence group in the corresponding image data, and adjacent sequence groups with overlapping areas have the same data in the mapping table.
[0146] In step 4, the task of each working core is to generate a mapping table, and the main core also needs to summarize the mapping tables of all working cores to obtain the mapping table of the image to be tested.
[0147] It should be noted that, before step 4, the initial state of the mapping table is a blank table with several columns and the number of rows may be one row.
[0148] In an optional implementation manner, in step 4, each working core generates a corresponding mapping table using its own task data in this step, including:
[0149] For each working core, the working core traverses the adjacency list of task data from left to right, and for the current column traversed,
[0150] If the current column is a first category column, where the first category column satisfies that the upstream and downstream data are the same, non-zero, and the data has not been traversed before; the current column is processed as follows: the data of the current column in the adjacency table is cleared, the number of connected domains is increased by 1, and the number of connected domains is filled into the column corresponding to the current column in the mapping table to update the mapping table; and after the current column is determined in the adjacency table, whether there are some second category columns, where the second category columns satisfy that the upstream and downstream data are different and the upstream data is the same as the current column data; if there are no some second category columns, continue to traverse the columns to the right of the original current column of the first category column; if there are some second category columns, each second category column is The category columns are updated to the current columns in turn for their respective processing, and after the processing of each second category column is completed, it is determined in the adjacency list whether there is a partial third category column, where the third category column satisfies that the data is the same as the downstream data of the previously processed column, and the previously processed column is the second category column; if there is no partial third category column, the original current column of the first category column is continued to the right for column traversal; if there is a partial third category column, the corresponding third category column is updated to the current column in turn according to the reverse order of each second category column for their respective processing, and after all third category columns are processed, the original current column of the first category column is continued to the right for column traversal.
[0151] If the current column is a second category column, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the data updated in the previous current column in the mapping table is repeated to update the column of the mapping table, and the number of connected domains is kept unchanged.
[0152] If the current column is a third category column, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the mapping table and the number of connected domains are not updated.
[0153] After all the adjacency lists are traversed, the mapping table of the working core is generated, wherein the number of columns is the maximum value of the sequence number of the sequence group before the mapping table is generated, and each data is the sequence number that each sequence group should update.
[0154] To facilitate understanding of the scheme, Figure 3 and Figure 4 Continue to explain. In the actual process of traversing the adjacency list, you can use the stack that stores data for processing. For the process of changing the adjacency list step by step, please refer to Figure 5As shown in the figure, the number under the adjacency table indicates the step number, and the corresponding adjacency table is the state at the end of the step. For the change process of the mapping table, please refer to Figure 6 As shown in the figure, the numbers under the mapping table represent the step numbers. For the stack change process, see Figure 7 As shown, the process of traversing the adjacency table to generate a mapping table includes the following steps:
[0155] Step 1: The current column (1, 1) of the adjacency list is the first category column. The data 1 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0. The number of connected domains is increased by 1. The data in the stack area is popped out of the stack. The number of connected domains 1 is assigned to the first column of the mapping table. After the judgment, there is no second category column, and the traversal continues to the right.
[0156] Step 2: The current column (2, 2) of the adjacency list is the first category column. The data 2 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0. The number of connected domains is increased by 1. The data in the stack is popped out. The number of connected domains 2 is assigned to the second column of the mapping table. After the judgment, there is no second category column, and the traversal continues to the right.
[0157] Step 3: The current column (3, 3) of the adjacency list is the first category column. The data 3 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0. The number of connected domains is increased by 1. The data in the stack area is popped out of the stack. The number of connected domains 3 is assigned to the third column of the mapping table. After the judgment, there is no second category column, and the traversal continues to the right.
[0158] Step 4: The current column (4, 4) of the adjacency list is the first category column. The data 4 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0. The number of connected domains is increased by 1. The data in the stack is popped out. The number of connected domains 4 is assigned to the fourth column of the mapping table. After the judgment, there is no second category column, and the traversal continues to the right.
[0159] Step 5: The current column (5, 5) of the adjacency list is the first category column. The data 5 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0. The number of connected domains is increased by 1. The data in the stack area is popped out of the stack. The number of connected domains 5 is assigned to the fifth column of the mapping table. After the judgment, there is no second category column, and the traversal continues to the right.
[0160] Step 6, the current column (6, 6) of the adjacency list is the first category column, the data 6 in the first row of the column is pushed into the stack, and the data in the column is cleared to 0; the number of connected domains is increased by 1; the data 6 in the stack is popped out; the number of connected domains 6 is assigned to the 6th column of the mapping table.
[0161] Step 7: Determine if there is a second category column (6, 7) in the adjacency list. Set it as the current column, push the number 7 in the other row of the column except 6 into the stack, and clear the data in the column to 0; pop the data 7 from the stack; repeat the number of connected domains 6 and assign it to the 7th column of the mapping table.
[0162] Step 8: Determine whether there is a third category column (7, 7) in the adjacency list, and use it as the current column. Clear the data in this column to 0. The number of connected domains 6 remains unchanged, and the mapping table and the number of connected domains are not updated.
[0163] Step 9: Continue to traverse the column to the right from the original current column of the first category column. The current column (8, 8) of the adjacency table is the first category column. The first row of data 8 is pushed into the stack, and the data in this column is cleared to 0; the number of connected domains is increased by 1; the data in the stack area is popped; the number of connected domains 7 is assigned to the 8th column of the mapping table. After judging that there is no second category column, continue to traverse to the right.
[0164] Step 10, the current column (9, 9) of the adjacency list is the first category column, the first row data 9 is pushed into the stack, and the data in this column is cleared to 0; the number of connected domains is increased by 1; the stack data 9 is popped out; the number of connected domains 8 is assigned to the 9th column of the mapping table; after judging that there is no second category column, continue traversing to the right.
[0165] Step 11: Determine that there are two second category columns (9, 10) and (9, 11) in the adjacency list, and use them as the current columns in turn. For the (9, 10) column, the data in this column is cleared to 0, and the number 10 in the other row of this column except 9 is pushed and popped, and the number of connected domains is repeated as 8, and assigned to the 10th column of the mapping table; similarly, for the (9, 11) column, the data in this column is cleared to 0, and the number 11 in the other row of this column except 9 is pushed and popped, and the number of connected domains is repeated as 8, and assigned to the 11th column of the mapping table.
[0166] Step 12: Determine if there is a third category column (11, 11) corresponding to (9, 11) in the adjacency list, and use it as the current column. Clear the data in this column to 0. The number of connected domains 8 remains unchanged, and the mapping table and the number of connected domains are not updated.
[0167] Step 13: Determine if there is a third category column (10, 10) corresponding to (9, 10) in the adjacency list, and use it as the current column. Clear the data in this column to 0. The number of connected domains 8 remains unchanged, and the mapping table and the number of connected domains are not updated. Determine if there are no other third category columns, and the second category columns have been processed. Continue to traverse the columns to the right from the original current column of the first category column.
[0168] Step 14, the current column (12, 12) of the adjacency list is the first category column, the first row of data is pushed into the stack, and the data in this column is cleared to 0; the number of connected domains is increased by 1; the data in the stack area is popped; the number of connected domains 9 is assigned to the 12th column of the mapping table.
[0169] Among them, the adjacency list completed after each step is listed in Figure 5In gray. At this point, the traversal of the adjacency table and the generation of the mapping table are completed. In the final mapping table, from left to right are the sequence groups that appear in rows, and the corresponding numbers are the sequence numbers that should be updated after step 4 of the sequence group. Therefore, after the mapping table is generated, the mapping table can be directly used to update the original sequence number. Specifically, for Figure 4 , update the sequence numbers of each sequence group according to the numbers in the mapping table, and the updated sequence group distribution is as follows Figure 8 shown. Figure 8 For the embodiment of the present invention Figure 4 Schematic diagram of sequence cluster distribution after updating using the mapping table. Figure 8 It can be seen that the serial numbers of multiple adjacent overlapping sequence groups are all the same.
[0170] Step 5: Each working core obtains the feature data information of the sequence group as the same connected domain from the respective task data in this step according to the same sequence number; the main core summarizes and updates the feature data information of all connected domains in the image to be tested as the data to be processed in the next step.
[0171] In step 5, the task of each working core is to extract the feature data information of the connected domain. The main core also needs to summarize the feature data information of the connected domain extracted by all working cores, and recalculate the feature data information with the same connected domain serial number, to update the connected domain serial number and each feature data information, and obtain the feature data information of all connected domains in the image to be tested.
[0172] Specifically, in step 5, the characteristic data information of the sequence group of the same connected domain includes:
[0173] The accumulated grayscale of the connected domain, the peak grayscale of the connected domain, the area of the connected domain, the accumulated row number of the connected domain, the accumulated column number of the connected domain, the row position of the centroid of the connected domain, the column position of the centroid of the connected domain, the mean grayscale of the connected domain, the maximum width of the connected domain, and the maximum height of the connected domain.
[0174] Among them, the same connected domain is composed of multiple sequence groups with the same sequence number; the cumulative grayscale of the connected domain is the sum of the cumulative grayscales of the sequence groups that constitute the connected domain, minus the difference between the product of the area of the connected domain and the grayscale mean of the image to be tested; the peak grayscale of the connected domain is the difference between the maximum value of the peak grayscale of the sequence groups that constitute the connected domain and the grayscale mean of the image to be tested; the area of the connected domain is the cumulative sum of the differences between the end column position and the start column position of each sequence group that constitutes the connected domain; the cumulative row number and the cumulative column number of the connected domain are respectively The sum of the row numbers and column numbers of all pixels in the sequence group that constitutes the connected domain; the centroid row position of the connected domain is the quotient of the cumulative row number of the connected domain and the area of the connected domain; the centroid column position of the connected domain is the quotient of the cumulative column number of the connected domain and the area of the connected domain; the mean grayscale of the connected domain is the quotient of the cumulative grayscale of the connected domain and the area of the connected domain; the maximum width of the connected domain is the difference between the maximum end column number and the minimum start column number of the sequence group in the connected domain; the maximum height of the connected domain is the difference between the maximum row number and the minimum row number of the sequence group in the connected domain. It can be understood that the feature data information of the above sequence groups can be obtained from the data obtained after step 2, and the specific calculation process will not be described in detail one by one.
[0175] Step 6: Each working core determines whether each connected domain in the task data of the step is a target; the main core summarizes the target judgment results of each working core to obtain the feature data information of all targets in the image to be tested.
[0176] It can be understood that, when a connected domain is determined as a target, the characteristic data information of the target is the characteristic data information of the connected domain.
[0177] In step 6, the task of each working core is to judge the target of the connected domain, and obtain the target judgment result corresponding to each task data, which includes the characteristic data information of the target.
[0178] In an optional implementation manner, in step 6, each work checks the task data of the step to determine whether each connected domain is a target, including:
[0179] For each working core, the working core performs target feature legitimacy judgment and image bad pixel judgment on each connected domain in its task data. If the connected domain has the target feature legitimacy and is not an image bad pixel, the connected domain is determined to be a target. In other words, only the connected domain that meets the above two conditions can be determined as a target.
[0180] The process of judging the legitimacy of target features and image bad pixels for a connected domain and a working core includes:
[0181] The working core determines whether the centroid row position and centroid column position of the connected domain are within the image data range corresponding to the working core, determines whether the maximum width and maximum height of the connected domain are both within the corresponding threshold range, and determines whether the ratio of the maximum width to the maximum height of the connected domain is within the corresponding threshold range. If all of them are yes, it is determined that the connected domain has the legitimacy of the target feature.
[0182] The working core determines whether the area of the connected domain is greater than or equal to 1, and whether the accumulated grayscale of the connected domain is greater than or equal to the corresponding threshold. If all are yes, it is determined that the connected domain is not a bad pixel of the image.
[0183] The ranges of various thresholds in the target feature legitimacy judgment process and the image bad pixel judgment process are different. However, they are all empirical values set according to scene changes. And for multiple frames of images to be tested, the same threshold is fixed.
[0184] In each of the above steps, the DSP with eight cores uses core 0 as the main core and the other cores as auxiliary cores to process data in a master-auxiliary mode. The main core is responsible for processing the assigned task data as well as data synchronization between the working cores. In the embodiment of the present invention, hardware semaphores are used to implement the synchronization function of each working core, that is, each working core obtains a semaphore numbered with the core number of the working core plus 1. When the main core determines that other working cores are blocked, it determines that all working cores have completed synchronization, the main core releases the semaphore, and each working core performs the next algorithm operation at the same time. After the algorithm operation is completed, each working core waits for the main core to determine whether other working cores are blocked to wait for synchronization, and the synchronization operations are performed alternately as above. Please refer to the detailed description for details. Fig. 9 , Fig. 9 Schematic diagram of multi-core synchronous processing interaction in an embodiment of the present invention, wherein the eight cores are main core 0 and auxiliary cores 1 to 7.
[0185] In each step, each working core processes the task data in DDR (Double Data Rate SDRAM), and accordingly, the main core summarizes the processing results of all working cores, including:
[0186] The master core moves the data stored in the DDR of each working core to the shared storage area for aggregation.
[0187] The main core puts the summary results into the shared storage area to facilitate the subsequent working cores to call the data, reduce space usage and improve processing speed.
[0188] For an example of the target detection result of the embodiment of the present invention, see Fig.10 , Fig.10Schematic diagram of target detection results of a frame of an image to be detected in an embodiment of the present invention. The box in the figure shows the detected target. Regarding the target in the embodiment of the present invention, it can include multiple categories according to different scenes and image objects, such as people, animals, buildings, vehicles, etc., and no specific limitation is made here.
[0189] In the solution provided by the embodiment of the present invention, the architectural characteristics of DSP are fully utilized, the advantages and processing speed of parallel execution of multi-core DSP are brought into play, and the processing tasks of each core are reasonably allocated so that each core of DSP can process data in parallel at the same time, which can improve the processing efficiency. In addition, the embodiment of the present invention scans the image data once to obtain the information of the sequence group, and the subsequent processing is based on the information of the sequence group rather than the image data. Therefore, compared with the region marking method in the prior art that scans the image twice, the embodiment of the present invention only scans once, is not limited by the number of gray levels of the image, and can reduce the scanning time. Compared with the traditional target detection method that uses the method of saving an image to extract image information, the embodiment of the present invention extracts sequence groups from the image data to carry key image information, and then generates an adjacency table and a mapping table. The storage required for this information is much smaller than the entire image. Therefore, the embodiment of the present invention can reduce the resource storage amount and improve the processing efficiency by extracting sequence groups; at the same time, by using sequence groups to represent image information, it is easier to extract features such as target area and target centroid, which can improve the processing efficiency of subsequent images and the accuracy of target detection. The embodiments of the present invention have low computational complexity and are easy to implement in engineering. They can solve the problems of low data processing rate and slow data exchange rate. While meeting the real-time requirement, they can simultaneously ensure high detection accuracy and have more obvious advantages in multi-target detection scenarios.
[0190] In addition, in an optional implementation, when the multi-core DSP-based image target parallel detection method is used to process multiple frames of images to be tested, in step 1, for any working core, the grayscale related statistics also include the grayscale square sums of the first grayscale class and the second grayscale class in the image data of the working core. The grayscale square sum of each grayscale class refers to the sum of the squares of the grayscale values of all pixels in the grayscale class.
[0191] Correspondingly, in step 1, after the main core obtains the grayscale mean of the image to be tested using the grayscale correlation statistics of all working cores, the method further includes:
[0192] The master core calculates the sum of the grayscale squares of all working cores under the target grayscale class to obtain the target grayscale square sum.
[0193] The main core uses the target grayscale square sum, the target pixel sum and the grayscale mean of the image to be tested to calculate the grayscale mean square error of the image to be tested, so as to determine the image segmentation threshold range of the next frame of the image to be tested.
[0194] Specifically, the calculation formula of the grayscale mean square error of the image to be tested is as follows:
[0195]
[0196] Among them, σ represents the grayscale mean square error of the image to be tested; represents the target grayscale square sum; where x i Represents the grayscale value of the target grayscale class; n represents the total number of target pixels; e represents the grayscale mean of the image to be tested.
[0197] Because multiple frames of images to be tested are changing, in order to improve the pertinence and accuracy of subsequent target prediction, the embodiment of the present invention does not use a fixed value for the image segmentation threshold range of each frame of the image to be tested, but predicts the image segmentation threshold range of the next frame of the image to be tested in advance when processing the current frame of the image to be tested.
[0198] In an optional implementation manner, the process of determining the image segmentation threshold range of the next frame of the image to be tested includes:
[0199] For the current frame of the image to be tested, the difference between the grayscale mean of the image to be tested and the grayscale mean square error of the image to be tested is calculated, and the product of the difference and the preset coefficient is used as the lower limit value; and the sum of the grayscale mean of the image to be tested and the grayscale mean square error of the image to be tested is calculated, and the product of the sum and the preset coefficient is used as the upper limit value; the image segmentation threshold range of the next frame of the image to be tested is determined by the obtained lower limit value and upper limit value.
[0200] Among them, the preset coefficient can be 3, etc.
[0201] Furthermore, when processing multiple frames of images to be tested, the embodiment of the present invention may not use a fixed value for the grayscale decision threshold of each frame of the image to be tested, but may predict the grayscale decision threshold of the next frame of the image to be tested in advance when processing the current frame of the image to be tested. Specifically:
[0202] For the first frame of the image to be tested, the grayscale decision threshold can be a fixed value such as 65; the grayscale decision threshold of the next frame of the image to be tested predicted by the current frame of the image to be tested is the difference between the grayscale mean of the current frame of the image to be tested and a preset value, which can be a fixed value, such as 5.
[0203] Therefore, the multi-core DSP-based image target parallel detection method of the embodiment of the present invention can be used for target detection of multiple frames of images to be tested, and can adaptively adjust the grayscale decision threshold and image segmentation threshold range for each frame of the image to be tested, so as to specifically improve the accuracy of subsequent target detection of each frame of the image to be tested while meeting high real-time and low resource requirements, and has broad application prospects.
[0204] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0205] The above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A parallel image target detection method based on multi-core DSP, characterized in that: The invention is applied to a digital signal processor DSP having eight cores, wherein the eight cores include a main core and seven auxiliary cores; in each step of the method: the main core determines the number of working cores including the main core according to the amount of data to be processed in the step, divides the data to be processed in the step into multiple copies according to the number of working cores, distributes a different copy of the copies to each working core as task data, and each working core processes its own task data independently; after the main core determines that all working cores have completed processing, the main core summarizes the processing results of all working cores; wherein the steps of the method include: Step 1: Each working core calculates the grayscale correlation statistics for its respective task data in this step; the main core obtains the grayscale mean of the image to be tested using the grayscale correlation statistics of all working cores; in step 1, the data to be processed is a frame of the image to be tested acquired by the DSP; Step 2: Each working core extracts information of sequence groups from the respective task data in step 1; the main core summarizes and updates the information of all sequence groups in the image to be tested as the data to be processed in the next step; a sequence group refers to a sequence composed of at least one pixel in a row of image data that continuously falls within the image segmentation threshold range; the information of the sequence group includes the sequence number of the sequence group; Step 3: Each working core generates a corresponding adjacency list using its own task data in this step, and updates the serial number of its own original sequence group; the main core obtains the adjacency list of the image to be tested as the data to be processed in the next step; wherein an adjacency list contains information on the adjacent overlapping relationship between rows of each sequence group in the corresponding image data; Step 4: Each working core generates a corresponding mapping table using its own task data in this step, and uses the mapping table to update the serial number of its own original sequence group; the main core obtains the mapping table of the image to be tested by summarizing, and obtains the information of the updated sequence group of the image to be tested as the data to be processed in the next step; the data in a mapping table represents the updated serial number of each sequence group in the corresponding image data, and adjacent sequence groups with overlapping areas have the same data in the mapping table; Step 5: Each working core obtains feature data information of a sequence group as the same connected domain from the respective task data in this step according to the same sequence number; the main core summarizes and updates the feature data information of all connected domains in the image to be tested as the data to be processed in the next step; Step 6: Each working core determines whether each connected domain in the task data in the step is a target; the main core summarizes the target judgment results of each working core to obtain the feature data information of all targets in the image to be tested; Wherein, in step 2, each work checks the task data extracted from step 1 to extract the information of the sequence group, including: For each working core, the working core performs pixel traversal row by row from left to right on the image data as task data. In the traversal of each row, pixels falling within the image segmentation threshold range are determined as valid pixels, and individual valid pixels and sequences consisting of two or more adjacent valid pixels are determined as sequence clusters. For each determined sequence cluster, information of the sequence cluster is determined, and the information of the sequence cluster includes a sequence number of the sequence cluster, a row position of the sequence cluster, a start column position of the sequence cluster, an end column position of the sequence cluster, a peak grayscale of the sequence cluster, and an accumulated grayscale of the sequence cluster. After the traversal of each row is completed, the working core proceeds to the traversal of the next row until the working core completes the traversal of all rows of the corresponding image data; wherein the sequence numbers of the sequence groups successively determined during the traversal of all rows are incremented in sequence.
2. The image target parallel detection method based on multi-core DSP according to claim 1 is characterized in that: For any working core, the grayscale related statistics include the number of pixels belonging to the first grayscale class and the second grayscale class in the image data of the working core, and the sum of the grayscales of the pixels in each grayscale class; wherein, if the grayscale value of a pixel is less than a preset grayscale decision threshold, it belongs to the first grayscale class, otherwise it belongs to the second grayscale class; Correspondingly, in step 1, the main core uses the grayscale correlation statistics of all working cores to obtain the grayscale mean of the image to be tested, including: Calculate the sum of the number of pixels in the first grayscale class of all working cores to obtain the sum of the number of pixels in the first grayscale class, and calculate the sum of the number of pixels in the second grayscale class of all working cores to obtain the sum of the number of pixels in the second grayscale class; Determine the grayscale class corresponding to the larger of the sum of the number of pixels of the first grayscale class and the sum of the number of pixels of the second grayscale class as the target grayscale class; The sum of the grayscale values of all working cores under the target grayscale class is calculated to obtain the target pixel grayscale sum, and the sum of the number of pixels of all working cores under the target grayscale class is calculated to obtain the target pixel number sum; The quotient of the grayscale sum of the target pixels and the total number of the target pixels is calculated to obtain the grayscale mean of the image to be tested.
3. The image target parallel detection method based on multi-core DSP according to claim 1 is characterized in that: In step 3, the main core determines the number of working cores including the main core according to the amount of data to be processed in this step, including: The main core determines the total number of different row numbers occupied by all sequence groups of the image to be tested; The main core determines whether the total number of the different row numbers is greater than or equal to a preset working core decision threshold, and if so, determines that the number of working cores is eight; if not, selects a number of working cores less than eight according to the total number of the different row numbers and a preset selection relationship; Correspondingly, in step 3, the task data of each working core is obtained by dividing the data to be processed in this step according to the total number of different row numbers.
4. The image target parallel detection method based on multi-core DSP according to claim 1 is characterized in that: Before step 3, the initial state of the adjacency list is a blank table with two rows and several columns; In step 3, each working core generates a corresponding adjacency table using its own task data in this step, and updates the sequence number of its own original sequence group, including: For each working core, the working core uses the information of the partial sequence group of the image to be tested as task data to traverse the sequence group row by row, and for the current sequence group traversed, If the current sequence group has no overlapping area with the sequence group in the previous row, the sequence number of the current sequence group is incrementally updated by the maximum sequence number of the previously determined sequence group, and the upper and lower rows of the column corresponding to the current sequence group in the adjacency table are filled with the updated sequence number of the current sequence group; If the current sequence group has only an overlapping area with one sequence group in the previous row, the sequence number of the current sequence group is updated to the sequence number of the overlapping sequence group in the previous row, and the adjacency table is not updated; If the current sequence group has an overlapping area with the m sequence groups in the previous row, the sequence number of the current sequence group is updated to the sequence number of the first sequence group overlapping with it in the previous row, and the m-1 columns corresponding to the current sequence group in the adjacency table are filled with the updated sequence number of the current sequence group in the upper row, and the sequence numbers of the remaining sequence groups overlapping with the current sequence group in the previous row are filled in the lower row in sequence; where m≥2.
5. The image target parallel detection method based on multi-core DSP according to claim 1 is characterized in that: Before step 4, the initial state of the mapping table is a blank table with several columns; In step 4, each working core generates a corresponding mapping table using its own task data in this step, including: For each working core, the working core traverses the adjacency list of task data from left to right, and for the current column traversed, If the current column is a first category column, wherein the first category column satisfies that the uplink and downlink data are the same, non-zero, and the data has not been traversed before; the current column is processed as follows: the data of the current column in the adjacency table is cleared, the number of connected domains is increased by 1, and the obtained number of connected domains is filled into the column corresponding to the current column in the mapping table to update the mapping table; and after judging the current column in the adjacency table, whether there are some second category columns, wherein the second category columns satisfy that the uplink and downlink data are different and the uplink data is the same as the data of the current column; if there are no some second category columns, continue to traverse the columns to the right of the original current column of the first category column; if there are some second category columns Category columns, update each second category column in turn to the current column for respective processing, and after each second category column is processed, determine whether there is a partial third category column in the adjacency list, wherein the third category column satisfies that the data is the same as the downstream data of the previously processed column, and the previously processed column is the second category column; if there is no partial third category column, continue to traverse the column to the right with the original current column of the first category column; if there is a partial third category column, according to the reverse order of each second category column, update the corresponding third category column in turn to the current column for respective processing, and after all third category columns are processed, continue to traverse the column to the right with the original current column of the first category column; If the current column is a column of the second category, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the data updated in the previous current column in the mapping table is repeated to update the column of the mapping table, and the number of connected domains is kept unchanged; If the current column is a third category column, the current column is processed as follows: the data of the current column in the adjacency table is cleared, and the mapping table and the number of connected domains are not updated; After the adjacency list is completely traversed, the mapping table of the working core is generated, wherein the number of columns is the maximum value of the sequence number of the sequence group before the mapping table is generated, and each data is the sequence number that each sequence group should update in turn.
6. The image target parallel detection method based on multi-core DSP according to claim 1 is characterized in that: In step 5, the characteristic data information of the sequence group of the same connected domain includes: The accumulated grayscale of the connected domain, the peak grayscale of the connected domain, the area of the connected domain, the accumulated row number of the connected domain, the accumulated column number of the connected domain, the row position of the centroid of the connected domain, the column position of the centroid of the connected domain, the mean grayscale of the connected domain, the maximum width of the connected domain, and the maximum height of the connected domain; Among them, the same connected domain is composed of multiple sequence groups with the same sequence number; the cumulative grayscale of the connected domain is the sum of the cumulative grayscales of the sequence groups constituting the connected domain, minus the difference between the product of the area of the connected domain and the grayscale mean of the image to be tested; the peak grayscale of the connected domain is the difference between the maximum value of the peak grayscale of the sequence groups constituting the connected domain and the grayscale mean of the image to be tested; the area of the connected domain is the cumulative sum of the differences between the end column position and the start column position of each sequence group constituting the connected domain; the cumulative row number and the cumulative column number of the connected domain are respectively the number of the sequence groups constituting the connected domain. The sum of the row numbers and the column numbers of all pixels in the sequence cluster of the connected domain; the centroid row position of the connected domain is the quotient of the accumulated row number of the connected domain and the area of the connected domain; the centroid column position of the connected domain is the quotient of the accumulated column number of the connected domain and the area of the connected domain; the mean grayscale of the connected domain is the quotient of the accumulated grayscale of the connected domain and the area of the connected domain; the maximum width of the connected domain is the difference between the maximum end column number and the minimum start column number of the sequence cluster in the connected domain; the maximum height of the connected domain is the difference between the maximum row number and the minimum row number of the sequence cluster in the connected domain.
7. The image target parallel detection method based on multi-core DSP according to claim 6 is characterized in that: In step 6, each task checks the task data in the step to determine whether each connected domain is a target, including: For each working core, the working core performs target feature legitimacy judgment and image bad pixel judgment on each connected domain in its task data. If the connected domain has the target feature legitimacy and is not an image bad pixel, the connected domain is determined to be a target; The process of judging the legitimacy of target features and image bad pixels for a connected domain and a working core includes: The working core determines whether the centroid row position and centroid column position of the connected domain are within the image data range corresponding to the working core, whether the maximum width and maximum height of the connected domain are both within the corresponding threshold range, and whether the ratio of the maximum width and maximum height of the connected domain is within the corresponding threshold range. If all of them are yes, it is determined that the connected domain has the legitimacy of the target feature; The working core determines whether the area of the connected domain is greater than or equal to 1, and whether the accumulated grayscale of the connected domain is greater than or equal to the corresponding threshold. If all are yes, it is determined that the connected domain is not a bad pixel of the image.
8. The image target parallel detection method based on multi-core DSP according to claim 2 is characterized in that: When the multi-core DSP-based image target parallel detection method is used to process multiple frames of images to be tested, in step 1, for any working core, the grayscale related statistics also include the grayscale square sum under each grayscale class in the image data of the working core; Correspondingly, in step 1, after the main core obtains the grayscale mean of the image to be tested using the grayscale related statistics of all working cores, the method further includes: The master core calculates the sum of the grayscale squares of all working cores under the target grayscale class to obtain a target grayscale square sum; The main core uses the target grayscale square sum, the target pixel quantity sum and the grayscale mean of the image to be tested to calculate the grayscale mean square error of the image to be tested, so as to determine the image segmentation threshold range of the next frame of the image to be tested.
9. The method for parallel image target detection based on multi-core DSP according to claim 1, characterized in that: The master core summarizes the processing results of all working cores, including: The master core moves the data stored in the double data rate synchronous dynamic random access memory DDR of each working core to the shared storage area for aggregation.
