A camera preview method, system and related device based on OpenHarmony lightweight system

Through the collaborative work of the integrated development framework and underlying threads, the camera preview interface is parsed and refreshed, which solves the problem that the OpenHarmony lightweight system cannot support the camera function, achieves smooth and efficient camera preview, and improves system performance and user experience.

CN118210507BActive Publication Date: 2024-08-23SHENZHEN XINGUODU TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410620448.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-08-23
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

The OpenHarmony lightweight system cannot support functions such as camera display preview, code scanning, and photo taking, resulting in limited system ecology and inconvenience to users.

Method used

The integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphics component. The underlying thread calls the camera driver interface to obtain camera data, fills and refreshes the image in the display window, and supports data format conversion and scaling. Enable smooth and efficient camera preview.

Benefits of technology

While maintaining low power consumption and high response speed, the performance of the OpenHarmony lightweight system in image processing and display has been significantly improved, the functionality has been improved, and the user experience has been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118210507B
    Figure CN118210507B
Patent Text Reader

Abstract

The present application discloses a camera preview method, system and related device based on the OpenHarmony lightweight system, which is used to provide a smooth and efficient camera preview function on the OpenHarmony lightweight system. The present application method includes: the integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphic component; the graphic component generates a display window based on the preview parameters, and passes the display data storage address of the display window to the underlying thread; the underlying thread calls the camera driver interface to obtain camera data; the underlying thread writes the camera data to the display data storage address; the underlying thread refreshes the display window.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of system data processing, and in particular to a camera preview method, system and related devices based on the OpenHarmony lightweight system. Background Art

[0002] The OpenHarmony system is an open-source, all-scenario distributed system that is applicable to a variety of scenarios, including mobile communications, smart homes, wearable devices, and vehicle systems. OpenHarmony is divided into three types: lightweight systems, small systems, and standard systems. The OpenHarmony lightweight system is a version designed specifically for low-power, low-resource devices. This lightweight system is suitable for many lightweight devices and can provide stable system operation and intelligent functions in resource-constrained environments.

[0003] Compared with the full-featured system, the OpenHarmony lightweight system has been appropriately simplified in terms of functions, removing some non-essential services and components to adapt to the performance and storage limitations of lightweight devices. Currently, the OpenHarmony lightweight system cannot support various camera-related functions such as camera display preview, code scanning, and photo taking, which limits the system ecology and brings inconvenience to users. Summary of the invention

[0004] The present application provides a camera preview method, system and related devices based on the OpenHarmony lightweight system, which are used to provide a smooth and efficient camera preview function on the OpenHarmony lightweight system.

[0005] The first aspect of the present application provides a camera preview method based on the OpenHarmony lightweight system, the method comprising:

[0006] The integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphic component;

[0007] The graphic component generates a display window based on the preview parameters, and transmits the display data storage address of the display window to the underlying thread;

[0008] The bottom thread calls the camera driver interface to obtain camera data;

[0009] The bottom thread writes the camera data into the display data storage address;

[0010] The bottom layer thread refreshes the display window.

[0011] Optionally, after the bottom thread calls the camera driver interface to obtain camera data, the method further includes:

[0012] The bottom thread uses a table lookup algorithm to convert the camera data from YUV format to RGB format.

[0013] Optionally, the bottom thread uses a table lookup algorithm to convert the camera data from a YUV format to an RGB format, including:

[0014] The bottom thread obtains a preset table, in which the intermediate calculation results of the conversion process are pre-stored;

[0015] The bottom thread determines the target intermediate calculation result corresponding to the camera data based on the preset table;

[0016] The bottom thread converts the camera data from a YUV format to an RGB format according to the target intermediate calculation result.

[0017] Optionally, the graphic component generates a display window based on the preview parameter, and transmits a storage address of display data of the display window to an underlying thread, including:

[0018] The graphic component generates a display window based on the preview parameters, and transmits the display data storage address of the display window and the size of the display window to the underlying thread;

[0019] After the bottom thread calls the camera driver interface to obtain camera data, the method further includes:

[0020] The bottom thread scales the camera data according to the size of the display window.

[0021] Optionally, after the bottom thread calls the camera driver interface to obtain camera data, the method further includes:

[0022] The bottom thread stores the camera data alternately in a preset position using double buffering.

[0023] Optionally, after the bottom thread calls the camera driver interface to obtain camera data, the method further includes:

[0024] The bottom thread decodes the camera data;

[0025] The JS application reads the decoding result of the camera data through the JSI interface polling, and displays the read decoding result in the preview interface.

[0026] Optionally, the preview parameters include: the starting coordinates of the display window and the width and height of the display window.

[0027] The second aspect of the present application provides a camera preview system based on the OpenHarmony lightweight system, including: an integrated development framework, a graphics component, an underlying thread, and a camera;

[0028] The integrated development framework is used to parse the layout information of the preview interface in the JS application, generate preview parameters and pass them to the graphic component;

[0029] The graphic component is used to generate a display window based on the preview parameters, and transmit the display data storage address of the display window to the bottom thread;

[0030] The bottom thread is used to call the camera driver interface to obtain camera data; write the camera data into the display data storage address; and refresh the preview interface.

[0031] Optionally, the bottom layer thread is specifically used for:

[0032] The camera data is converted from YUV format to RGB format using a table lookup algorithm.

[0033] Optionally, the bottom layer thread is specifically used for:

[0034] Obtaining a preset table in which intermediate calculation results of the conversion process are pre-stored;

[0035] Determine the target intermediate calculation result corresponding to the camera data based on the preset table;

[0036] The camera data is converted from a YUV format to an RGB format according to the target intermediate calculation result.

[0037] Optionally, the graphic component is specifically used for:

[0038] Generate a display window based on the preview parameters, and pass the display data storage address of the display window and the size of the display window to the bottom thread;

[0039] The bottom thread is specifically used for:

[0040] The camera data is scaled according to the size of the display window.

[0041] Optionally, the bottom layer thread is further used for:

[0042] The camera data is stored alternately in a preset position using double buffering.

[0043] Optionally, the bottom layer thread is further used for:

[0044] Decoding the camera data;

[0045] The JS application is used to poll and read the decoding result of the camera data through the JSI interface, and display the read decoding result in the preview interface.

[0046] The third aspect of the present application provides a camera preview device based on the OpenHarmony lightweight system, the device comprising:

[0047] Processor, memory, input-output unit, and bus;

[0048] The processor is connected to the memory, the input and output unit, and the bus;

[0049] The memory stores a program, and the processor calls the program to execute the first aspect and any optional camera preview method based on the OpenHarmony lightweight system in the first aspect.

[0050] The fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional camera preview method based on the OpenHarmony lightweight system in the first aspect.

[0051] It can be seen from the above technical solutions that this application has the following advantages:

[0052] The integrated development framework effectively parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphics component, then uses the graphics component to generate a display window based on the preview parameters, and then obtains the camera data through the camera driver interface in the underlying thread, and accurately fills the preview image in the display window in combination with the display data storage address provided by the graphics component, and finally dynamically refreshes the display window at the bottom layer. Through the collaborative work of the integrated development framework, graphics components and underlying threads, a smooth and efficient camera preview function can be provided on the OpenHarmony lightweight system. In addition, the UI layout and the underlying camera driver are separated, and the preview interface is directly refreshed at the bottom layer to improve the refresh efficiency and reduce the refresh jam caused by the middle layer call. This significantly improves the image processing and display performance of the OpenHarmony lightweight system while maintaining low power consumption and high response speed, improves the functionality of the OpenHarmony lightweight system and enhances the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0054] Figure 1 A schematic diagram of an embodiment of a camera preview method based on the OpenHarmony lightweight system provided in this application;

[0055] Figure 2 A flowchart of another embodiment of the camera preview method based on the OpenHarmony lightweight system provided by the present application;

[0056] Figure 3 A schematic diagram of an embodiment flow of format conversion in a camera preview method based on the OpenHarmony lightweight system provided in this application;

[0057] Figure 4 A schematic diagram of an embodiment of the process of implementing the code scanning function in the camera preview method based on the OpenHarmony lightweight system provided in this application;

[0058] Figure 5 A schematic diagram of the structure of an embodiment of a camera preview system based on the OpenHarmony lightweight system provided in this application;

[0059] Figure 6 This is a schematic structural diagram of an embodiment of a camera preview device based on the OpenHarmony lightweight system provided in this application. DETAILED DESCRIPTION

[0060] The present application provides a camera preview method, system and related devices based on the OpenHarmony lightweight system, which are used to provide a smooth and efficient camera preview function on the OpenHarmony lightweight system.

[0061] It should be noted that the camera preview method based on the OpenHarmony lightweight system provided in this application is applied to the OpenHarmony lightweight system, and can be specifically applied to lightweight devices equipped with the OpenHarmony lightweight system, such as mobile payment devices, smart home devices, smart wearable devices, and vehicle-mounted devices. For the convenience of explanation, this application uses the system as an example for illustration.

[0062] See also Figure 1 , Figure 1An embodiment of a camera preview method based on the OpenHarmony lightweight system provided by the present application includes:

[0063] S101, the integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphic component;

[0064] In order to implement the camera preview function based on the OpenHarmony lightweight system, you first need to modify the system's software development kit (SDK) to build a user interface that can display the camera's real-time image. This specifically involves the development of custom components and the writing of JS applications. JS applications refer to applications written in JavaScript. JS applications run on the OpenHarmony lightweight system and use the system's APIs and services to implement various functions. When creating a camera preview interface, developers define the layout structure, style design, and user interaction logic of the preview interface by writing JS applications.

[0065] The ACE (Ability Cross-platform Environment) framework is one of the core components of the OpenHarmony lightweight system. The integrated development framework in this application is the ACE framework. The system uses the integrated development framework to parse the layout information of the preview interface defined in the JS application, accurately identify and process the preview interface elements defined in the JS application, and thus determine the size, position, style and other attributes of the window used to display the camera image in the preview interface. In addition, the preview interface can also include other element designs besides the window that displays the camera image, which are not limited here.

[0066] The integrated development framework then generates preview parameters based on the parsed layout information. Specifically, it generates preview parameters based on the window properties used to display the camera image in the preview interface. The preview parameters are the basis for subsequent camera image rendering and interface display. The integrated development framework encapsulates the preview parameters and passes them to the graphics component, thereby converting the preview interface layout information defined by the developer into preview parameters that can be used by the graphics component, providing necessary support for subsequent graphics rendering.

[0067] S102, the graphics component generates a display window based on the preview parameters, and transmits the display data storage address of the display window to the underlying thread;

[0068] The Graphic component is the UI component responsible for graphics rendering in the OpenHarmony lightweight system. After receiving the preview parameters, the Graphic component creates and manages the display window according to the preview parameters to ensure that the real-time image captured by the camera can be accurately and timely displayed in the display window. After generating the display window, the Graphic component passes the display data storage address of the display window to the underlying thread, and the underlying thread performs subsequent processing operations related to the camera hardware, so that the UI layout is separated from the underlying camera driver, improving the maintainability and scalability of the system. The display data storage address is a memory location used to store and manage the image data of the display window. After receiving this address, the underlying thread can directly interact with this memory location to read or write data.

[0069] S103, the bottom thread calls the camera driver interface to obtain camera data;

[0070] In this embodiment, the bottom thread is responsible for directly communicating with the camera hardware to obtain real-time image data. Specifically, the bottom thread calls the camera driver interface through the API provided by the system, starts the camera hardware to start capturing image data, and transfers the camera data to the memory. This process may also involve camera parameter configuration, such as configuring the camera resolution, frame rate, etc., and starting data transmission and other operations.

[0071] To ensure the integrity and accuracy of the data, the underlying thread can use synchronization mechanisms to monitor the data transmission process, including checking the status of data transmission and handling possible errors. In addition, the underlying thread can also dynamically adjust the camera's data capture frequency and quality based on system resources and performance requirements to optimize the overall system performance and user experience, which is not limited here.

[0072] S104, the bottom thread writes the camera data into the display data storage address;

[0073] The bottom-level thread writes the acquired camera data into the display data storage address provided by the graphics component. This process ensures that the image data can be updated to the memory area of ​​the display window in a timely manner to prepare for subsequent rendering and display. It should be noted that during the data writing process, the bottom-level thread needs to ensure that the access rights and size of the display data storage address meet the requirements to avoid potential memory overflow or access conflicts. In addition, the bottom-level thread can also perform necessary processing on the image data, such as format conversion and compression, to meet the display requirements and system performance requirements, which are not limited here.

