UVC camera multi-format coding and decoding method and system based on open source gap

By obtaining and filtering the video output formats supported by UVC cameras, and combining the hardware codec collaborative architecture, the problem that UVC cameras cannot adaptive codec is solved, and multi-format codec is realized, which improves data processing efficiency and compatibility.

CN120263972APending Publication Date: 2025-07-04UNIONMANTECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510468720.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The existing UVC camera encoding and decoding methods based on open source Hongmeng cannot effectively support adaptive encoding and decoding in multiple video output formats, resulting in low data processing efficiency and low compatibility.

Method used

Through the open source Hongmeng video device driver framework, all video output formats supported by the target UVC camera are obtained, the optimal video output format is filtered out, and the resolution and frame rate are combined. Dynamic format negotiation is achieved using the hardware encoding and codec architecture, and the encoding and decoding of multiple video output formats is supported.

Benefits of technology

It significantly improves data processing efficiency, improves compatibility and scalability of UVC cameras, and reduces data output latency and CPU occupancy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120263972A_ABST
    Figure CN120263972A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of video processing, and discloses a UVC camera multi-format encoding and decoding method and system based on an open source gap. Comprising the following steps: acquiring all video output formats supported by a target UVC camera based on a video equipment driving framework of an open source gap; screening the video output formats according to a preset adaptive strategy, determining an optimal video output format, and determining an optimal video output format; combining and screening all resolutions and frame rates supported by the optimal video output format, and determining an optimal resolution and frame rate combination; starting a target UVC camera based on the combination of the optimal resolution and the frame rate to obtain a to-be-processed video stream; and performing format conversion on the to-be-processed video stream, and outputting a video stream in a target format. According to the invention, the coding and decoding of various video output formats can be supported, the data processing efficiency can be effectively improved, and the compatibility and expandability of the UVC camera can be obviously and effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video processing, and particularly to a multi-format encoding and decoding method and system for a UVC camera based on OpenHarmony. Background Art

[0002] Currently, the video device management module V4L2DeviceManager of the native OpenHarmony system can only fill the resolutions and frame rates supported by the YUYV422 format into the metadata of the UVC camera, but cannot support the data filling of other video output formats (such as MJPEG or H.264). This makes the data formats supported by the UVC camera for display single, and it is impossible to adaptively adjust the data output format according to factors such as the device hardware capabilities, application scenario requirements, the size of the video data volume, or the system load, resulting in low data processing efficiency, as well as low compatibility and expandability of the UVC camera.

[0003] It can be seen that the existing encoding and decoding methods for UVC cameras based on OpenHarmony have the problem of single supported video output formats, resulting in the inability to effectively support the adaptive encoding and decoding of multiple video output formats. Summary of the Invention

[0004] The purpose of the present invention is to overcome the problem that the existing encoding and decoding methods for UVC cameras based on OpenHarmony cannot effectively support the adaptive encoding and decoding of multiple video output formats, and provide a multi-format encoding and decoding method and system for a UVC camera based on OpenHarmony.

[0005] To achieve the above purpose, on the one hand, the present invention provides a multi-format encoding and decoding method for a UVC camera based on OpenHarmony, mainly including:

[0006] Based on the video device driver framework of OpenHarmony, obtain all video output formats supported by the target UVC camera;

[0007] Filter the video output formats according to a preset adaptive strategy to determine the optimal video output format;

[0008] Combine and filter all resolutions and frame rates supported by the optimal video output format to determine the preferred resolution and frame rate combination;

[0009] Turn on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination to obtain the video stream to be processed;

[0010] Convert the format of the video stream to be processed and output the video stream in the target format.

[0011] Optionally, screening the video output formats according to a preset adaptive strategy to determine the optimal video output format includes:

[0012] Obtaining the compression ratio of each video output format and setting the weight of each video output format based on the compression ratio;

[0013] Screening the video output formats based on the weights to determine the optimal video output format.

[0014] Optionally, combining and screening all the resolutions and frame rates supported by the optimal video output format to determine the preferred resolution and frame rate combination includes:

[0015] Combining all the resolutions and frame rates corresponding to the optimal video output format to obtain several resolution and frame rate combinations;

[0016] Filling all the resolution and frame rate combinations into the metadata of the target UVC camera and screening to determine the preferred resolution and frame rate combination.

