Camera management method and electronic device
By stopping and restarting the camera service when the camera is unplugged, and using the unplugging time recorded in the registry to determine the pop-up display, the problem of device freezing and pop-up interference caused by reconnecting a detachable camera after disconnection is solved, improving the user experience of the device and the normal operation of shared cameras.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2026-03-27
AI Technical Summary
In electronic devices, when a detachable camera is disconnected and then reconnected shortly afterward, it may cause the camera to freeze or display an unauthorized access message, affecting the user experience. Furthermore, unnecessary pop-up messages may interfere with the normal use of the shared camera.
By stopping and restarting the camera service when the camera is unplugged, and recording the unplugging time in the registry, the system determines whether to display a pop-up message, thereby reducing unnecessary pop-up displays and ensuring the normal use of the shared camera.
Unnecessary pop-up messages have been reduced, preventing camera freezing and unauthorized use, thus improving the user experience and normal operation of shared cameras.
Smart Images

Figure CN119583947B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of terminals, and in particular to a camera management method and an electronic device. BACKGROUND
[0002] With the development of communication technology, different electronic devices can share some functional modules, for example, a camera can be shared, that is, one electronic device can use its own camera as a shared camera for another electronic device. When a certain electronic device is using its own camera and using the shared camera of another electronic device, if the camera of the electronic device is a detachable camera, the detachable camera of the electronic device can be disconnected from the electronic device after use. However, when the detachable camera is disconnected and connected to the electronic device again in a short time, since the camera resources of the detachable camera are not completely released, there is a problem of camera freezing leading to a black screen or a prompt of illegal occupation of the camera. Therefore, when the detachable camera is disconnected, stopping the camera service can avoid the problem of a black screen or a prompt of illegal occupation of the camera.
[0003] However, since the shared camera on the electronic device is also in use, it is necessary to restart the camera service and display a pop-up message in the application interface to request the use permission of the shared camera. Such unnecessary pop-up messages can seriously interfere with the normal use of the shared camera, thereby affecting the use experience of the device. SUMMARY
[0004] The present application provides a camera management method and an electronic device, which can reduce unnecessary pop-up messages for a shared camera when a detachable camera is pulled out, thereby improving the use experience of the device.
[0005] In a first aspect, an embodiment of the present application provides a camera management method, which can be applied to an electronic device to which a first camera belongs. The method comprises: starting a camera service when the first camera is started; displaying a first pop-up message in response to a starting instruction for a second camera; the second camera is different from the electronic device to which the first camera belongs, and the first pop-up message is used to request starting of the second camera; stopping the camera service, restarting the camera service, and not displaying the first pop-up message when the first camera is pulled out.
[0006] It can be seen that since the first pop-up message has been displayed to start the second camera when the second camera is used before the first camera is pulled out, it is equivalent to having obtained the use permission of the second camera. Therefore, when the camera service is restarted after being stopped when the first camera is pulled out, the first pop-up message does not need to be displayed again, which can reduce the display of unnecessary pop-up messages in the application interface, thereby improving the use experience of the electronic device.
[0007] With reference to the first aspect, in a possible implementation, the method further includes: restarting the camera service, and not displaying the first pop-up message, including: restarting the camera service if the second camera is in use; obtaining the first camera ejection time from the registry; and if the first camera ejection time is not empty, not displaying the first pop-up message and clearing the first camera ejection time in the registry.
[0008] It can be seen that, since the second camera is in use, stopping the camera service will affect the normal use of the second camera, and thus the normal use of the second camera can be ensured by restarting the camera application. Moreover, by obtaining the first camera ejection time from the registry, it can be further determined whether the normal use of the second camera is abnormally interrupted by the camera service being closed when the first camera is ejected, and thus the first pop-up message does not need to be displayed when the second camera is restarted, which can improve the use experience of the second camera.
[0009] With reference to the first aspect, in a possible implementation, the method further includes: if the first camera ejection time is empty, displaying the first pop-up message.
[0010] It can be seen that, if the first camera ejection time is empty, it can mean that the second camera is normally started or the second camera is restarted after being exited, and thus the first pop-up message is displayed to start the second camera, so that the normal start of the second camera can be ensured.
[0011] With reference to the first aspect, in a possible implementation, the method further includes: if the second camera is exited, clearing the first camera ejection time in the registry.
[0012] It can be seen that, after the first camera is ejected, if the second camera is normally exited, for example, the second camera is normally exited after use, and the second camera needs to be used again, the first pop-up message can be normally displayed to start the second camera. By clearing the first camera ejection time in the registry, it can be ensured that the first pop-up message is displayed when the second camera is used again, so that the normal start of the second camera can be ensured.
[0013] With reference to the first aspect, in a possible implementation, the method further includes: when the first camera is ejected, if the second camera is in use, recording the first camera ejection time in the registry.
[0014] It can be seen that, by recording the first camera ejection time in the registry, it can be determined whether to display the first pop-up message in combination with the ejection time in the future, so that the normal start of the second camera can be ensured.
[0015] With reference to the first aspect, in a possible implementation, if the first camera ejection time is not empty, the first pop-up message is not displayed, including: if the first camera ejection time is not empty, obtaining a time interval between the camera service restart time and the first camera ejection time; if the time interval is less than or equal to a preset time length, the first pop-up message is not displayed.
[0016] It can be seen that if the time interval is less than or equal to the preset time length, it indicates that the time interval is short, that is, the use exception of the second camera this time is caused by the ejection of the first camera, and the first pop-up message for requesting to start the second camera is not displayed when the camera service is restarted, which can reduce the use interference of the second camera and improve the use experience of the second camera.
[0017] With reference to the first aspect, in a possible implementation, the method further includes: if the time interval is greater than the preset time length, displaying the first pop-up message and clearing the first camera ejection time in the registry.
[0018] It can be seen that if the time interval is greater than the preset time length, it indicates that the time interval is long, that is, the use exception of the second camera this time is not caused by the ejection of the first camera, but may be caused by other factors. By displaying the first pop-up message for requesting to start the second camera when the camera service is restarted, the normal use of the second camera can be ensured.
[0019] With reference to the first aspect, in a possible implementation, the method further includes: when the camera service is stopped, releasing the camera resource of the first camera and the camera resource of the second camera; and when the camera service is restarted, re-applying the camera resource of the second camera.
[0020] It can be seen that by stopping the camera service to release the camera resource of the first camera and the camera resource of the second camera, the problem of black screen or illegal occupation caused by the first camera being connected again in a short time can be avoided. When the camera service is restarted, the camera resource of the second camera is re-applied, so that the normal use of the second camera can be ensured.
[0021] With reference to the first aspect, in a possible implementation, the method of restarting the camera service includes: calling the operating system layer to send a resource application request to the hardware layer, the resource application request being used to instruct the hardware layer to send a video stream playing parameter to the driver layer to generate a trigger event of a callback function of the driver layer; and in response to a start message of the camera service sent by the driver layer based on the trigger event of the callback function, restarting the camera service.
[0022] It can be seen that, since the callback function is in the driver layer, triggering the callback function can realize restarting the camera service. Therefore, by calling the operating system layer to send a resource application request to the hardware layer, the hardware layer can send the playing parameter of the video stream to the driver layer, so as to trigger the callback function of the driver layer, and then the starting message of the camera service sent by the driver layer can be acquired, so as to realize restarting the camera service. By restarting the camera service, the normal use of the second camera can be ensured.
[0023] In a second aspect, the present application provides an electronic device, comprising: one or more processors and one or more memories; the one or more memories are coupled with the one or more processors, and the one or more memories are used to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, the electronic device executes the camera management method in any possible implementation manner of the first aspect.
[0024] In a third aspect, the present application provides a chip system, comprising a processor and an interface, the processor and the interface are coupled; the interface is used to receive or output signals, and the processor is used to execute code instructions to execute the camera management method in any possible implementation manner of the first aspect.
[0025] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, when the computer program is executed by a processor, the camera management method in any possible implementation manner of the first aspect is realized.
[0026] In a fifth aspect, the present application provides a computer program product, when the computer program product is run on a computer, the computer executes the camera management method in any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0027] Figure 1a An application scenario schematic diagram provided by an embodiment of the present application is shown in FIG. 1;
[0028] Figure 1b An application scenario schematic diagram provided by an embodiment of the present application is shown in FIG. 1; Figure Two ;
[0029] Figure 2 A flowchart of a camera management method provided by an embodiment of the present application is shown in FIG. 2;
[0030] Figure 3a A flowchart of a camera management method provided by an embodiment of the present application is shown in FIG. 2; Figure Two ;
[0031] Figure 3bFlow chart of a camera management method provided by an embodiment of the present application III;
[0032] Figure 4 Interaction flow chart of each module of an electronic device provided by an embodiment of the present application I;
[0033] Figure 5 Interaction flow chart of each module of an electronic device provided by an embodiment of the present application Figure Two ;
[0034] Figure 6 Hardware structure schematic diagram of an electronic device provided by an embodiment of the present application;
[0035] Figure 7 Software structure schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0036] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, “ / ” represents the meaning of or, for example, A / B can represent A or B; the “and / or” in the text only represents a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that there are three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, “multiple” means two or more than two.
[0037] It should be understood that the terms “first”, “second” and the like in the specification and claims of the present application and the drawings are used to distinguish different objects, and are not used to describe a specific order. In addition, the terms “include” and “have” and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.
[0038] In the present application, the phrase “embodiment” means that the specific features, structures or characteristics described in conjunction with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment to other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in the present application can be combined with other embodiments.
[0039] In order to facilitate the understanding of the scheme provided by the embodiments of the present application, the related concepts involved in the embodiments of the present application are introduced as follows:
[0040] I. Camera
[0041] Camera refers to a camera module for video stream acquisition. Cameras can be mainly divided into two types: separate cameras and shared cameras.
[0042] Separate camera: A separate camera refers to a detachable camera that can be installed on an electronic device. When the electronic device needs to use the separate camera, the separate camera can be inserted into the corresponding slot of the electronic device. When the electronic device does not need to use the separate camera, the separate camera can be removed from the corresponding slot of the electronic device.
[0043] Shared camera: A shared camera refers to a camera on another electronic device. By connecting the electronic device with one or more other electronic devices, the multi-device and different platform interaction function can be easily achieved, such as sharing the camera between multiple electronic devices. That is, the camera of one electronic device is shared with another electronic device for use. When one electronic device uses the camera of another electronic device, the camera of the other electronic device is called a shared camera.
[0044] II. MEP (Microsoft Effect Pack) function
[0045] MEP function is a function for optimizing camera effects. The algorithm processing of the video stream collected by the camera involves many MEP resources, so the MEP resources used need to be released after the camera is removed. The MEP function mainly includes the following:
[0046] Auto framing: Auto framing refers to detecting a person in the camera's field of view and maintaining the person in the frame through cropping / zooming.
[0047] Eye contact: Eye contact refers to an eye line compensation effect that gives the effect of looking at the screen instead of the camera. Eye contact includes standard correction and reading correction. Standard correction: a subtle correction for the device user looking down from the camera to the screen, which does not adjust the left and right movement of the eyes. Reading correction: provides advanced correction for the user's eye line when scanning around the screen while reading the content of the document.
[0048] Background effect: Background effect refers to the effect of background blur. Background effect includes standard blur, which is a simple "Gaussian blur" effect. Portrait blur: a subtle bokeh-style blur effect. Depending on the functionality of the electronic device, it can be a subtle or deep bokeh blur processing.
[0049] Portrait light: Improves the lighting of the characters in the film in poor lighting environments and eliminates strong screen reflections.
[0050] Creative filters: Video filters can add some fun and flair.
[0051] Voice Focus: The microphone's effect, designed to filter background noise and ensure the user's voice is clearly conveyed during video calls.
[0052] III. System Camera Frame Service (Windows Camera Frame Server)
[0053] Windows Camera Frame Server refers to a camera framework service in Windows systems, hereinafter referred to as "Camera Service". Video streams captured by the camera in an application can run within this service framework. For example, requesting resources to play the video stream and releasing camera resources can be achieved by calling interfaces within this Camera Frame Server. This Camera Service is a system process that can be started when any application on an electronic device uses camera functionality.
[0054] The following describes the application scenarios of the embodiments of this application:
[0055] Please see Figure 1a , Figure 1a This is a schematic diagram illustrating an application scenario provided by an embodiment of this application. For example... Figure 1a As shown, the electronic device to which the first camera belongs can be electronic device A, and the first camera on electronic device A can be a detachable camera. When the first camera is inserted into the corresponding slot of electronic device A, a connection is established between the first camera and electronic device A. For example, the display interface of electronic device A can display a "Camera attached" message. When the first camera is pulled out of the corresponding slot of electronic device A, the connection between the first camera and electronic device A is broken. For example, the display interface of electronic device A can display a "Camera ejected" message.
[0056] In a scenario, such as Figure 1a As shown, when the first camera is connected to electronic device A, i.e., when the first camera is started, the camera service is activated, and the first camera can capture video streams for corresponding processing. For example, after capturing a video stream, the first camera can transmit it to electronic device A for playback. When the first camera is disconnected from electronic device A, the camera resources of the first camera begin to be released. Because the release speed of the camera resources of the first camera is slow, if the first camera is briefly plugged back into electronic device A after being disconnected, that is, if the camera resources of the first camera are not fully released before the first camera is reconnected to electronic device A, the camera may freeze, resulting in a black screen or a message indicating that the camera is being illegally occupied.
[0057] Therefore, in order to solve the problem that the disconnection and reconnection of the first camera and the electronic device A within a short time cause the freezing and the black screen or the prompt of the camera being illegally occupied, when the first camera is disconnected with the electronic device A, the camera service is stopped to accelerate the release speed of the camera resource of the first camera. When the release of the camera resource of the first camera is completed, the reconnection of the first camera and the electronic device A does not cause the problem of the black screen or the prompt of the camera being illegally occupied.
[0058] In another scenario, please refer to Figure 1b , Figure 1b An application scenario provided by the embodiment of the present application is shown in Figure Two . If the first camera is connected to the electronic device A, the first camera is used to enter the video conference in the conference application. And the connection between the electronic device A and the electronic device B is established, and the cameras can be shared, so that the electronic device A can use the shared camera of the electronic device B, that is, the second camera. If the electronic device A needs to record a video during the video conference using the first camera, the video recording application on the electronic device A can be started, for example, the camera application. The selection icon for the second camera is displayed in the display interface of the camera application, and in response to the trigger instruction of the selection icon for the second camera, the first pop-up message is displayed on the display interface of the electronic device A to request to start the second camera. The electronic device A can also respond to the permission instruction of the first pop-up message to switch the camera of the camera application on the electronic device A to the second camera, so that the video recording using the second camera can be started.
[0059] Optionally, if the electronic device A establishes a connection with multiple electronic devices respectively, the cameras of the multiple electronic devices are all shared cameras, that is, there are multiple second cameras, and the electronic device A can respond to the trigger instruction of the selection icon for the second camera to select the second camera. The electronic device can also switch multiple second cameras by responding to the trigger instruction of the selection icon multiple times, so as to select any one of the multiple second cameras.
[0060] Further, as Figure 1bAs shown, in the scenario that the electronic device A uses the first camera and the second camera simultaneously, for example, in the process of using the second camera for video recording, the first camera is used for video conference. When the video conference ends and the first camera is unplugged, the camera resource release of the camera can be accelerated by stopping the camera service. However, stopping the camera service will release the camera resource of the first camera and the camera resource of the second camera, and the camera resource release of the second camera will affect the normal use of the second camera. Therefore, in order to continue to use the second camera, the first pop-up message is displayed again on the display interface of the electronic device A to request to start the second camera. Since the first camera is disconnected from the electronic device A, the first pop-up message will be displayed again on the display interface of the electronic device A, which will interfere with the normal use of the second camera, thereby reducing the user experience.
[0061] Therefore, in order to solve the problem that the disconnection between the first camera and the electronic device A causes the first pop-up message to be displayed again, which interferes with the normal use of the second camera. After the disconnection between the first camera and the electronic device A, if the second camera is being used, the unplugging time of the first camera is recorded in the registry, and the camera service is stopped. Since the second camera is being used, the camera service is restarted, and the first pop-up message is not displayed by judging the unplugging time, thereby reducing the display of unnecessary pop-up messages in the application interface, avoiding interfering with the normal use of the second camera, thereby improving the use experience of the second camera.
[0062] In the following, the camera management method provided by the embodiments of the present application will be described in detail in combination with Figure 2 The specific flow of the camera management method provided by the embodiments of the present application will be described in detail, please refer to Figure 2 , Figure 2 The flowchart of the camera management method provided by the embodiments of the present application is shown in FIG. 1, which can include but is not limited to the following steps: Figure 2
[0063] S101, when the first camera is started, the camera service is started.
[0064] The camera management method in the embodiments of the present application can be applied to the electronic device to which the first camera belongs. The electronic device to which the first camera belongs can refer to the electronic device in which the first camera is deployed. The electronic device to which the first camera belongs can refer to a personal computer (PC), and the PC can include but is not limited to a tablet computer, a notebook computer, a palm computer, a desktop computer, etc.
[0065] The first camera can be a detachable camera, which can be connected to and disconnected from the electronic device. For example, the detachable camera can be connected to the electronic device by being inserted into a corresponding slot of the electronic device, or by being magnetically connected to the electronic device, or by other connection methods. The present application does not limit the connection method between the detachable camera and the electronic device. The camera service can be a service required for video stream acquisition by any application that needs to use the camera. By running the camera service, the camera started on the electronic device can normally operate, for example, to acquire a video stream for corresponding processing.
[0066] Optionally, the camera service can be, for example, a windows Camera Frame Server. The camera service can be automatically triggered and started when the first camera is started.
[0067] Optionally, the electronic device can be installed with a shooting application that needs to use the camera. The shooting application can be an application program that can use the camera to acquire images and videos. The shooting application can include, but is not limited to, a camera application, a conference application that can take pictures, a chat application that can take pictures, or any other application that can acquire video images. When the electronic device needs to use the first camera, a connection between the electronic device and the first camera can be established, so that when the electronic device starts the shooting application, the first camera can be started, and the camera service can be started. For example, the first camera can be inserted into the corresponding slot of the electronic device by the use object of the electronic device, so as to establish a connection between the electronic device and the first camera.
[0068] Optionally, when the shooting application is a camera application, the first camera can be started when the electronic device starts the camera application and enters a shooting interface, so as to start the camera service.
[0069] Optionally, when the shooting application is a chat application that can take pictures, the first camera can be started by establishing a video call between the electronic device and any chat object in the chat application after the electronic device starts the chat application, so as to start the camera service. Alternatively, the electronic device can start the first camera in response to a trigger instruction for a shooting function in the chat application, so as to start the camera service.
[0070] Optionally, when the first camera is connected to the electronic device, the electronic device can acquire a video stream through the first camera for corresponding processing, such as video playing, video calling, video conferencing, and the like.
[0071] S102, in response to a start instruction for the second camera, a first pop-up message is displayed.
[0072] For example,Figure 1b As shown, when the electronic device enters a shooting application, for example, enters a camera application, the application interface of the camera application can display a selection icon of the second camera, and when a selection operation on the selection icon of the second camera is detected, a first pop-up message is displayed in response to the start instruction of the second camera. For example, the first pop-up message can include "Do you allow the application to use the front camera of the electronic device B? You can switch other cameras in the application settings".
[0073] The purpose of displaying the first pop-up message in response to the start instruction of the second camera is to obtain the use permission of the second camera, so as to start the second camera. Generally, the first pop-up message can be displayed before starting the second camera each time the second camera is connected, so as to obtain the use permission of the second camera and realize normal use of the second camera. Displaying the first pop-up message when the electronic device starts the second camera each time the second camera is connected is the normal process of starting the second camera.
[0074] The second camera is different from the electronic device to which the first camera belongs, and the second camera can be a shared camera, which can be a camera on another electronic device other than the electronic device to which the first camera belongs. The second camera can be a fixed camera on the electronic device to which the second camera belongs, or a separate camera on the electronic device to which the second camera belongs. The fixed camera can be a camera integrated on the electronic device and cannot be plugged out. The present application does not limit the form of the second camera on the electronic device to which the second camera belongs.
[0075] Optionally, the electronic device to which the second camera belongs can include but is not limited to a mobile phone, a vehicle-mounted device, a smart voice interaction device, a wearable device, a tablet computer, a notebook computer, a palm computer, a desktop computer, etc.
[0076] Optionally, the electronic device to which the first camera belongs and the electronic device to which the second camera belongs can establish a communication connection, so as to realize shared use of some functional modules on the electronic device, for example, the electronic device to which the first camera belongs shares the use of the camera on the electronic device to which the second camera belongs.
[0077] Optionally, the electronic device to which the first camera belongs and the electronic device to which the second camera belongs can establish a communication connection in the following manner: the electronic device to which the first camera belongs and the electronic device to which the second camera belong can log in to the same device account, and multiple electronic devices under the same device account are integrated in a shareable shared cluster, and the device models and operating systems of the devices in the shared cluster can be different, so that the sharing of the functional modules between the electronic devices in the shared cluster can be realized, for example, the sharing of the cameras on any electronic device in the shared cluster. By connecting the camera of one electronic device, such as a mobile phone, to another electronic device, such as a PC, through the shared cluster, the PC can use the camera of the mobile phone, and the switching of multiple cameras under the same application installed on the PC can also be realized, for example, the camera of the PC can be switched to the camera of the mobile phone when the PC uses the camera, and different cameras can be used by different applications on the PC at the same time, for example, the camera application on the PC can record a video through the camera on the PC, and the conference application on the PC can conduct a video conference through the camera on the mobile phone.
[0078] Optionally, the electronic device to which the first camera belongs and the electronic device to which the second camera belong can also establish a communication connection in other manners, for example, through Bluetooth (BT), wireless local area networks (WLAN) such as Wi-Fi networks, or other manners, so that the sharing of the functional modules between the electronic devices can be realized, and the application does not limit the manner of establishing a communication connection between the electronic devices.
[0079] Optionally, if the first camera is inserted into the slot corresponding to the electronic device, and a communication connection is established between the electronic device and the electronic device to which the second camera belongs, when the electronic device needs to use the camera, one or both of the first camera and the second camera can be selected for use.
[0080] Optionally, the first pop-up message is used to request to start the second camera. After the electronic device to which the first camera belongs and the electronic device to which the second camera belong establish a communication connection, if the electronic device to which the first camera belongs needs to use the second camera, the first pop-up message can be displayed to request the use permission of the second camera. When the permission operation for the first pop-up message is detected, the electronic device to which the first camera belongs starts the second camera in response to the permission instruction for the first pop-up message, and the electronic device can use the second camera to collect a video stream.
[0081] Optionally, when the second camera is connected to the electronic device, the electronic device can collect a video stream through the second camera for corresponding processing, such as video playing, video calling, video conferencing, and the like.
[0082] Optionally, the execution sequence of step S101 and step S102 in the present application is not limited, for example, step S101 can be executed first and then step S102 is executed, or step S102 can be executed first and then step S101 is executed. That is, the starting timing of the first camera and the second camera is not limited, for example, the first camera can be started first and then the second camera is started, or the second camera can be started first and then the first camera is started. The camera service in the present application does not necessarily have to be started when the first camera is started. If the second camera is started first, the camera service can also be started along with the starting of the second camera. Alternatively, if there is another camera on the electronic device other than the first camera and the second camera that is started first, the camera service can also be started along with the camera that is started first. The present application does not limit the starting time of the camera service. Any camera on the electronic device can start the camera service, and the camera service can be started along with the camera that is started first.
[0083] Optionally, the second camera can refer to the front camera or the rear camera on the electronic device to which the second camera belongs. When the electronic device to which the second camera belongs establishes a communication connection with the electronic device to which the first camera belongs, a communication connection can be established for the front camera and the rear camera on the electronic device to which the second camera belongs respectively, so that when the electronic device to which the first camera belongs uses the second camera, any one or both of the front camera and the rear camera on the electronic device to which the second camera belongs can be used.
[0084] S103, when the first camera is unplugged, if the second camera is in use, record the unplugging time of the first camera in the registry, and stop the camera service.
[0085] Optionally, the first camera being unplugged can trigger a first camera unplugging event, and the electronic device can detect that the first camera is unplugged. The first camera being unplugged refers to the disconnection between the first camera and the electronic device, for example, the first camera is unplugged from the corresponding slot of the electronic device. When the first camera is unplugged, the electronic device can detect whether the second camera is in use, if the second camera is in use, the unplugging time of the first camera can be recorded in the registry, and the camera service is stopped.
[0086] Optionally, when the first camera is unplugged from the electronic device, the control module, for example, can be Device Manager, can detect the unplugging and plugging of the first camera by the Basic Input Output System (BIOS) of the electronic device, thereby triggering the first camera to interrupt the electronic device.
[0087] Optionally, the electronic device can determine whether the second camera is in use by reading a flag bit, the field in the flag bit being different when the second camera is in use and not in use. For example, when the second camera is in use, the field in the flag bit is "true". For example, when the second camera is not in use, the field in the flag bit is "false". Optionally, when the second camera is in use, the field in the flag bit can also be other fields, and when the second camera is not in use, the field in the flag bit can also be other fields, as long as the field in the flag bit is different when the second camera is in use and not in use, which is not limited in the present application.
[0088] Optionally, when the first camera is unplugged, the camera service is stopped, the camera service is restarted, and the first pop-up message is not displayed. Since the first camera is unplugged, stopping the camera service can accelerate the release efficiency of the camera resources of the first camera, thereby avoiding the problem of black screen or illegal occupation caused by the reinsertion of the first camera within a short time after the first camera is unplugged. However, since the electronic device is using the second camera, stopping the camera service will affect the normal use of the second camera, so by restarting the camera service, the normal use of the second camera can be ensured. Since the camera service is stopped due to the unplugging of the first camera, the interruption of the second camera caused by the stopping of the camera service is also caused by the unplugging of the first camera, so by not displaying the first pop-up message, unnecessary pop-up messages can be reduced, and the normal use of the second camera can be avoided.
[0089] Optionally, when the first camera is unplugged, if the second camera is in use, the unplugging time of the first camera is recorded in the registry, and the camera service is stopped to accelerate the release of the camera resources of the camera, for example, the camera resources of the camera can include camera-related resources such as MEP, and the camera resources of the camera can include the camera resources of the first camera, the camera resources of the second camera, system resources, etc. When the release of the camera resources of the camera is completed, the second camera is stuck.
[0090] The camera resource of the first camera can refer to a camera resource used by the first camera in operation, the camera resource of the second camera can refer to a camera resource used by the first camera in operation, and the system resource can refer to a system resource used by the first camera in operation and a system resource used by the second camera in operation. Since the MEP resource is required for the electronic device to perform algorithm processing on the video streams collected by the first camera and the second camera, the MEP resource used is released after the first camera is unplugged or when the first camera and the second camera are exited. Stopping the camera service causes the MEP resource and the system resource corresponding to all cameras to be released.
[0091] Optionally, the system resource can include a buffer used by the first camera and the second camera, a library encapsulating an algorithm plan corresponding to algorithm processing on the video streams collected by the first camera and the second camera, and the like. Since the camera service is used to run the cameras on the electronic device, including the first camera and the second camera, when the camera service is stopped, the camera resource and the system resource of all cameras on the electronic device are released, thereby accelerating the release of the camera resource of the camera.
[0092] The unplugging time of the first camera is recorded in the registry, and the unplugging time of the first camera recorded in the registry can be combined to determine whether to display the first pop-up message.
[0093] S104, restarting the camera service, and obtaining the unplugging time of the first camera from the registry.
[0094] Since the first camera is unplugged to stop the camera service, and the second camera is in use, stopping the camera service will cause the second camera to abnormally stop and affect normal use. Therefore, in order to ensure the normal use of the second camera, the electronic device can restart the camera service to ensure the normal use of the second camera. Further, the unplugging time of the first camera can be obtained from the registry, and the unplugging time of the first camera can be combined to control whether to display the first pop-up message.
[0095] Optionally, when the camera service is restarted, the camera resource of the second camera can be re-applied to ensure the normal use of the second camera. Further optionally, the system resource corresponding to the second camera can also be re-applied to ensure the normal use of the second camera.
[0096] S105, if the unplugging time of the first camera is not empty, the first pop-up message is not displayed, and the unplugging time of the first camera in the registry is cleared.
[0097] If the pull-out time of the first camera is not empty, it indicates that the pull-out time is recorded in the registry when the first camera is pulled out, and thus the use abnormality of the second camera is caused by the pull-out of the first camera, instead of the normal process of starting the second camera after the electronic device is connected with the second camera. Therefore, the electronic device can control not to display the first pop-up message in the display interface in the shooting application, thereby reducing the interference to the use of the second camera, and thus affecting the user experience. After clearing the pull-out time of the first camera in the registry, the pull-out time of the first camera in the registry is empty.
[0098] Further, since the judgment process of the first pop-up message of the second camera caused by the pull-out of the first camera ends, the pull-out time of the first camera in the registry can be cleared, so as to avoid that the pull-out time of the first camera in the registry is not cleared, and thus the pull-out time of the first camera in the registry is read when the second camera is started next time, and the first pop-up message is not displayed, thereby avoiding affecting the judgment of whether to display the first pop-up message for the use of the second camera next time, and thus improving the accuracy of the display of the subsequent pop-up message, and ensuring the normal use of the second camera.
[0099] Optionally, since the second camera is being used, stopping the camera service will cause the use abnormality of the second camera, for example, the second camera is stuck, that is, the image picture displayed in the interface on the electronic device to which the first camera belongs is stuck. Since the video stream is always refreshed, the image picture displayed in the interface on the electronic device to which the first camera belongs is refreshed after being stuck, and the second camera returns to normal use after restarting the camera service.
[0100] Optionally, if the pull-out time of the first camera is not empty, the electronic device can further determine the time interval between the restart time of the camera service and the pull-out time of the first camera, and if the time interval is less than or equal to a preset time length, the first pop-up message is not displayed, and the pull-out time of the first camera in the registry is cleared.
[0101] The time interval less than or equal to the preset time length indicates that the time interval is short, that is, the use abnormality of the second camera is caused by the pull-out of the first camera, and thus the first pop-up message for requesting to start the second camera is not displayed when the camera service is restarted, which can reduce the interference to the use of the second camera, and improve the user experience of the second camera. The preset time length can be set to be small according to the demand, for example, 3 seconds, 2 seconds, 5 seconds, etc.
[0102] Optionally, if the pull-out time of the first camera is not empty, the electronic device can further determine the time interval between the restart time of the camera service and the pull-out time of the first camera, and if the time interval is greater than a preset time length, the first pop-up message is displayed, and the pull-out time of the first camera in the registry is cleared.
[0103] In the case that the time interval is greater than the preset time length, it indicates that the time interval is long, i.e., the abnormal use of the second camera this time is not caused by the dismounting of the first camera, and may be caused by other factors. For example, after recording the dismounting time of the first camera to the registry, the electronic device is powered off, the electronic device is disconnected from the network, or the electronic device fails to restart, etc. Since the dismounting time of the first camera has been recorded to the registry before the electronic device is powered off or abnormally caused long time lag or restart, the time in the registry can still be read after the electronic device restarts or does not lag. Therefore, the first pop-up message can be displayed at this time. By displaying the first pop-up message for requesting to start the second camera when restarting the camera service, the normal use of the second camera can be ensured.
[0104] Further, since the first pop-up message has been displayed this time, it indicates that the judgment logic of whether to display the first pop-up message for the second camera this time has ended. Therefore, by clearing the dismounting time of the first camera in the registry, it will not affect the judgment of whether to display the first pop-up message for the use of the second camera next time, thereby improving the accuracy of the subsequent pop-up message display.
[0105] Optionally, when the electronic device clears the dismounting time of the first camera in the registry, the following three different clearing mechanisms can be used for clearing. After the dismounting time of the first camera in the registry is cleared by different clearing mechanisms, the result read out is different, but no matter which clearing mechanism is used, the meaning represented by the result read out after clearing is the same. For example:
[0106] The first clearing mechanism empties the dismounting time of the first camera in the registry. When the time in the registry is read again, the dismounting time of the first camera is empty. Correspondingly, if the dismounting time of the first camera in the registry is not emptied, the dismounting time of the first camera can be read as not empty.
[0107] The second clearing mechanism clears the dismounting time of the first camera in the registry to zero. When the time in the registry is read again, the dismounting time of the first camera is 0. Correspondingly, if the dismounting time of the first camera in the registry is not cleared to zero, the dismounting time of the first camera can be read as not 0.
[0108] The third clearing mechanism clears the dismounting time of the first camera in the registry. When the time in the registry is read again, the dismounting time of the first camera cannot be obtained since it has been cleared. Correspondingly, if the dismounting time of the first camera in the registry is not cleared, the dismounting time of the first camera can be obtained.
[0109] Optionally, if the first camera's pull-out time is not acquired, the first pop-up message is displayed; or if the first camera's pull-out time acquired is 0, the first pop-up message is displayed.
[0110] If the first camera's pull-out time is not acquired in the registry, it indicates that the electronic device has cleared the first camera's pull-out time in the registry. For example, the first camera's pull-out time in the registry can be cleared when the second camera exits use, when the first pop-up message is displayed, or when the first pop-up message is not displayed. If clearing the registry means clearing the first camera's pull-out time in the registry to 0, the first camera's pull-out time acquired is 0, and the first pop-up message is displayed.
[0111] Optionally, if the first camera's pull-out time acquired is abnormal, the first pop-up message is displayed. For example, the first camera's pull-out time being abnormal can mean that the pull-out time is after or equal to the time when the camera service is restarted, which can indicate that an error is recorded when recording the first camera's pull-out time. Although the first camera's pull-out time is recorded with an error, since the first camera's pull-out time is recorded when the first camera is pulled out, it can also indicate that the second camera's abnormality is caused by the first camera being pulled out, and thus the first pop-up message can not be displayed.
[0112] In S106, if the first camera's pull-out time is empty, the first pop-up message is displayed.
[0113] If the first camera's pull-out time is empty, it indicates that this time of use of the second camera is a normal use case, for example, the second camera can be used again after exiting use after the first camera is pulled out, and the first pop-up message can be displayed to start the second camera.
[0114] Optionally, the first pop-up message displayed when the first camera's pull-out time is empty and the first pop-up message displayed in response to the start instruction of the second camera can be the same or different, which is not limited in the present application.
[0115] In one embodiment, if the second camera exits use, the first camera's pull-out time in the registry is cleared.
[0116] Optionally, if the second camera exits use and the first camera's pull-out time is not empty, the first camera's pull-out time in the registry is cleared.
[0117] The second camera exiting use can mean that the second camera normally exits use, for example, the normal use exit case of the second camera includes the following cases:
[0118] After the second camera is used, the electronic device to which the first camera belongs will normally stop using the second camera; or the electronic device to which the first camera belongs will stop using the second camera when it exits a shooting application; or the electronic device to which the first camera belongs will stop using the second camera when it switches to use the camera of another electronic device.
[0119] Since the second camera was shut down normally, and this shutdown was not caused by the first camera being unplugged, clearing the unplugging time of the first camera from the registry can prevent the first pop-up message from not being displayed when the second camera is restarted. This can improve the accuracy of whether the first pop-up message is displayed when using the second camera in the future.
[0120] As can be seen from the embodiments of this application, since the first pop-up message has already been displayed to start the second camera before the first camera is unplugged, it is equivalent to having obtained the right to use the second camera. Therefore, when the camera service is stopped and restarted after the first camera is unplugged, there is no need to display the first pop-up message again. This can reduce unnecessary pop-up messages during the use of the second camera as a shared camera, thereby improving the user experience of the electronic device.
[0121] Optionally, steps S101 to S106 above can also be divided into two independent flowcharts, please refer to [link / reference]. Figure 3a and Figure 3b , Figure 3a A flowchart illustrating a camera management method provided in this application embodiment. Figure Two ,like Figure 3a As shown, this method is applied to the electronic device to which the first camera belongs, and the method may include, but is not limited to, the following steps:
[0122] S201, in response to the startup command for the camera application, starts the first camera and starts the camera service.
[0123] The electronic device to which the first camera belongs may have a camera application installed. When a startup command for the camera application is detected, the first camera on the electronic device can be started, and the camera service can be initiated. The specific implementation of step S201 here can refer to the implementation of step S101 above, and will not be repeated here.
[0124] S202, when the first camera is pulled out, detect whether the second camera is in use.
[0125] S203, if the second camera is in use, write the unplugging time of the first camera into the registry and stop the camera service.
[0126] The specific implementation of steps S202-S203 can refer to the implementation in the aforementioned step S103, and details are not described herein.
[0127] S204, if the second camera is not used, stopping the camera service.
[0128] If the second camera is not used, the camera service is directly stopped, thereby accelerating the release of the camera resource of the camera. For example, when the first camera is unplugged, the application using the second camera exits, or the second camera exits, the second camera is not used, and the camera service is directly stopped.
[0129] Steps S201-S204 are processes started by the first camera, and the processes of stopping the camera service and recording the unplugging time of the first camera in the registry. Alternatively, steps S201-S204 can be independently executed, so that the electronic device can accelerate the release of the camera resource of the first camera by stopping the camera service after the use of the first camera is finished and the second camera is being used, thereby avoiding the problem of black screen or illegal occupation caused by the reconnection of the first camera to the electronic device within a short time.
[0130] Alternatively, the electronic device can include a first camera module, and the processes of steps S201-S204 can be executed by the first camera module on the electronic device.
[0131] It can be seen that after the first camera is unplugged, the camera resource release of the camera can be accelerated by stopping the camera service, thereby avoiding the problems of black screen and illegal occupation caused by the reconnection of the first camera within a short time. Moreover, since the second camera is detected to be in use when the first camera is unplugged, the unplugging time of the first camera is recorded in the registry before the camera service is stopped, and when the camera service is restarted subsequently, whether to display the first pop-up message can be determined in combination with the unplugging time of the first camera in the registry, thereby improving the accuracy of the display of the first pop-up message.
[0132] Alternatively, please refer to Figure 3b , Figure 3b A flowchart of a camera management method provided by an embodiment of the present application is shown in FIG. 3, which is applied to an electronic device to which a first camera belongs. The method can include but is not limited to the following steps: Figure 3b
[0133] S301, calling an operating system layer to send a resource application request to a hardware layer, the resource application request being used to instruct the hardware layer to send a video stream playing parameter to a driver layer to generate a trigger event of a callback function of the driver layer.
[0134] Optionally, the electronic device can include a hardware layer, a driver layer, an application layer, and an operating system layer. The hardware layer can mainly include hardware, such as the first camera module and the second camera module. The first camera module and the second camera module can both be used to capture video streams. The driver layer can include camera drivers, such as a first camera driver (such as usbvideo.sys) and a second camera driver (such as dmsdpvirtualbus.sys). The first camera driver is used to trigger the first camera to start capturing a video stream when a trigger command sent by a shooting application is received. The second camera driver is used to trigger the second camera to start capturing a video stream when a trigger command sent by a shooting application is received. The application layer mainly includes a shooting application and a device management application. The device management application can be used to manage the electronic device, such as a device manager on the electronic device. The device management application is used to record the plug-out time of the first camera in the registry, and determine whether to display the first pop-up message through the second camera module in the device management application, and the like. The shooting application is used to receive compressed video streams for video stream playback, and stop playing the video streams when a stop playing message for the video streams is received. The operating system layer is used to detect the plug-out and plug-in of the first camera, and notify the device management application of the device change of the first camera, such as the plug-out and plug-in.
[0135] The device management application can call the operating system layer to send a resource application request to the hardware layer. The resource application request is used to request to obtain video playback resources to play the video stream captured by the second camera. The video playback resources can include camera resources of the second camera and system resources required by the second camera.
[0136] The playback parameters of the video stream can be configuration messages used to play the video stream, such as resolution, code rate, and the like. The callback function of the driver layer is used to trigger the second camera module in the device management application to read the plug-out time of the first camera in the registry to determine whether to display the first pop-up message. Optionally, the callback function of the driver layer can be a SET_WAIT callback.
[0137] S302, in response to the start message of the camera service sent by the driver layer based on the trigger event of the callback function, restarting the camera service.
[0138] In the callback function is in the driver layer, when the driver layer triggers the callback function, the second camera module in the device management application reads the plug-out time of the first camera in the registry to determine whether to display the first pop-up message. Therefore, the hardware layer sends the play parameters of the video stream to the driver layer. The driver layer receives the play parameters of the video stream, and then triggers the callback function to send a start message to the second camera module in the device management application. The second camera module knows that the second camera needs to be started, and then restarts the camera service and reads the plug-out time of the first camera in the registry to determine whether to display the first pop-up message. When the first pop-up message is displayed and the permission instruction for the first pop-up message is obtained, the second camera is started. Or, the second camera is directly started without displaying the first pop-up message.
[0139] Optionally, the start message sent by the driver layer to the second camera module in the device management application does not necessarily need to be in the form of message sending, but can also be communicated through an input / output (I / O) port. As long as the communication between the driver layer and the second camera module in the device management application can be realized, the second camera module in the device management application can start to read the plug-out time of the first camera in the registry to determine whether to display the first pop-up message. The communication mode between the driver layer and the second camera module in the device management application is not limited in the present application.
[0140] Optionally, when the camera service is restarted, a resource application request is sent to the hardware layer through the operating system layer, so that the camera service is restarted when the video play resource is applied. When the camera service is restarted, the second camera is started again.
[0141] S303, read the plug-out time of the first camera in the registry to determine whether the plug-out time is empty.
[0142] S304, if empty, display the first pop-up message.
[0143] S305, if not empty, do not display the first pop-up message, and clear the plug-out time of the first camera in the registry.
[0144] The specific implementation of steps S304-S305 can refer to the implementation of steps S104-S106 described above, which will not be repeated here.
[0145] S306, call the second camera to collect a video stream.
[0146] Since the camera service has been restarted and the second camera is in a normal use state, the second camera can be called to collect a video stream for playing.
[0147] Optionally, steps S301 to S306 can be executed by a device management application in the electronic device. Optionally, the device management application on the electronic device may include a second camera module, and the process of steps S301 to S306 described above can be executed by the second camera module.
[0148] Optionally, steps S301 to S306 can be executed independently, thereby enabling the electronic device to start normally for the second camera. Alternatively, steps S301 to S306 can also be executed after steps S201 to S204, and this application does not limit this.
[0149] As can be seen, by triggering the callback function, the unplugging time of the first camera can be read from the registry. This, combined with the unplugging time, determines whether to display the first pop-up message, improving the accuracy of its display. Furthermore, if the unplugging time of the first camera is not empty, it indicates that the malfunction of the second camera is due to the unplugging of the first camera; therefore, the first pop-up message can be hidden to avoid degrading the user experience of the second camera. If the unplugging time of the first camera is empty, it indicates that the second camera is being used normally after being connected to the electronic device; therefore, the first pop-up message can be displayed to ensure the normal use of the second camera.
[0150] The above Figure 2 , Figure 3a , Figure 3b The following embodiments illustrate the process of camera management on electronic devices. Figure 4 and Figure 5 Regarding the above Figure 2 , Figure 3a , Figure 3b The following is an exemplary illustration of the flowchart illustrating the interaction between various modules during the camera management process of an electronic device. For an example, please refer to... Figure 4 , Figure 4 The first flowchart illustrates the interaction between various modules of an electronic device, as provided in this embodiment of the application. During camera management within the electronic device, the interaction flow between these modules is as follows:
[0151] S401, the operating system detects the user's unplugging operation on the first camera and triggers an interrupt for the first camera.
[0152] Specifically, when the first camera is unplugged from the electronic device, the control module (Device Manager) in the operating system layer of the electronic device can detect the unplugging of the first camera and trigger an interrupt notification to the operating system layer of the electronic device.
[0153] S402, the operating system sends an interrupt message to the device management application.
[0154] The interrupt message is used to indicate that the first camera is unplugged. The interrupt message sent by the operating system layer can be a windows message. The interrupt message of the first camera is transmitted to the device management application through the windows message mechanism. The windows message mechanism can include a message type used to indicate device changes, such as WM_devicechange (windows manager device change, device change message). The WM_devicechange can indicate that the first camera is unplugged.
[0155] S403, the device management application writes the unplugging time of the first camera into the registry and calls an interface to stop the camera service.
[0156] The camera service is a system process running in the operating system. Therefore, the device management application can call an interface on the operating system to stop the camera service, so that the operating system stops the camera service.
[0157] S404, the operating system releases the camera resources of the camera when stopping the camera service.
[0158] The operating system releases the camera resources of the camera during the process of stopping the camera service. The released camera resources of the camera include the camera resources of the first camera, the camera resources of the second camera, and system resources.
[0159] S405, the operating system sends a stop playing message for the video stream to the shooting application.
[0160] After the camera resources of the camera are released, the operating system sends a stop playing message for the video stream to the shooting application, so that the shooting application stops playing the video stream. Alternatively, the operating system and the shooting application can also interact in other ways other than sending messages, as long as the operating system can notify the shooting application to stop playing the video stream. The communication mode between the operating system and the shooting application is not limited in the present application.
[0161] S406, the shooting application stops playing the video stream.
[0162] Alternatively, the stopped video stream can include the video stream collected by the first camera and the video stream collected by the second camera. Since the first camera and the second camera both need the camera service to run, after the camera service is stopped, the video stream collected by the first camera and the video stream collected by the second camera will stop playing.
[0163] S407, the operating system sends a resource application request to the hardware layer to the second camera module.
[0164] In the embodiment, since the first camera and the second camera both establish a video stream before the first camera is pulled out. When the first camera is pulled out, stopping the camera service can accelerate the release of the camera related resources. When the camera resources of the second camera are released, since the second camera is still in use, in order to ensure the normal use of the second camera, the camera resources of the second camera need to be re-applied to ensure the normal operation of the second camera. Therefore, the operating system can send a resource application request to the hardware layer due to the detection of the use of the second camera.
[0165] S408, the hardware layer sends the playing parameters of the video stream to the driver layer to generate a trigger event of the callback function of the driver layer.
[0166] In the embodiment, when the hardware layer receives the resource application request, the hardware layer can send the playing parameters of the video stream to the driver layer. When the driver layer receives the playing parameters of the video stream, the callback function of the driver layer can be triggered, thereby generating the trigger event of the callback function of the driver layer.
[0167] S409, the driver layer sends a start message of the camera service to the device management application based on the trigger event of the callback function.
[0168] In the embodiment, after the driver layer triggers the callback function, the driver layer can send the start message of the camera service to the device management application to inform the device management application that the second camera needs to be run.
[0169] S410, the device management application restarts the camera service and calls the second camera module to obtain the pull-out time of the first camera from the registry.
[0170] In the embodiment, the device management application can call the interface on the operating system for running the camera service to make the operating system restart the camera service and apply for the camera resources and the system resources of the second camera to the operating system layer when the camera service is restarted. The system resources refer to the system resources required for running the second camera.
[0171] Optionally, the second camera module can refer to a module on the device management application for managing the second camera. The device management application can further include a first camera module for managing the first camera, a camera module for managing other cameras, and the like.
[0172] S411, if the pull-out time of the first camera is not empty, the device management application calls the second camera module to not display the first pop-up message and clears the pull-out time of the first camera in the registry.
[0173] S412, the device management application sends a play message for the video stream to the shooting application.
[0174] Wherein, since the first camera is pulled out at this time, the video stream here can refer to the video stream collected by the second camera.
[0175] S413, the shooting application resumes playing the video stream.
[0176] Wherein, when the shooting application receives the play message, it resumes playing the video stream. For example, it resumes playing the video stream collected by the second camera.
[0177] S414, if the pull-out time of the first camera is empty, the device management application calls the second camera module to display a first pop-up message.
[0178] S415, the device management application sends a play message for the video stream to the shooting application in response to an allow instruction for the first pop-up message.
[0179] Further, after the device management application sends a play message for the video stream to the shooting application in response to an allow instruction for the first pop-up message, the shooting application resumes playing the video stream.
[0180] Optionally, Figure 4 The implementation modes not mentioned in steps S401-S415 in the corresponding embodiments can refer to the specific implementation of steps S101-S106, and refer to the specific implementation of steps S201-S204 and steps S301-S306, which will not be repeated here.
[0181] Further optionally, please refer to Figure 5 , Figure 5 An electronic device module interaction process provided by the embodiments of the present application Figure Two , Figure 5 Mainly detailed description is made on the process of video stream collection and video stream playing for the first camera and the second camera respectively in the process of camera management in the electronic device, and the interaction process of each module in the electronic device in the process is as follows:
[0182] S501, the device management application detects that the first camera and the second camera are accessed.
[0183] The device management application can detect whether the first and second cameras are accessed simultaneously. For example, it can determine which applications and cameras are in use by reading the registry. If the first camera is accessed, the application can read the corresponding markers in the registry to confirm access. Similarly, the application can read the corresponding markers in the registry to confirm access to the second camera. The first camera at the hardware layer refers to the first camera module, i.e., the first camera device. The second camera at the hardware layer refers to the second camera module, i.e., the second camera device.
[0184] S502, the first camera samples data to obtain the first video stream.
[0185] Data sampling refers to the process of acquiring image frames to obtain a video stream.
[0186] S503, the first camera transmits the first video stream to the first camera driver in the driver layer.
[0187] Optionally, the driver layer may include a first camera driver and a second camera driver. The communication module can transmit the first video stream to the first camera driver in the driver layer. The first camera driver is used to perform video processing on the first video stream.
[0188] After the first camera samples and obtains the first video stream, it can transmit the first video stream to the driver layer via data transmission. For example, the data transmission method can include, but is not limited to, Universal Serial Bus (USB) transmission. USB transmission means that the video stream is transmitted from the first camera to the central processing unit (CPU) of the electronic device, and then played by the shooting application on the electronic device.
[0189] Optionally, the camera module includes a first camera and a second camera, both of which are hardware. The driver layer, shooting applications, device management applications, and operating system are all programs that run on the CPU of the electronic device. By capturing video streams through the camera module, the data can be transmitted to the CPU of the electronic device for processing, thereby enabling data interaction between the hardware and the processor of the electronic device, and thus realizing the capture and playback of video streams.
[0190] S504, the first camera driver in the driver layer performs video compression on the first video stream to obtain the compressed first video stream.
[0191] Optionally, when the first camera driver in the driver layer receives the transmitted first video stream, the first video stream can be video processed, such as video compressed, to obtain a compressed first video stream. By compressing the video stream, the data amount can be reduced, and the transmission efficiency of the video stream can be improved.
[0192] S505, the first camera driver of the driver layer delivers the compressed first video stream to the shooting application.
[0193] Optionally, after the first camera driver in the driver layer video compresses the first video stream, the compressed first video stream can be delivered to the shooting application for video stream playing.
[0194] S506, the shooting application decompresses the compressed first video stream and plays the decompressed first video stream.
[0195] Optionally, the video compression can be video encoding, and the decompression can be video decoding. After the first video stream is video encoded and transmitted to the shooting application, the shooting application can transmit the compressed first video stream to the underlying graphics card for video decoding, and the shooting application can play the decoded first video stream.
[0196] S507, the second camera samples data to obtain a second video stream.
[0197] Optionally, the first camera and the second camera can sample data to obtain video streams, respectively. The first video stream obtained by the first camera sampling data and the second video stream obtained by the second camera sampling data can be the same or different, which is not limited in the present application.
[0198] S508, the communication module transmits the second video stream to the second camera driver of the driver layer.
[0199] Optionally, the driver layer can include a second camera driver, and the second camera driver is configured to video process the second video stream.
[0200] Optionally, since the second camera is a shared camera, i.e., the second camera is a camera on an electronic device other than the electronic device to which the first camera belongs, after the second camera collects the second video stream, the second video stream can be transmitted to the driver layer on the electronic device to which the first camera belongs through the communication module. Optionally, the communication module can include, but is not limited to, a Wi-Fi chip, and the present application does not limit the communication module as long as it can realize the transmission of the video stream from the electronic device to which the second camera belongs to the electronic device to which the first camera belongs.
[0201] Optionally, the driver layer can include a first camera driver and a second camera driver. The communication module can transmit the second video stream to the second camera driver in the driver layer.
[0202] S509, the second camera driver of the driver layer performs video compression on the second video stream to obtain a compressed second video stream.
[0203] S510, the second camera driver of the driver layer transmits the compressed second video stream to the shooting application.
[0204] Optionally, after the second camera driver of the driver layer performs video compression on the second video stream, the compressed second video stream can be transmitted to the shooting application for video stream playback.
[0205] S511, the shooting application performs video decompression on the compressed second video stream and plays the decompressed second video stream.
[0206] Optionally, by transmitting the second video stream to the shooting application after video compression, the shooting application can transmit the compressed second video stream to the underlying graphics card for video decoding, and the shooting application can play the second video stream after video decoding.
[0207] Optionally, the execution sequence of steps S502-S506 and steps S507-S508 is not limited, for example, steps S502-S506 can be executed first, and then steps S507-S508 can be executed; or steps S507-S508 can be executed first, and then steps S502-S506 can be executed; or steps S502-S506 and steps S507-S508 can be executed simultaneously, and the execution sequence of steps S502-S506 and steps S507-S508 will not affect the implementation of the present application.
[0208] Optionally, the steps S501-S511 in the embodiments of the present application can be executed independently, or can be executed before steps S401-S415, for example, before steps S401-S415, by running the first camera and the second camera on the electronic device to which the first camera belongs at the same time, when the first camera is unplugged, the camera service can be stopped, the camera service can be restarted, the second camera can be run, and the first pop-up message can not be displayed by using steps S401-S415.
[0209] The hardware structure of the electronic device 100 will be introduced as follows:
[0210] Please refer to Figure 6 , Figure 6 The hardware structure of the electronic device 100 provided in the embodiments of the present application is shown in the following figure.
[0211] The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0212] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0213] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units can be independent devices, or can be integrated in one or more processors.
[0214] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching instructions and executing instructions.
[0215] The processor 110 can also have internal memory for storing instructions and data. In some embodiments, the internal memory of the processor 110 is a cache memory. This memory can hold instructions or data which the processor 110 has recently accessed, or which are likely to be accessed. If the processor 110 needs to access this data again, it can be accessed directly from the cache memory. This avoids repeated accesses to the main memory, reducing the latency of the processor 110 and improving the efficiency of the system.
[0216] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0217] It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative and does not constitute a limitation on the structure of the electronic device 100. In some other embodiments of the present application, the electronic device 100 can also use different interface connection methods or a combination of multiple interface connection methods in the above embodiments.
[0218] The charging management module 140 is configured to receive a charging input from a charger. The charger can be a wireless charger or a wired charger.
[0219] The power management module 141 is configured to connect the battery 142 and the charging management module 140 to the processor 110. The power management module 141 receives the input of the battery 142 and / or the charging management module 140 to supply power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160, etc. In some other embodiments, the power management module 141 can also be arranged in the processor 110.
[0220] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0221] The antenna 1 and the antenna 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antennas can be used in combination with a tuning switch.
[0222] The mobile communication module 150 can provide a solution including 2G / 3G / 4G / 5G wireless communication applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert the signals into electromagnetic waves radiated by the antenna 1. In some embodiments, at least part of the functional modules of the mobile communication module 150 can be arranged in the processor 110. In some embodiments, at least part of the functional modules of the mobile communication module 150 can be arranged in the same device as at least part of the modules of the processor 110.
[0223] The modem processor can include a modulator and a demodulator. The modulator is used to modulate a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal processed by the baseband processor is transmitted to the application processor.
[0224] The wireless communication module 160 can provide a solution for wireless communication including a Wi-Fi network, Bluetooth, BLE broadcasting, a global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), and the like, which is applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives an electromagnetic wave via the antenna 2, frequency-modulates and filters the electromagnetic wave signal, and transmits the processed signal to the processor 110. The wireless communication module 160 can also receive a signal to be transmitted from the processor 110, frequency-modulate it, amplify it, and radiate it as an electromagnetic wave via the antenna 2.
[0225] In some embodiments, the antenna 1 and the mobile communication module 150 of the electronic device 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology.
[0226] The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs that execute program instructions to generate or change display information.
[0227] The display screen 194 is used to display images, videos, and the like. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 can include 1 or N display screens 194, N being a positive integer greater than 1. Among them, the display screen 194 can include an OLED screen.
[0228] Optionally, the display screen 194 can further include an OLED glass layer, an OLED light-emitting unit, a fingerprint identification sensor, a microlens array, and the like. The display screen 194 supports optical under-screen fingerprint identification.
[0229] The electronic device 100 can implement a photographing function through an ISP, a camera 193, a video codec, a GPU, a display 194, and an application processor, etc. The ISP is used to process data fed back by the camera 193. The camera 193 is used to capture a still image or a video. The camera 193 can include a front camera and a rear camera, the front camera is located in the display area of the screen, and the rear camera is located in the back area of the screen. The digital signal processor is used to process digital signals, which can process not only digital image signals but also other digital signals. The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs.
[0230] The NPU is a neural-network (NN) computing processor, which can quickly process input information by referring to the structure of a biological neural network, for example, by referring to the transmission mode between human brain neurons, and can also constantly self-learn. Through the NPU, the electronic device 100 can implement intelligent cognitive applications such as image recognition, face recognition, voice recognition, and text understanding.
[0231] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, compressed driver files and other files are saved in the external memory card.
[0232] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a video playing function), etc. The data storage area can store data (such as a video stream) created during the use of the electronic device 100, etc. In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as a flash memory device, etc.
[0233] The electronic device 100 can implement an audio function through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and an application processor, etc. For example, music playing, recording, etc.
[0234] The audio module 170 is configured to convert digital audio information into analog audio signals and to convert analog audio input into digital audio signals. The audio module 170 can also be configured to encode and decode audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110 or some of the functions of the audio module 170 can be disposed in the processor 110.
[0235] The speaker 170A, also referred to as a "loudspeaker", is configured to convert audio electrical signals into sound signals. The receiver 170B, also referred to as an "earpiece", is configured to convert audio electrical signals into sound signals. The microphone 170C, also referred to as a "microphone", "transducer", is configured to convert sound signals into electrical signals. The earphone interface 170D is configured to connect a wired earphone. The pressure sensor 180A is configured to sense pressure signals and to convert the pressure signals into electrical signals. In some embodiments, the pressure sensor 180A can be disposed in the display screen 194. The gyroscope sensor 180B can be configured to determine the motion posture of the electronic device 100. The barometric pressure sensor 180C is configured to measure air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of acceleration of the electronic device 100 in various directions, typically three axes. The distance sensor 180F is configured to measure distance. The proximity light sensor 180G can include, for example, a light emitting diode (LED) and a light detector. The ambient light sensor 180L is configured to sense ambient light brightness. The fingerprint sensor 180H is configured to acquire a fingerprint. The temperature sensor 180J is configured to detect temperature. The touch sensor 180K, also referred to as a "touch panel". The touch sensor 180K can be disposed in the display screen 194, and the touch sensor 180K and the display screen 194 together form a touch screen, also referred to as a "touch panel". The touch sensor 180K is configured to detect touch operations acting on or near the touch sensor 180K. The bone conduction sensor 180M can acquire vibration signals. The keys 190 include a power key, a volume key, and the like. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light and can be configured to indicate a charging state, a power change, and can also be configured to indicate a message, a missed call, a notification, and the like. The SIM card interface 195 is configured to connect a SIM card.
[0236] The software structure of the electronic device is described as follows:
[0237] Figure 7 A software structure of the electronic device 100 of the embodiments of the present application is shown in FIG. 2. The software structure adopts a layered architecture, which divides the software into a plurality of layers, each layer having a clear role and division of labor. The layers communicate with each other through software interfaces. In the embodiments of the present application, the electronic device can include an application layer (application, APP), an operating system layer (Operating System, OS), a driver layer, and a hardware layer (Hardware).
[0238] The application layer can include a series of application packages. For example... Figure 7 As shown, the application package may include device management applications and camera applications. Optionally, the application package may also include navigation, Bluetooth, video, and other applications.
[0239] The operating system layer is used to facilitate interaction between the application layer and the driver layer by calling the interfaces of the operating system layer. This operating system layer may include: a control module (Device Manager) and camera services.
[0240] The control module is used to detect when the first camera is pulled out or inserted.
[0241] The Camera Service is a camera framework service in Windows systems. Audio and video captured by the camera in a camera application run within this service framework. This service is a system process that starts when the camera application uses its camera function.
[0242] The driver layer, also known as the kernel layer, is responsible for managing system hardware resources and providing necessary services to applications. This layer includes drivers for various hardware devices, which are responsible for controlling and operating these devices. Figure 7 As shown, the driver layer includes: a camera driver, for example, the camera driver may include a first camera driver (such as usbvideo.sys) and a second camera driver (such as dmsdpvirtualbus.sys).
[0243] The first camera driver is used to trigger the first camera to capture video streams when it receives a trigger command sent by a shooting application.
[0244] The second camera driver is used to trigger the second camera to capture a video stream when a trigger command is received from a shooting application.
[0245] The hardware layer can include multiple hardware components, such as a first camera, a second camera, etc.
[0246] The first camera can refer to the first camera module, i.e., a separate camera device, or a separate camera. The first camera module can be used to capture video streams.
[0247] The second camera can refer to a second camera module, i.e. a shared camera device, or a shared camera. The second camera module can be used to capture video streams.
[0248] In the above embodiments, all or part of the processes can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the processes can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes described in the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk), etc.
[0249] Those of ordinary skill in the art can understand that all or part of the processes in the above embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The storage medium includes ROM or random access memory (RAM), magnetic disk or optical disk, and various media that can store program codes.
[0250] In summary, the above only describes the embodiments of the technical scheme of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of the present application shall be included in the protection scope of the present application.
Claims
1. A camera management method, characterized by, The method is applied to an electronic device to which the first camera belongs, and the method comprises: starting a camera service when the first camera is started; displaying a first pop-up message in response to a starting instruction for a second camera, the second camera being different from the electronic device to which the first camera belongs, and the first pop-up message being used to request starting the second camera; stopping the camera service, restarting the camera service, and not displaying the first pop-up message when the first camera is unplugged; wherein the restarting the camera service and not displaying the first pop-up message comprise: restarting the camera service if the second camera is being used; obtaining an unplugging time of the first camera from a registry; not displaying the first pop-up message and clearing the unplugging time of the first camera in the registry if the unplugging time of the first camera is not empty.
2. The method of claim 1, wherein, The method further comprises: displaying the first pop-up message if the unplugging time of the first camera is empty.
3. The method of claim 1, wherein, The method further comprises: clearing the unplugging time of the first camera in the registry if the second camera is not being used.
4. The method of claim 1, wherein, The not displaying the first pop-up message if the unplugging time of the first camera is not empty comprises: obtaining a time interval between a restarting time of the camera service and the unplugging time of the first camera if the unplugging time of the first camera is not empty; not displaying the first pop-up message if the time interval is less than or equal to a preset time length.
5. The method of claim 4, wherein, The method further comprises: displaying the first pop-up message and clearing the unplugging time of the first camera in the registry if the time interval is greater than the preset time length.
6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: recording the unplugging time of the first camera in the registry if the second camera is being used when the first camera is unplugged.
7. The method of claim 1, wherein, The method further comprises: releasing camera resources of the first camera and camera resources of the second camera when the camera service is stopped; reapplying the camera resources of the second camera when the camera service is restarted.
8. The method of claim 1, wherein, The restarting the camera service comprises: sending a resource application request from an operating system layer to a hardware layer, the resource application request being used to instruct the hardware layer to send a playing parameter of a video stream to a driver layer to generate a trigger event of a callback function of the driver layer; restarting the camera service in response to a starting message of the camera service sent by the driver layer based on the trigger event of the callback function.
9. An electronic device, comprising: The electronic device comprises one or more processors, a memory, and a touch screen; the memory is used to store program codes; and the processors are used to run the program codes, so that the electronic device implements the method according to any one of claims 1-8.
10. A chip system for use in electronic devices, characterized in that, The chip system comprises at least one processor and an interface, the interface being used to receive instructions and transmit the instructions to the at least one processor; and the at least one processor runs the instructions, so that the electronic device executes the method according to any one of claims 1-8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program which, when executed by the processor, implements the method of any one of claims 1-8.
12. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instructions, when executed by the processor, implement the steps of the method of any one of claims 1-8.
Citation Information
Patent Citations
Method and system for coordinating camera resources
CN103793246A
Terminal equipment and camera resource sharing method
CN113014792A