[0074] S105: The bottom thread refreshes the display window.

[0075] After the camera data is written, the underlying thread will trigger a partial refresh operation, which only updates the image data of the area corresponding to the display window without affecting the display of other parts. The underlying thread will refresh the image data corresponding to the display window on the display screen according to the latest written camera data, ensuring that only the changed parts are re-rendered, thereby improving the efficiency and performance of the system. The underlying thread performs a partial refresh operation on the display window so that the new image frame is output to the display screen of the device, and the user can see the latest camera image on the preview interface. The underlying thread is directly responsible for refreshing the display window and can bypass the processing of the middle layer, which means that the image data does not need to be transferred between multiple components or threads, thereby reducing the delay in data transmission and processing. This method avoids the performance overhead that may be caused by the middle layer call, thereby reducing the risk of jamming.

[0076] In this embodiment, the integrated development framework effectively parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphics component, then uses the graphics component to generate a display window based on the preview parameters, and then obtains the camera data through the camera driver interface in the underlying thread, and accurately fills the preview image in the display window in combination with the display data storage address provided by the graphics component, and finally dynamically refreshes the display window at the bottom layer. Through the collaborative work of the integrated development framework, graphics components and underlying threads, a smooth and efficient camera preview function can be provided on the OpenHarmony lightweight system. And the UI layout and the underlying camera driver are separated, and the preview interface is directly refreshed at the bottom layer to improve the refresh efficiency, reduce the refresh jam caused by the middle layer call, thereby significantly improving its image processing and display performance while maintaining the low power consumption and high response speed of the OpenHarmony lightweight system, improving the functionality of the OpenHarmony lightweight system and improving the user experience.

[0077] The following is a detailed description of the camera preview method based on the OpenHarmony lightweight system provided by this application. Figure 2 , Figure 2 Another embodiment of the camera preview method based on the OpenHarmony lightweight system provided by the present application includes:

[0078] S201, the integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphic component;

[0079] In this embodiment, step S201 is similar to the aforementioned step S101 and will not be described in detail herein.

[0080] S202, the graphics component generates a display window based on the preview parameters, and transmits the display data storage address of the display window and the size of the display window to the underlying thread;

[0081] In this embodiment, the preview parameters specifically include the starting coordinates of the display window and the width and height of the display window, and these preview parameters define the exact position and size of the display window on the preview interface. After the graphics component generates the display window based on the preview parameters, in addition to passing the display data storage address of the display window to the underlying thread, it is also necessary to pass the size of the display window, that is, the width and height of the display window to the underlying thread, so that the underlying thread processes the camera data according to the size of the display window to ensure that the image can correctly fit the display window.

[0082] S203, the bottom thread calls the camera driver interface to obtain camera data;

[0083] In this embodiment, step S203 is similar to the aforementioned step S103 and will not be described in detail herein.

[0084] S204, the bottom thread stores the camera data alternately to a preset position using double buffering;

[0085] In this embodiment, the bottom thread specifically adopts a double buffer mechanism to store camera data. Specifically, the system is configured with two buffers, namely a foreground buffer and a background buffer. The two buffers have the same size and format and can store complete image frame data. When the bottom thread obtains new camera data from the camera hardware, the camera data will be written to the current background buffer, and during this process, the camera data in the foreground buffer is undergoing subsequent image processing. Once the data writing of the background buffer is completed, the bottom thread will switch the buffer. In this switch, the background buffer becomes the new foreground buffer, and the data in the middle will be subjected to subsequent image processing, while the original foreground buffer becomes the background buffer, ready to receive the next frame of camera data. Through this double-buffered alternating storage method, the system can effectively improve the performance of image processing, while ensuring the fluency and stability of the preview interface.

[0086] S205, the bottom thread scales the camera data according to the size of the display window;

[0087] In this embodiment, the bottom thread is responsible for performing a scaling operation on the camera data to ensure that the camera data can correctly fit the size of the display window. Specifically, the bottom thread applies a scaling algorithm, such as a bilinear interpolation algorithm or a bicubic interpolation algorithm, to scale the original camera data according to the size of the display window provided by the graphics component, that is, to calculate each pixel of the original camera data and reallocate its position and color value, thereby generating scaled camera data.

