Camera Control Method and System, and Storage Device

By temporarily storing camera usage requests and establishing communication channels, the method and system stabilize camera control in complex scenarios, ensuring efficient management and reduced complexity.

CN114598806BActive Publication Date: 2025-07-15AUTOCHIPS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011431437.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-07
Publication Date
2025-07-15
Estimated Expiration
2040-12-07

AI Technical Summary

Technical Problem

In the complex scenarios of multiple camera usage requests, the camera control in the prior art is prone to loss of control, resulting in abnormal situations and cannot be used normally.

Method used

By temporarily storing the camera usage request with a preset data structure, a communication channel with the camera is established, and the camera is controlled to work according to the requested content through the communication channel, centralized management of camera usage requests is realized.

Benefits of technology

In the complex scenarios of multiple camera usage requests, multiple requests can be maintained and controlled uniformly, reducing the complexity of camera control and improving camera control stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114598806B_ABST
    Figure CN114598806B_ABST
Patent Text Reader

Abstract

The present invention discloses a camera control method, a system, and a storage device. The camera control method includes: temporarily storing at least one camera usage request in a preset data structure; in response to the temporarily stored camera usage request, establishing a communication channel with the camera by using a camera interface program; and controlling the camera to work according to the content of the camera usage request through the communication channel. By the above method, the present invention can improve the stability of camera control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a camera control method and system, and a storage device. Background Art

[0002] In the field of program development such as Android, the Android native system, or a system developed based on Android for the second time such as MIUI, or a system compatible with Android applications such as HarmonyOS, these system frameworks usually provide a set of standard APIs (Application Programming Interfaces) for controlling cameras to implement other camera functions such as preview, recording, and taking pictures.

[0003] It has been found through research that in complex scenarios such as the existence of multiple camera usage requests, directly using the APIs provided by the native system framework is extremely likely to cause the camera to get out of control, resulting in abnormal situations such as the camera being unable to be used normally. In view of this, how to improve the stability of camera control has become an urgent problem to be solved. Summary of the Invention

[0004] The main problem to be solved by the present invention is to provide a camera control method and system, and a storage device, which can improve the stability of camera control.

[0005] To solve the above technical problems, the technical solution adopted by the present invention is to provide a camera control method. The program running method includes: temporarily storing at least one camera usage request in a preset data structure; in response to the temporarily stored camera usage request, establishing a communication channel with the camera by using a camera interface program; and controlling the camera to work according to the content of the camera usage request through the communication channel.

[0006] To solve the above technical problems, another technical solution adopted by the present invention is to provide a camera control system, including a camera, a memory, and a processor. The camera and the memory are coupled to the processor. Among them, the processor is used to control the memory to temporarily store at least one camera usage request in a preset data structure, the processor is used to establish a communication channel with the camera by using a camera interface program in response to the temporarily stored camera usage request, and the processor is further used to control the camera to work according to the content of the camera usage request through the communication channel.

[0007] To solve the above technical problems, another technical solution adopted by the present invention is to provide a storage device, storing program instructions that can be run by a processor, and the program instructions are used to implement the above camera control method.

[0008] Through the above solution, the beneficial effects of the present invention are as follows: By temporarily storing at least one camera usage request in a preset data structure, in response to the temporarily stored camera usage request, a communication channel is established with the camera using a camera interface program, and through the communication channel, the camera is controlled to work according to the content of the camera usage request. Therefore, by temporarily storing the camera usage request in a preset data structure, it is beneficial to achieve centralized management of camera usage requests. Thus, even in complex scenarios with multiple camera usage requests, multiple camera usage requests can be uniformly maintained and controlled, thereby reducing the complexity of camera control and improving the stability of camera control. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings. Among them:

[0010] Figure 1 is a flowchart of an embodiment of the camera control method provided by the present invention;

[0011] Figure 2 is a flowchart of another embodiment of the camera control method provided by the present invention;

[0012] Figure 3 is a flowchart of yet another embodiment of the camera control method provided by the present invention;

[0013] Figure 4 is a schematic framework diagram of an embodiment of the camera control system provided by the present invention;

[0014] Figure 5 is a schematic framework diagram of an embodiment of the storage device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0015] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention belong to the scope of protection of the present invention.

[0016] Refer to Figure 1 , Figure 1 which is a schematic structural diagram of an embodiment of the camera control method provided by the present invention. Specifically, it may include the following steps:

[0017] Step S11: Temporarily store at least one camera usage request in a preset data structure.

[0018] In an implementation scenario, the camera usage request may include, but is not limited to: a recording request, a preview request, a photo-taking request, etc., which are not limited here. It should be noted that the recording request represents a request related to video shooting, the preview request represents a request related to displaying the scene within the camera's field of view on the display interface, and the photo-taking request represents a request related to taking photos. That is to say, the camera usage request can be regarded as a request for the camera to collect image data according to the camera usage request.

