CN-122019080-A - Multi-task image analysis method and system based on producer consumer mode
Abstract
The invention provides a multi-task image analysis method and a multi-task image analysis system based on a producer consumer mode, wherein the method comprises the steps of starting an image data receiving and preprocessing task, attempting to acquire an ID feature data lock which is started to be calculated currently, reading an ID feature data array which is generated by image data computing and analyzing task computing and started to be calculated when the image data receiving and preprocessing task acquires the ID feature data lock, starting the image data computing and analyzing task, acquiring feature long package data from a feature data queue, checking whether a value exists in the computing queue, reading the image feature data from the computing queue to calculate and assigning a calculation result to telemetry data if the value exists, acquiring system broadcasting time, recording time when each computation is completed as time of the current computing image data, and judging that the computation is ended. The invention can ensure that the data is completely received and the correct result is output under the scene of quick data generation and long analysis time consumption.
Inventors
- ZHANG YONGQING
- ZHANG ZEHAO
- ZHANG HAI
- XU QING
- WANG XIYANG
Assignees
- 上海卫星工程研究所
Dates
- Publication Date
- 20260512
- Application Date
- 20260104
Claims (10)
- 1. A method of multitasking image analysis based on producer consumer model, comprising the steps of: step S1, starting an image data receiving and preprocessing task, receiving image preprocessing data and image characteristic data which are input from the outside, caching the image preprocessing data into a preprocessing data caching queue, and caching the image characteristic data into a characteristic data queue; Step S2, the image data receiving and preprocessing task tries to acquire an ID feature data lock which is used for controlling access to an ID feature data array which is started to be calculated, wherein the ID feature data array is generated by image data calculation and analysis task calculation; Step S3, when the image data receiving and preprocessing task successfully acquires the ID feature data lock, reading an ID feature data array which is generated by image data calculation and analysis task calculation and is started to be calculated, and judging whether the ID feature contained in the current image preprocessing data exists in the ID feature data array which is started to be calculated or not; step S4, starting the image data calculation and analysis task, wherein the image data calculation and analysis task is triggered by a timer and runs in parallel with the image data receiving and preprocessing task; Step S5, the image data calculation and analysis task acquires characteristic long packet data from the characteristic data queue and checks whether the characteristic long packet data has a value or not; if the value exists, carrying out matching calculation on the characteristic long packet data and the preprocessing data in the preprocessing data cache queue, putting a matching result into the calculation queue, and storing the ID characteristic after matching into the ID characteristic data array which starts to be calculated; step S6, the image data calculation and analysis task checks whether the calculation queue has a value, if so, the image characteristic data is read from the calculation queue for calculation, and the calculation result is assigned to telemetry data; Step S7, the image data calculation and analysis task acquires system broadcasting time, records the time when each calculation is completed as the time of currently calculating the image data, and judges whether the difference value between the time of currently calculating the image data and the system broadcasting time exceeds a set time; Step S8, in the calculation ending judging program, judging whether the difference value between the data receiving updating period and the current running period exceeds a given value, if so, clearing the corresponding ID feature from the ID feature data array which is started to be calculated, and releasing the cache data occupied by the ID feature; Wherein, through the loop execution of the step S1 to the step S8, the image data receiving and preprocessing task and the image data calculating and analyzing task continue to run in parallel until the external input is terminated.
- 2. The method according to claim 1, wherein in the step S1, the image preprocessing data and the image feature data are stored in respective first-in first-out queues, and for the image preprocessing data, it is determined whether the ID included in the data has been calculated, if calculation has been started, the image preprocessing data is placed in a calculation queue, and if calculation has not been started, the image preprocessing data is placed in a preprocessing data buffer queue, and the image feature data is placed in a feature data queue without additional processing.
- 3. The method according to claim 1, wherein in step S2, the ID feature data array that has been started to be calculated is generated by the image data calculation and analysis task by matching feature long packet data with the preprocessing data in the preprocessing data cache queue, after matching is completed, the successfully matched ID feature is stored in the ID feature data array that has been started to be calculated, and the ID feature data lock is acquired when the image data receiving and preprocessing task accesses the ID feature data array that has been started to be calculated.
- 4. The method for multi-task image analysis based on the producer consumer model according to claim 1, wherein the image data receiving and preprocessing task is used as a producer and stores data to be calculated into a calculation queue, the image data calculating and analyzing task is used as a consumer, and the data is taken out from the calculation queue for calculation and analysis, and the calculation queue is written by the producer and read by the consumer.
- 5. The method according to claim 1, wherein in step S3, after the image data receiving and preprocessing task acquires the ID feature data lock, the ID feature data array that has been started to be calculated is copied to a local cache, and then it is determined whether the ID feature of the current image preprocessing data is present in the ID feature data array that has been started to be calculated of the local cache, if so, the current image preprocessing data is placed in the calculation queue, and if not, the current image preprocessing data is retained in the preprocessing data cache queue.
- 6. The method according to claim 1, wherein in step S3, the image data receiving and preprocessing task and the image data calculating and analyzing task interact through a synchronization data object, the synchronization data object including a calculation queue, a system broadcasting time, an ID feature data array having started calculation, and calculation telemetry data, the storage length of the synchronization data object being configured according to data traffic.
- 7. The method according to claim 1, wherein in step S6, the image data calculation and analysis task synchronizes the calculation state variables to the image data reception and preprocessing task via telemetry data, and the image data reception and preprocessing task receives the telemetry data at a fixed period.
- 8. The method according to claim 1, wherein in step S6, the number of data pieces read from the calculation queue per cycle is set by the configuration parameter.
- 9. The method according to claim 1, wherein in step S7, the image data calculation and analysis task acquires the system broadcast time through the synchronization data object, and the system broadcast time is periodically acquired and updated from an external system by the image data receiving and preprocessing task.
- 10. A producer consumer pattern based multitasking image analysis system employing the producer consumer pattern based multitasking image analysis method of any one of claims 1-9 comprising: The image preprocessing module comprises a module M1, a characteristic data queue and a characteristic data queue, wherein the module M1 starts an image data receiving and preprocessing task, receives image preprocessing data and image characteristic data which are input from the outside, caches the image preprocessing data into the preprocessing data caching queue, and caches the image characteristic data into the characteristic data queue; The module M2 is used for the image data receiving and preprocessing task to attempt to acquire an ID characteristic data lock which is used for controlling access to an ID characteristic data array which is started to be calculated, and the ID characteristic data array which is started to be calculated is generated by the image data calculating and analyzing task; The module M3 is used for reading an ID feature data array which is generated by calculation of the image data calculation and analysis task and is started to be calculated when the image data receiving and preprocessing task successfully acquires the ID feature data lock, judging whether the ID feature contained in the current image preprocessing data exists in the ID feature data array which is started to be calculated or not, if so, putting the current image preprocessing data into a calculation queue, and if not, keeping the current image preprocessing data in the preprocessing data cache queue; the module M4 starts the image data calculation and analysis task, wherein the image data calculation and analysis task is triggered by a timer and runs in parallel with the image data receiving and preprocessing task; the module M5 is used for acquiring the characteristic long packet data from the characteristic data queue by the image data calculation and analysis task, checking whether the characteristic long packet data has a value or not, if so, carrying out matching calculation on the characteristic long packet data and the preprocessing data in the preprocessing data cache queue, putting a matching result into the calculation queue, and storing the matched ID characteristic into the ID characteristic data array which starts to be calculated; the module M6 is used for checking whether the calculation queue has a value or not by the image data calculation and analysis task, if so, reading the image characteristic data from the calculation queue for calculation, and assigning a calculation result to telemetry data; The module M7 is used for acquiring system broadcasting time by the image data calculation and analysis task, recording the time when each calculation is completed as the time of currently calculating the image data, and judging whether the difference value between the time of currently calculating the image data and the system broadcasting time exceeds the set time or not; The module M8 judges whether the difference value between the data receiving update period and the current running period exceeds a given value or not in the calculation ending judging program, if so, the corresponding ID feature is cleared from the ID feature data array which is started to be calculated, and the cache data occupied by the ID feature is released; the image data receiving and preprocessing task and the image data calculating and analyzing task continuously run in parallel through the cyclic execution of the modules M1 to M8 until the external input is terminated.
Description
Multi-task image analysis method and system based on producer consumer mode Technical Field The invention relates to the technical field of image data processing, in particular to a multi-task image analysis method and system based on a producer consumer mode. Background At the moment of rapid development of satellite remote sensing technology, on-board data processing capability has become one of the core elements for improving satellite application performance. The embedded software is used as a neural center of a satellite single machine and bears the tasks of real-time analysis and processing of various image data. The multi-task image analysis system is embedded software and runs in a satellite single machine to realize a more complex calculation function, and the analysis system is provided with a plurality of data sources, and when a preset trigger condition is met, the plurality of data sources can simultaneously generate massive image data to require the system to synchronously start a plurality of analysis processes for parallel processing. However, on-board computing resources are limited, which requires the image analysis system to output the analysis result at the fastest speed by using limited resources on the premise of ensuring the accuracy of the analysis result. In the current satellite embedded software field, the scheduling and running of multiple tasks typically relies on the kernel task to trigger according to a timer or a specific synchronization object. The mechanism can meet basic requirements when processing simple tasks, but when facing complex scenes of multi-source data concurrency and multi-process concurrency, the mechanism exposes obvious limitations that if the processing time of a certain task exceeds a preset maximum time threshold, the loss of subsequent received data is easily caused, and further, the deviation of data analysis results is caused. The invention discloses a distributed telemetry collection method and system based on a multitasking mechanism through the search discovery of a patent document, wherein the distributed telemetry collection method and system comprises a main task, a source task lock and a source telemetry cache pool, the source task lock and the source telemetry cache pool exist as a group of source components, the main task starts telemetry processing, interacts with the source task through the source task lock, each source task is provided with a source task lock, a telemetry collection instruction is sent by the source task, each source task collects telemetry of a plurality of sources of the same type, the collected telemetry data are stored in the source telemetry cache pool corresponding to the source task, and the main task uniformly processes the data in all the source telemetry cache pools according to a set period. The patent focuses on the distributed telemetering acquisition, does not involve the complex image analysis and processing, the application scene is single. The invention discloses a pipeline navigation computing method realized by satellite-borne software multitasking, which comprises the steps of adopting a timing triggering and condition triggering mode, scheduling attitude and orbit control tasks as timing tasks, judging and waking up the pipeline navigation tasks by the attitude and orbit control tasks, preferentially ensuring that the attitude and orbit control tasks are correctly executed, protecting read-write operations of shared data among tasks, locking and unlocking, occupying the highest priority when the current task reads and writes the shared data, and recovering the priority set by a user after the read-write operations are finished. The patent aims at pipeline navigation computation realized by satellite-borne software multitasking, does not relate to multi-source image data concurrency and multi-flow parallel analysis, and cannot solve the problem of data receiving integrity and data analysis correctness under the condition that the execution time of a data analysis task is long and uncertain. In summary, in view of the above-mentioned problems in the prior art, research on a method and a system for multi-task image analysis based on a producer-consumer model is a critical task to be solved. Disclosure of Invention In view of the drawbacks of the prior art, an object of the present invention is to provide a method and a system for multi-tasking image analysis based on producer consumer model. According to the invention, the method for analyzing the multitasking image based on the producer consumer mode comprises the following steps: Step S1, starting an image data receiving and preprocessing task, receiving image preprocessing data and image characteristic data which are input from the outside, caching the image preprocessing data into a preprocessing data caching queue, and caching the image characteristic data into a characteristic data queue; step S2, the image data receiving and preprocessing task trie