[0017] Optionally, turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination to obtain the video stream to be processed includes:

[0018] Creating a session of the target UVC camera and turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination;

[0019] Transmitting the optimal video output format to the device node of the UVC driver so that the target UVC camera outputs a series of image frames in the optimal video output format as the video stream to be processed.

[0020] Optionally, converting the format of the video stream to be processed to output a video stream in the target format includes:

[0021] Using a preset decoding node to convert the format of the video stream to be processed based on the optimal video output format and the preset target video output format to output a video stream in the target format.

[0022] Optionally, after outputting the video stream in the target format, it further includes:

[0023] Invoking the current service type of the target UVC camera;

[0024] Converting the video stream in the target format to the data format corresponding to the current service type based on the data formats corresponding to the preset service types.

[0025] Optionally, it further includes: constructing a preset decoding node;

[0026] The construction process of the preset decoding node includes:

[0027] Add a video decoding node in the source code describing the pipeline task of the UVC camera in the configuration description file of the HDF driver framework of the OpenHarmony system as the preset decoding node.

[0028] The second aspect of the present invention provides a multi-format encoding and decoding system for a UVC camera based on OpenHarmony, mainly including:

[0029] A video output format acquisition module, configured to obtain all video output formats supported by a target UVC camera based on the video device driver framework of OpenHarmony;

[0030] An optimal video output format screening module, configured to screen the video output formats according to a preset adaptive strategy to determine the optimal video output format;

[0031] A resolution and frame rate screening module, configured to combine and screen all resolutions and frame rates supported by the optimal video output format to determine a preferred resolution and frame rate combination;

[0032] A video stream acquisition module, configured to turn on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination to obtain a video stream to be processed;

[0033] A video stream format conversion module, configured to perform target format conversion on the video stream to be processed and output a video stream in the target format.

[0034] The third aspect of the present invention provides an electronic device, where the electronic device includes a memory for storing executable instructions; and a processor for calling and running the executable instructions in the memory to execute the steps of the above-mentioned multi-format encoding and decoding method for a UVC camera based on OpenHarmony.

[0035] The fourth aspect of the present invention provides a computer-readable storage medium, where program instructions are stored in the computer-readable storage medium, and when the program instructions are run by a processor, the steps of the above-mentioned multi-format encoding and decoding method for a UVC camera based on OpenHarmony are implemented.

[0036] Compared with the prior art, the beneficial effects of this solution are as follows:

[0037] Based on the video device driver framework of OpenHarmony, the present invention obtains all video output formats supported by the target UVC camera, and screens the video output formats that can support multiple compression formats as the optimal video output format, realizes a dynamic format negotiation mechanism, can support the encoding and decoding of multiple video output formats, can effectively improve the data processing efficiency, and significantly improves the compatibility and scalability of the UVC camera.

[0038] Other features and advantages of the embodiments of the present invention will be described in detail in the following detailed implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention, and constitute a part of the specification. Together with the following detailed implementation, they are used to explain the embodiments of the present invention, but do not constitute a limitation to the embodiments of the present invention. In the accompanying drawings:

[0040] Figure 1 is the overall code timing diagram of the native open-source HarmonyOS;

[0041] Figure 2 is the processing timing of the pipeline task of the native open-source HarmonyOS;

[0042] Figure 3 is the flowchart of the multi-format encoding and decoding method of the UVC camera based on the open-source HarmonyOS of the present invention;

[0043] Figure 4 is the optimized timing diagram of the multi-format encoding and decoding method of the UVC camera based on the open-source HarmonyOS of the present invention;

[0044] Figure 5 is the schematic diagram of the system module of the multi-format encoding and decoding system of the UVC camera based on the open-source HarmonyOS of the present invention;

[0045] Figure 6 is the schematic diagram of the electronic device structure of the present invention. DETAILED IMPLEMENTATION

[0046] The following combines the accompanying drawings of 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 a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present invention.

[0047] Many specific details are set forth in the following description in order to fully understand the present invention, but the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.

[0048] In the face of the problem that the encoding and decoding methods of UVC cameras in the prior art cannot effectively support the adaptive encoding and decoding of multiple video output formats, in Figure 1Based on the overall code timing diagram of the native open-source HarmonyOS, on the basis of the overall process of video data transmission, encoding, and decoding of the UVC camera described therein, by Figure 2 As can be seen from the processing timing of the pipeline task (pipeline) of the native open-source HarmonyOS shown in Figure 2 , through the video device management module V4L2DeviceManager of the native open-source HarmonyOS, only the resolution and frame rate supported by the YUYV422 format can be filled into the metadata of the UVC camera, and it is impossible to support data filling of other video output formats (such as MJPEG or H.264); on the uvc_node node in the UVC driver framework, the YUYV422 format is converted to the YUV420 format by using software transcoding, and then the YUV420 format data is passed to the rk_codec_node node, the YUV420 format is converted to the RGBA8888 format, and finally the video stream in the RGBA8888 format is output to the display module for display.

[0049] It can be seen that the current native open-source HarmonyOS only supports the input of UVC cameras in the YUYV422 format, and it is impossible to support data filling of other video output formats (such as MJPEG or H.264), making the data format supported by the UVC camera for display single, unable to adaptively adjust the data output format according to factors such as device hardware capabilities, application scenario requirements, the size of video data volume, or system load, resulting in low data processing efficiency, as well as low compatibility and scalability of the UVC camera.

[0050] Based on this, the present invention proposes a multi-format encoding and decoding method and system for a UVC camera based on open-source HarmonyOS, mainly including: based on the video device driver framework of open-source HarmonyOS, obtaining all video output formats supported by the target UVC camera, and screening the optimal video output formats that support compression formats such as H.264 and MJPEG, implementing a dynamic format negotiation mechanism, and being able to dynamically adjust the output format according to device capabilities, so as to support the encoding and decoding of multiple video output formats; by creating device nodes related to the hardware codec of Rockchip, the deep integration of the open-source HarmonyOS and the Rockchip chip hardware decoder is realized, thus realizing a hardware encoding and decoding collaborative architecture, only requiring one execution of video data format conversion, which can significantly reduce the data output delay and effectively reduce the CPU occupancy, thereby helping to significantly improve the compatibility and scalability of the UVC camera.

[0051] Please refer to Figure 3 and Figure 4 , an embodiment of the present invention proposes a multi-format encoding and decoding method for a UVC camera based on open-source HarmonyOS, including:

[0052] Step 100: Based on the video device driver framework of OpenHarmony, obtain all video output formats supported by the target UVC camera.

[0053] Specifically, after opening the target UVC camera (i.e., the target UVC camera) based on the camera framework of OpenHarmony, use the video device management module V4L2DeviceManager in the V4L2 (Video4Linux2) adaptation layer of the video device driver framework provided by the Linux kernel to obtain the image formats supported by the UVC camera. Specifically, the VIDIOC_ENUM_FMT command can be used to execute, and all video output formats supported by the target camera can be obtained. The video output formats include H.264, MJPEG, NV12, and YUV420, etc. Among them, H.264 is an efficient video compression standard, which belongs to lossy compression and is suitable for real-time video transmission (such as video conferencing, streaming media); MJPEG is a video output format with frame-by-frame compression, where each frame is an independent JPEG image without inter-frame compression and is suitable for static scenes; YUV420 is a planar format that stores Y, U, and V separately, facilitating separate adjustment of chrominance and is suitable for scenarios such as image processing and software processing; NV12 is a semi-planar variant of YUV420 with an interleaved UV layout, which occupies less memory bandwidth and is suitable for hardware acceleration, mobile devices, i.e., low-latency scenarios.

[0054] Step 200: Screen the video output formats according to a preset adaptive strategy to determine the optimal video output format.

[0055] Specifically, after the V4L2 adaptation layer obtains all video output formats supported by the target camera, construct an adaptive strategy based on the specific application scenario and the performance of each video output format, so as to select an optimal video output format that can exhibit good performance in the target application scenario.

[0056] In a preferred embodiment, screening the video output formats according to a preset adaptive strategy in Step 200 to determine the optimal video output format includes:

[0057] Step 210: Obtain the compression ratio of each video output format and set the weight of each video output format based on the compression ratio;

[0058] Step 220: Screen the video output formats based on the weight to determine the optimal video output format.