[0019] In a specific implementation scenario, the recording request may specifically include: a start recording request, a stop recording request. The preview request may specifically include: a start preview request, a stop preview request. The photo-taking request may specifically include: a start photo-taking request, a stop photo-taking request. It should be noted that the start recording request represents a request for the camera to start shooting video, while the stop recording request represents a request for the camera to stop video shooting; similarly, the start preview request represents a request to display the scene within the camera's field of view on the display interface, while the stop preview request represents a request to cancel the display of the scene within the camera's field of view on the display interface; similarly, the start photo-taking request represents a request for the camera to take a photo, while the stop photo-taking request represents a request for the camera to cancel taking a photo.

[0020] In another specific implementation scenario, the camera usage request may specifically be issued by an application with a shooting function. For example, after receiving a click operation by the user on the "Record" button in the above application, the application may issue a start recording request, and when receiving the click operation by the user on the "Record" button again, the application may issue a stop recording request, which can be specifically set according to the actual situation of the application, and no more examples will be given here.

[0021] In an implementation scenario, the preset data structure may include, but is not limited to: a list, a stack, a queue, a linked list, etc., which are not limited here.

[0022] In a specific implementation scenario, the camera usage request may specifically be encapsulated as a message and temporarily stored in a preset data structure, which can further facilitate the temporary storage of multiple camera usage requests, enabling the coexistence of the same type or different types of camera usage requests, thereby being able to reduce the possibility of interference between camera usage requests as much as possible and greatly facilitating the expansion of camera usage requests in terms of type and quantity.

[0023] In another specific implementation scenario, taking Android as an example, the native class of Android can be used to encapsulate the camera usage request as a message. The native class of Android is a class that comes with the Android system, which can specifically include but is not limited to: Message class, which is not limited here; in addition, users can also customize classes and use customized classes to encapsulate the camera usage request as a message. It should be noted that a class can be understood as a type, and any object can be instantiated based on a class. Similarly, in systems based on Android secondary development such as MIUI, or systems compatible with Android applications such as Hongmeng OS, the system's native class can be used to encapsulate the camera usage request as a message, or a user-defined class can be used to encapsulate the camera usage request as a message, which is not limited here.

[0024] In another specific implementation scenario, the camera use request can be temporarily stored in a Message List. After the application with a shooting function sends a camera use request, the camera use request can be encapsulated as a Message and added to the List, which can help to efficiently implement the centralized management of multiple camera use requests, so as to facilitate the subsequent simultaneous processing of multiple camera use requests, thereby helping to improve processing efficiency. The specific method of processing multiple camera use requests in parallel can be referred to the following related description, which will not be repeated here.

[0025] Step S12: In response to the temporarily stored camera use request, a communication channel with the camera is established using the camera interface program.

[0026] In an implementation scenario, as described above, a camera usage request can be regarded as a request for the camera to capture image data according to the camera usage request. To identify the storage space for the image data, the camera usage request may specifically include: an identifier for the storage space of the image data. Still taking Android as an example, the camera usage request includes a Surface, which is used to indicate a memory space, facilitating the camera to temporarily store the captured image data in the memory space indicated by the Surface. In addition, to identify the specific request content of the camera usage request, the camera usage request may further include: the camera usage type of the camera usage request, for example: start recording, stop recording, start preview, stop preview, etc., which are not limited here. Still taking Android as an example, all Surfaces can be specifically retrieved from the temporarily stored camera usage requests to form a Surface list to create a CameraCaptureSession (i.e., a camera capture session). It should be noted that CameraCaptureSession is a transaction used to send a request to the camera to obtain image data. In addition, CameraCaptureSession mainly has two methods: setRepeatingRequest (i.e., setting a repeating request) and capture (i.e., capturing). Among them, setRepeatingRequest is used to repeatedly request to obtain image data (such as preview, continuous shooting, etc.), and capture is used for single-shot photography. On this basis, after the CameraCaptureSession is configured, it can be considered that the communication channel is established. It should be noted that CameraCaptureSession, Request, setRepeatingRequest, capture, etc. are all programs defined in the Android camera interface program (i.e., camera API), and their specific program codes will not be elaborated here. That is to say, after configuring the CameraCaptureSession using the temporarily stored camera usage requests, these temporarily stored camera usage requests all correspond to the same CameraCaptureSession. On this basis, the camera can be controlled to work according to the content requested by the above-mentioned temporarily stored camera usage requests based on the communication channel established by the CameraCaptureSession.

[0027] In an implementation scenario, step S12 and subsequent steps of the embodiments of the present disclosure can be specifically executed when it is detected that the camera state is a preset state. Specifically, the camera state may include: turned on, turned off, turning on, turning off, and the preset state may be turned on. Still taking Android as an example, the camera state (i.e., the state of CameraDevice) specifically includes: opening (i.e., turning on), opened (i.e., turned on), closing (i.e., turning off), closed (i.e., turned off). It should be noted that the above CameraDevice (i.e., the camera device) is an abstract class defined in Android and can be used to represent the camera. In the above manner, when it is detected that the camera state is the preset state, a communication channel with the camera can be established in response to the temporarily stored camera usage request, thereby improving the success rate of establishing the communication channel.

[0028] In another implementation scenario, when it is detected that the camera state is not the above preset state and the number of temporarily stored camera usage requests is not less than one, the camera state can be automatically switched to the preset state, and then step S12 and subsequent steps in the embodiments of the present disclosure are executed. Still taking Android as an example, when it is detected that the camera state is not the above preset state and the number of temporarily stored camera usage requests is not less than one, the CameraDevice can be switched to the opened state through openCamera (i.e., opening the camera). It should be noted that openCamera is also a program defined in the camera interface program (i.e., camera API) of Android, and its main function is to open the camera. The specific program code is not elaborated here. The above can automatically switch the camera state to the preset state when it is detected that the camera state is not the above preset state and the number of temporarily stored camera usage requests is not less than one, and then establish a communication channel with the camera in response to the temporarily stored camera usage request, thereby improving the speed of responding to the camera usage request and enhancing the user experience.

[0029] In an implementation scenario, in addition to the temporarily stored camera usage requests, new camera usage requests may also be obtained during the entire process of controlling the camera. The new camera usage requests can also be temporarily stored in a preset data structure according to the foregoing description. On this basis, if a new camera usage request is obtained, the created communication channel can be closed in response to the new camera usage request, and the communication channel can be re-established using the camera interface program in response to the temporarily stored camera usage requests and the new camera usage request. The above method can further improve the response rate to camera usage requests. In addition, since the communication channel is re-established in response to the temporarily stored camera usage requests and the new camera usage request, it is beneficial to improve the success rate of subsequent control of the camera to work according to the content of the new camera usage request. It should be noted that, as described above, the camera usage request is used to make the camera collect image data according to the camera usage request, and the camera usage request includes the storage space identifier of the image data, and the storage space identifier of the aforementioned new camera usage request is different from the storage space identifier of the temporarily stored camera usage request.

[0030] In a specific implementation scenario, after obtaining a new camera usage request, it can be detected whether the storage space identifier included in the new camera usage request is already included in the storage space identifiers included in the temporarily stored camera usage requests. If not, the created communication channel can be closed, and the communication channel can be re-established using the camera interface program in response to the temporarily stored camera usage requests and the new camera usage request. Still taking Android as an example, the temporarily stored camera usage requests include: a request to start previewing and a request to start recording. Correspondingly, the storage space identifiers included in the temporarily stored camera usage requests, that is, the Surface list, can be represented as [A, B], where A indicates the storage space identifier included in the request to start previewing, and B indicates the storage space identifier included in the request to start recording. If the new camera usage request is a request to start taking pictures, the new camera usage request is theoretically different from any of the storage space identifiers included in the Surface list [A, B], and can be denoted as C for example. Since it is not included in the Surface list [A, B], if the camera is still controlled to work according to the content of the request to start taking pictures through the created communication channel subsequently, it will cause the camera to pause. Therefore, the created communication channel can be closed, and the communication channel with the camera can be re-established in response to the updated Surface list [A, B, C], which can be beneficial to improving the success rate of subsequent control of the camera to work according to the content of the new camera usage request.

[0031] In another specific implementation scenario, the storage space identifier requested by the new camera usage request may also be the same as the storage space identifier of the camera usage request that has been staged. In this case, if it is detected that the storage space identifier included in the new camera usage request is already included in the storage space identifier included in the staged camera usage request, the new camera usage request can be staged in the above-mentioned preset data structure, and the following step S13 in the embodiments of the present disclosure can be continued, that is, the already created communication channel can be directly utilized without closing the already created communication channel. Still taking Android as an example, the staged camera usage requests include: a preview start request and a recording start request. Correspondingly, the storage space identifier included in the staged camera usage request, that is, the Surface list, can be represented as [A, B], where A indicates the storage space identifier included in the preview start request, and B indicates the storage space identifier included in the recording start request. If the new camera usage request is a preview stop request corresponding to the staged preview start request, the storage space identifier included in the new camera usage request is also A, that is, the storage space identifier included in the new camera usage request is included in the storage space identifier included in the staged camera usage identifier. At this time, the new camera usage request (that is, the preview stop request) can be added to the preset data structure. That is, at this time, the staged camera usage requests in the preset data structure are updated to include: a preview start request, a recording start request, and a preview stop request.

[0032] Step S13: Control the camera to work according to the content of the camera usage request through the communication channel.

[0033] After the communication channel with the camera is established, the camera can be controlled to work according to the content of the camera usage request through this communication channel. Still taking Android as an example, specifically, the Surface list included in the staged camera usage request can be used as a parameter to send a repeating request to the CameraCaptureSession, and each camera usage request can be parsed respectively to control the camera to work according to the content of the camera usage request. For example, for a recording start request, the MediaRecorder can be parsed from it, and the MediaRecorder interface can be called to start recording. Other situations can be inferred by analogy and will not be exemplified one by one here.

[0034] In a specific implementation scenario, the steps disclosed in the embodiments of the present disclosure and other disclosed embodiments of the present invention can be written as programs in programming languages such as JAVA, C, C++, etc., and integrated into an application program with a shooting function; or, the steps disclosed in the embodiments of the present disclosure and other disclosed embodiments of the present invention can be written as programs in programming languages such as JAVA, C, C++, etc., and used as programs independent of the application program with a shooting function, so that it can be reused by multiple application programs with a shooting function, which is not limited herein.