[0088] S206, the bottom thread uses a table lookup algorithm to convert the camera data from YUV format to RGB format;

[0089] Generally, the camera data obtained by the bottom thread is in YUV format, which is a color encoding method widely used for camera data, including different sub-sampling formats such as YUV422, YUV420, and YUV444. These formats are highly efficient in storing and transmitting image data, but they usually need to be converted to RGB format when displayed.

[0090] In this embodiment, the bottom thread converts the camera data from YUV format to RGB format through a table lookup algorithm, that is, a conversion table is created in advance, which is obtained based on the color space conversion formula from YUV to RGB, and can specifically contain RGB values ​​corresponding to each possible YUV value. During the actual conversion, the bottom thread traverses the YUV data captured by the camera, and for each pixel, the corresponding RGB value is found in the conversion table according to its YUV value to achieve conversion, simplifying the conversion process to a simple search operation, thereby reducing the computational complexity, improving the processing speed and reducing the power consumption of the system. By using the table lookup algorithm, the bottom thread can quickly and efficiently convert the camera data from YUV format to RGB format, ensuring that the image data can be displayed on the preview interface in a timely manner, and maintaining the fluency of the system.

[0091] S207, the bottom thread writes the camera data into the display data storage address;

[0092] S208. The bottom thread refreshes the display window.

[0093] In this embodiment, steps S207 to S208 are similar to steps S104 to S105 of the aforementioned embodiment, and are not described again here.

[0094] In this embodiment, the integrated development framework, graphics components and underlying threads work together to provide a smooth and efficient camera preview function on the OpenHarmony lightweight system. In this embodiment, the UI layout and the underlying camera driver are separated to improve the maintainability and scalability of the system. The double-buffer alternating storage mechanism is combined to reduce frame loss and increase the flow of the camera, and the camera data is converted from YUV format to RGB format through a table lookup algorithm to improve conversion efficiency while saving computing resources. And the preview interface is directly refreshed at the bottom layer to improve refresh efficiency and reduce refresh jams caused by middle-layer calls. In this way, the performance of the OpenHarmony lightweight system in image processing and display is significantly improved while maintaining low power consumption and high response speed, improving the functionality of the OpenHarmony lightweight system and enhancing user experience.

[0095] In step S206, the format conversion process can be divided into two steps: table lookup and simple calculation to improve conversion efficiency. Figure 3 , Figure 3 The present invention is a flowchart of an embodiment of implementing camera data format conversion in a camera preview method based on the OpenHarmony lightweight system, and the embodiment includes:

[0096] S301, the bottom thread obtains a preset table, in which the intermediate calculation results of the conversion process are pre-stored;

[0097] S302, the bottom thread determines the target intermediate calculation result corresponding to the camera data based on the preset table;

[0098] S303, the bottom thread converts the camera data from YUV format to RGB format according to the target intermediate calculation result.

[0099] The conventional algorithm for converting YUV to RGB is:

[0100] R = Y + 1.4075 × (V - 128);

[0101] G=Y-0.3455×(U-128)-0.7169×(V-128);

[0102] B = Y + 1.779 × (U-128);

[0103] Considering that the value range of U and V components is usually -128 to 127, the multiplication calculation related to U and V components can be calculated in advance to obtain the intermediate calculation results of the conversion process, and the intermediate calculation results can be saved as a preset table.

[0104] Specifically, the preset table can contain 4 arrays, namely:

[0105] V1_array

[256] : used to store the intermediate calculation results of 1.4075×(V-128);

[0106] V2_array

[256] : used to store the intermediate calculation results of 0.7169×(V-128);

[0107] U1_array

[256] : used to store the intermediate calculation results of 0.3455×(U-128);

[0108] U2_array

[256] : used to store the intermediate calculation results of 1.779×(U-128);

[0109] Therefore, in the actual conversion process, the corresponding intermediate calculation results of each target of the real-time camera data can be obtained by table lookup.

[0110] During the actual conversion, the underlying thread only needs to calculate the RGB value based on the target intermediate calculation result and the following formula:

[0111] R = Y + V1_array[V];

[0112] G=Y-U1_array[U]-V2_array[V];

[0113] B=Y+U2_array[U];

[0114] In this embodiment, since the preset table already contains the intermediate calculation results of complex calculations, the bottom thread can quickly find the corresponding intermediate calculation results of each target of the real-time camera data, and then perform simple addition and subtraction calculations through the target intermediate calculation results to obtain the final RGB value. This method greatly reduces the amount of calculation compared to the original YUV to RGB conversion formula, so it can significantly improve the processing speed while maintaining the conversion quality, thereby improving the efficiency of format conversion, saving computing resources, and ensuring the low power consumption and high response speed of the OpenHarmony lightweight system.

[0115] In this application, the code scanning function can be realized based on the camera preview method based on the OpenHarmony lightweight system mentioned above, please refer to Figure 4 , Figure 4 This is a flow chart of an embodiment of implementing the code scanning function provided in this application, which includes:

[0116] S401, the bottom thread decodes the camera data;

[0117] After the bottom-level thread calls the camera driver interface to obtain camera data in step S203, the bottom-level thread uses a decoding algorithm to decode the obtained camera data to parse and identify information contained in the image, such as parsing and identifying QR code information contained in the image.

[0118] S402 , the JS application polls and reads the decoding result of the camera data through the JSI interface, and displays the read decoding result in the preview interface.

[0119] In JS applications, the JSI interface provides a mechanism that allows JS applications to communicate and exchange data with the underlying thread, so JS applications can poll the decoding results of the underlying thread through the JSI (JavaScript Interface) interface. When the underlying thread successfully decodes the camera data, the JS application will provide corresponding user feedback according to the preset logic. For example, if the QR code contains URL information, the JS application will jump to the corresponding web page. If the QR code contains text information, the JS application will display the text on the preview interface. In addition, the JS application can also perform other operations as needed, such as recording logs, triggering events, or interacting with other services.

[0120] In this embodiment, the OpenHarmony lightweight system can effectively implement the code scanning function based on the camera preview method based on the OpenHarmony lightweight system. The underlying thread is responsible for processing the decoding of the camera data, while the JS application is responsible for displaying the results and performing user interaction. This layered processing method improves the modularity and maintainability of the OpenHarmony lightweight system, and also provides users with an intuitive and convenient operating experience, so that devices equipped with the OpenHarmony lightweight system can also implement code scanning operations.

[0121] The following is a detailed description of the camera preview system based on the OpenHarmony lightweight system provided by this application. Figure 5 , Figure 5 An embodiment of a camera preview system based on the OpenHarmony lightweight system provided in this application includes:

[0122] Integrated development framework 501, graphics component 502, underlying thread 503 and camera 504;

[0123] The integrated development framework 501 is used to parse the layout information of the preview interface in the JS application, generate preview parameters and pass them to the graphic component;

[0124] The graphic component 502 is used to generate a display window based on the preview parameters, and pass the display data storage address of the display window to the bottom thread 503;

[0125] The bottom thread 503 is used to call the driver interface of the camera 504 to obtain the camera data; write the camera data to the display data storage address; and refresh the preview interface.

[0126] Optionally, the bottom thread 503 is specifically used for:

[0127] Use a table lookup algorithm to convert camera data from YUV format to RGB format.

[0128] Optionally, the bottom thread 503 is specifically used for:

[0129] Obtain a preset table, in which the intermediate calculation results of the conversion process are stored;

[0130] Determine the target intermediate calculation result corresponding to the camera data based on the preset table;

[0131] Convert the camera data from YUV format to RGB format according to the target intermediate calculation results.

[0132] Optionally, the graphic component 502 is specifically used for:

[0133] Generate a display window based on the preview parameters, and pass the display data storage address of the display window and the size of the display window to the bottom thread 503;

[0134] The bottom thread 503 is specifically used for:

[0135] Scale the camera data according to the size of the display window.

[0136] Optionally, the bottom thread 503 is further used for:

[0137] The camera data is stored alternately in the preset location using double buffering.

[0138] Optionally, the bottom thread 503 is further used for:

[0139] Decode the camera data;