[0059] Specifically, for the target application scenario and the compression ratio of each video output format, a weight value is set for each video output format, and then the video output format with the largest weight value is selected. For example, the weight value of the corresponding video output format is increased in the order of increasing compression ratio, and then the video output format with the largest weight value is selected, that is, the video output format with the highest compression ratio. By selecting the video output format with a high compression ratio in this embodiment, the bandwidth occupied during input can be reduced, and at the same time, the size of the video data will be reduced. The reduction in the size of the video data can reduce the system load.

[0060] It should be noted that as other preferred embodiments, factors such as compression format characteristics, hardware capabilities, application scenario requirements, bandwidth size, the size of video data volume, and system load can be comprehensively considered to select a suitable video output format, which is not limited to the video output format corresponding to the highest compression ratio selected in this embodiment.

[0061] Step 300: Combine and filter all the resolutions and frame rates supported by the optimal video output format to determine the preferred resolution and frame rate combination.

[0062] Specifically, the camera bitrate refers to the compressed camera video data stream and is an important indicator for measuring the quality of the output video encoded picture. Considering that under the same resolution and frame rate conditions, the larger the video bitrate, the higher the quality of the presented picture, and at the same time, the corresponding memory required will also increase. And the video bitrate can be expressed as the product of resolution, frame rate, and compression ratio, and also as the ratio of video size to duration. Among them, the resolution determines the size of the monitoring picture, and the frame rate represents the number of data pictures transmitted per second, which is used to reflect the continuity and real-time nature of the video. Then, if a high-quality video picture is to be output, under the condition that the optimal video output format is determined, the resolutions and frame rates supported by the optimal video output format can be combined, and the combination with the largest product of resolution and frame rate is selected as the preferred resolution and frame rate combination.

[0063] In a preferred embodiment, the combining and filtering of all the resolutions and frame rates supported by the optimal video output format in step 300 to determine the preferred resolution and frame rate combination includes:

[0064] Combine all the resolutions and frame rates corresponding to the optimal video output format to obtain several resolution and frame rate combinations;

[0065] Fill all the resolution and frame rate combinations into the metadata of the target UVC camera and filter to determine the preferred resolution and frame rate combination.

[0066] Specifically, considering that the metadata of the UVC camera covers the full-link information of device description attributes, video stream parameters, and real-time control, which is the key data for optimizing video processing, device compatibility, and function expansion. In this embodiment, all resolutions and frame rates supported by the optimal video output format are combined through the V4L2 adaptation layer to obtain several combinations of resolution and frame rate; all combinations of resolution and frame rate are filled into the metadata of the target UVC camera respectively; and the combinations of resolution and frame rate are screened according to actual application requirements such as device hardware capabilities, application scenario requirements, the size of video data volume, or system load, so as to determine the preferred combination of resolution and frame rate, so as to collect the video stream using the preferred resolution and frame rate corresponding to the optimal video output format subsequently.

[0067] Step 400: Turn on the target UVC camera according to the resolution and frame rate corresponding to the preferred combination of resolution and frame rate, and obtain the video stream to be processed.

[0068] Specifically, before using services such as preview, taking pictures, and recording videos with the UVC camera, it is necessary to create a camera session to configure the input stream and output stream of the camera before using the UVC camera to take pictures. Configuring the input stream, that is, adding device input, is equivalent to selecting the camera for shooting; configuring the output stream, that is, selecting the data output format.

[0069] Based on this, in this embodiment, a session of the target UVC camera is created, and the target UVC camera is turned on according to the resolution and frame rate corresponding to the preferred combination of resolution and frame rate; the optimal video output format is transmitted to the device node of the UVC driver, so that the target UVC camera can output a series of image frames in the optimal video output format as the video stream to be processed. Specifically, it includes: creating a session of the target UVC camera based on a HarmonyOS application (i.e., an installation package format (HarmonyAbilityPackage, HAP) application of an open-source HarmonyOS application), reading the camera metadata to obtain the supported resolution and frame rate, and turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred combination of resolution and frame rate; passing the optimal video output format to the uvc_node node in the UVC driver framework, and setting the target UVC camera to output a series of image frames in the optimal video output format as the video stream to be processed. Among them, the uvc_node node refers to the device node of the UVC driver, which is the interface for the application program to interact with the kernel UVC driver.

[0070] It is easy to understand that since the video output format supported by the target UVC camera is unknown, the video data format output by the target UVC camera through the uvc_node node may be an uncompressed raw video output format or a video output format compressed by H.264 / MJPEG. Therefore, the video stream to be processed output by the target UVC camera may be an uncompressed raw video output format or a compressed video output format.