[0035] In another specific implementation scenario, there may be multiple camera usage requests temporarily stored in a preset data structure (such as the aforementioned Message List). To improve the processing efficiency of camera usage requests, it is possible to work simultaneously according to the content of multiple camera usage requests through a communication channel.

[0036] For example, multiple interfaces can be correspondingly provided on the screen, and the multiple interfaces can be used to respectively display the image data collected by executing camera usage requests corresponding to different storage space identifiers. Still taking Android as an example, on the screen, interfaces 1, 2, 3, and 4 are correspondingly set in an arrangement of 2 rows * 2 columns. As mentioned above, the Surface list is [A, B, C], where the storage space identifier A corresponds to the camera usage request: start preview request, the storage space identifier B corresponds to the camera usage request: start recording request, and the storage space identifier C corresponds to the camera usage request: start taking pictures request. Then, interface 1 can display the image data collected by executing the camera usage request "start preview request", interface 2 can display the image data collected by executing the camera usage request "start recording request", and interface 3 can display the image data collected by executing the camera usage request "start taking pictures request". Other situations can be inferred by analogy and will not be exemplified one by one here.

[0037] Or, there can also be multiple display screens correspondingly, and the multiple display screens are used to respectively display the image data collected by executing camera usage requests corresponding to different storage space identifiers. Still taking Android as an example, 4 display screens can be set. As mentioned above, the Surface list is [A, B, C], where the storage space identifier A corresponds to the camera usage request: start preview request, the storage space identifier B corresponds to the camera usage request: start recording request, and the storage space identifier C corresponds to the camera usage request: start taking pictures request. Then, display screen 1 can display the image data collected by executing the camera usage request "start preview request", display screen 2 can display the image data collected by executing the camera usage request "start recording request", and display screen 3 can display the image data collected by executing the camera usage request "start taking pictures request". Other situations can be inferred by analogy and will not be exemplified one by one here.

[0038] In the above solution, by temporarily storing the camera usage request, in response to the temporarily stored camera usage request, a communication channel with the camera is established using the camera interface program, and through the communication channel, the camera is controlled to work according to the content of the camera usage request. Therefore, by temporarily storing the camera usage request, it is beneficial to achieve centralized management of the camera usage request. Thus, even in complex scenarios such as the existence of multiple camera usage requests, multiple camera usage requests can be uniformly maintained and controlled, thereby reducing the complexity of camera control and improving the stability of camera control.

[0039] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of another embodiment of the camera control method provided by the present invention. In the embodiments of the present disclosure, the camera usage request is used to make the camera collect image data according to the camera usage request. The camera usage request includes: the storage space identifier of the image data and the camera usage type of the camera usage request. For the specific description of the storage space identifier and the camera usage type, reference can be made to the relevant descriptions in the foregoing disclosed embodiments, which will not be elaborated herein. The embodiments of the present disclosure may specifically include the following steps:

[0040] Step S21: Temporarily store the camera usage request.

[0041] For the specific steps, reference can be made to the steps in the foregoing disclosed embodiments, which will not be elaborated herein.

[0042] Step S22: In response to the temporarily stored camera usage request, establish a communication channel with the camera using the camera interface program.

[0043] For the specific steps, reference can be made to the steps in the foregoing disclosed embodiments, which will not be elaborated herein.

[0044] Step S23: Take a pair of camera usage requests with the same storage space identifier and opposite camera usage types as the target usage request pair.

[0045] In the embodiments of the present disclosure, a storage space identifier can be used to identify the object pointed to by a camera usage request. Still taking Android as an example, as described in the foregoing disclosed embodiments, a camera usage request includes a Surface, which is used to indicate a memory space, so that it is convenient for the camera to temporarily store the captured image data in the memory space indicated by the Surface. Therefore, if the Surfaces of two camera usage requests are the same, it can be considered that the two camera usage requests point to the same object. For example, if the Surface included in a certain start preview request is the same as the Surface included in a certain stop preview request, it can be considered that the above start preview request and stop preview request point to the same preview interface; or, if the Surface included in a certain start recording request is the same as the Surface included in a certain stop recording request, it can be considered that the above start recording request and stop recording request point to the same recording interface, and other situations can be deduced by analogy, and no more examples will be given here.

[0046] It should be noted that the opposite camera usage types referred to in the embodiments of the present disclosure refer to completely opposite usage behaviors. Without loss of generality, the opposite camera usage types can include: start recording and stop recording, start preview and stop preview, etc., and no more examples will be given here.

[0047] In a specific implementation scenario, still taking the Surface list [A, B, C] in the foregoing disclosed embodiments as an example, as mentioned above, A indicates the storage space identifier included in the start preview request, B indicates the storage space identifier included in the start recording request, and C indicates the storage space identifier included in the start photo-taking request. It can be seen that among these three camera usage requests, there is no pair of target usage requests with the same storage space identifier and opposite camera usage types; or, taking the Surface list [A, B, A] as an example, the first A indicates the storage space identifier included in the start preview request, B indicates the storage space identifier included in the start recording request, and the second A indicates the storage space identifier included in the stop preview request. It can be seen that among these three camera usage requests, the start preview request and the stop preview request satisfy the condition of having the same storage space identifier and opposite camera usage types. Therefore, the start preview request and the stop preview request can be used as a pair of target usage requests. Other situations can be deduced by analogy, and no more examples will be given here.

[0048] Step S24: Delete the pair of target usage requests from the temporarily stored camera usage requests.

[0049] After determining the target usage request pair included in the temporarily stored camera usage request, the target usage request pair can be deleted from the temporarily stored camera usage request, so that in multiple camera usage requests, camera usage requests with opposite camera usage types and the same storage space identifier can be offset. Especially in cases such as quickly and continuously switching a preview interface (or a recording), the intermediate process requests during these quickly and continuously switching processes can be directly offset, so that the on / off state of the preview interface (or the on / off state of the recording) can be ensured to be consistent with the last on / off operation.

[0050] In one implementation scenario, steps S23 and S24 above can also be executed before establishing a communication channel. That is, before establishing a communication channel, first analyze the temporarily stored camera usage request, determine the target usage request pair included therein, and delete it from the temporarily stored camera usage request. On this basis, in response to the temporarily stored camera usage request after deleting the target usage request pair, use the camera interface program to establish a communication channel with the camera. The above method can directly offset the intermediate process camera usage requests when the speed of consecutive and rapid camera usage requests exceeds the speed of establishing the communication channel, so that the on / off state of the preview interface (or the on / off state of the recording) can be ensured to be consistent with the last on / off operation.

[0051] Step S25: Control the camera to work according to the content of the camera usage request through the communication channel.

[0052] Specifically, reference can be made to the steps in the foregoing disclosed embodiments, which will not be elaborated here.

[0053] Different from the foregoing disclosed embodiments, before controlling the camera to work according to the content of the camera usage request through the communication channel, a pair of camera usage requests with the same storage space identifier and opposite camera usage types is used as the target usage request pair, and the target usage request pair is deleted from the temporarily stored camera usage request, so that in multiple camera usage requests, camera usage requests with opposite camera usage types and the same storage space identifier can be offset. Especially in cases such as quickly and continuously switching a preview interface (or a recording), the intermediate process requests during these quickly and continuously switching processes can be directly offset, so that the on / off state of the preview interface (or the on / off state of the recording) can be ensured to be consistent with the last on / off operation, and further, it is beneficial to further improve the stability of camera control.

[0054] Please refer to Figure 3 , Figure 3 is a schematic flowchart of another embodiment of the camera control method provided by the present invention. In the disclosed embodiments of the present disclosure, the initial camera state is defaulted to be closed. For example, in Android, the CameraDevice is in the closed state. It should be noted thatFigure 3 The rounded rectangle in the middle represents the camera state, and the right-angled rectangle and diamond represent specific execution steps. The embodiment of the present disclosure may specifically include the following steps:

[0055] Step S301: When a camera use request is detected, a preset data structure of the camera use request is temporarily stored, and the camera state is switched to turned on.

[0056] When a camera use request is detected, the camera use request can be temporarily stored and the camera state can be switched to turned on. In addition, when no camera use request is detected, the camera state can be maintained as turned off.

[0057] In one implementation scenario, the camera use request can be encapsulated as a message and temporarily stored in a preset data structure. For details, please refer to the relevant description in the aforementioned disclosed embodiment, which will not be repeated here. In the disclosed embodiment, the camera use request can be temporarily stored before the camera state is switched to turned on, and then after the camera state is switched to turned on, the temporarily stored camera use request can be responded to, so that the camera use request can be issued indiscriminately anytime and anywhere without waiting for the camera state to be switched to turned on.

[0058] Please refer to Figure 3 , the camera state is switched from closed to open, and needs to go through the opening state. Taking Android as an example, by calling openCamera, you can switch to the opening state (i.e., opening), and then switch from the opening state to the opened state.

[0059] In one implementation scenario, during the entire process of camera control, if multiple camera switch instructions for the camera are obtained within a preset time, the camera state can be switched to the camera state corresponding to the last camera switch instruction in response to the multiple camera switch instructions obtained. For example, the following camera switch instructions are obtained within the preset time: camera on instruction, camera off instruction, camera on instruction, camera off instruction. In this case, if the above four camera switch instructions are responded to one by one, the camera response speed may be slowed down. The camera state can be directly switched to the camera state corresponding to the last camera switch instruction (i.e., camera off instruction), so that the first three instructions involved in the intermediate process (i.e., camera on instruction, camera off instruction, camera on instruction) can be directly offset to improve the camera response speed. The above method can offset the on and off that cannot be immediately turned on and off within the preset time, thereby improving the camera response speed.

[0060] In a specific implementation scenario, the camera switch instruction includes any one of the following: a camera on instruction, a camera off instruction, the camera state corresponding to the camera on instruction is turned on, and the camera state corresponding to the camera off instruction is turned off.

[0061] In another specific implementation scenario, the preset duration can be set according to the actual situation. For example, in the case of high requirements for the camera response speed, the preset duration can be set to be relatively small, while in the case of relatively loose requirements for the camera response speed, the preset duration can be set to be slightly larger.

[0062] In yet another specific implementation scenario, if the camera state switches to the "turned on" state, then in response to the switch to the "turned on" state, the temporarily stored camera usage requests can be obtained, and the following steps S303 and subsequent steps can be executed, that is, the step of establishing a communication channel with the camera using the camera interface program in response to the temporarily stored camera usage requests and subsequent steps; or, if the camera state switches to the "turned off" state, the temporarily stored camera usage requests can be deleted. The above method can help decouple the process management of camera usage requests from the on / off management of the camera state, thereby facilitating the simplification of camera control and improving the stability of camera control.

[0063] In yet another specific implementation scenario, when the camera state switches to the "turned off" state due to reasons such as an error in the application program with a shooting function, the camera state can be switched back to the "turned on" state, and the camera usage requests temporarily stored before the shutdown can be obtained, so as to re-execute the following steps S303 and subsequent steps, that is, the step of establishing a communication channel with the camera using the camera interface program in response to the temporarily stored camera usage requests and subsequent steps.

[0064] Step S302: Detect whether there is a camera usage request in the preset data structure. If so, execute step S303; otherwise, execute step S310.

[0065] As mentioned above, during the entire process of camera control, if multiple camera switch commands for the camera are obtained within the preset duration, then in response to the obtained multiple camera switch commands, the camera state can be switched to the camera state corresponding to the last camera switch command. Therefore, in order to improve the robustness of camera control, before establishing the communication channel, it is necessary to detect again whether there is a camera usage request in the preset data structure. If so, execute the following steps S303 and subsequent steps; if not, the following step S310 can be directly executed, that is, switch the camera state to the idle state.

[0066] Step S303: Establish a communication channel with the camera using the camera interface program in response to the temporarily stored camera usage requests.

[0067] For details, please refer to the steps in the foregoing disclosed embodiments, which will not be elaborated here. For example, still taking Android as an example, the storage space identifier Surface of the camera usage request that has been temporarily stored can be obtained by parsing the Message List, and a CameraCaptureSession can be created based on the storage space identifier Surface. For details, please refer to the relevant descriptions in the foregoing disclosed embodiments, which will not be elaborated here.

[0068] Step S304: Control the camera to work according to the content of the camera usage request through the communication channel.

[0069] For details, please refer to the steps in the foregoing disclosed embodiments, which will not be elaborated here. For example, still taking Android as an example, controlling the camera to work according to the content of the camera usage request can be achieved by calling the RepeatingRequest method. For details, please refer to the relevant descriptions in the foregoing disclosed embodiments, which will not be elaborated here.

[0070] Step S305: Detect whether there is a new camera usage request. If so, execute step S306; if not, execute step S308.

[0071] During the process of controlling the camera to work according to the content of the camera usage request, it is also possible to detect whether there is a new camera usage request. If there is a new camera usage request, the following step S306 can be executed; if no new camera usage request is detected, the following step S308 can be executed. It should be noted that as described in the foregoing disclosed embodiments, the camera usage request is used to make the camera collect image data according to the camera usage request, and the camera usage request includes the storage space identifier of the image data, and the storage space identifier of the new camera usage request mentioned above is different from the storage space identifier of the camera usage request that has been temporarily stored.

[0072] Step S306: Close the created communication channel and re - establish a communication channel based on the existing camera usage request using the camera interface program.

[0073] For details, please refer to the steps in the foregoing disclosed embodiments, which will not be elaborated here.

[0074] Step S307: Re - execute step S304 and subsequent steps.

[0075] After re - establishing the communication channel, the camera can be controlled to work according to the content of the camera usage request through the new communication channel.

[0076] Step S308: Detect whether there is an unexecuted camera usage request with the same storage space identifier as the camera usage request that has been temporarily stored. If so, execute step S309; otherwise, execute step S310.

[0077] In the process of controlling the camera to work according to the content of the camera usage request, it is also possible to detect whether all camera usage requests with the same storage space identifier as the temporarily stored camera usage request have not been executed. If so, step S309 is executed; otherwise, step S310 is executed.

[0078] Step S309: Re-execute step S304 and subsequent steps.

[0079] In the case where it is detected that there are still camera usage requests with the same storage space identifier as the temporarily stored camera usage request that have not been executed, based on the established communication channel, the above-mentioned step S304 and subsequent steps can be continued to be executed.

[0080] Step S310: Switch the camera state to the idle state.

[0081] In the case where there is neither a new camera usage request nor a camera usage request with the same storage space identifier as the temporarily stored camera usage request that has not been executed, the camera state can be switched to the idle state.

[0082] In one implementation scenario, as Figure 3 shown, when the camera state is in the idle state, it is also possible to detect whether there is a new camera usage request. If there is a new camera usage request, the above-mentioned step S306 and subsequent steps can be executed, that is, in response to obtaining a new camera usage request, a communication channel can be re-established using the camera interface program, and the camera can be controlled to work according to the content of the new camera usage request.

[0083] Different from the foregoing embodiments, by temporarily storing the camera usage requests, it is beneficial to realize the centralized management of the camera usage requests. Thus, even in complex scenarios with multiple camera usage requests, etc., multiple camera usage requests can be uniformly maintained and controlled, and further, the camera control complexity can be reduced and the camera control stability can be improved.

