Method for processing image data based on QCamera
Patent Information
- Application Number
- CN202410881025.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-07-02
AI Technical Summary
[0002]在Qt mu ltimedia框架中采集摄像头数据一般用QCameraImageCapture对象采集数据,这种方式对高帧率下视频流的二次处理会有性能问题,影响软件UI层的交互体验
[0017] The present invention also provides an electronic device, including at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor, so that the processor executes The processing method based on QCamera camera image data as described in any of the above embodiments.
Smart Images

Figure CN118632136A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a processing method based on QCamera camera image data. Background Art
[0002] In the Qt multimedia framework, the QCameraImageCapture object is generally used to collect camera data. This method will have performance problems for secondary processing of video streams at high frame rates, affecting the interactive experience of the software UI layer. At the same time, the existing data is mostly processed by the Qt multimedia framework itself, causing CPU memory jams and affecting image acquisition and data processing. Summary of the invention
[0003] In order to solve the deficiencies in the above-mentioned prior art, the present invention provides a method for processing image data based on QCamera, comprising:
[0004] S100, the data capture thread obtains the QCamera camera data packet and stores it in a preset location, and sends a transcoding operation signal to the data transcoding thread;
[0005] S200, after receiving the transcoding operation signal, the data transcoding thread determines whether a transcoding operation is required; if necessary, the data transcoding thread extracts a QCamera camera data packet from a preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread;
[0006] S300, after receiving the data processing signal, the data drawing thread determines whether a data processing operation is required; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain a second image data packet, so as to obtain the processed data of the QCamera camera image data.
[0007] Furthermore, the data capture thread uses the registration callback mechanism to obtain the QCamera camera data packet.
[0008] Furthermore, the data capture thread stores the acquired QCamera data packets into the program running memory area, and the data transcoding thread extracts the QCamera data packets from the program running memory area for transcoding operation.
[0009] Furthermore, the latest QCamera data packet obtained in the data capture thread will be cached at the front end of the shared queue. When the QCamera data packet in the shared queue reaches the preset cache data amount, the old QCamera data packet will be discarded from the end of the shared queue.
[0010] Furthermore, the data transcoding thread converts the QCamera data packet in the yuyv format into a first image data packet in the RGB format.
[0011] Furthermore, the data transcoding thread copies at least one QCamera data packet from the end of the shared queue, the shared queue deletes the copied QCamera data packet, and the data transcoding thread performs transcoding processing on the copied QCamera data packet.
[0012] Furthermore, the data drawing thread uses a UI double buffer mechanism to draw the first image data packet to obtain a second image data packet.
[0013] The present invention also provides a processing device based on QCamera camera image data, including a data capture thread module, which is used to obtain QCamera camera data packets and store them in a preset position, and send a transcoding operation signal to a data transcoding thread;
[0014] The data transcoding thread module is used to determine whether a transcoding operation is required after receiving a transcoding operation signal; if necessary, the data transcoding thread extracts a QCamera camera data packet from a preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread;
[0015] The data drawing thread module is used to determine whether data processing operation is required after receiving the data processing signal; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain the second image data packet, so as to obtain the processed data of the QCamera camera image data.
[0016] The present invention also provides a computer-readable storage medium, which stores computer instructions. When the computer is executed by a processor, the processing method based on QCamera camera image data as described in any of the above embodiments is implemented.
[0017] The present invention also provides an electronic device, comprising at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor so that the processor executes the processing method based on QCamera camera image data as described in any of the above embodiments.
[0018] Based on the above, compared with the prior art, the present invention provides a processing method based on QCamera camera image data, which integrates a data capture thread, a data transcoding thread and a data drawing thread in the Qt multi image framework, transmits the data to the data transcoding thread through the data capture thread for transcoding processing, and finally draws the data through the data drawing thread, which greatly shares the memory burden of the Qt multi image framework MCU and significantly improves the performance of secondary processing of camera raw data based on the Qt multi timed ia framework.
[0019] Other features and beneficial effects of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other beneficial effects of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The positional relationships described in the drawings in the following description are based on the directions in which the components are drawn in the diagrams, unless otherwise specified.
[0021] Figure 1 A flowchart of a method for processing image data based on a QCamera camera provided in Embodiment 1 of the present invention;
[0022] Figure 2 A structural block diagram of a QCamera camera image data processing device provided in Embodiment 2 of the present invention;
[0023] Figure 3 This is a structural block diagram of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments; the technical features designed in different implementation modes of the present invention described below can be combined with each other as long as they do not conflict with each other; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0025] In the description of the present invention, it should be noted that all terms used in the present invention (including technical terms and scientific terms) have the same meanings as those generally understood by ordinary technicians in the field to which the present invention belongs, and cannot be understood as limiting the present invention; it should be further understood that the terms used in the present invention should be understood to have the same meanings as these terms in the context of this specification and in the relevant fields, and should not be understood in an idealized or overly formal sense, unless explicitly defined in the present invention.
[0026] Embodiment 1
[0027] The present invention provides a method for processing image data based on QCamera. Figure 1 As shown, including:
[0028] S100, the data capture thread obtains the QCamera camera data packet and stores it in a preset location, and sends a transcoding operation signal to the data transcoding thread.
[0029] Specifically, the data capture thread uses the registration callback mechanism to obtain the QCamera camera data packet and stores the obtained QCamera camera data packet in the program running memory area. The data capture thread and the data transcoding thread communicate through the transcoding operation signal. Each time the data capture thread obtains a QCamera camera data packet, it sends a transcoding operation signal to the data transcoding thread (without synchronous blocking and waiting); when there is new data update, the data capture thread will trigger an asynchronous signal to notify the transcoding thread to process.
[0030] In specific implementation, when CPU resources are insufficient or the software is in the background, a shared queue cache mechanism is used to automatically discard data packets with a longer time distance to reduce latency and memory usage.
[0031] The latest QCamera data packet obtained in the data capture thread will be cached at the front of the shared queue. When the QCamera data packet in the shared queue reaches the preset cache data amount, the old QCamera data packet will be discarded from the end of the shared queue.
[0032] Preferably, the QCamera camera data packet is frame-by-frame camera images captured by the camera.
[0033] S200, after receiving the transcoding operation signal, the data transcoding thread determines whether a transcoding operation is required; if necessary, the data transcoding thread extracts the QCamera camera data packet from the preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread.
[0034] Specifically, the data transcoding thread converts the QCamera data packet in yuyv format into a first image data packet in RGB format. After receiving the transcoding operation signal, the data transcoding thread first determines whether a transcoding operation is required. If necessary, the QCamera data packet is extracted from the program running memory area to perform a transcoding operation to obtain a first image data packet. Preferably, the sending of the transcoding operation signal and the extraction of the QCamera data packet by the data transcoding thread do not need to be synchronized, and no blocking waiting will occur. When the first image data packet is generated, the data transcoding thread sends a data processing signal to the data drawing thread.
[0035] Preferably, if the environmental resources (CPU and memory) are sufficient, the number of queues in the cache will be maintained at 1 data packet; if the system resources are insufficient, the data packets in the shared queue will be adjusted between 1 and the preset cache data volume, thereby automatically realizing a mechanism for high-efficiency and low-latency data processing.
[0036] Preferably, the data transcoding thread copies at least one QCamera data packet from the end of the shared queue, the shared queue deletes the copied QCamera data packet, and the data transcoding thread transcodes the copied QCamera data packet, which ensures that data memory will not be wasted and improves the efficiency of system operation.
[0037] S300, after receiving the data processing signal, the data drawing thread determines whether a data processing operation is required; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain a second image data packet, so as to obtain the processed data of the QCamera camera image data.
[0038] Preferably, the data processing signal is a signal generated by the data drawing thread by sending a refresh interface signal or directly calling a processing function for updating the UI interface. The data transcoding thread triggers the data processing signal through the assembled Q Image object. Q Image is a memory object of Qt multimedia about image data. It is converted into Q Image for easy transmission and processing on the Qt multimedia platform. When the data drawing thread receives the data processing signal and needs to perform data processing, the data drawing thread draws the first image data packet to obtain the second image data packet.
[0039] The result of the secondary processing of the camera data is updated on the UI interface. If the background image is updated first and then the objects drawn on it are updated within a unit of time, the time difference in the updates will cause visual flickering. Therefore, all objects processed twice are first processed on the memory image and then updated once within a unit of time on the interface.
[0040] In specific implementation, the data drawing thread uses the UI double buffer mechanism to draw the first image data packet to obtain the second image data packet. The general principle of the double buffer drawing mechanism is "drawing various objects in the virtual screen in the memory and then copying them to the actual display screen to eliminate flicker", that is, the core drawing work is transferred to the outside of the screen, and when the screen is displayed, it is just a simple memory copy. Optionally, the memory of the second image data packet can be image processed; or a mask can be covered on the image of the second image data packet for image processing.
[0041] If real-time annotation operations are required for camera data, the scenario requires low latency and high fluency. If all operations are concentrated in the data drawing thread, i.e., the UI thread, it will cause serious jamming and high lag. The present invention uses the data capture thread to receive data, the data transcoding thread to transcode and assemble and process image objects, and the data drawing thread to receive user operations, such as drawing images with the mouse. At the same time, shared queue caching will be performed according to environmental resources, so as to achieve the goal of high efficiency and low latency.
[0042] Preferably, this embodiment integrates a data capture thread, a data transcoding thread and a data drawing thread in the Qt multimedia framework. When marking objects on a data stream with a pixel of 1920*1080 and a frame rate of 30 frames / s, the delay of the solution is less than 300ms, the fluency is high, and the memory occupied is within 120MB.
[0043] Embodiment 2
[0044] The present invention also provides a processing device based on QCamera camera image data, such as Figure 2 As shown, it includes: a data capture thread module, which is used to obtain the QCamera camera data packet and store it in a preset position, and send a transcoding operation signal to the data transcoding thread.
[0045] The data transcoding thread module is used to determine whether a transcoding operation is required after receiving a transcoding operation signal; if necessary, the data transcoding thread extracts the QCamera camera data packet from a preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread.
[0046] The data drawing thread module is used to determine whether data processing operation is required after receiving the data processing signal; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain the second image data packet, so as to obtain the processed data of the QCamera camera image data.
[0047] The device uses the Qt multimedia framework to integrate the data capture thread module, the data transcoding thread module and the data drawing thread module to complete the secondary processing of the camera data. The present invention is responsible for receiving data through the data capture thread module, the data transcoding thread module is responsible for transcoding and the assembly and processing of image objects, and the data drawing thread module is responsible for receiving user operations, such as drawing images through the mouse. At the same time, shared queue cache processing will be performed according to environmental resources, which can achieve the goal of high efficiency and low delay.
[0048] Embodiment 3
[0049] The present invention also provides a computer-readable storage medium, which stores computer instructions. When the computer is executed by a processor, a processing method based on QCamera camera image data as in any of the above embodiments is implemented.
[0050] In a specific implementation, the computer-readable storage medium is a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (Solid-State Drive, SSD), etc.; the computer-readable storage medium may also include a combination of the above-mentioned types of memory.
[0051] Embodiment 4
[0052] The present invention also provides an electronic device, such as Figure 3 As shown, it includes at least one processor and a memory connected to the processor in communication, wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the processor to execute a processing method based on QCamera camera image data as in any of the above embodiments.
[0053] In specific implementation, the number of processors may be one or more, and the processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned chips. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0054] The memory and the processor can be communicatively connected via a bus or other means. The memory stores instructions that can be executed by at least one processor. The instructions are executed by at least one processor so that the processor executes the processing method based on QCamera camera image data in the above embodiment.
[0055] In addition, those skilled in the art should understand that, although there are many problems in the prior art, each embodiment or technical solution of the present invention can be improved in only one or several aspects, without having to solve all the technical problems listed in the prior art or background technology at the same time. Those skilled in the art should understand that the content not mentioned in a claim should not be used as a limitation on the claim.
[0056] Although the terms such as data capture thread, QCamera camera data packet, data transcoding thread, first image data packet, data drawing thread and second image data packet are used more frequently in this article, the possibility of using other terms is not excluded. These terms are used only to more conveniently describe and explain the essence of the present invention; interpreting them as any additional restrictions is contrary to the spirit of the present invention; the terms "first", "second", etc. (if any) in the description and claims of the embodiments of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0057] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A processing method based on QCamera camera image data, It is characterized in that include: S100, the data capture thread obtains the QCamera camera data packet and stores it in a preset location, and sends a transcoding operation signal to the data transcoding thread; S200: After receiving a transcoding operation signal, the data transcoding thread determines whether a transcoding operation is required; If necessary, the data transcoding thread extracts the QCamera camera data packet from the preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread; S300, after receiving the data processing signal, the data drawing thread determines whether a data processing operation is required; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain a second image data packet, so as to obtain the processed data of the QCamera camera image data.
2. The method for processing image data based on QCamera according to claim 1, It is characterized in that The data capture thread uses a registration callback mechanism to obtain the QCamera camera data packet.
3. The method for processing image data based on QCamera according to claim 1, It is characterized in that The data capture thread stores the acquired QCamera data packet in the program running memory area, and the data transcoding thread extracts the QCamera data packet from the program running memory area for transcoding operation.
4. The method for processing image data based on QCamera according to claim 3, It is characterized in that The latest QCamera data packet obtained in the data capture thread will be cached at the front end of the shared queue. When the QCamera data packet in the shared queue reaches the preset cache data amount, the old QCamera data packet will be discarded from the end of the shared queue.
5. The method for processing image data based on QCamera according to claim 1, It is characterized in that The data transcoding thread converts the QCamera camera data packet in yuyv format into the first image data packet in RGB format.
6. The method for processing image data based on QCamera according to claim 4 or 5, It is characterized in that The data transcoding thread copies at least one of the QCamera camera data packets from the end of the shared queue, the shared queue deletes the copied QCamera camera data packet, and the data transcoding thread performs transcoding processing on the copied QCamera camera data packet.
7. The method for processing image data based on QCamera according to claim 1, It is characterized in that The data drawing thread uses a UI double buffer mechanism to draw the first image data packet to obtain the second image data packet.
8. A processing device based on QCamera camera image data, It is characterized in that include: The data capture thread module is used to obtain the QCamera camera data packet and store it in a preset location, and send a transcoding operation signal to the data transcoding thread; The data transcoding thread module is used to determine whether a transcoding operation is required after receiving a transcoding operation signal; If necessary, the data transcoding thread extracts the QCamera camera data packet from the preset position to perform a transcoding operation to obtain a first image data packet, and sends a data processing signal to the data drawing thread; The data drawing thread module is used to determine whether a data processing operation is required after receiving a data processing signal; if necessary, the first image data packet is transmitted to the data drawing thread for drawing to obtain a second image data packet, so as to obtain the processed data of the QCamera camera image data.
9. A computer-readable storage medium, Features: The computer-readable storage medium stores computer instructions, and when the computer is executed by a processor, the processing method based on QCamera camera image data according to any one of claims 1 to 7 is implemented.
10. An electronic device, Features: It includes at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor so that the processor executes the processing method based on QCamera camera image data as described in any one of claims 1-7.
Citation Information
Patent Citations
Transcoding control method and device and electronic equipment
CN112543373A
Graph drawing processing method and device based on multiple threads
CN115456859A
Shared camera control method and system, conference terminal and readable medium
CN116320262A
Image annotation method and system based on canvas
CN116433882A
Method for adjusting color temperature of display screen, electronic equipment and related medium
CN117995137A