[0071] This embodiment realizes the automatic configuration of the camera output format by transmitting the selected optimal format to the uvc_node node, and realizes the dynamic format negotiation mechanism.

[0072] Step 500: Perform format conversion on the video stream to be processed and output a video stream in the target format.

[0073] Specifically, considering that the native open-source HarmonyOS does not support directly displaying compressed video output formats on the display, this embodiment first adds a video decoding node as a preset decoding node in the source code describing the pipeline task of the UVC camera based on the HDF driver framework of the open-source HarmonyOS to ensure that the output video format can be directly output and displayed. Then, the video stream to be processed and the optimal video output format are both transmitted to the preset decoding node, and based on the optimal video output format and the preset target video output format, the preset decoding node is used to perform format conversion on the video stream to be processed and output a video stream in the target format. It is easy to understand that since those skilled in the art know the data formats supported by the display, the target video output format preset in this embodiment refers to one of the data formats that can be directly displayed on the display. This embodiment does not make specific limitations on the preset target video output format, and all data formats that can be directly displayed on the display are within the protection scope of the present invention.

[0074] As an exemplary example, based on the HDF driver framework of the open-source HarmonyOS for Rockchip chips, a device node rk_decode_node related to the Rockchip hardware codec is added as a preset decoding node in the source code describing the pipeline task of the UVC camera in the configuration description file (HDF Configuration Source, HCS) of this framework. Then, the video stream to be processed and the optimal video output format are both transmitted to the preset decoding node. The preset decoding node determines the output format of the current frame according to the optimal video output format and realizes hardware-accelerated video decoding by calling the Rockchip hardware decoding unit.

[0075] Since the video stream to be processed output by the target UVC camera may be in an uncompressed raw video output format or a compressed video output format, that is, the format of the video stream to be processed is not unique. Also, in this embodiment, by creating an rk_decodec_node node, the hardware decoder of the target UVC camera and the Rockchip chip is deeply integrated, and hardware decoding of H.264 or MJPEG is supported through the rk_decodec_node node. Therefore, in this embodiment, video streams to be processed in different formats can be uniformly transcoded into a preset target video output format on the rk_decodec_node node, that is, during the entire output transmission process, only one format conversion process needs to be performed on the newly added device node rk_decode_node related to the Rockchip hardware codec to obtain a data format that can be directly transmitted to the display module for display, reducing the number of transcoding times and reducing the system load, thereby being beneficial to improving system performance.

[0076] The following details the video output format conversion optimization path supported by the method of the present invention for video streams to be processed in different formats, specifically as follows:

[0077] Based on the camera session created by the HAP application, the optimal video output format is passed to the uvc_node node in the UVC driver framework. If the format of the video stream to be processed output is YUYV422, the YUYV422 format can be converted to the YUV420 format through the rk_decodec_node node; if the format of the video stream to be processed output is a video output format compressed by H.264 / MJPEG, the compressed video output format can also be converted to the YUV420 format through the rk_decodec_node node.

[0078] Among them, YUYV422 (also known as YUY2 or YUV422) is an uncompressed raw video output format and belongs to the pixel arrangement method in the YUV color space; YUV420 (also known as NV12 or I420) is a subsampling format in the YUV color space and belongs to the mainstream video compression storage format. It can be seen that in this example, by constructing an rk_decodec_node node, a hardware codec collaborative processing architecture is realized, which can support hardware decoding of H.264 and MJPEG, thereby effectively reducing the decoding delay and being compatible with mainstream UVC camera devices, significantly enhancing device compatibility.

[0079] In a preferred embodiment, after the video stream in the target format is output in step 500, step 600 is included, specifically:

[0080] The video stream in the target format (such as YUV420sp format) is transmitted through the rk_codec_node node to the display for preview display, without performing data format conversion at the rk_codec_node node, which helps to reduce the system performance overhead and lower the picture latency.

[0081] Experiments show that the method of the present invention realizes the conversion of the data format of the camera output from the uncompressed image format RGBA8888 in the RGB color space to the video compression storage format YUV420SP in the YUV color space, avoiding the traditional transcoding operation twice in the data conversion mode of YUYV→YUV420→RGBA. The CPU occupancy rate is reduced by 15%-20%, which shows that the performance overhead is effectively reduced and the picture latency is lowered.

[0082] In a preferred embodiment, after the video stream in the target format is output in step 500, step 700 is further included, specifically:

[0083] Step 710: Invoke the current service type of the target UVC camera;

[0084] Step 720: Based on the data formats corresponding to each preset service type, convert the video stream in the target format into the data format corresponding to the current service type.

[0085] Specifically, the data formats corresponding to the service types supported by the target UVC camera are pre-configured, where the service types include but are not limited to preview, taking pictures, and video recording. Then, based on the HarmonyOS application (i.e., HAP application), any one of the service types supported by the target UVC camera, such as preview, taking pictures, and video recording, is invoked as the current service type, and the video stream in the target format is converted into the data format corresponding to the current service type, thereby effectively improving the diversity and real-time performance of the data format output by the UVC camera.

[0086] For example, when taking pictures is triggered through the HAP application, the video stream in the target format (such as YUV420sp format) is transcoded into the.jpeg format and saved to disk; when video recording is triggered through the HAP application, the video stream in the target format (such as YUV420sp format) is transcoded into the H.264 format and saved to disk.

[0087] In summary, the beneficial effects of the method of the present invention mainly include:

[0088] The video device driver framework V4L2 of the present invention based on the open-source HarmonyOS adaptively selects a video output format for the UVC camera to effectively support the adaptive encoding and decoding of multiple video output formats, and can dynamically configure parameters such as resolution and frame rate, thereby implementing a dynamic format negotiation mechanism. At the same time, by adding a device node rk_decodec_node related to the hardware codec of Rockchip, the deep integration of the open-source HarmonyOS and the Rockchip chip hardware decoder is realized, thereby implementing a hardware encoding and decoding collaborative architecture, and only one format conversion process needs to be performed at the rk_decodec_node node to obtain a data format that can be directly transmitted to the display module for display, which can significantly reduce the data output latency and improve the utilization rate of computing resources. Through the collaborative optimization of software and hardware, the UVC camera based on the open-source HarmonyOS supports the encoding and decoding of multiple video output formats such as YUYV, MJPEG, NV12, and H264, significantly improving the diversity and scalability of the output data format, and effectively enhancing the compatibility of the UVC camera.

[0089] Please refer to Figure 5 , the present invention provides a multi-format encoding and decoding system for a UVC camera based on the open-source HarmonyOS, including:

[0090] A video output format acquisition module 510, configured to obtain all video output formats supported by a target UVC camera based on the video device driver framework of the open-source HarmonyOS;

[0091] An optimal video output format screening module 520, configured to screen the video output formats according to a preset adaptive strategy to determine an optimal video output format;

[0092] A resolution and frame rate screening module 530, configured to combine and screen all resolutions and frame rates supported by the optimal video output format to determine an optimal resolution and frame rate combination;

[0093] A video stream acquisition module 540, configured to turn on the target UVC camera according to the resolution and frame rate corresponding to the optimal resolution and frame rate combination to obtain a video stream to be processed;

[0094] A video stream format conversion module 550, configured to perform target format conversion on the video stream to be processed and output a video stream in the target format.

[0095] Specifically, in this embodiment, the specific functions of the above multi-format encoding and decoding system for a UVC camera based on the open-source HarmonyOS can also refer to the corresponding descriptions in the above multi-format encoding and decoding method for a UVC camera based on the open-source HarmonyOS, which will not be elaborated here.

[0096] Based on the above embodiments, the present invention also provides an electronic device, and its principle block diagram can be asFigure 6 As shown in the figure. This electronic device can be used to execute the multi-format encoding and decoding method of the UVC camera based on OpenHarmony provided in the above embodiments. For the sake of brevity, it will not be elaborated here. This electronic device includes: a processor, the processor is coupled with a memory, the memory is used to store computer programs or instructions, and the processor is used to execute the computer programs or instructions stored in the memory, so that the method in the above method embodiments is executed.

[0097] The present invention also provides a computer-readable storage medium, on which computer instructions for implementing the method in the above method embodiments are stored.

[0098] For example, when the computer program is executed by a computer, the computer can implement the method in the above method embodiments.

[0099] The embodiments of the present application also provide a computer program product containing instructions, and when the instructions are executed by a computer, the computer implements the method in the above method embodiments.