[0084] Please refer to Figure 4 , Figure 4 is a schematic framework diagram of an embodiment of a camera control system 40 provided by the present invention. The camera control system 40 includes a memory 41, a processor 42, and a camera 43. The memory 41 and the camera 43 are coupled to the processor 42. Specifically, the camera control system 40 may include, but is not limited to: electronic devices such as mobile phones and tablet computers with a shooting function. In particular, the camera control system 40 may further include a driving recorder, a safety monitoring device for monitoring the driver, etc., which are not limited herein.

[0085] Specifically, the processor 42 can also be referred to as a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. Additionally, the processor 42 can be implemented jointly by multiple integrated circuit chips.

[0086] In the embodiments of the present disclosure, the processor 42 is configured to control the memory 41 to temporarily store at least one camera usage request in a preset data structure; the processor 42 is configured to, in response to the temporarily stored camera usage request, establish a communication channel with the camera 43 using a camera interface program; the processor 42 is configured to, through the communication channel, control the camera 43 to operate according to the content of the camera usage request.

[0087] In the above solution, by temporarily storing at least one camera usage request in a preset data structure, thus in response to the temporarily stored camera usage request, establishing a communication channel with the camera using a camera interface program, and through the communication channel, controlling the camera to operate according to the content of the camera usage request. Therefore, by temporarily storing the camera usage request in a preset data structure, it is beneficial to achieve centralized management of camera usage requests, so that even in complex scenarios with multiple camera usage requests, etc., multiple camera usage requests can be uniformly maintained and controlled, and further, the camera control complexity can be reduced and the camera control stability can be improved.

[0088] In some disclosed embodiments, the processor 42 is configured to, when detecting that the camera state is a preset state, execute the steps of establishing a communication channel with the camera 43 using a camera interface program in response to the temporarily stored camera usage request and subsequent steps.

[0089] Different from the foregoing embodiments, it is possible to, when detecting that the camera state is a preset state, then establish a communication channel with the camera in response to the temporarily stored camera usage request, thereby improving the success rate of establishing the communication channel.

[0090] In some disclosed embodiments, the processor 42 is used to detect that the camera state is not a preset state and that there are at least one temporarily stored camera usage requests, switch the camera state to the preset state, and execute steps of establishing a communication channel with the camera 43 using a camera interface program in response to the temporarily stored camera usage requests, as well as subsequent steps.

[0091] Different from the aforementioned embodiment, when it is detected that the camera state is not the above-mentioned preset state and there are at least one temporarily stored camera usage requests, the camera state can be automatically switched to the preset state, and then a communication channel with the camera is established in response to the temporarily stored camera usage requests, thereby increasing the speed of responding to the camera usage requests and improving the user experience.

[0092] In some disclosed embodiments, the camera status includes: turned on, turned off, turning on, and turning off, and the default status is turned on.

[0093] In some disclosed embodiments, the processor 42 is used to switch the camera state to a camera state corresponding to the last camera switch instruction in response to obtaining multiple camera switch instructions for the camera 43 within a preset time length; wherein the camera switch instruction includes any one of the following: a camera on instruction, a camera off instruction, the camera state corresponding to the camera on instruction is turned on, and the camera state corresponding to the camera off instruction is turned off.

[0094] Different from the aforementioned embodiment, by responding to obtaining multiple camera switch instructions for the camera within a preset time period, the camera state is switched to the camera state corresponding to the last camera switch instruction, so that the opening and closing that cannot be immediately achieved within the preset time period can be offset, thereby improving the camera response speed.

[0095] In some disclosed embodiments, the processor 42 is used to obtain a temporarily stored camera usage request in response to switching to turned on, and execute the steps of establishing a communication channel with the camera 43 using the camera interface program in response to the temporarily stored camera usage request and subsequent steps; and / or, the processor 42 is used to delete the temporarily stored camera usage request in response to switching to turned off.

[0096] Different from the aforementioned embodiment, it is helpful to decouple the process management of camera use request and the switch management of camera status, so as to simplify the camera control and improve the stability of camera control.

[0097] In some disclosed embodiments, the processor 42 is configured to close an established communication channel in response to obtaining a new camera usage request, and to re-establish the communication channel using a camera interface program in response to a temporarily stored camera usage request and a new camera usage request.

[0098] Different from the foregoing embodiments, by responding to the acquisition of a new camera usage request, closing the created communication channel, and responding to the temporarily stored camera usage request and the new camera usage request, re - establishing the communication channel using the camera interface program can further improve the response rate to the camera usage request. In addition, since the communication channel is re - established in response to the temporarily stored camera usage request and the new camera usage request, it is beneficial to improve the success rate of controlling the camera to work according to the content of the new camera usage request in the follow - up.

[0099] In some disclosed embodiments, the camera usage request is used to make the camera acquire image data according to the camera usage request. The camera usage request includes: the storage space identifier of the image data, and the storage space identifier of the new camera usage request is different from the storage space identifier of the temporarily stored camera usage request.

[0100] Different from the foregoing embodiments, the camera usage request is used to make the camera acquire image data according to the camera usage request, and the camera usage request includes: the storage space identifier of the image data, and the storage space identifier of the new camera usage request is different from the storage space identifier of the temporarily stored camera usage request, which can effectively distinguish whether a new communication channel needs to be created and is beneficial to improving the robustness of camera control.

