Method for controlling camera to display preview image and electronic device
By issuing the SOF signal after the Init Deskew process is completed, the camera application crash problem caused by small exposure time is solved, ensuring the successful transmission of image frame data of the MIPI interface and improving the user experience.
Patent Information
- Application Number
- CN202410893612.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In camera applications of electronic devices, due to the small exposure time, the SOF signal is sent earlier than or coincides with the Init Deskew process, resulting in the MIPI interface failing to transmit image frame data, which in turn causes the camera application to crash and affect the user experience.
In the case of small exposure time, use the default photography parameters to configure the image sensor, and issue a SOF signal after the Init Deskew process is completed to ensure that the image frame data is transmitted successfully by the MIPI interface and avoid camera application crashes.
By sending SOF signals after the Init Deskew process, the image frame data is successfully transmitted, so as to avoid camera application crashes and improve user experience.
Smart Images

Figure CN118574000B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method for controlling a camera to display a preview image and an electronic device. Background Art
[0002] Currently, camera applications are installed in the operating systems of electronic devices such as mobile phones, and users can use the camera application to trigger a photo event to take photos, such as taking photos of people or scenery.
[0003] When an electronic device opens a camera application, the photographic parameters of the last frame of image captured by the camera application before it was last closed can be used to configure the photosensitive element sensor, so that the sensor generates an optical image using the photographic parameters. The sensor then converts the optical image into an electrical signal and sends it to the image signal processor ISP. The ISP uses the mobile industry processor interface (MIPI) interface to send the converted electrical signal to the application processor (AP) for display processing.
[0004] Generally, before the image frame data starts to be transmitted, the application processor needs to perform an initialization de-skew process to reduce errors in data transmission and ensure that the signal maintains the correct timing and phase during transmission. After the Init Deskew process is completed, the ISP can send a Start of Frame (SOF) signal on each data transmission channel to indicate the start of transmission of new image frame data, ensuring that the application processor can accurately start receiving new image frame data.
[0005] When the exposure time of the sensor is short, the SOF signal is sent earlier than the init deskew process or the SOF signal is sent at the same time as the init deskew process, resulting in failure to transmit image frame data using the MIPI interface. As a result, the camera application cannot display the preview image and crashes, affecting the user experience. Summary of the invention
[0006] The present application provides a method for controlling a camera to display a preview image, so that a SOF signal is sent after executing the init deskew process, thereby avoiding failure in transmitting image frame data using a MIPI interface, and further avoiding the situation where the camera application does not display an image and then crashes, thereby improving the user experience.
[0007] In order to achieve the above objectives, this application adopts the following technical solutions:
[0008] In a first aspect, the present application provides a method for controlling a camera to display a preview image, which may include:
[0009] In the present application, when the electronic device requests the camera application to start the preview image frame function, the photographic parameters of the last frame of image captured by the camera application before the last shutdown can be obtained. When the exposure time of the sensor is short, that is, the exposure time is less than or equal to the exposure time threshold, the electronic device can configure the sensor using the default photographic parameters in which the exposure time is greater than the exposure time threshold. Since the exposure time in the default photographic parameters is greater than the exposure time threshold, the start frame SOF signal is sent after the sensor finishes outputting the image using the default photographic parameters. The SOF signal can be sent after the initialization de-skew process is executed, and the image frame data can be successfully transmitted using the MIPI interface, thereby avoiding the situation in which the camera application flashes back without outputting the image, and thus improving the user experience.
[0010] In some possible implementations, the electronic device may directly send the stored photographic parameters to the image sensor, so that the image sensor captures image data using the photographic parameters.
[0011] When the image sensor fails to transmit image frame data to the processor using the MIPI interface of the mobile industry processor, it can be determined that the exposure time in the photographic parameters is less than or equal to the exposure time threshold, and then the electronic device can trigger the recovery mechanism of the camera application to send the pre-set default photographic parameters to the image sensor.
[0012] In some possible implementations, the photographic parameters may be saved in the form of a txt file, in order to ensure that there exists a txt file storing the photographic parameters (the photographic parameters here refer to the photographic parameters of the last frame of image captured by the camera application before it was last closed) and that the values of the photographic parameters are valid values (if the photographic parameter value is zero, it can be determined that the photographic parameter value is an invalid value; if the photographic parameter value is a non-zero value, it can be determined that the photographic parameter value is a valid value).
[0013] The hardware abstraction layer of the electronic device can determine whether the txt file exists and whether the value of the photography parameter in the txt file is equal to zero during the process of loading the photography parameter.
[0014] When it is determined that the txt file exists and the value of the photography parameter in the txt file is a non-zero value, the kernel layer of the electronic device can send the photography parameter saved in the txt file to the sensor.
[0015] When it is determined that the txt file does not exist or the value of the photography parameter in the txt file is zero, the kernel layer of the electronic device can send the preset default photography parameters to the sensor.
[0016] In some possible implementations, triggering the recovery mechanism of the camera application to send the preset default photography parameters to the image sensor may be:
[0017] The recovery mechanism of the camera application is triggered to recover the camera application. When the number of executions of the recovery mechanism reaches the preset number and the camera application fails to recover, the Full recovery mechanism is triggered to recover the camera application and the preset default photography parameters are sent to the image sensor. The execution of the Full recovery mechanism consumes more resources than the recovery mechanism, so the execution of the Full recovery mechanism can increase the recovery probability of the camera application compared to the recovery mechanism.
[0018] In some possible implementations, when it is determined that the image sensor fails to transmit sensor image data corresponding to photographic parameters to the processor using the MIPI interface, a txt file including the photographic parameters of the last frame of image captured by the camera application before the last shutdown can be reported to the data analysis platform so that relevant personnel can analyze the txt file or use the txt file to locate the problem.
[0019] In some possible implementations, in order to save storage space, the saved txt file may be deleted after being reported to the data analysis platform.
[0020] In some possible implementations, when the electronic device triggers an event to close a camera application, it can save the photographic parameters of the last frame of image before the camera application is closed (the photographic parameters here can also be called target photographic parameters), so that the next time the camera application outputs an image, the saved photographic parameters can be directly called.
[0021] Furthermore, in order to avoid the problem of failure to transmit image frame data using the MIPI interface and generating an error when the next camera application calls the saved photography parameters to output an image, due to the timing of sending the SOF signal earlier than the execution of the init deskew process or the timing of sending the SOF signal coincides with the init deskew process. The electronic device can also determine whether the exposure time in the target photography parameter is greater than the exposure time threshold.
[0022] When it is determined that the exposure time in the target photography parameter is greater than the exposure time threshold, the target photography parameter can be saved. When it is determined that the exposure time in the target photography parameter is less than or equal to the exposure time threshold, the target photography parameter is not saved.
[0023] In some possible implementations, before obtaining the photographic parameters, the application may also:
[0024] It is determined whether the camera device supports early power-on. If the camera device supports early power-on, the camera device can be powered on and initialized. Powering on the camera device means providing power to the camera hardware to switch it from an off state, a dormant state, or a low-power state to a working state. Initialization means writing initialization parameters such as exposure time, sensitivity, and white balance into the image sensor so that the camera application can perform photo taking, video recording, or other image capture functions.
[0025] In a second aspect, the present application provides an electronic device, including: a processor and a memory;
[0026] One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device performs the method described in any one of the first aspects.
[0027] In a third aspect, the present application provides a computer storage medium, comprising computer instructions, which, when executed on a mobile terminal, enables the electronic device to execute the method described in any one of the first aspects.
[0028] It can be seen from the above technical solution that the present application has the following beneficial effects:
[0029] In the present application, when the electronic device requests the camera application to start the preview image frame function, the photographic parameters of the last frame of image captured by the camera application before the last shutdown can be obtained. When the camera application does not produce frames abnormally, it can be determined that the exposure time of the sensor is short, that is, when the exposure time is less than or equal to the exposure time threshold, the electronic device can configure the sensor using the default photographic parameters in which the exposure time is greater than the exposure time threshold. Since the exposure time in the default photographic parameters is greater than the exposure time threshold, the start frame SOF signal is sent after the sensor finishes producing images using the default photographic parameters. The SOF signal can be sent after the initialization de-skew process is executed, and the image frame data can be successfully transmitted using the MIPI interface, thereby avoiding the situation in which the camera application flashes back without producing images, and thus improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A schematic diagram of opening a camera application provided in an embodiment of the present application;
[0031] Figure 2 A schematic diagram of a camera closing application provided in an embodiment of the present application;
[0032] Figure 3 A schematic diagram of a camera application outputting an image provided by an embodiment of the present application;
[0033] Figure 4 A schematic diagram of a camera application crashing provided in an embodiment of the present application;
[0034] Figure 5 A flowchart of a method for controlling a camera to display a preview image provided by an embodiment of the present application;
[0035] Figure 6 A flowchart of another method for controlling a camera to display a preview image provided by an embodiment of the present application;
[0036] Figure 7 Provide a flowchart of the interaction between various layers for the embodiment of the present application;
[0037] Figure 8 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.
[0039] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0040] Currently, camera applications are installed in the operating systems of electronic devices such as mobile phones, and users can use the camera application to trigger a photo event to take photos, such as taking photos of people or scenery.
[0041] like Figure 1 As shown, Figure 1 A schematic diagram of opening a camera application is shown. For example, the user touch operation is to open the camera. The touch sensor can receive the user's touch operation on the camera icon and report the touch operation on the camera icon to the processor. After receiving the touch operation on the camera icon, the processor can respond to the touch operation and start the application corresponding to the camera icon (which can be referred to as the camera application). In some possible implementation methods, the user can also enable the electronic device to start the camera application in other ways. For example, through voice commands or other preset gestures, etc., which are not limited in the embodiments of the present application.
[0042] When the electronic device opens the camera application, the lens receives the light reflected from the target scene (the scene to be photographed) and projects the light onto the image sensor. The sensor generates an optical image based on the photography parameters sent by the HAL layer or the pre-set photography parameters (such as exposure time, white balance parameters, focus parameters, etc.). The sensor then converts the optical image into an electrical signal and sends it to the image signal processor ISP. This can then be presented as follows: Figure 2 The shooting preview interface shown in Figure 2 In the interface shown, the user can trigger a photo shooting operation by touching the shooting key 301 in the shooting preview interface of the camera application.
[0043] In some electronic devices, after the ISP receives the electrical signal sent by the sensor, it can convert the electrical signal into a digital image signal through analog-to-digital conversion and transmit the digital image signal to the DSP using standard interface protocols such as the Mobile Industry Processor Interface (MIPI). The DSP converts the digital image signal into an image signal in standard RGB, YUV and other formats, outputs it to the application processor (also called processor) of the electronic device, and finally converts it into an image displayed on the screen of the electronic device. Among them, the MIPI interface protocol is a hardware and software standard designed for electronic devices. It can include multiple interfaces, among which the MIPI CSI interface is used as an interface protocol between the camera and the processor in the electronic device. It supports multiple camera types, such as CMOS and CCD, and uses serial bus communication to support high-bandwidth and high-resolution image data transmission.
[0044] In some electronic devices, the functions of DSP may be assumed by some parts of the application processor (such as CPU or GPU). Then, the ISP can transmit the processed digital image signal to the application processor of the electronic device through standard interfaces such as MIPI, and finally convert it into an image displayed on the screen of the electronic device.
[0045] The following is an introduction using the example of the application processor taking over the function of DSP in an electronic device.
[0046] It can be seen that in order to ensure that the image data collected by the sensor can be displayed on the screen of the electronic device, the image data collected by the sensor needs to be transmitted to the application processor of the electronic device, and in order to ensure the rate and stability of data transmission, multi-channel data transmission can be adopted between the ISP and the application processor.
[0047] Furthermore, in order to ensure data synchronization between multiple data transmissions, before data transmission begins, the application processor needs to perform an initialization de-skew Init Deskew process. That is, during the data transmission process, due to factors such as hardware design, signal transmission path or environmental changes, the signal may be skewed. The signal skew may cause the data to be incorrectly decoded at the receiving end, affecting the final quality of the image or data. Therefore, Init Deskew can be performed to eliminate signal skew, reduce errors in data transmission, and ensure that the signal maintains the correct timing and phase during transmission.
[0048] Under normal circumstances, after the Init Deskew process is completed, the ISP can send a Start of Frame (SOF) signal on each data transmission channel (the specific timing of sending the SOF signal is determined by the exposure time of the sensor), where SOF is used to indicate the start of transmission of new image frame data to ensure that the application processor can accurately start receiving new image frame data. It should be noted that the MIPI protocol stipulates that the SOF signal must be sent after the Init Deskew process to indicate the start of transmission of new image frame data. In this way, when the application processor receives the SOF signal, it has completed the necessary synchronization process and is ready to receive and process new image frame data.
[0049] After completing the shooting, the user may touch the back key 302 of the camera application to exit the camera application, for example, Figure 2 As shown, the touch sensor can receive the user's operation of sliding the return key to the left on the camera application and report the operation to the processor. The processor can exit the camera application (which can be simply referred to as the camera application) in response to the above touch operation.
[0050] In some possible implementations, the user may also close the camera application of the electronic device in other ways, such as through voice commands or other preset gestures, etc., which are not limited in the embodiments of the present application.
[0051] When the electronic device is closing the camera application, in order to make the image converge quickly during the sensor output stage when the camera application is used next time, the exposure time, white balance parameters, focus parameters and other photography parameters of the last frame captured before the camera application is closed will be saved in the form of a txt file. Then, when the electronic device opens the camera application again and triggers a photo event, the sensor can directly use the last saved photography parameters to output the image. For example, Figure 3As shown, it can be divided into three cases. For example, case (a) may be that the camera application was closed in a high-brightness scene last time, and the exposure time of the last frame image saved before the camera application was closed was small, for example, the exposure time was saved in 4 lines in the txt file.
[0052] In case (b), when the camera application was last closed, the scene brightness was darker than that in case (a). Therefore, the exposure time of the last frame image saved before the camera application was closed is larger than the exposure parameters saved in (a). For example, the exposure time is saved in 6 lines in the txt file.
[0053] Case (c) may be that the camera application was closed in a low-brightness scene last time, and the exposure time of the last frame image saved before the camera application was closed was the largest. For example, the exposure time is saved as 8 lines in the txt file.
[0054] When the electronic device opens the camera application again and triggers a photo event, the sensor can directly use the last saved photography parameters to output the image. The exposure time in the photography parameters will affect the length of time the sensor collects the image. That is, when the exposure time is 4 lines, the length of time the sensor collects image data is the shortest, and when the exposure time is 8 lines, the length of time the sensor collects image data is the longest.
[0055] When the sensor ends the image data collection time (also called exposure), the ISP can send a SOF signal on each data transmission channel to indicate the start of transmission of new image frame data, to ensure that the application processor can accurately start receiving new image frame data.
[0056] It can be seen that, as shown in case (a), when the last saved exposure time is relatively small, for example, 4 lines, the timing of sending the SOF signal will be earlier than the execution of the init deskew process.
[0057] When the exposure time is 6 lines, as shown in case (b), the timing of sending the SOF signal will coincide with the initdeskew process. Only when the exposure time is large enough, as shown in case (c), will the SOF signal be sent after the initdeskew process is executed.
[0058] Since the MIPI protocol stipulates that the SOF signal needs to be sent after the init deskew is executed, so that when the application processor receives the SOF signal, it has completed the necessary synchronization process and is ready to receive and process new image frame data. Therefore, similar to situations (a) and (b), when the sensor's exposure time is short, the timing of sending the SOF signal will be earlier than the execution of the init deskew process or the timing of sending the SOF signal will coincide with the init deskew process, resulting in the failure of using the MIPI interface to transmit image frame data, and then causing the camera application to flash back without displaying images, such as Figure 4 As shown, thus affecting the user experience.
[0059] In view of this, a method for controlling a camera to display a preview image is proposed in the present application, including that when the electronic device responds to the user's camera opening operation, the camera application is started and the camera device is powered on, the camera application is initialized, and the output stream of the camera application is configured, the electronic device can request to start the preview image frame to activate the real-time preview function of the camera. In the process of requesting to start the preview, the photographic parameters of the last frame of the image captured by the camera application before the last shutdown can be sent to the sensor so that the sensor uses the photographic parameters to produce the image. In the case where the camera application does not produce frames abnormally, it can be determined that the exposure time of the sensor is small, that is, when the exposure time of the photographic parameter is less than or equal to the exposure time threshold, the electronic device can trigger the recovery mechanism to recover the camera application. If the recovery mechanism fails to recover, the Full recovery mechanism is executed to reconfigure the sensor using the default photographic parameters, wherein the exposure time in the default photographic parameters needs to be greater than the exposure time threshold. In this way, the sensor can be re-produced using the default photographic parameters. In the present application, when the camera application does not produce frames abnormally, that is, when the exposure time sent to the sensor is small, the recovery mechanism and the Full recovery mechanism can be executed, and the sensor can be reconfigured using the default photographic parameters. Since the exposure time in the default photographic parameters is greater than the exposure time threshold, the SOF signal is sent after the sensor finishes producing images using the default photographic parameters. The SOF signal can be sent after the init deskew process is executed, and the image frame data can be successfully transmitted using the MIPI interface, thereby avoiding the situation where the camera application does not produce images and flashes back, which improves the user experience.
[0060] In order to make the technical solution of the present application clearer and easier to understand, the following describes the method for controlling the camera to display a preview image provided by the present application embodiment in combination with the above embodiments and the corresponding drawings, taking an electronic device as the execution subject and the operating system in the electronic device as the Android operating system as an example. Figure 5 As shown, the method for controlling a camera to display a preview image provided by an embodiment of the present application may include:
[0061] S501: In response to a user opening a camera operation, starting a camera application.
[0062] The electronic device launches a camera application in response to a user opening a camera operation.
[0063] Specifically, the electronic device receives a user's touch operation on the camera icon and reports the touch operation on the camera icon to the processor. After receiving the touch operation on the camera icon, the processor can respond to the touch operation and start the application corresponding to the camera icon (which may be referred to as the camera application). In some possible implementations, the user can also enable the electronic device to start the camera application in other ways. For example, through voice commands or other preset gestures, etc., which are not limited in the embodiments of the present application.
[0064] When an electronic device starts a camera application, it needs to call some functions to activate the camera function to ensure that the camera application can correctly access and control the camera hardware.
[0065] Specifically, you can use the startActivity method to start a new Activity to activate the camera function. After starting a new Activity, Figure 7 As shown ( Figure 7 The serial numbers ①②③ in the function can represent the order in which the functions are executed). The application layer of the electronic device (also called the AP layer) can call the doOpenCamera interface (i.e. Figure 7 Then the application framework layer of the electronic device (also called FWK layer) can call the connectdecice function (i.e. Figure 7 After calling the connectdecice function, the hardware abstraction layer (also called HAL layer) of the electronic device can call the OpenCamera function (i.e. Figure 7The camera open function in () uses the cameraId parameter to specify the unique identifier of the camera device to be accessed (for example, "0" for the rear camera and "1" for the front camera), and checks the logicalCamerald to verify whether the cameraId is valid and ensure that it corresponds to the camera device that actually exists on the device. Checking the logicalCamerald may include, for example, checking whether the cameraID is in the list of cameras supported by the system. When confirming that the cameraId is valid, the electronic device may obtain a pointer to the image sensor sensor associated with the cameraId, and use the pointer to write initialization parameters to the sensor (initialization parameters may include, for example, exposure time, sensitivity, and white balance, etc.).
[0066] The application layer may include a series of application packages, such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0067] The application framework layer provides application programming interface (API) and programming framework for the application layer. The framework layer includes some predefined functions. In addition, the application framework layer can also include: window manager, content provider, view system, phone manager, resource manager and notification manager, etc.
[0068] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0069] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0070] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0071] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0072] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0073] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0074] The Hardware Abstraction Layer (HAL) is a layer in the operating system that abstracts hardware functions. It provides a set of standard interfaces that enable upper-layer software (such as the application layer) to operate in a manner independent of specific hardware devices.
[0075] S502: Determine whether the camera device supports early power-on.
[0076] The electronic device can determine whether the camera device supports early power-on, where powering on the camera device refers to providing power to the camera hardware to switch it from an off state, a sleep state, or a low-power state to a working state, thereby being able to perform photo taking, video recording, or other image capture functions.
[0077] Camera devices that support early power-on can power on the camera device when the camera application is opened. As a result, the camera application can be started faster when the user needs to take a photo or record a video, which can reduce the user's waiting time because it is already in standby mode, but it consumes a certain amount of energy and resources. Camera devices that do not support early power-on will only power on the camera device when the user requests it (for example, the user clicks on the photo or video space). The actual response speed of the camera may be delayed, but it can save a certain amount of energy and resources. Therefore, manufacturers can set whether the camera device supports early power-on based on the needs and usage scenarios of the target users.
[0078] Exemplarily, whether the camera device supports early power-on can be determined in the following ways: for example, a list of all cameras can be obtained through the getCameraIdList() method of CameraManager, and the characteristics of the camera corresponding to the cameraID can be queried by calling the CameraCharacteristics function, thereby determining whether the camera supports early power-on. Among them, CameraManager is a system service used to detect cameras, open cameras, and obtain the characteristics of camera devices.
[0079] S503: If it is determined that the camera device supports early power-on, the camera device is powered on and the camera application is initialized.
[0080] If the electronic device determines that the camera device supports early power-on, the camera device may be powered on and the camera application may be initialized.
[0081] Specifically, after checking logicalCamerald and confirming that cameraId is valid, the electronic device can obtain the CameraCharacteristics of the camera corresponding to cameraId, where CameraCharacteristics is a key-value pair set containing all characteristics of the camera device. Then, a pointer to the sensor can be obtained through CameraCharacteristics, that is, a HwSensorlnfo pointer matching the sensor can be returned, and the HwSensorlnfo pointer can include initialization parameters of the camera application.
[0082] Then the electronic device can initialize the Camera Service (CSL) service through the system service framework, where the CSL service is an interface for accessing and managing camera hardware. After initializing the CSL service, the hardware node handle used by the camera application to communicate with the camera device can be obtained. By using the hardware node handle to interact with the specific interface or driver of the camera device, a device handle can be created. The kernel layer (also called the Kernel layer) of the electronic device can perform power-on operations by controlling the device handle, and then control the camera device to power on, so that the camera device can be switched from the off state, the sleep state, or the low-power state to the working state.
[0083] After the camera device is powered on, the CaptureRequest.Builder interface can be called to send the initialization parameters of the camera application included in the HwSensorInfo pointer to the kernel layer. The kernel layer can write the initialization parameters to the sensor, thereby providing the camera application with the initialization parameters such as exposure time, sensitivity, and white balance required to start capturing images. In this way, the init setting parameters can be written to the sensor to complete the initialization of the camera application. Among them, the kernel layer is the layer between hardware and software. The kernel layer can at least include display drivers, camera drivers, audio drivers, and sensor drivers.
[0084] S504: If it is determined that the camera device does not support early power-on, the electronic device powers on the camera device and initializes the camera application when a photo taking event or a video recording event is triggered.
[0085] If the electronic device determines that the camera device does not support early power-on, the electronic device powers on the camera device and initializes the camera application when a photo taking event or a video recording event is triggered.
[0086] The specific principle of powering on the camera device and initializing the camera application is similar to step S503 , and details may refer to step S503 , which will not be described in detail here.
[0087] S505: Configure the output stream of the camera application.
[0088] After writing the initialization parameters to the sensor, that is, after the camera application is initialized, such as Figure 7 As shown, the application layer of the electronic device can call the onConfigured function (i.e. Figure 7 Request to configure the output stream) Request to configure the output stream. Among them, onConfigured is a callback method of the CameraCaptureSession.StateCallback interface in the Camera API.
[0089] Specifically, after the application layer of the electronic device calls the on Configured function, the application framework layer of the electronic device can call the ConfigureStream function (i.e. Figure 7 The first configuration output stream function in) to configure the output stream, and then the hardware abstraction layer of the electronic device can call the configure_streams function (ie Figure 7 The second configuration output stream function in () is used to configure the data stream that matches the determined use case. It should be noted that the use case can be determined according to application requirements (such as taking pictures, recording videos, and previewing). Electronic devices can use the kernel layer to set parameters such as resolution, frame rate, and data format for each data stream, and then create a pipeline for capturing and processing images or videos based on the configured data stream. Algorithm nodes can be configured in the pipeline, such as automatic exposure, automatic white balance, and automatic focus. In this way, the mode setting parameters can be written to the sensor, thereby completing the configuration of the camera output stream. At this point, the channel configuration of the camera application is completed.
[0090] S506: Request to start preview.
[0091] After the channel configuration of the camera application is completed, the electronic device can request to start the preview image frame function, wherein starting the preview image frame function can refer to requesting to activate the real-time preview function of the camera. This process can allow the user to preview the real-time video stream captured by the camera application before triggering a photo event or triggering a start recording event.
[0092] Specifically, Figure 7 As shown, the application layer of the electronic device can call the startPreview function (ie Figure 7 The real-time preview function of the camera is started in the function), and the Surface used to display the preview is added to the CaptureRequest. Then the application framework layer of the electronic device can call the setRepeatingRequest function (i.e. Figure 7 The request function in the send request function) repeatedly sends CaptureRequest to request the camera device to continuously capture images, thereby requesting to preview the continuously captured images.
[0093] The startPreview method is a method in the Camera API, which is used to start the real-time preview function of the camera, so as to allow the user to preview the real-time image captured from the camera application on the display screen of the electronic device.
[0094] The setRepeatingRequest method is a method of the CameraCaptureSession class, which is used to submit a repeated capture request (CaptureRequest) to periodically capture image data.
[0095] CaptureRequest is a request object used to define single or repeated capture operations.
[0096] Then the application framework layer of the electronic device can call the processCaptureRequest function, the ProcessRequest function, and the StartStreaming function (these three functions are in Figure 7 The application framework layer can then call the LoadWarmStartData function (that is, Figure 7 Load photography parameters function in ) loads the exposure time, white balance parameters, focus parameters and other photography parameters of the last frame image captured by the camera application before it was last closed. The photography parameters here can be saved in the form of a txt file.
[0097] For example, a txt file may look like this:
[0098] { / data / vendor / camera /
[0099] aecWarmStartCamera_0.txt
[0100] awbWarmStartCamera_1.txt
[0101] awbWarmStartCamera_0.txt
[0102] awbWarmStartCamera_1.txt}
[0103] In some possible implementations, it is ensured that there is a txt file storing photographic parameters (the photographic parameters here refer to the photographic parameters of the last frame of image captured by the camera application before it was last closed) and that the values of the photographic parameters are valid values (if the photographic parameter value is zero, it can be determined that the photographic parameter value is an invalid value; if the photographic parameter value is a non-zero value, it can be determined that the photographic parameter value is a valid value).
[0104] The hardware abstraction layer of the electronic device can determine whether the txt file exists and whether the value of the photography parameter in the txt file is equal to zero during the process of loading the photography parameter.
[0105] When it is determined that the txt file exists and the value of the photography parameter in the txt file is a non-zero value, the kernel layer of the electronic device can send the photography parameter saved in the txt file to the sensor.
[0106] When it is determined that the txt file does not exist or the value of the photography parameter in the txt file is zero, the kernel layer of the electronic device can send the preset default photography parameters to the sensor, wherein those skilled in the art can set the value of the default photography parameters according to actual needs, which is not limited here. It should be noted that in order to make the start frame SOF signal that marks the start of data transmission between the sensor and the processor be sent after the processor executes the initialization de-skew process, so that the application processor can accurately start receiving new image frame data, the exposure time in the default photography parameters needs to be greater than the exposure time threshold. The exposure time threshold here can also be set according to actual needs, for example, set to 6lins.
[0107] S507: When the camera application abnormally fails to produce frames, a recovery mechanism is triggered to perform recovery.
[0108] After the photographic parameters saved in the txt file are sent to the sensor, the sensor can use the photographic parameters to capture image data, and then the captured image data can be sent to the processor for display processing.
[0109] When the camera application fails to produce frames abnormally, that is, the timing of sending the SOF signal is earlier than the execution of the init deskew process or the timing of sending the SOF signal coincides with the init deskew process, resulting in the failure of transmitting image frame data using the MIPI interface, the camera application will be unable to display the preview image and will crash.
[0110] When the camera application does not produce frames abnormally, it can be determined that the exposure time of the sensor is small, that is, when the exposure time is less than or equal to the exposure time threshold, the electronic device can trigger the recovery mechanism to recover the camera application. The purpose of triggering the recovery mechanism is to restore the camera application from an error state or an abnormal state to a normal working state.
[0111] Exemplarily, triggering the recovery mechanism may include performing the following operations.
[0112] Call the openCamera method of CameraDevice to reinitialize the camera device.
[0113] Call CaptureRequest.Builder to reconfigure the algorithm nodes of the camera application, such as reconfiguring the automatic exposure control (Auto Exposure Control, AEC) and automatic white balance control (Auto White BalanceControl, AWB), and rebinding the Surface used to display the preview.
[0114] In some possible implementations, in order to further improve the success rate of the recovery mechanism in recovering the camera application, the recovery mechanism can be executed multiple times, for example, three times. The specific number of times the recovery mechanism is executed can be set according to needs and is not limited here.
[0115] In a possible implementation, an error code may be assigned to the error generated by the camera application because the timing of sending the SOF signal is earlier than the execution of the initdeskew process or the timing of sending the SOF signal coincides with the initdeskew process, resulting in the failure to transmit the image frame data using the MIPI interface, for example, the error code is dotted 927009005. In this way, when the camera application reports an error again and 927009005 is dotted, it can be determined that the error is caused by the above reasons.
[0116] In some possible implementations, a txt file including photographic parameters of the last frame of image captured by the camera application before it was last shut down can be reported to a data analysis platform so that relevant personnel can analyze the txt file or use the txt file to locate the problem.
[0117] In some possible implementations, in order to save storage space, the saved txt file can be deleted after it is reported to the data analysis platform.
[0118] S508: If the recovery mechanism fails, the Full recovery mechanism is executed to reconfigure the sensor using the default photography parameters.
[0119] When the recovery mechanism fails to restore the camera application, the Full recovery mechanism can be executed to reconfigure the sensor using the default photography parameters. Executing the Full recovery mechanism consumes more resources than the recovery mechanism. Therefore, executing the Full recovery mechanism can increase the recovery probability of the camera application compared to the recovery mechanism.
[0120] Specifically, the camera device may be turned off and powered off to release CameraDevice resources, ensuring that all resources related to the camera device are correctly released, and then the camera device may be powered on again.
[0121] Then, the default photography parameters can be sent to the sensor, that is, the sensor is reconfigured using the default photography parameters, and then the preview stream can be restarted and the CaptureRequest can be resubmitted to capture images or videos. Then, the sensor can re-output images using the default photography parameters.
[0122] S509: Close the camera application.
[0123] After completing the shooting, the user can touch the back key of the camera application to trigger a close camera application event, thereby closing the camera application. Figure 2 As shown, the touch sensor can receive a left sliding operation of the user on the camera application and report the operation to the processor. The processor can close the camera application (which may be referred to as the camera application for short) in response to the touch operation.
[0124] In some possible implementations, the user may also close the camera application of the electronic device in other ways, such as through voice commands or other preset gestures, etc., which are not limited in the embodiments of the present application.
[0125] Specifically, Figure 7 As shown, the application layer of the electronic device can call the docloseCamera interface function (ie Figure 7 The request to close the camera function in the ) is used to perform cleanup work before closing the camera application, such as stopping the preview. Then the application framework layer of the electronic device can call the disconnectdecide function (i.e. Figure 7The disconnect function in the device is used to disconnect the camera device from the camera service. Finally, the hardware abstraction layer of the electronic device can use the closeCamra function of CameraDevice (i.e. Figure 7 The hardware abstraction layer can then call the Node::Destory function and the CAECEngine::Destory function to release resources related to the camera application.
[0126] S510: Saving the photography parameters of the last frame of image before closing the camera application.
[0127] When the electronic device triggers the event of closing the camera application, it can save the photographic parameters of the last frame image before the camera application is closed (the photographic parameters here can also be called target photographic parameters), so that the next time the camera application outputs an image, the saved photographic parameters can be directly called.
[0128] Specifically, the electronic device can determine whether a txt file exists. If a txt file exists, the hardware abstraction layer can call the StoreWarmStartData function (i.e. Figure 7 Save the target photography parameters to a txt file.
[0129] If the txt file does not exist, create one, and then call the StoreWarmStartData function to save the target photography parameters into the txt file.
[0130] For example, the photographic parameters of the last frame of image before the camera application is closed are saved to a txt file as follows:
[0131] / data / vendor / camera /
[0132] aecWarmStaryCamera_x.txt
[0133] awb WarmStaryCamera_x.txt
[0134] In some possible implementations, in order to avoid the problem of failure to transmit image frame data using the MIPI interface and generating an error when the next camera application calls the saved photography parameters to output an image, the timing of sending the SOF signal is earlier than the timing of executing the init deskew process or the timing of sending the SOF signal coincides with the init deskew process.
[0135] The electronic device may also determine whether the exposure time in the target photography parameters is greater than an exposure time threshold.
[0136] When it is determined that the exposure time in the target photography parameter is greater than the exposure time threshold, the target photography parameter can be saved. When it is determined that the exposure time in the target photography parameter is less than or equal to the exposure time threshold, the target photography parameter is not saved.
[0137] After the electronic device executes the step of saving the photographic parameters of the last frame of the image before the camera application is closed, the kernel layer of the electronic device can control the camera device to power off to reduce energy consumption and extend the life of the camera device.
[0138] In the first embodiment of the present application, when the electronic device responds to the user's camera opening operation, starts the camera application and completes the power-on of the camera device, the initialization of the camera application and the configuration of the output stream of the camera application, the electronic device can request to start the preview to activate the real-time preview function of the camera. In the process of requesting to start the preview, the photographic parameters of the last frame image captured by the camera application before the last shutdown can be sent to the sensor so that the sensor can use the photographic parameters to produce the image. In the case where the camera application does not produce frames abnormally, it can be determined that the exposure time of the sensor is small, that is, when the exposure time of the photographic parameter is less than or equal to the exposure time threshold, the electronic device can trigger the recovery mechanism to recover the camera application. If the recovery mechanism fails to recover, the Full recovery mechanism is executed to reconfigure the sensor using the default photographic parameters, wherein the exposure time in the default photographic parameters needs to be greater than the exposure time threshold. In this way, the sensor can be re-produced using the default photographic parameters. In the present application, when the camera application does not produce frames abnormally, that is, when the exposure time sent to the sensor is small, the recovery mechanism and the Full recovery mechanism can be executed, and the sensor can be reconfigured using the default photographic parameters. Since the exposure time in the default photographic parameters is greater than the exposure time threshold, the SOF signal is sent after the sensor finishes producing images using the default photographic parameters. The SOF signal can be sent after the init deskew process is executed, and the image frame data can be successfully transmitted using the MIPI interface, thereby avoiding the situation where the camera application does not produce images and flashes back, which improves the user experience.
[0139] The above embodiment can be referred to as embodiment one. In addition, the present application provides another embodiment, which is referred to as embodiment two. The method of embodiment two can also be applied to electronic devices. The difference between embodiment two and embodiment one is that in embodiment two, in the process of requesting to start preview, it can be determined whether the exposure time in the last saved photographic parameters is less than or equal to the exposure time threshold. If it is determined that the exposure time is less than or equal to the threshold (indicating that the exposure time is too small), the default photographic parameters (including exposure time and white balance parameters, etc.) can be sent to the sensor. If it is determined that the exposure time is greater than the exposure time threshold, the last saved photographic parameters can be sent to the sensor. This can avoid the problem of error caused by failure to transmit image frame data using the MIPI interface due to the timing of sending the SOF signal earlier than the execution of the init deskew process or the timing of sending the SOF signal coinciding with the init deskew process. Compared with the method in embodiment one, it can save the recovery mechanism in step S507 and step S508 for recovery and the process of Full recovery, thereby further improving the efficiency of sensor output. Specifically, it can be as follows Figure 6 As shown, including:
[0140] S601: In response to a user opening a camera operation, starting a camera application.
[0141] S602: Determine whether the camera device supports early power-on.
[0142] S603: If it is determined that the camera device does not support early power-on, when the electronic device triggers a photo taking event or a video recording event, the camera device is powered on and the camera application is initialized.
[0143] S604: If it is determined that the camera device supports early power-on, the camera device is powered on and the camera application is initialized.
[0144] S605: Configure the output stream of the camera application.
[0145] S606: Request to start preview.
[0146] The implementation method and principle of steps S601-S604 are similar to those of steps S501-S504, and reference may be made to the introduction in the first embodiment, and no redundant description is given here.
[0147] When it is necessary to call the LoadWarmStartData function to load photographic parameters such as exposure time, white balance parameters, and focus parameters of the last frame of image captured by the camera application before it was last closed, step S607 may be executed.
[0148] S607: Determine whether the exposure time in the stored photography parameters is less than or equal to a threshold.
[0149] The electronic device may determine whether the exposure time in the saved photography parameters of the last frame of image captured by the camera application before it was last closed is less than or equal to a threshold.
[0150] S608: If it is determined that the exposure time in the saved photography parameters is less than or equal to the threshold, the sensor is configured using the default photography parameters.
[0151] If the electronic device determines that the exposure time in the saved photographic parameters is less than or equal to the exposure parameter threshold, it can be determined that the exposure time is relatively small. When the exposure time of the sensor is relatively small, it will cause the timing of sending the SOF signal to be earlier than the execution of the init deskew process or the timing of sending the SOF signal to coincide with the init deskew process, resulting in failure to transmit image frame data using the MIPI interface, and then causing the camera application to flash back without displaying an image. Then, the pre-set default photographic parameters can be sent to the sensor, so that the sensor can be configured using the default photographic parameters. The technicians in this field can set the default photographic parameter values according to actual needs, which is not limited here. The exposure time in the photographic parameters needs to be greater than the exposure time threshold. The exposure time threshold here can also be set according to actual needs, for example, set to 6lins.
[0152] S609: If it is determined that the exposure time in the stored photography parameters is greater than the threshold, the sensor is configured using the stored photography parameters.
[0153] If the electronic device determines that the exposure time in the saved photography parameters is greater than the exposure parameter threshold, it can be determined that the exposure time is large enough. If the exposure time of the sensor is large enough, the timing of sending the SOF signal will be later than the execution of the initdeskew process, so that the transmission of image frame data using the MIPI interface will not fail. In this way, the saved photography parameters can be sent to the sensor, so that the sensor can be configured using the saved photography parameters.
[0154] S610: Close the camera application.
[0155] S611: Save the photography parameters of the last frame of image before closing the camera application.
[0156] The implementation method and principle of steps S610-S611 are similar to those of steps S509-S510, and reference may be made to the introduction in the first embodiment, and no redundant description is given here.
[0157] In the second embodiment of the present application, after the electronic device completes powering on the camera device, initializing the camera application, and configuring the output stream of the camera application, the electronic device can request to start the preview to activate the real-time preview function of the camera.
[0158] During the request to start the preview, the last saved photographic parameters can be determined (the saved photographic parameters here refer to the photographic parameters of the last frame of image captured by the camera application before it was last closed). If it is determined that the exposure time is less than or equal to the threshold, the default photographic parameters can be sent to the sensor. If it is determined that the exposure time is greater than the exposure time threshold, the last saved photographic parameters can be sent to the sensor. Since the exposure time of both the default photographic parameters and the last saved photographic parameters sent is greater than the exposure time threshold, the SOF signal will be sent after the sensor uses the photographic parameters to output the image. The SOF signal can be sent after the init deskew process is executed, and the image frame data can be successfully transmitted using the MIPI interface, thereby avoiding the situation where the camera application does not output the image and flashes back, which improves the user experience.
[0159] In addition, the technical solution provided in the second embodiment can save the recovery mechanism and the Full recovery process in step S507 and step S508, that is, in the second embodiment, the photographic parameters with an exposure time greater than the exposure time threshold can be directly sent down without sending the last saved photographic parameters. When the last saved exposure time is small, the recovery mechanism and Full recovery are executed, so that the sensor is reconfigured using the default photographic parameters. Therefore, the technical solution provided in the second embodiment can further improve the efficiency of the sensor output.
[0160] The method provided in the present application can be executed on an electronic device. In some embodiments, the electronic device can be a mobile phone, a tablet computer, a desktop, a laptop, a notebook computer, an ultra-mobile personal computer (UMPC), a handheld computer, a netbook, a personal digital assistant (PDA), a wearable electronic device, a smart watch, etc. The present application does not impose any special restrictions on the specific form of the above electronic devices. In this embodiment, the structure of the electronic device can be as follows: Figure 8 As shown, Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0161] like Figure 8As shown, the electronic device may include a processor 810, a sensor module 820, a camera 830, a display screen 840, etc. The sensor module 820 may include a touch sensor 820A, etc.
[0162] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0163] The processor 810 may include one or more processing units, for example, the processor 810 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0164] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0165] The processor 810 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 810 is a cache memory. The memory may store instructions or data that the processor 810 has just used or cyclically used. If the processor 810 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 810, and thus improves the efficiency of the system.
[0166] In some embodiments, the processor 810 may include one or more interfaces, which may include an inter-integrated circuit (I2C) interface, a universal asynchronous receiver / transmitter (UART) interface, and a mobile industry processor interface (MIPI).
[0167] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 810 may include multiple groups of I2C buses. The processor 810 may be coupled to the touch sensor 820A, the charger, the flash, the camera 830, etc. through different I2C bus interfaces. For example, the processor 810 may be coupled to the touch sensor 820A through the I2C interface, so that the processor 810 communicates with the touch sensor 820A through the I2C bus interface to realize the touch function of the electronic device.
[0168] The MIPI interface can be used to connect the ISP to the processor 810, and to connect the processor 810 to peripheral devices such as the display screen 840. The MIPI interface can include a camera serial interface (CSI), a display serial interface (DSI), and the like.
[0169] In some embodiments, the ISP can transmit the processed digital image signal to the processor 810 through the CSI interface in the MIPI standard interface to realize the shooting function of the electronic device. The processor 810 and the display screen 840 communicate through the DSI interface, and finally convert it into an image displayed on the screen of the electronic device to realize the display function of the electronic device.
[0170] The electronic device implements the display function through a GPU, a display screen 840, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 840 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 810 may include one or more GPUs that execute program instructions to generate or change display information.
[0171] The display screen 840 is used to display images, videos, etc. The display screen 840 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oled, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 840, where N is a positive integer greater than 1.
[0172] A series of graphical user interfaces (GUIs) can be displayed on the display screen 840 of the electronic device, and these GUIs are the main screen of the electronic device. Generally speaking, the size of the display screen 840 of the electronic device is fixed, and only limited controls can be displayed on the display screen 840 of the electronic device. A control is a GUI element, which is a software component included in an application. It controls all data processed by the application and the interactive operations on these data. Users can interact with the controls through direct manipulation to read or edit relevant information of the application. Generally speaking, controls can include visual interface elements such as icons, controls, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc.
[0173] The electronic device can realize the shooting function through the ISP, the camera 830, the video codec, the GPU, the display screen 840 and the application processor.
[0174] The ISP is used to process the data fed back by the camera 830. For example, when taking a photo, the shutter is opened, and the ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature, and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 830.
[0175] The camera 830 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto a photosensitive element (also called an image sensor). The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device may include 1 or N cameras 830, where N is a positive integer greater than 1.
[0176] Digital signal processors are used to process digital signals. In addition to processing digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency point, a digital signal processor is used to perform Fourier transform on the frequency point energy.
[0177] Video codecs are used to compress or decompress digital videos. Electronic devices can support one or more video codecs. In this way, electronic devices can play or record videos in multiple coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0178] NPU is a neural network (NN) computing processor. It can quickly process input information and continuously self-learn by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. NPU can realize applications such as intelligent cognition of electronic devices, such as image recognition.
[0179] The touch sensor 820A is also called a "touch control device". The touch sensor 820A can be set on the display screen 840, and the touch sensor 820A and the display screen 840 form a touch screen, also called a "touch control screen". The touch sensor 820A is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 840. In other embodiments, the touch sensor 820A can also be set on the surface of the electronic device, which is different from the position of the display screen 840.
[0180] The technical solution of this embodiment, in essence, 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, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk, etc., various media that can store program codes.
[0181] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for controlling a camera to display a preview image, characterized in that: include: In response to a request from a camera application to start a preview image frame function, obtaining photographic parameters of a last frame of image captured by the camera application before the camera application was last closed; When the exposure time in the photographic parameters is less than or equal to the exposure time threshold, the pre-set default photographic parameters are sent to the image sensor, so that the image sensor captures image frame data using the default photographic parameters, and sends the captured image frame data to the processor for display processing. The exposure time in the default photographic parameters is greater than the exposure time threshold. The exposure time greater than the exposure time threshold indicates that the start frame SOF signal marking the start of data transmission between the image sensor and the processor is sent after the processor performs the initialization de-skew process.
2. The method according to claim 1, characterized in that The method further comprises: Sending the photographic parameters to an image sensor so that the image sensor captures image frame data using the photographic parameters; When the exposure time in the photographic parameter is less than or equal to the exposure time threshold, sending the preset default photographic parameter to the image sensor includes: When the image sensor fails to transmit the image frame data to the processor using the mobile industry processor MIPI interface, it is determined that the exposure time in the photographic parameters is less than or equal to the exposure time threshold, triggering the recovery mechanism of the camera application, and sending the pre-set default photographic parameters to the image sensor.
3. The method according to claim 2, characterized in that The sending the photographic parameters to the image sensor includes: When it is determined that the photographic parameter is saved and the value of the photographic parameter is a non-zero value, the photographic parameter is sent to the image sensor.
4. The method according to claim 1, characterized in that: The method further comprises: In response to the camera application being closed, obtaining a target photography parameter of the last frame of image captured by the camera application before being closed; When the exposure time in the target photography parameter is greater than the exposure time threshold, the target photography parameter is saved.
5. The method according to claim 2, characterized in that: The triggering of the recovery mechanism of the camera application to send the preset default photography parameters to the image sensor includes: Trigger the recovery mechanism of the camera application to restore the camera application; When the number of times the recovery mechanism is executed reaches a preset number and the camera application fails to recover, the Full recovery mechanism is triggered to recover the camera application and send the preset default photography parameters to the image sensor.
6. The method according to claim 2, characterized in that When it is determined that the image sensor fails to transmit the image frame data corresponding to the photographic parameter to the processor using the MIPI interface, the method further includes: The txt file including the photographic parameters is reported to the data analysis platform for analysis by relevant personnel or the problem is located using the txt file.
7. The method according to claim 6, characterized in that The method further comprises: The hardware abstraction layer of the electronic device deletes the txt file.
8. The method according to any one of claims 1 to 7, characterized in that: Before obtaining the photographic parameters of the last frame of image captured by the camera application before the camera application was last closed, the method further includes: Determine whether the camera device supports early power-on; When the camera device supports early power-on, the camera device is powered on and initialized.
9. An electronic device, characterized in that: include: Processor and memory; Wherein, one or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-8.
10. A computer storage medium, characterized in that: The method comprises computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image processing method and device
CN106506950A
Shooting control method and device, electronic equipment and computer readable storage medium
CN110248111A