[0100] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0101] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated here.

[0102] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be in an electrical, mechanical or other form.

[0103] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0104] In addition, each functional unit in various embodiments of the present application may be integrated in a processing unit, may exist separately as individual physical units, or two or more units may be integrated in one unit.

[0105] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

Claims

1. A multi-format encoding and decoding method for UVC cameras based on OpenHarmony, characterized in that The method includes: Based on the video device driver framework of OpenHarmony, obtaining all video output formats supported by the target UVC camera; Screening the video output formats according to a preset adaptive strategy to determine the optimal video output format; Combining and screening all resolutions and frame rates supported by the optimal video output format to determine the preferred resolution and frame rate combination; Turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination to obtain a video stream to be processed; Performing format conversion on the video stream to be processed and outputting a video stream in the target format.

2. The multi-format encoding and decoding method of the UVC camera based on OpenHarmony according to claim 1, wherein, The screening the video output formats according to a preset adaptive strategy to determine the optimal video output format includes: Obtaining the compression ratio of each video output format and setting the weight of each video output format based on the compression ratio; Screening the video output formats based on the weight to determine the optimal video output format.

3. The multi-format encoding and decoding method of the UVC camera based on OpenHarmony according to claim 1, wherein The combining and screening all resolutions and frame rates supported by the optimal video output format to determine the preferred resolution and frame rate combination includes: Combining all resolutions and frame rates corresponding to the optimal video output format to obtain several resolution and frame rate combinations; Filling all the resolution and frame rate combinations into the metadata of the target UVC camera and screening to determine the preferred resolution and frame rate combination.

4. The multi-format encoding and decoding method of a UVC camera based on OpenHarmony according to claim 1, characterized in that, The turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination to obtain a video stream to be processed includes: Creating a session of the target UVC camera and turning on the target UVC camera according to the resolution and frame rate corresponding to the preferred resolution and frame rate combination; Transmitting the optimal video output format to the device node of the UVC driver so that the target UVC camera outputs a series of image frames in the optimal video output format as the video stream to be processed.

5. The multi-format encoding and decoding method of a UVC camera based on OpenHarmony according to claim 1, characterized in that The performing format conversion on the video stream to be processed and outputting a video stream in the target format includes: Using a preset decoding node to perform format conversion on the video stream to be processed based on the optimal video output format and the preset target video output format, and outputting a video stream in the target format.

6. The multi-format encoding and decoding method for a UVC camera based on OpenHarmony according to any one of claims 1-5, characterized in that After outputting the video stream in the target format, it further includes: Invoking the current service type of the target UVC camera; Converting the video stream in the target format into the data format corresponding to the current service type based on the data formats corresponding to the preset service types.

7. The multi-format encoding and decoding method of the UVC camera based on OpenHarmony according to claim 5, characterized in that, It further includes: Constructing a preset decoding node; The construction process of the preset decoding node includes: Adding a video decoding node to the source code describing the pipeline task of the UVC camera in the configuration description file of the HDF driver framework in the OpenHarmony system as the preset decoding node.

8. A multi-format encoding and decoding system for UVC cameras based on OpenHarmony, characterized in that, It includes: A video output format acquisition module for obtaining all video output formats supported by the target UVC camera based on the video device driver framework of OpenHarmony; An optimal video output format screening module for screening the video output formats according to a preset adaptive strategy to determine the optimal video output format; A resolution and frame rate screening module, which is used to combine and screen all resolutions and frame rates supported by the optimal video output format to determine an optimal resolution and frame rate combination; A video stream acquisition module, which is used to turn on a target UVC camera according to the resolution and frame rate corresponding to the optimal resolution and frame rate combination to obtain a video stream to be processed; A video stream format conversion module, which is used to perform target format conversion on the video stream to be processed and output a video stream in the target format.

9. An electronic device, characterized in that, It includes: A memory, which is used to store executable instructions; A processor, which is used to call and run the executable instructions in the memory to execute the steps of the multi-format encoding and decoding method of the UVC camera based on OpenHarmony as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, Program instructions are stored in the computer-readable storage medium. When the program instructions are run by the processor, the steps of the multi-format encoding and decoding method of the UVC camera based on OpenHarmony as described in any one of claims 1-7 are implemented.