[0101] In some disclosed embodiments, the camera usage request is used to make the camera 43 acquire image data according to the camera usage request. The camera usage request includes: the storage space identifier of the image data and the camera usage type of the camera usage request. The processor 42 is used to use a pair of camera usage requests with the same storage space identifier and opposite camera usage types as the target usage request pair, and the processor 42 is used to delete the target usage request pair from the temporarily stored camera usage requests.

[0102] Different from the foregoing embodiments, using a pair of camera usage requests with the same storage space identifier and opposite camera usage types as the target usage request pair, and deleting the target usage request pair from the temporarily stored camera usage requests, so that among multiple camera usage requests, the camera usage requests with opposite camera usage types and the same storage space identifier can be offset. Especially in the case of quickly and continuously switching a certain preview interface (or a certain recording), the intermediate process requests during these quick and continuous switching processes can be directly offset, so as to ensure that the on - off state of the preview interface (or the on - off state of the recording) is consistent with the last on / off operation, and further improve the stability of camera control.

[0103] Please refer to Figure 5 , Figure 5It is a schematic diagram of the framework of an embodiment of the storage device 50 provided by the present invention. The storage device 50 stores program instructions 501 that can be run by a processor, and the program instructions 501 are used to implement the steps in any of the above-described embodiments of the camera control method.

[0104] In the above solution, by temporarily storing the camera usage requests in a preset data structure, it is beneficial to achieve centralized management of the camera usage requests. Thus, even in complex scenarios with multiple camera usage requests, multiple camera usage requests can be uniformly maintained and controlled, thereby reducing the complexity of camera control and improving the stability of camera control.

[0105] In some embodiments, the functions or modules included in the device provided by the present disclosure embodiment can be used to execute the methods described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be elaborated here.

[0106] The above descriptions of each embodiment tend to emphasize the differences between each embodiment. The same or similar parts can be referred to each other. For the sake of brevity, they will not be elaborated in this article.

[0107] In several embodiments provided by the present invention, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation manners described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there can be other division manners. For example, units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.

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

[0109] In addition, in each embodiment of the present invention, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

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

Claims

1. A camera control method, characterized in that, Including: When a camera usage request is detected, temporarily store the camera usage request in a preset data structure, and switch the camera status to turned on. When the camera usage request is not detected, maintain the camera status as turned off; Detect whether there is a camera usage request in the preset data structure; If so, in response to the temporarily stored camera usage request, establish a communication channel with the camera using a camera interface program. Through the communication channel, control the camera to work according to the content of the camera usage request, and detect whether there is a new camera usage request. If there is a new camera usage request, close the created communication channel, and in response to the temporarily stored camera usage request and the new camera usage request, use the camera interface program to re-establish the communication channel, and return to the re-established communication channel, control the camera to work according to the content of the camera usage request. If there is no new camera usage request, detect whether there is a camera usage request that has not been executed and has the same storage space identifier as the temporarily stored camera usage request. If so, return to the communication channel and control the camera to work according to the content of the camera usage request. If not, switch the camera status to the idle state; If not, switch the camera status to the idle state.

2. The method according to claim 1, wherein The method further includes: In response to obtaining multiple camera switch instructions for the camera within a preset duration, switch the camera status to the camera status corresponding to the last camera switch instruction; Wherein, the camera switch instruction includes any one of the following: a camera turn-on instruction, a camera turn-off instruction. The camera status corresponding to the camera turn-on instruction is turned on, and the camera status corresponding to the camera turn-off instruction is turned off.

3. The method according to claim 2, wherein After switching the camera status to the camera status corresponding to the last camera switch instruction, the method further includes: In response to the camera status being switched to turned on, obtain the temporarily stored camera usage request, and execute the step of establishing a communication channel with the camera using a camera interface program in response to the temporarily stored camera usage request and subsequent steps.

4. The method according to claim 2, characterized in that, After switching the camera status to the camera status corresponding to the last camera switch instruction, the method further includes: In response to the camera status being switched to turned off, delete the temporarily stored camera usage request.

5. The method according to claim 1, wherein The camera usage request is used to make the camera collect image data according to the camera usage request. The camera usage request includes: the storage space identifier of the image data, and the storage space identifier of the new camera usage request is different from the storage space identifier of the temporarily stored camera usage request.

6. The method according to claim 1, characterized in that The camera usage request is used to make the camera collect image data according to the camera usage request. The camera usage request includes: the storage space identifier of the image data and the camera usage type of the camera usage request; Before controlling the camera to work according to the content of the camera usage request through the communication channel, the method further includes: Regarding a pair of the camera usage requests with the same storage space identifier and opposite camera usage types, use them as a target usage request pair; In the temporarily stored camera usage requests, delete the target usage request pair.

7. A camera control system, characterized in that, It includes a camera, a memory, and a processor. The camera and the memory are coupled to the processor, and the camera control system is used to implement the camera control method according to any one of claims 1 to 6.

8. A storage device, characterized in that, It stores program instructions that can be run by the processor, and the program instructions are used to implement the camera control method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Abstract camera pipeline for uniform cross-device control of image capture and processing

    CN104471510A

  • Processing method and processing device

    CN108540356A