[0140] The JS application is used to poll the decoding results of the camera data through the JSI interface and display the decoded results in the preview interface.

[0141] In the system of this embodiment, the functions of the integrated development framework 501, the graphics component 502, the underlying thread 503 and the camera 504 are the same as those described above. Figures 1 to 4 The steps in the method embodiment shown correspond to each other and will not be repeated here.

[0142] This application also provides a camera preview device based on the OpenHarmony lightweight system, see Figure 6 , Figure 6 An embodiment of a camera preview device based on the OpenHarmony lightweight system provided by the present application includes:

[0143] Processor 601, memory 602, input and output unit 603, bus 604;

[0144] The processor 601 is connected to the memory 602, the input and output unit 603 and the bus 604;

[0145] The memory 602 stores a program, and the processor 601 calls the program to execute any of the above camera preview methods based on the OpenHarmony lightweight system.

[0146] The present application also relates to a computer-readable storage medium on which a program is stored, wherein when the program is run on a computer, the computer executes any of the above-mentioned camera preview methods based on the OpenHarmony lightweight system.

[0147] 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 aforementioned method embodiments and will not be repeated here.

[0148] In the several embodiments provided in 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 only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0149] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0150] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0151] If the integrated unit 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 is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. A camera preview method based on OpenHarmony lightweight system, characterized in that: The method comprises: The integrated development framework parses the layout information of the preview interface in the JS application, generates preview parameters and passes them to the graphic component; The graphic component generates a display window based on the preview parameters, and transmits the display data storage address of the display window to the underlying thread; The bottom thread calls the camera driver interface to obtain camera data; The bottom thread writes the camera data into the display data storage address; The bottom thread refreshes the display window; After the bottom thread calls the camera driver interface to obtain camera data, the method further includes: The bottom thread decodes the camera data; The JS application reads the decoding result of the camera data through the JSI interface polling, and displays the read decoding result in the preview interface; After the bottom thread calls the camera driver interface to obtain camera data, the method further includes: The bottom thread obtains a preset table, in which the intermediate calculation results of the conversion process are pre-stored; The bottom thread determines the target intermediate calculation result corresponding to the camera data based on the preset table; The bottom thread converts the camera data from a YUV format to an RGB format according to the target intermediate calculation result; The graphic component generates a display window based on the preview parameters, and transmits the display data storage address of the display window to the underlying thread, including: The graphic component generates a display window based on the preview parameters, and transmits the display data storage address of the display window and the size of the display window to the underlying thread; After the bottom thread calls the camera driver interface to obtain camera data, the method further includes: The bottom thread scales the camera data according to the size of the display window; After the bottom thread calls the camera driver interface to obtain camera data, the method further includes: The bottom thread stores the camera data alternately in a preset position using double buffering.

2. The method according to claim 1, characterized in that The preview parameters include: the starting coordinates of the display window and the width and height of the display window.

3. A camera preview system based on OpenHarmony lightweight system, characterized in that: The system includes: an integrated development framework, a graphics component, an underlying thread and a camera; The integrated development framework is used to parse the layout information of the preview interface in the JS application, generate preview parameters and pass them to the graphic component; The graphic component is used to generate a display window based on the preview parameters, and pass the display data storage address of the display window to the bottom thread; The bottom thread is used to call the camera driver interface to obtain camera data; write the camera data into the display data storage address; and refresh the preview interface; The bottom thread is also used for the bottom thread to decode the camera data, read the decoding result of the camera data through the JSI interface of the JS application, and display the read decoding result in the preview interface; The bottom layer thread is specifically used for: Obtaining a preset table in which intermediate calculation results of the conversion process are pre-stored; Determine the target intermediate calculation result corresponding to the camera data based on the preset table; Converting the camera data from a YUV format to an RGB format according to the target intermediate calculation result; The graphic component is specifically used for: Generate a display window based on the preview parameters, and pass the display data storage address of the display window and the size of the display window to the bottom thread; The bottom layer thread is specifically used for: Scaling the camera data according to the size of the display window; The bottom layer thread is also specifically used for: The camera data is stored alternately in a preset position using double buffering.

4. A camera preview device based on OpenHarmony lightweight system, characterized in that: The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 2.

5. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the method according to any one of claims 1 to 2.