CN114598806A - Camera control method and system and storage device - Google Patents
Camera control method and system and storage device Download PDFInfo
- Publication number
- CN114598806A CN114598806A CN202011431437.2A CN202011431437A CN114598806A CN 114598806 A CN114598806 A CN 114598806A CN 202011431437 A CN202011431437 A CN 202011431437A CN 114598806 A CN114598806 A CN 114598806A
- Authority
- CN
- China
- Prior art keywords
- camera
- use request
- request
- communication channel
- temporarily stored
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 54
- 238000004891 communication Methods 0.000 claims abstract description 75
- 230000004044 response Effects 0.000 claims description 46
- 230000006870 function Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 5
- 230000009286 beneficial effect Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000012423 maintenance Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 229910003460 diamond Inorganic materials 0.000 description 1
- 239000010432 diamond Substances 0.000 description 1
- 238000012806 monitoring device Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/60—Control of cameras or camera modules
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/60—Control of cameras or camera modules
- H04N23/62—Control of parameters via user interfaces
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/60—Control of cameras or camera modules
- H04N23/63—Control of cameras or camera modules by using electronic viewfinders
- H04N23/631—Graphical user interfaces [GUI] specially adapted for controlling image capture or setting capture parameters
- H04N23/632—Graphical user interfaces [GUI] specially adapted for controlling image capture or setting capture parameters for displaying or modifying preview images prior to image capturing, e.g. variety of image resolutions or capturing parameters
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/60—Control of cameras or camera modules
- H04N23/665—Control of cameras or camera modules involving internal camera communication with the image sensor, e.g. synchronising or multiplexing SSIS control signals
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/76—Television signal recording
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Human Computer Interaction (AREA)
- Studio Devices (AREA)
Abstract
The invention discloses a camera control method, a camera control system and a storage device, wherein the camera control method comprises the following steps: temporarily storing at least one camera use request in a preset data structure; responding to the camera use request which is temporarily stored, and establishing a communication channel with the camera by utilizing a camera interface program; and controlling the camera to work according to the content of the camera use request through the communication channel. Through the mode, the camera control stability can be improved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a camera control method and system and a storage device.
Background
In the field of Android and other program development, Android native systems, Android secondary development-based systems such as MIUI, and Android Application-compatible systems such as hongmeng OS, these system frameworks generally provide a set of standard API (Application Programming Interface) for controlling a camera to implement other camera functions such as preview, recording, and taking pictures.
Research shows that under complex scenes such as a plurality of camera use requests, camera runaway is easily caused by directly adopting the API provided by the native system framework, so that abnormal conditions such as normal use of the camera cannot be caused. In view of the above, how to improve the stability of camera control is an urgent problem to be solved.
Disclosure of Invention
The invention mainly solves the problem of providing a camera control method, a camera control system and a storage device, which can improve the stability of camera control.
In order to solve the technical problem, the technical scheme adopted by the invention is to provide a camera control method, and the program running method comprises the following steps: temporarily storing at least one camera use request in a preset data structure; responding to the camera use request which is temporarily stored, and establishing a communication channel with the camera by utilizing a camera interface program; and controlling the camera to work according to the content of the camera use request through the communication channel.
In order to solve the above technical problem, another technical solution of the present invention is to provide a camera control system, including a camera, a memory and a processor, wherein the camera and the memory are coupled to the processor, the processor is configured to control the memory to temporarily store at least one camera usage request in a preset data structure, the processor is configured 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 configured to control the camera to operate according to the content of the camera usage request through the communication channel.
In order to solve the above technical problem, a further technical solution of the present invention is to provide a storage device, which stores program instructions that can be executed by a processor, where the program instructions are used to implement the camera control method.
Through the scheme, the invention has the beneficial effects that: at least one camera use request is temporarily stored in a preset data structure, so that a communication channel between the camera and the camera is established by utilizing a camera interface program in response to the temporarily stored camera use request, and the camera is controlled to work according to the content of the camera use request through the communication channel. Therefore, the camera use requests are temporarily stored through the preset data structure, the centralized management of the camera use requests can be favorably realized, even if complex scenes such as a plurality of camera use requests exist, the camera use requests can be uniformly maintained and controlled, the camera control complexity can be reduced, and the camera control stability is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts. Wherein:
fig. 1 is a schematic flowchart of a camera control method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a camera control method according to another embodiment of the present invention;
FIG. 3 is a flow chart illustrating a camera control method according to another embodiment of the present invention;
FIG. 4 is a block diagram of an embodiment of a camera control system according to the present invention;
FIG. 5 is a block diagram of an embodiment of a storage device according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an embodiment of a camera control method provided by the present invention. Specifically, the method may include the steps of:
step S11: and temporarily storing the at least one camera use request in a preset data structure.
In one implementation scenario, the camera usage request may include, but is not limited to: a recording request, a preview request, a photographing request, etc., which are not limited herein. It should be noted that the recording request represents a request related to capturing a video, the preview request represents a request related to displaying a scene of a camera view field range on the display interface, and the photographing request represents a request related to capturing a photograph, that is, the camera use request may be regarded as a request for causing the camera to capture image data in accordance with the camera use request.
In a specific implementation scenario, the recording request may specifically include: a recording start request and a recording stop request, where the preview request may specifically include: the method specifically includes the steps of starting a preview request and closing the preview request, wherein the photographing request specifically includes: start the photographing request, stop the photographing request. It should be noted that, the recording start request indicates that the camera is requested to start shooting the video, and the recording stop request indicates that the camera is requested to stop shooting the video; similarly, turning on the preview request indicates a request to display a scene of the camera view field range on the display interface, and turning off the preview request indicates a request to cancel the display of the scene of the camera view field range on the display interface; similarly, the start photographing request means that the camera is requested to take a picture, and the stop photographing request means that the camera is requested to cancel taking a picture.
In another specific implementation scenario, the camera use request may be specifically issued by an application having a shooting function. For example, after receiving a click operation of a user on a "record" button in the application program, the application program may send a request to start recording, and after receiving a click operation of the user on the "record" button again, the application program may send a request to stop recording.
In one implementation scenario, the default data structure may include, but is not limited to: list (list), stack (stack), queue (queue), linked list (link list), etc., without limitation.
In a specific implementation scenario, the camera usage requests may be specifically encapsulated as messages and temporarily stored in a preset data structure, so that temporary storage of multiple camera usage requests may be further facilitated, camera usage requests of the same type or different types may coexist, and then the possibility of mutual interference of the camera usage requests may be reduced as much as possible, and the expansion of the camera usage requests at the type and quantity level is greatly facilitated.
In another specific implementation scenario, for example, with Android, the camera use request may be encapsulated as a message by using a native class of Android, where the native class of Android is a class owned by the Android system, and specifically may include but is not limited to: a Message class, which is not limited herein; in addition, the user can also define the class, and the camera use request is encapsulated into the message by adopting the defined class. It should be noted that a class can be understood as a type, and any object can be instantiated based on the class. Similarly, in a system based on Android secondary development, such as MIUI, or a system compatible with an Android application, such as hongmeng OS, a native class of the system may be used to package a camera usage request as a message, or a user-defined class may be used to package a camera usage request as a message, which is not limited herein.
In another specific implementation scenario, the camera usage request may be temporarily stored in a Message List. After the application program with the shooting function sends out the camera use request, the camera use request can be packaged into a Message and added into the List, so that the centralized management of a plurality of camera use requests can be realized efficiently, the processing of the plurality of camera use requests can be performed simultaneously, and the processing efficiency can be improved. For a specific way of processing multiple camera usage requests in parallel, reference may be made to the following related description, and details will not be repeated herein.
Step S12: and establishing a communication channel with the camera by utilizing the camera interface program in response to the temporarily stored camera use request.
In one implementation scenario, as previously described, the camera use request may be considered for the camera to acquire image data in accordance with the camera use request. To identify the storage space of the image data, the camera use request may specifically include: and identifying the storage space of the image data. Still taking Android as an example, the camera use request includes a Surface for indicating a block of memory space, so that the camera can temporarily store the captured image data in the memory space indicated by the Surface. Further, to identify the specific request content of the camera use request, the camera use request may further include: camera usage type of camera usage request, for example: start recording, stop recording, turn on preview, turn off preview, etc., without limitation. Still taking Android as an example, all surfaces can be taken out from the temporarily stored camera use request to form a Surface list to create a camera capture session, where it should be noted that a camera capture session is a transaction used to send a request for acquiring image data to a camera. In addition, the camera capture mainly has two methods, setretastatingrequest (i.e., a set repeat request) for repeatedly requesting to acquire image data (e.g., preview, continuous shooting, etc.) and capture (i.e., capture) for single-shot shooting. On this basis, after the CameraCaptureSession configuration is completed, the communication channel establishment can be considered to be completed. It should be noted that, the camera capture, Request, setRepeatingRequest, capture, etc. are all programs defined in the camera interface program (i.e., the camera API) of the Android, and specific program codes thereof are not described herein again. That is to say, after the camera usage requests that have been temporarily stored are configured to complete the camera capturesession, the temporarily stored camera usage requests all correspond to the same camera capturesession, and on this basis, the camera can be controlled to operate according to the content requested by the temporarily stored camera usage requests based on the communication channel established by the camera capturesession.
In an implementation scenario, step S12 and the following steps in the embodiment of the present disclosure may be specifically executed when it is detected that the camera state is the preset state. Specifically, the camera states may include: opened, closed, opening, closing, the predetermined state may be opened. Still taking Android as an example, the camera state (i.e., the state of the CameraDevice) specifically includes: open (i.e., open), close (i.e., close), closed (i.e., close). It should be noted that the CameraDevice (i.e., the camera device) is an abstract class defined in Android, and can be used to represent a camera. By the method, the communication channel with the camera can be established in response to the camera use request which is temporarily stored under the condition that the camera state is detected to be the preset state, so that the success rate of establishing the communication channel can be improved.
In another implementation scenario, when it is detected that the camera status is not the preset status, and the buffered camera usage request is not less than one, the camera status may be automatically switched to the preset status, and then step S12 and the following steps in the embodiment of the disclosure are performed. Still taking Android as an example, when it is detected that the camera status is not the preset status, and there is not less than one temporarily stored camera usage request, the camera device may be switched to an opened status through openCamera (i.e., the camera is turned on). It should be noted that openCamera is also a program defined in the camera interface program (i.e., the camera API) of Android, and is mainly used for opening the camera, and specific program codes thereof are not described herein again. Above-mentioned, can be detecting the camera state not be above-mentioned preset state, and the camera operation request of having kept in is no less than a condition, automatic switch camera state to preset the state, respond to the camera operation request of having kept in again and establish the communication channel with the camera to can improve the speed of responding to camera operation request, improve user experience.
In an implementation scenario, in addition to the temporarily stored camera usage request, a new camera usage request may also be obtained during the whole process of controlling the camera, and the new camera usage request may also be temporarily stored in the preset data structure according to the foregoing description. On the basis, if a new camera use request is acquired, the created communication channel can be closed in response to the new camera use request, and the communication channel can be reestablished by using the camera interface program in response to the temporarily stored camera use request and the new camera use request. In the above manner, the response rate to the camera use request can be further improved. In addition, the communication channel is reestablished in response to the temporarily stored camera use request and the new camera use request, so that the success rate of the subsequent control camera working according to the content of the new camera use request is improved. It should be noted that, as mentioned above, the camera use request is used to make the camera acquire image data according to the camera use request, and the camera use request includes a storage space identifier of the image data, and the storage space identifier of the new camera use request mentioned above is different from the storage space identifier of the camera use request that has been temporarily stored.
In a specific implementation scenario, after acquiring a new camera usage request, it may be detected whether a storage space identifier included in the new camera usage request is already included in a storage space identifier included in a buffered camera usage request, and if not, the created communication channel may be closed, and the communication channel may be re-established by using the camera interface program in response to the buffered camera usage request and the new camera usage request. Still taking Android as an example, the cached camera use request includes: starting a preview request and a recording start request, and correspondingly, a storage space identifier included in the temporarily stored camera use request, that is, a Surface list may be represented as [ a, B ], where a indicates that the storage space identifier included in the preview request is started, and B indicates that the storage space identifier included in the recording start request, if a new camera use request is a photographing start request, the new camera use request is theoretically different from any storage space identifier included in the Surface list [ a, B ], and may be, for example, denoted as C, since the new camera use request is not included in the Surface list [ a, B ], if the camera still passes through the created communication channel in the following, controlling the camera to operate according to the content of the photographing start request will cause the camera to pause, so the created communication channel may be closed, and a communication channel with the camera is re-established in response to the updated Surface list [ a, B, C ], the success rate of the subsequent control camera working according to the content of the new camera use request can be improved.
In another specific implementation scenario, the memory identifier of the new camera usage request may also be the same as the memory identifier of the camera usage request that has been staged. In this case, 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 buffered camera usage request, the new camera usage request may be buffered to the preset data structure, and the following step S13 in the embodiment of the present disclosure is continuously performed, so that the created communication channel may be directly utilized without closing the created communication channel. Still taking Android as an example, the cached camera use request includes: opening the preview request and starting recording request, and correspondingly, the stored memory space identifier contained in the camera use request, that is, the Surface list may be represented as [ a, B ], where a indicates a storage space identifier included in the start preview request, B indicates a storage space identifier included in the start recording request, and if the new camera usage request is a close preview request corresponding to the temporarily stored start preview request, the storage space identifier included in the new camera usage request is also a, that is, the memory space id included in the new camera usage request is included in the memory space id included in the camera usage id that has been temporarily stored, and at this time, a new camera usage request (i.e., a close preview request) may be added to the preset data structure, that is, at this time, the camera usage request that has been temporarily stored in the preset data structure is updated to include: opening a preview request, starting a recording request, and closing the preview request.
Step S13: and controlling the camera to work according to the content of the camera use request through the communication channel.
After the communication channel with the camera is established, the camera can be controlled to work according to the content of the camera use request through the communication channel. Still taking Android as an example, a Surface list included in the temporarily stored camera use Request may be specifically used as a parameter to send a requesting Request to a camera capture service, and each camera use Request may be analyzed separately, so as to control the camera to work according to the content of the camera use Request. For example, for a start recording request, MediaRecorder may be parsed out therefrom and a MediaRecorder interface may be invoked to start recording. Other cases may be analogized, and no one example is given here.
In a specific implementation scenario, the steps disclosed in the embodiments of the present disclosure and other embodiments of the present disclosure may be written as programs in programming languages such as JAVA, C + +, etc., and integrated into an application program with a shooting function; alternatively, the steps disclosed in the embodiments of the present disclosure and other embodiments of the present disclosure may be written as a program in a programming language such as JAVA, C + +, etc., and may be a program independent of the application having the photographing function, so that the program can be reused by a plurality of applications having the photographing function, which is not limited herein.
In another specific implementation scenario, a plurality of camera usage requests may be temporarily stored in a predetermined data structure (e.g., the aforementioned Message List), and in order to improve the processing efficiency of the camera usage requests, the communication channel may be used to simultaneously perform operations according to the contents of the plurality of camera usage requests.
For example, a plurality of interfaces may be correspondingly provided on the screen, and the plurality of interfaces may be used to respectively display image data acquired by executing camera use requests corresponding to different storage space identifiers. Still taking Android as an example, the interface 1, the interface 2, the interface 3, and the interface 4 are correspondingly arranged on the screen in an arrangement manner of 2 rows by 2 columns, as described above, the Surface list is [ a, B, C ], where the storage space identifier a corresponds to a camera use request: opening a preview request, wherein the storage space identifier B corresponds to a camera use request: starting a recording request, the storage space identification C corresponding to a camera use request: when a photographing request is started, the interface 1 may display image data collected by executing the camera use request "start preview request", the interface 2 may display image data collected by executing the camera use request "start record request", and the interface 3 may display image data collected by executing the camera use request "start photographing request". Other cases may be analogized, and no one example is given here.
Or, a plurality of display screens may be provided, and the plurality of display screens are used to respectively display image data acquired by executing camera use requests corresponding to different storage space identifiers. Still taking Android as an example, 4 display screens may be provided, as described above, the Surface list is [ a, B, C ], where the storage space identifier a corresponds to a camera use request: opening a preview request, wherein the storage space identifier B corresponds to a camera use request: starting a recording request, the storage space identification C corresponding to a camera use request: when a photographing request is started, the display screen 1 may display image data collected by executing the camera use request "start preview request", the display screen 2 may display image data collected by executing the camera use request "start record request", and the display screen 3 may display image data collected by executing the camera use request "start photographing request". Other cases may be analogized and are not illustrated here.
According to the scheme, the camera use request is temporarily stored, so that a communication channel between the camera and the camera is established by utilizing the camera interface program in response to the temporarily stored camera use request, and the camera is controlled to work according to the content of the camera use request through the communication channel. Therefore, the camera use requests are temporarily stored, centralized management of the camera use requests can be favorably realized, even if complex scenes such as a plurality of camera use requests exist, unified maintenance and management and control can be carried out on the camera use requests, the camera control complexity can be reduced, and the camera control stability is improved.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a camera control method according to another embodiment of the present invention. In an embodiment of the present disclosure, the camera use request is used to enable the camera to acquire image data according to the camera use request, and the camera use request includes: for the storage space identifier of the image data and the camera usage type of the camera usage request, reference may be specifically made to the related description in the foregoing disclosed embodiment for the storage space identifier and the camera usage type, and details are not repeated here. The embodiment of the present disclosure may specifically include the following steps:
step S21: and temporarily storing the camera use request.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described herein again.
Step S22: and establishing a communication channel with the camera by utilizing the camera interface program in response to the temporarily stored camera use request.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described herein again.
Step S23: and taking a pair of camera use requests with the same storage space identification and opposite camera use types as a target use request pair.
In the disclosed embodiments, the storage space identification may be employed to identify the object to which the camera use request is directed. Still taking Android as an example, as described in the foregoing disclosure, the camera use request includes a Surface for indicating a memory space, so that the camera can store the captured image data in the memory space indicated by the Surface, and therefore, if the surfaces of the two camera use requests are the same, it can be considered that the two camera use requests point to the same object. For example, if the Surface included in a certain opening preview request is the same as the Surface included in a certain closing preview request, it can be considered that the opening preview request and the closing preview request point to the same preview interface; or, the Surface included in a certain recording start request and the Surface included in a certain recording stop request are the same, that is, the recording start request and the recording stop request are considered to be directed to the same recording interface, and the rest may be similar, which is not illustrated herein.
It should be noted that the camera usage type referred to in the embodiments of the present disclosure refers to the usage behavior completely opposite. Without loss of generality, the opposite camera usage types may include: start and stop recording, turn on and turn off previews, etc., to name but a few examples.
In a specific implementation scenario, still taking the Surface list [ a, B, C ] in the foregoing disclosed embodiment as an example, as described above, a indicates the storage space identifier included in the request to start preview, B indicates the storage space identifier included in the request to start recording, and C indicates the storage space identifier included in the request to start taking a picture, so that, in these three camera usage requests, there is no target usage request pair with the same storage space identifier and the 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, the second B indicates the storage space identifier included in the start recording request, and the second a indicates the storage space identifier included in the close preview request, so that it can be seen that, in the three camera use requests, the start preview request and the close preview request satisfy the condition that the storage space identifiers are the same and the camera use types are opposite, so that the start preview request and the close preview request can be used as a target use request pair. Other cases may be analogized, and no one example is given here.
Step S24: in the registered camera use requests, the target use request pair is deleted.
After determining the target use request pair contained in the camera use request which has been temporarily stored, the target use request pair can be deleted from the temporarily stored camera use request, so that the camera use requests with opposite camera use types and same storage space identification can be cancelled in a plurality of camera use requests, particularly in the case of quickly and continuously switching a certain preview interface (or a certain recording) and the like, intermediate process requests in the quickly and continuously switching processes can be directly cancelled, and the switching state (or the recorded switching state) of the preview interface can be ensured to be consistent with the last on/off operation.
In an implementation scenario, the above steps S23 and S24 may also be performed before the communication channel is established, that is, before the communication channel is established, the buffered camera usage request is analyzed to determine the target usage request pair contained therein, and the target usage request pair is deleted from the buffered camera usage request, and then, in response to the camera usage request buffered after the target usage request pair is deleted, the communication channel with the camera is established by using the camera interface program. In the above manner, in the case where the speed of the continuously fast camera use request exceeds the speed of the communication channel establishment, the camera use request in the middle process can be directly canceled, so that it can be ensured that the on/off state (or the recorded on/off state) of the preview interface coincides with the last on/off operation, for example.
Step S25: and controlling the camera to work according to the content of the camera use request through the communication channel.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described herein again.
Different from the embodiment disclosed in the foregoing, 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 identification and the opposite camera usage types is used as a target usage request pair, and in the camera usage requests that have been temporarily stored, the target usage request pair is deleted, so that the camera use requests with opposite camera use types and the same storage space identification can be counteracted from a plurality of camera use requests, particularly under the conditions of quickly and continuously switching on and off a certain preview interface (or a certain recording) and the like, intermediate process requests in the quickly and continuously switching on and off processes can be directly counteracted, it can be ensured that the on/off state (or recorded on/off state) of the preview interface coincides with the last on/off operation, which can be advantageous to further improve the stability of the camera control.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a camera control method according to another embodiment of the present invention. In the embodiment of the present disclosure, the initial camera state is default to be closed, for example, in Android, the CameraDevice is in a closed state. It should be noted that the rounded rectangle in fig. 3 represents the camera state, and the right-angled rectangle and the diamond represent specific implementation steps. The embodiment of the present disclosure may specifically include the following steps:
step S301: and under the condition that the camera use request is detected, temporarily storing a preset data structure of the camera use request, and switching the state of the camera to be started.
In the case that a camera use request is detected, the camera use request can be temporarily stored, and the state of the camera is switched to be started. Further, in the case where the camera use request is not detected, the camera state may be maintained as being turned off.
In an implementation scenario, the camera use request may be encapsulated as a message and temporarily stored in a preset data structure, which may specifically refer to the related description in the foregoing disclosed embodiment and is not described herein again. In the embodiment of the disclosure, the temporary storage of the camera use request can be performed before the camera state is switched to be started, and then the temporary stored camera use request is responded after the camera state is switched to be started, so that the camera use request can be sent indiscriminately at any time and any place without waiting for the camera state to be switched to be started.
Referring to fig. 3, the camera state is switched to on when the camera state is in the off state, and needs to be turned on. For example, Android calls the openCamera to switch to an opening (i.e., opening) state, and the opening state is switched to an opened state.
In an implementation scenario, in the whole process of camera control, if a plurality of camera switching instructions for a camera are acquired within a preset time period, the camera state may be switched to the camera state corresponding to the last camera switching instruction in response to the plurality of acquired camera switching instructions. For example, the following camera switching instruction is acquired within a preset time period: in this case, if the four camera switch instructions are responded one by one and the response speed of the camera may be slowed down, the camera state may be directly switched to the camera state corresponding to the last camera switch instruction (i.e., the camera turn-off instruction), so that the first three instructions (i.e., the camera turn-on instruction, the camera turn-off instruction, and the camera turn-on instruction) involved in the middle process may be directly offset, and the response speed of the camera is increased. By the mode, the on and off of the camera can be offset within the preset time length rather than immediately, and the response speed of the camera is improved.
In a specific implementation scenario, the camera switching command includes any one of: the camera control system comprises a camera opening instruction and a camera closing instruction, wherein the camera state corresponding to the camera opening instruction is opened, and the camera state corresponding to the camera closing instruction is closed.
In another specific implementation scenario, the preset duration may be set according to an actual situation. For example, in the case where the demand for the camera response speed is high, the preset duration may be set small, and in the case where the demand for the camera response speed is relatively loose, the preset duration may be set large.
In another specific implementation scenario, if the camera state is switched to on, the buffered camera usage request may be obtained in response to the camera state being switched to on, and the following step S303 and subsequent steps are executed, that is, the step of establishing a communication channel with the camera using the camera interface program and the subsequent steps are executed in response to the buffered camera usage request; or, if the camera state is switched to off, the camera use request which is temporarily stored can be deleted. By the method, the decoupling of the process management of the camera use request and the switch management of the camera state can be facilitated, so that the camera control can be simplified, and the stability of the camera control can be improved.
In another specific implementation scenario, when the camera state is switched to off due to an error in the application with the shooting function, the camera state may be switched to on again, and a camera usage request that has been temporarily stored before the camera usage request is turned off is acquired, so as to re-execute step S303 and subsequent steps, in which a communication channel with the camera is established by using the camera interface program in response to the temporarily stored camera usage request, and subsequent steps.
Step S302: detecting whether a camera using request exists in the preset data structure, if so, executing step S303, otherwise, executing step S310.
As described above, in the whole process of camera control, if a plurality of camera switch commands to the camera are acquired within a preset time period, the camera state may be switched to the camera state corresponding to the last camera switch command in response to the plurality of acquired camera switch commands. Therefore, in order to improve the robustness of the camera control, it is necessary to detect whether there is a camera use request in the preset data structure again before establishing the communication channel, if so, the following step S303 and subsequent steps are executed, and if not, the following step S310 may be directly executed, that is, the camera state is switched to the idle state.
Step S303: and establishing a communication channel with the camera by utilizing the camera interface program in response to the temporarily stored camera use request.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described herein again. For example, still taking Android as an example, the Message List may be parsed to obtain a temporary storage space identifier Surface of the camera use request, and based on the storage space identifier Surface, a camera capture session is created.
Step S304: and controlling the camera to work according to the content of the camera use request through the communication channel.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described in detail herein. For example, still taking Android as an example, the camera can be controlled to work according to the content of the camera use request by calling a repeatgrequest method, which may specifically refer to the related description in the foregoing disclosed embodiments, and details are not described here.
Step S305: whether a new camera use request exists is detected, if so, step S306 is executed, and if not, step S308 is executed.
In the process of controlling the camera to operate according to the content of the camera use request, it may be further detected whether there is a new camera use request, if there is a new camera use request, the following step S306 may be performed, and if no new camera use request is detected, the following step S308 may be performed. It should be noted that, as described in the foregoing disclosure, the camera use request is used to enable the camera to acquire image data according to the camera use request, and the camera use request includes a storage space identifier of the image data, and the storage space identifier of the new camera use request referred to in the foregoing description is different from the storage space identifier of the camera use request that has been temporarily stored.
Step S306: the created communication channel is closed and re-established using the camera interface program based on the existing camera use request.
Specifically, reference may be made to the steps in the foregoing disclosed embodiments, which are not described herein again.
Step S307: step S304 and subsequent steps are re-executed.
After the communication channel is reestablished, the camera can be controlled to operate according to the content of the camera use request through the new communication channel.
Step S308: detecting whether a camera use request with the same storage space identifier as the temporarily stored camera use request is not executed, if so, executing step S309, otherwise, executing step S310.
In the process of controlling the camera to work according to the content of the camera usage request, it may also be detected whether all the camera usage requests having the same storage space identifier as the temporarily stored camera usage request are not executed, if so, step S309 is executed, otherwise, step S310 is executed.
Step S309: step S304 and subsequent steps are re-executed.
In the case where it is detected that there is still a camera use request that is the same as the storage space identification of the camera use request that has been temporarily stored, the above-described step S304 and subsequent steps may be continued on the basis of the communication channel that has been created.
Step S310: the camera state is switched to the idle state.
In the case where neither a new camera use request nor a camera use request identical to the memory space identification of the camera use request that has been temporarily stored is not executed, the camera state may be switched to the idle state.
In an implementation scenario, as shown in fig. 3, when the camera state is in the idle state, it may further be detected whether there is a new camera usage request, and if there is a new camera usage request, the above step S306 and subsequent steps may be executed, that is, in response to acquiring the new camera usage request, the communication channel may be reestablished by using the camera interface program, and the camera is controlled to operate according to the content of the new camera usage request.
Different from the embodiment, the camera use requests are temporarily stored, so that the centralized management of the camera use requests can be favorably realized, even in complex scenes such as a plurality of camera use requests, unified maintenance and management and control can be performed on the plurality of camera use requests, the camera control complexity can be reduced, and the camera control stability is improved.
Referring to fig. 4, fig. 4 is a schematic block diagram of a camera control system 40 according to an embodiment of 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 being coupled to the processor 42. Specifically, the camera control system 40 may include, but is not limited to: mobile phones, tablet computers, and the like have electronic devices with shooting functions. In particular, the camera control system 40 may further include a driving recorder, a safety monitoring device for monitoring the driver, and the like, which are not limited herein.
Specifically, the processor 42 may also be referred to as a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip having signal processing capabilities. The Processor 42 may 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 device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, processor 42 may be commonly implemented by a plurality of integrated circuit chips.
In the embodiment 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 used for responding to the buffered camera use request, and establishing a communication channel with the camera 43 by using the camera interface program; the processor 42 is configured to control the camera 43 to operate according to the contents of the camera use request through the communication channel.
According to the scheme, at least one camera use request is temporarily stored in a preset data structure, so that a communication channel between the camera and the camera is established by utilizing a camera interface program in response to the temporarily stored camera use request, and the camera is controlled to work according to the content of the camera use request through the communication channel. Therefore, the camera use requests are temporarily stored through the preset data structure, the centralized management of the camera use requests can be favorably realized, even if complex scenes such as a plurality of camera use requests exist, the camera use requests can be uniformly maintained and controlled, the camera control complexity can be reduced, and the camera control stability is improved.
In some disclosed embodiments, the processor 42 is configured to detect that the camera status is a preset status, and execute the step of establishing a communication channel with the camera 43 by using the camera interface program in response to the buffered camera usage request and the subsequent steps.
Different from the foregoing embodiment, the communication channel with the camera can be established in response to the camera use request that has been temporarily stored when the camera state is detected to be the preset state, so that the success rate of establishing the communication channel can be improved.
In some disclosed embodiments, the processor 42 is configured to detect that the camera status is not a preset status and that the buffered camera usage request is not less than one, switch the camera status to the preset status, and perform the step of establishing a communication channel with the camera 43 using the camera interface program in response to the buffered camera usage request and the subsequent steps.
Different from the embodiment, the camera state can be automatically switched to the preset state when the camera state is detected not to be the preset state and the number of the camera use requests which are temporarily stored is not less than one, and then the communication channel with the camera is established in response to the temporarily stored camera use requests, so that the speed of responding to the camera use requests can be increased, and the user experience is improved.
In some disclosed embodiments, the camera states include: opened, closed, opening, closing, the preset state is opened.
In some disclosed embodiments, the processor 42 is configured to switch the camera state to a camera state corresponding to the last camera switch instruction in response to acquiring a plurality of camera switch instructions to the camera 43 within a preset time period; wherein the camera switch command comprises any one of: the camera control system comprises a camera opening instruction and a camera closing instruction, wherein the camera state corresponding to the camera opening instruction is opened, and the camera state corresponding to the camera closing instruction is closed.
Different from the embodiment, the camera state is switched to the camera state corresponding to the last camera switch instruction by responding to the plurality of camera switch instructions of the camera acquired within the preset time length, so that the camera can be switched on and off in the preset time length too soon to be counteracted, and the response speed of the camera is improved.
In some disclosed embodiments, the processor 42 is configured to obtain the buffered camera usage request in response to the switch being turned on, and perform the step of establishing a communication channel with the camera 43 using the camera interface program in response to the buffered camera usage request and the subsequent steps; and/or the processor 42 may be configured to delete a staged camera usage request in response to switching to shutdown.
Different from the embodiment, the method and the device can be beneficial to decoupling the process management of the camera use request and the switch management of the camera state, thereby being beneficial to simplifying the camera control and improving the stability of the camera control.
In some disclosed embodiments, the processor 42 is configured to close the created communication channel in response to acquiring the new camera usage request, and to re-establish the communication channel using the camera interface program in response to the staged camera usage request and the new camera usage request.
Unlike the foregoing embodiment, the response rate to the camera use request can be further increased by closing the created communication channel in response to acquiring a new camera use request, and reestablishing the communication channel using the camera interface program in response to the camera use request that has been temporarily stored and the new camera use request. In addition, the communication channel is reestablished in response to the temporarily stored camera use request and the new camera use request, so that the success rate of the subsequent control camera working according to the content of the new camera use request is improved.
In some disclosed embodiments, the camera use request is for causing the camera to capture image data in accordance with the camera use request, the camera use request including: the storage space identification of the image data, the storage space identification of the new camera use request is different from the storage space identification of the camera use request which is temporarily stored.
Unlike the foregoing embodiment, the camera use request is for causing the camera to acquire image data in accordance with the camera use request, and the camera use request includes: the storage space identification of the image data and the storage space identification of the new camera use request are different from the storage space identification of the camera use request which is temporarily stored, so that whether a new communication channel needs to be created or not can be effectively distinguished, and the robustness of camera control is improved.
In some disclosed embodiments, the camera use request is for causing the camera 43 to capture image data in accordance with the camera use request, the camera use request including: the processor 42 is configured to use a pair of camera usage requests with the same storage space identification and opposite camera usage types as a target usage request pair, and the processor 42 is configured to delete the target usage request pair from the buffered camera usage requests.
Different from the foregoing embodiment, a pair of camera use requests with the same storage space identifier and opposite camera use types are used as a target use request pair, and the target use request pair is deleted from the temporarily stored camera use requests, so that the camera use requests with the opposite camera use types and the same storage space identifier can be cancelled from a plurality of camera use requests, and particularly, when a certain preview interface (or a certain recording) is rapidly and continuously switched on and off, and the like, intermediate process requests in the rapid and continuous switching processes can be directly cancelled, so that the consistency between the on-off state (or the recorded on-off state) of the preview interface and the last on/off operation can be ensured, and the stability of camera control can be further improved.
Referring to fig. 5, fig. 5 is a schematic diagram of a memory device 50 according to an embodiment of the present invention. The memory device 50 stores program instructions 501 capable of being executed by the processor, the program instructions 501 being for implementing the steps in any of the camera control method embodiments described above.
According to the scheme, the camera use requests can be temporarily stored through the preset data structure, centralized management of the camera use requests can be favorably realized, even if complex scenes such as a plurality of camera use requests exist, unified maintenance and management and control can be carried out on the camera use requests, the camera control complexity can be reduced, and the camera control stability is improved.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
The foregoing description of the various embodiments is intended to highlight various differences between the embodiments, and the same or similar parts may be referred to each other, and for brevity, will not be described again herein.
In the embodiments provided in the present invention, it should be understood that the disclosed method and apparatus can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely one type of logical division, and an actual implementation may have another division, for example, a unit or a component may be combined or integrated with another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on network elements. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may substantially or partially contribute to the prior art, or all or part of the technical solution may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Claims (10)
1. A camera control method, comprising:
temporarily storing at least one camera use request in a preset data structure;
responding to the camera use request which is temporarily stored, and establishing a communication channel with the camera by utilizing a camera interface program;
and controlling the camera to work according to the content of the camera use request through the communication channel.
2. The method of claim 1, further comprising:
detecting that the camera state is a preset state, and executing the step of responding to the temporarily stored camera use request and establishing a communication channel with the camera by using a camera interface program and the subsequent steps; and/or the presence of a gas in the gas,
and switching the camera state to the preset state and executing the step of establishing a communication channel with the camera by utilizing a camera interface program in response to the temporarily stored camera use request and the subsequent steps when the camera state is detected not to be the preset state and the temporarily stored camera use request is not less than one.
3. The method of claim 2, wherein the camera state comprises: opened, closed, opening, closing, the preset state is opened.
4. The method of claim 1, further comprising:
responding to a plurality of camera switching instructions of the camera acquired within a preset time length, and switching the camera state to a camera state corresponding to the last camera switching instruction;
wherein the camera switch command comprises any one of: the camera control system comprises a camera opening instruction and a camera closing instruction, wherein the camera state corresponding to the camera opening instruction is opened, and the camera state corresponding to the camera closing instruction is closed.
5. The method of claim 4, wherein after the switching the camera state to the camera state corresponding to the last camera switch command, the method further comprises:
responding to the started camera use request, acquiring the temporarily stored camera use request, and executing the step of establishing a communication channel with the camera by using a camera interface program and the subsequent steps in response to the temporarily stored camera use request; and/or the presence of a gas in the gas,
deleting the camera use request that has been staged in response to switching to the closed.
6. The method of claim 1, further comprising:
in response to acquiring a new camera use request, closing the created communication channel, and in response to the camera use request that has been temporarily stored and the new camera use request, reestablishing the communication channel using the camera interface program.
7. The method of claim 6, wherein the camera use request is for the camera to capture image data in accordance with the camera use request, the camera use request comprising: the storage space identifier of the image data, the storage space identifier of the new camera use request is different from the storage space identifier of the camera use request which is temporarily stored.
8. The method of claim 1, wherein the camera use request is for causing the camera to capture image data in accordance with the camera use request, the camera use request comprising: a memory space identification of the image data and a camera usage type of the camera usage request;
before the controlling the camera to operate according to the content of the camera use request through the communication channel, the method further includes:
taking a pair of the camera use requests with the same storage space identification and the opposite camera use types as a target use request pair;
deleting the target use request pair from the temporarily stored camera use requests.
9. A camera control system comprising a camera, a memory, and a processor, the camera, the memory coupled to the processor;
the processor is used for controlling the memory to temporarily store at least one camera use request in a preset data structure; the processor is used for responding to the camera use request which is temporarily stored, and establishing a communication channel with the camera by utilizing the camera interface program; the processor is further configured to control the camera to operate according to the content of the camera usage request through the communication channel.
10. A storage device, characterized by program instructions executable by a processor for implementing a camera control method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011431437.2A CN114598806A (en) | 2020-12-07 | 2020-12-07 | Camera control method and system and storage device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011431437.2A CN114598806A (en) | 2020-12-07 | 2020-12-07 | Camera control method and system and storage device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114598806A true CN114598806A (en) | 2022-06-07 |
Family
ID=81803054
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011431437.2A Pending CN114598806A (en) | 2020-12-07 | 2020-12-07 | Camera control method and system and storage device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114598806A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104471510A (en) * | 2012-07-11 | 2015-03-25 | 谷歌公司 | Abstract camera pipeline for uniform cross-device control of image capture and processing |
CN108540356A (en) * | 2018-03-30 | 2018-09-14 | 联想(北京)有限公司 | Processing method and processing equipment |
CN109144728A (en) * | 2018-08-22 | 2019-01-04 | Oppo广东移动通信有限公司 | The occupancy control method and device of camera applications |
-
2020
- 2020-12-07 CN CN202011431437.2A patent/CN114598806A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104471510A (en) * | 2012-07-11 | 2015-03-25 | 谷歌公司 | Abstract camera pipeline for uniform cross-device control of image capture and processing |
CN108540356A (en) * | 2018-03-30 | 2018-09-14 | 联想(北京)有限公司 | Processing method and processing equipment |
CN109144728A (en) * | 2018-08-22 | 2019-01-04 | Oppo广东移动通信有限公司 | The occupancy control method and device of camera applications |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107493375B (en) | Mobile terminal expansion screen projection method and screen projection system | |
EP2763034B1 (en) | Method and device for image-capturing application screen for use in mobile terminal | |
US10871985B2 (en) | Displaying media files between changes in states of an application client | |
CN111274510A (en) | Page rendering method, device and equipment and readable storage medium | |
CN115525453B (en) | Multi-screen collaborative interrupt processing method and electronic equipment | |
CN110650164B (en) | File uploading method and device, terminal and computer storage medium | |
CN111367456A (en) | Communication terminal and display method in multi-window mode | |
WO2007119550A1 (en) | System management apparatus | |
CN106919377B (en) | Method and device for determining whether display interface of application program is white screen | |
CN114339419B (en) | Video stream pulling processing method, device and storage medium | |
CN113709026B (en) | Method, device, storage medium and program product for processing instant communication message | |
EP3852363A1 (en) | Device state monitoring method and apparatus | |
CN108170585A (en) | log processing method, device, terminal device and storage medium | |
US7761853B2 (en) | Portable terminal device, method for restoring program, method for terminating program, and computer program therefor | |
CN113542545B (en) | Electronic device and video recording method | |
CN114598806A (en) | Camera control method and system and storage device | |
CN107835454B (en) | WebApp-based timeout processing method and device and storage medium | |
CN103516864B (en) | Monitor the method and apparatus of predetermined registration operation in the terminal | |
CN117056173A (en) | Method for monitoring android application life cycle on Web operating system | |
EP4340436A1 (en) | Operation and maintenance method, apparatus, and system, server, electronic device, and medium | |
CN111400137B (en) | Storage method and device of monitoring event, mobile terminal and storage medium | |
CN113778696A (en) | Thread control method, thread control device, and storage medium | |
WO2020199469A1 (en) | Interface call recording method, apparatus, device, and storage medium based on django framework | |
CN104850551B (en) | Data processing method and device and mobile terminal | |
CN114356559A (en) | Multithreading control method and terminal equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |