Shooting mode switching method, device, electronic device and readable storage medium
By adding a mark to the task thread before switching in the camera application, the problem of camera crash caused by thread switching when switching shooting modes is solved, ensuring that the camera application runs normally after switching.
Patent Information
- Application Number
- CN202310866589.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-07-13
AI Technical Summary
In existing camera applications, abnormal situations such as camera crashes due to the thread switching scheme when switching shooting modes affect the user experience.
By adding a mark to the task thread before the switch when switching the shooting mode, it prevents its release operation from affecting the creation of the task thread after the switch, ensuring that there is no memory conflict, thereby avoiding the occurrence of abnormal situations.
This effectively avoids abnormal situations caused by thread switching after the camera application switches shooting modes, ensuring the normal operation of the camera application.
Smart Images

Figure CN117082339B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a shooting mode switching method, device, electronic device and readable storage medium. Background Art
[0002] Cameras on electronic devices such as mobile phones usually include multiple shooting modes such as front and rear cameras. Users can switch between different shooting modes according to their shooting needs after turning on the camera. In each shooting mode, the mobile phone will create a corresponding camera thread. When the camera switches from one shooting mode to another, the mobile phone will release the existing camera thread corresponding to the shooting mode before switching, and create a new camera thread corresponding to the shooting mode after switching. Releasing the existing camera thread and creating a new camera thread are performed in parallel.
[0003] When each camera thread is created, at least two nodes are created. Therefore, when releasing the camera thread, the at least two nodes created need to be released one after another. For example, the nodes created by the camera thread include a device call handle and an entry function set.
[0004] Then, the release operation of at least two nodes of the existing camera thread and the creation operation of at least two nodes of the new camera thread may result in an exception in the creation of the existing camera thread due to similar logic such as the node of the new camera thread being released during the node release operation of the existing camera thread after being created, and then an exception such as the camera crashing after switching the shooting mode may occur.
[0005] It can be seen that the thread switching solution in the existing camera application may cause abnormal situations such as camera crash. Summary of the invention
[0006] The embodiment of the present application provides a shooting mode switching method, device, electronic device and readable storage medium, which are used to mark the first task thread of the first shooting mode before switching in the scenario where the electronic device opens the camera application and switches the shooting mode, so as to avoid the release operation of the first task thread affecting the creation operation of the second task thread of the second shooting mode after switching through marking. In this way, abnormal situations such as camera flashback caused by the thread switching scheme when the camera application switches the shooting mode can be effectively avoided, and the camera application can be ensured to operate normally after switching the shooting mode.
[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0008] In a first aspect, a shooting mode switching method is provided. The shooting mode switching method provided is applied to an electronic device, wherein a camera module is installed in the electronic device, and the electronic device runs a camera application, and captures images in different shooting modes by calling the camera module. The shooting mode switching method provided in the present application mainly involves the process of releasing and creating threads inside the electronic device when switching between two shooting modes.
[0009] Specifically, the electronic device first receives a first operation, and the first operation is used to trigger the electronic device to capture an image in a first shooting mode. The first operation can be an operation for the electronic device to open a camera application, or an operation for the electronic device to select a shooting mode, such as clicking on shooting modes such as professional, large aperture, and night scene. The previous shooting mode can be defined as the first shooting mode. In response to the first operation, the electronic device creates a first task thread corresponding to the first shooting mode. There can be multiple operations to create the first task thread, such as creating global variables, local variables, etc. In an embodiment of the present application, the operation of creating the first task thread may include the operation of creating a first handle module and creating a first entry function.
[0010] Afterwards, the electronic device receives a second operation, and the second operation is used to trigger the electronic device to switch from the first shooting mode to the second shooting mode. The second shooting mode may be another shooting mode different from the first shooting mode, such as a selfie mode, a dual-view video recording mode, etc. After the electronic device switches to the second shooting mode, it can shoot images in the second shooting mode. After the electronic device switches to the second shooting mode, it needs to create a second task thread for the second shooting mode, for example, create a second local variable or create a second global variable, etc.
[0011] Since the electronic device has switched to the second shooting mode, it is not necessary to shoot images in the first shooting mode. Therefore, the first task thread corresponding to the first shooting mode created earlier does not need to be retained and needs to be released. The operations of the electronic device releasing the first task thread and creating the second task thread can be performed successively or in parallel and cross-executed. In order to avoid abnormal situations that may cause the failure of the creation of the second task site during parallel and cross-execution, the electronic device can add a first mark to the first task thread. There are many ways to add the first mark, such as adding a status identifier of a to-be-released state, or adding a thread lock, etc. Among them, the first mark is used to indicate that the memory corresponding to the global variables of the first task thread is unavailable. Based on the first mark, the memory allocated to the global variables of the second task thread during the creation of the second task thread is different from the memory corresponding to the global variables of the first task thread.
[0012] In this way, the shooting mode switching method provided by the present application, during the shooting mode switching process, adds a first mark to the first task thread corresponding to the shooting mode before switching to indicate that the memory corresponding to the global variables of the first task thread is unavailable. This can effectively avoid the abnormal situation in which the creation of the second task thread fails due to the memory allocated to the global variables of the second task thread being the same as the memory corresponding to the global variables of the first task thread (also known as a memory conflict) during the creation of the second task thread, thereby ensuring that the electronic device can normally capture images in the second shooting mode after switching the shooting mode.
[0013] In a specific implementation of the first aspect, the first shooting mode before switching and the second shooting mode after switching may both be single-view shooting modes. The single-view shooting mode may be a mode that only requires foreground shooting or only requires background shooting. In the single-view shooting mode, only one corresponding task thread needs to be created, and when the single-view shooting mode is turned off, only one corresponding task thread needs to be released. If the single-view shooting mode is used before and after the switching, then after the switching, one task thread (i.e., the first task thread) needs to be released and one task thread (i.e., the second task thread) needs to be created.
[0014] According to another possible implementation of the first aspect, the first shooting mode before switching is a single-view shooting mode, and the second shooting mode after switching is a multi-view shooting mode. Then, after switching, the task thread of the first shooting mode that needs to be released includes the first task thread, and the task thread of the second shooting mode that needs to be created includes, in addition to the second task thread, a third task thread needs to be created, and the shooting operation of the second shooting mode can be completed through the second task thread and the third task thread.
[0015] According to another possible implementation of the first aspect, the first shooting mode before switching is a multi-view shooting mode, and the second shooting mode after switching is a single-view shooting mode. Then, when the first shooting mode is turned on, in addition to creating a first task thread, a fourth task thread needs to be created, and the first task thread and the fourth task thread cooperate to complete the shooting operation of the first shooting task. Correspondingly, after switching to the second shooting mode, the first task thread and the fourth task thread of the first shooting mode need to be released, and the second task thread of the second shooting mode needs to be created.
[0016] Of course, in other possible implementations, the first shooting mode before switching and the second shooting mode after switching can both be multi-view shooting modes, for example, switching from a multi-view photo mode to a multi-view video mode. Then, after switching, it is necessary to release the first task thread and the fourth task thread of the first shooting mode, and create the second task thread and the third task thread of the second shooting mode.
[0017] It should be noted that the first task thread, the second task thread, the third task thread and the fourth task thread involved in these implementations are named only according to the order of introduction in this article, and do not limit the order of their creation, nor do they limit whether their categories are the same. In the above implementation, only the multi-view shooting mode is a dual-view shooting mode as an example to introduce the scheme of this application. The multi-view shooting mode can also be a three-view shooting mode, a four-view shooting mode, etc., and this application does not limit it multiple times.
[0018] In a specific implementation of the first aspect, the node variables in each task thread are divided into global variables and variables according to the type of influence of each node in the task thread on the overall process of the camera application. The first task thread includes a first local variable and a first global variable, and the second task thread includes a second local variable and a second global variable. Specifically in the camera application shooting scenario, the first local variable is a first module handle, and the second local variable is a second module handle; the first global variable is a first entry function, and the second global variable is a second entry function.
[0019] The step of the electronic device creating the first task thread corresponding to the first shooting mode may include: creating the first local variable and the first global variable, and associating the memory corresponding to the first local variable and the memory corresponding to the first global variable with each other through an address pointer;
[0020] Correspondingly, the step of releasing the first task thread by the electronic device may include: releasing the first local variable, releasing the first global variable, and canceling the association between the memory corresponding to the first local variable and the memory corresponding to the second local variable;
[0021] Furthermore, the step of the electronic device creating a second task thread corresponding to the second shooting mode may include: creating the second local variable, creating the second global variable, and associating the memory corresponding to the second local variable with the memory corresponding to the second global variable through an address pointer.
[0022] When creating a task thread, the electronic device creates associated local variables and global variables respectively, and associates the memory address corresponding to the local variable in the task thread with the memory address corresponding to the global variable through an address pointer.
[0023] In a specific camera application shooting scenario, the process of creating a task thread can be: first create a handle module and allocate the corresponding memory, then create an entry function and allocate the corresponding memory, and then associate the memory corresponding to the handle module with the memory corresponding to the entry function through the address pointer. The process of releasing a task thread can be: first release the handle module, and cancel the pointer from the handle module's memory to the entry function's memory; then release the entry function, and cancel the pointer from the entry function's memory to the handle module's memory. Before releasing the entry function, the pointer from the entry function's memory to the handle module's memory will always exist.
[0024] In a specific implementation of the first aspect, when the electronic device adds the first mark to the first task thread, it can add the first mark to the first global variable and execute the operation of releasing the first global variable and the first local variable when starting to release the first task thread. The electronic device can add the first mark to the first global variable after receiving the second operation, or add the first mark to the first global variable when releasing the first local variable.
[0025] Correspondingly, when the electronic device creates a second task thread for the switched shooting mode, it first creates a second local variable, and then queries whether there is a third global variable associated with the memory of the second local variable through an address pointer. If no third global variable is found, a new second global variable is directly created, and the memory of the new second global variable is associated with the second local variable through the address pointer.
[0026] If the electronic device finds that there is a third global variable associated with the memory of the second local variable through an address pointer, it will further determine whether the third global variable has a first mark. If the first mark exists, it means that the third global variable is in a pending release state and cannot be used. At this time, the electronic device can create a new second global variable and associate the memory of the new second global variable with the second local variable through an address pointer. If the third global variable found does not have the first mark, it means that the third global variable can be used, and the third global variable can be directly used as the second global variable. Specifically for the camera shooting scene, the second local variable is the second module handle, and the second global variable and the third global variable are both entry functions.
[0027] In a specific implementation of the first aspect, the electronic device may add a first mark to the first global variable by marking the structure of the first entry function as a to-be-released state, or marking the memory corresponding to the first global variable as a to-be-released state. In this way, it is ensured that the to-be-released state of the first entry function can be seen by other threads to avoid being reused by other threads.
[0028] In a specific implementation of the first aspect, after the first global variable is released, the memory can be reused, but if it is always marked with the first tag, it cannot be reused. When or after the first global variable of the first task thread is released, an operation of deleting the first tag can be added to release the original occupied memory of the first global variable, thereby improving the memory utilization of the electronic device.
[0029] In a specific implementation of the first aspect, the first mark used to mark the first global variable can be a thread lock, and the thread lock is used to lock the continuous state of multiple steps in the thread. The electronic device can acquire the thread lock before the first task thread is released, and release the thread lock after the first task thread is released. Specifically for the camera shooting scene, the thread lock can be acquired before the first module handle is released, and the operations of releasing the first module handle and releasing the first entry function of the first task thread are locked to avoid inserting the creation operation of the second task thread. After the first entry function is released, the thread lock is released, and the creation operation of the second task thread can be jumped to execute.
[0030] In a specific implementation of the first aspect, considering the property of global variables as temporary resources in threads, thread locks can also be introduced to protect the operation of global variables. Specifically, the thread lock can be acquired before the first global variable is created, and the thread lock can be canceled when the first global variable is created. In addition, the thread lock can be acquired before the first global variable is released, and the thread lock can be canceled when the first global variable is released. And, the thread lock can also be introduced before the second global variable is created, and the thread lock can be canceled when the second global variable is created.
[0031] In a second aspect, a shooting mode switching device is provided, comprising a processor, wherein the processor is configured to execute the shooting mode switching method as described in any one of the first aspects.
[0032] In a specific implementation of the second aspect, the first shooting mode and the second shooting mode are both single-view shooting modes.
[0033] In a specific implementation of the second aspect, the first shooting mode is a single-view shooting mode, and the second shooting mode is a multi-view shooting mode; and the processor is further configured to:
[0034] In response to the second operation, creating a third task thread corresponding to the second shooting mode;
[0035] In response to the second operation, based on the first mark, in the process of creating the third task thread, the memory allocated for the global variables of the third task thread is different from the memory corresponding to the global variables of the first task thread.
[0036] In a specific implementation of the second aspect, the first shooting mode is a multi-view shooting mode, and the second shooting mode is a single-view shooting mode; and the processor is further configured to:
[0037] In response to the first operation, creating a fourth task thread corresponding to the first shooting mode;
[0038] In response to the second operation, the first mark is added to the fourth task thread and the fourth task thread is released; wherein, based on the first mark, the memory allocated for the global variables of the second task thread during the creation of the second task thread is different from the memory corresponding to the global variables of the fourth task thread.
[0039] In a specific implementation of the second aspect, the first task thread includes a first local variable and a first global variable, and the second task thread includes a second local variable and a second global variable;
[0040] The processor is further configured to:
[0041] Creating the first local variable, creating the first global variable, and associating the memory corresponding to the first local variable and the memory corresponding to the first global variable with each other through an address pointer;
[0042] The step of releasing the first task thread includes:
[0043] releasing the first local variable, releasing the first global variable, and canceling the association between the memory corresponding to the first local variable and the memory corresponding to the second local variable;
[0044] The step of creating a second task thread corresponding to the second shooting mode includes:
[0045] The second local variable is created, and the second global variable is created, and the memory corresponding to the second local variable is associated with the memory corresponding to the second global variable through an address pointer.
[0046] In a specific implementation of the second aspect, the processor is further configured to:
[0047] In response to the second operation, adding the first tag to the first global variable, releasing the first local variable, and releasing the first global variable;
[0048] Create the second local variable, and query whether a third global variable exists; wherein the third global variable is a global variable whose corresponding memory is associated with the memory corresponding to the second local variable through an address pointer; if the memory corresponding to the second local variable is associated with other memories, the third global variable exists;
[0049] If the third global variable is found to exist, determine whether the third global variable includes the first mark; if the third global variable includes the first mark, create a new second global variable, and associate the memory corresponding to the new second global variable with the memory of the second local variable; if the third global variable does not include the first mark, use the third global variable as the second global variable.
[0050] In a specific implementation of the second aspect, the first local variable is a first module handle, and the second local variable is a second module handle;
[0051] The first global variable is a first entry function, the second global variable is a second entry function, and the third global variable is a third entry function.
[0052] In a specific implementation of the second aspect, the processor is further configured to:
[0053] When releasing the first module handle, the first tag is added to the first entry function.
[0054] In a specific implementation of the second aspect, the processor is further configured to:
[0055] The structure of the first entry function is marked as a state to be released, or the memory corresponding to the first global variable is marked as a state to be released.
[0056] In a specific implementation of the second aspect, the processor is further configured to:
[0057] Delete the first mark of the first task thread.
[0058] In a specific implementation of the second aspect, the first tag includes a thread lock;
[0059] The processor is further configured to:
[0060] Get thread lock;
[0061] releasing the first task thread;
[0062] Release the thread lock.
[0063] In a specific implementation of the second aspect, the processor is further configured to:
[0064] Get thread lock;
[0065] Create the first global variable;
[0066] Release the thread lock;
[0067] and / or,
[0068] The processor is further configured to:
[0069] Get thread lock;
[0070] Release the first global variable;
[0071] Release the thread lock;
[0072] and / or,
[0073] The processor is further configured to:
[0074] Get thread lock;
[0075] Create the second global variable;
[0076] Release the thread lock.
[0077] In a third aspect, an electronic device is provided, comprising a camera module, a memory, and one or more processors. The camera module and the memory are coupled to the processor. The memory stores computer-executable instructions. The processor executes the computer-executable instructions stored in the memory, so that the electronic device performs the shooting mode switching method as described in any one of the first aspects.
[0078] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer can execute the shooting mode switching method described in any one of the first aspects.
[0079] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the shooting mode switching method described in any one of the first aspects.
[0080] In a sixth aspect, the present application provides a chip system, which is applied to an electronic device including a camera module and a memory. The chip system includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by a line. The interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor, and the signal includes a computer instruction stored in the above-mentioned memory. When the processor executes the computer instruction, the electronic device executes the method described in the first aspect and any possible design thereof.
[0081] Among them, the technical effects brought about by any design method in the second to sixth aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] Figure 1One of the schematic diagrams of the camera application shooting interface of the electronic device provided in the embodiment of the present application;
[0083] Figure 2 A second schematic diagram of a camera application shooting interface of an electronic device provided in an embodiment of the present application;
[0084] Figure 3 A structural diagram of a front camera head installed in an electronic device provided in an embodiment of the present application;
[0085] Figure 4 A structural diagram of a rear camera installed in an electronic device provided by an embodiment of the present application;
[0086] Figure 5 A schematic diagram of the internal architecture of an electronic device provided in an embodiment of the present application;
[0087] Figure 6 An internal logic diagram of an electronic device provided in an embodiment of the present application for implementing a shooting function of a camera application;
[0088] Figure 7 One of the schematic diagrams of possible coexistence of threads in an electronic device in a shooting mode switching scenario provided by an embodiment of the present application;
[0089] Figure 8 A second schematic diagram of possible thread coexistence in an electronic device in a shooting mode switching scenario provided by an embodiment of the present application;
[0090] Fig. 9 A third schematic diagram of possible thread coexistence in an electronic device in a shooting mode switching scenario provided by an embodiment of the present application;
[0091] Fig.10 A fourth schematic diagram of possible coexistence of threads in an electronic device in a shooting mode switching scenario provided by an embodiment of the present application;
[0092] Fig.11 A schematic diagram of internal interaction of an electronic device in a shooting mode switching scenario provided by an embodiment of the present application;
[0093] Fig.12 A schematic diagram of the operation execution sequence of the electronic device in the shooting mode switching scenario provided by an embodiment of the present application;
[0094] Fig.13 This is a schematic diagram of executing sequence 1;
[0095] Fig.14 It is a schematic diagram of execution sequence 2;
[0096] Fig.15 One of the schematic diagrams for executing sequence 3;
[0097] Fig.16 This is the second schematic diagram of executing sequence 3;
[0098] Fig.17 A schematic diagram of an application execution sequence 3 of the shooting mode switching method provided in an embodiment of the present application;
[0099] Fig.18 A schematic diagram of a flow chart of a shooting mode switching method in the prior art;
[0100] Fig.19 One of the flowcharts of the shooting mode switching method provided in the embodiment of the present application;
[0101] Fig. 20 The second flowchart of the shooting mode switching method provided in the embodiment of the present application;
[0102] Fig.21 A schematic diagram of an electronic device applying a thread lock in multiple concurrent threads provided by an embodiment of the present application;
[0103] Fig. 22 The third flowchart of the shooting mode switching method provided in the embodiment of the present application;
[0104] Fig.23 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0105] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0106] To facilitate understanding, some technical common sense involved in the embodiments of the present application is first introduced.
[0107] See also Figure 1, is a schematic diagram of a camera application shooting interface of an electronic device provided in an embodiment of the present application. The electronic device may be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA) or a dedicated camera (such as a SLR camera, a card camera), etc., without limitation.
[0108] like Figure 1 As shown, the shooting interface 100 mainly includes: a shutter control 101, a gallery control 102, a mode control area 103, a front and rear camera flip control 104, an image display area 105, a zoom control 106 and a parameter control area 107. Among them, the shutter control 101 is used to respond to the shutter opening operation input by the user, and the shutter is opened to capture images based on the shutter opening operation. The gallery control 102 is used to respond to the gallery opening operation input by the user, and the gallery control 102 displays a thumbnail schematic diagram of an image with the most recent collection time in the album. Based on the gallery opening operation, the images in the gallery of the electronic device are displayed for the user to view. After the user opens the camera application of the electronic device, the camera application starts to collect preview images and displays the collected preview images in the image display area 105 in the shooting interface 100. If the user clicks the shutter control 101, the electronic device will collect new images, and the newly collected images will be directly stored in the gallery, and the thumbnail schematic diagram of the image with the most recent collection time displayed at the gallery control 102 in the shooting interface 100 will be updated at the same time. The zoom control 106 is used to respond to the zoom operation input by the user to adjust the field of view of the camera. The parameter control area 107 includes a plurality of parameter controls, each of which is used to respond to the shooting parameter adjustment operation input by the user. The parameter controls included in the parameter control area may include, but are not limited to: a flash control, an AI recognition switch control, a color standard control, and a more detailed camera setting control.
[0109] In addition, the shooting interface 100 also includes a mode control area 103, in which a plurality of mode controls are displayed, each of which corresponds to a different shooting mode, such as a photo mode, a video mode, a night scene mode, a portrait mode, a professional mode, a dual-view shooting mode, or a multi-view shooting mode. Figure 1As shown in the shooting interface 100, the mode controls included in the mode control area 103 may include: aperture mode control 1031, night scene mode control 1032, portrait mode control 1033, photo mode control 1034, video mode control 1035, professional mode control 1036 and more mode control 1037, etc., and the various mode controls can respond to the mode selection operation input by the user and call the camera module associated with each shooting mode to shoot. The more mode control 1037 can also respond to the more modes input by the user and display the mode controls corresponding to other shooting modes included in the more modes. Figure 2 The second schematic diagram of the shooting interface of the camera application of the electronic device is shown. In addition to Figure 1 In addition to the mode controls shown, the mode control area of the electronic device may also include: slow motion controls, panoramic controls, black and white art controls, fun AR controls, streamer shutter controls, HDR controls, time-lapse photography controls, watermark controls, document correction controls, underwater camera controls, super macro controls, dual-view recording controls, high-pixel controls, multi-camera controls, etc.
[0110] It should be noted that different models of electronic devices may provide different shooting modes, so the type and display method of the mode control in the mode control area 103 of the corresponding shooting interface may also be different, without limitation. Figure 1 As shown, each mode control can be displayed only by text information, such as "Aperture", "Night Scene", "Portrait", "Photo", "Video", "Professional", "More", or as shown in the figure. Figure 2 As shown, each mode control may also be displayed in a manner combining text information and icons.
[0111] In addition, the shooting interface 100 also includes a front and rear camera flip control 104, which is used to respond to the camera flip operation input by the user to control the camera for shooting to flip from the front camera to the rear camera, or from the rear camera to the front camera. In actual use, turning on the front camera for shooting and turning on the rear camera for shooting can also be used as different shooting modes, such as the front camera mode and the rear camera mode. The front camera mode and the rear camera mode can be respectively limited to a working mode of the camera with the large aperture, portrait, night scene and other shooting modes mentioned above. Of course, the front camera mode and the rear camera mode can also be superimposed with the shooting modes such as large aperture, portrait, night scene and other shooting modes to form a comprehensive shooting mode, such as the front camera portrait mode, the rear camera night scene mode, the front camera video mode, the rear camera panoramic mode, etc., and each comprehensive shooting mode can also be respectively limited to a working mode of the camera. In the relevant description of the shooting mode of the camera later, it can refer to a single shooting mode such as the front camera, the rear camera, the large aperture, the portrait, the night scene and the like, or it can refer to the comprehensive shooting mode.
[0112] The electronic device is provided with a camera module as a hardware support structure for realizing the shooting functions of the different shooting modes mentioned above, as well as the shooting functions of the front camera and the rear camera. The camera module can be mainly divided into a camera and a lens, which will be described from the two levels of the camera and the lens below.
[0113] On the one hand, from the camera level, the camera module mainly includes a front camera and a rear camera. Among them, the front camera can be used to refer to the camera set on the side where the screen of the electronic device is located, and the front camera can capture images within the front camera field of view. The rear camera can be used to refer to the camera set on the surface where the rear shell of the electronic device is located, and the rear camera can capture images within the rear camera field of view. The number of front cameras installed in an electronic device may be one or more, such as Figure 3 The structure diagram of the electronic device with the front camera installed is shown in FIG. 2 . The number of the front cameras 200 of the electronic device is two, and the number of the rear cameras installed in the electronic device may be one or more. Figure 4 The figure shows a schematic diagram of the structure of the electronic device with a rear camera installed. The number of the rear cameras 300 of the electronic device can be three. It should be noted that the basic difference between the front camera and the rear camera is the installation position and the field of view range, and it does not limit whether there is a difference in camera function, lens model and pixel.
[0114] On the other hand, from the lens level, the camera module can include a main camera lens, a wide-angle lens, a telephoto lens, a depth of field lens, etc., and different lenses have different functions. Specifically, the main camera lens can be a conventional lens with a certain resolution. A wide-angle lens refers to a lens with a wide-angle function. The viewing angle of a wide-angle lens is wider than that of a general lens and the focal length is shorter. It is often used to shoot objects with a large area. A telephoto lens can take longer images to ensure the clarity of the image. Wide-angle lenses and telephoto lenses can make up for the shortcomings of the main camera lens and improve the shooting effect. The depth of field lens can choose to blur the image area where some objects are located according to the distance of each object within the field of view. The camera module can also include other commonly used lenses, which will not be elaborated.
[0115] In an electronic device, both the front camera and the rear camera may include one lens or multiple lenses. For example, the front camera includes a front main camera lens, an always-on (AO) lens, and a time of flight (TOF) lens, and the rear camera may include a rear main camera lens, a wide-angle lens, a depth of field lens, and a telephoto lens.
[0116] After the electronic device opens the camera application, different lenses will be called for different shooting modes. One lens or multiple lenses may be called in a shooting mode to perform the image acquisition task in that shooting mode. For example, in the front shooting mode, the called lenses may include at least one of the main camera lens, AO lens, and TOF lens. For another example, in the rear panoramic shooting mode, the called lenses may include at least one of the rear main camera lens, depth of field lens, wide-angle lens, etc.
[0117] When an electronic device executes a task, it will create a task thread for each task, and execute the task-related software processing and hardware calls based on the task thread. In camera applications, in different shooting modes, the electronic device needs to call different lenses to perform the image acquisition tasks corresponding to each shooting mode, so a task thread will also be created for the image acquisition tasks corresponding to each shooting mode, and different lenses can be called for image acquisition through this task thread.
[0118] like Figure 5 The figure is a schematic diagram of the internal architecture of an electronic device provided by an embodiment of the present application. The process of creating task threads for image acquisition tasks corresponding to each shooting mode by the electronic device will be explained in detail below in combination with the internal architecture of the electronic device.
[0119] Specifically, the software architecture inside the electronic device can be divided into four layers, from top to bottom, namely the application layer (APPlication, APP), the framework layer (Framework, FWK), the hardware abstraction layer (HAL), and the kernel layer (or driver layer). The software architecture is connected to the hardware layer, which is usually connected to the kernel layer in the software framework layer and driven by the kernel layer. It should be noted that in addition to these main functional layers, other functional modules can also be included without limitation.
[0120] The application layer can include a series of application packages, such as camera applications, gallery applications, applications with camera functions, etc. Application packages can also include applications such as calls, calendars, maps, navigation, music, videos, short messages, etc.
[0121] The framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0122] The framework layer runs a camera service, which can be called by the camera application to implement functions related to shooting. In addition, the framework layer can also include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. Among them, the window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, dialed and received calls, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, notification information is used to inform the completion of downloads, message reminders, etc. Notification information can also be a notification that appears in the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. Notification information can also be, for example, a text message prompted in the status bar, a prompt sound, a vibration of the power terminal, a flashing indicator light, etc. It should be pointed out that the camera application can also call the content provider, resource manager, notification manager, window manager, view system, etc. according to actual business needs, and the embodiments of the present application do not impose any restrictions on this.
[0123] The kernel layer is a layer between hardware and software. The kernel layer includes at least a camera driver. The camera driver can be used to drive hardware modules with shooting functions in the hardware layer, such as lenses and camera sensors. In other words, the camera driver is responsible for data interaction with the lens and camera sensor. The kernel layer may also include a display driver, an audio driver, a sensor driver, etc., and the embodiments of the present application do not impose any restrictions on this. The various hardware modules such as the lenses mentioned above can perform image acquisition tasks via the camera driver in the kernel layer.
[0124] The hardware abstraction layer can encapsulate the drivers in the kernel layer and provide a calling interface to the framework layer, shielding the implementation details of the underlying hardware. Figure 5As shown, the hardware abstraction layer may include a camera call processing module (Camera HAL), a multi-camera decision module, and the like. The camera call processing module is the core software framework of the camera, and the camera call processing module includes an interface module, a sensor node (Sensor Node), and a data processing module, and the like. The sensor node, the data processing module, and the interface module are components in the image data and control instruction transmission pipeline in the camera call processing module. The interface module may be a software interface for the application framework layer, which is used to interact with the application framework layer for data. Of course, the interface module may also interact with the multi-camera decision module, the data processing module, the sensor node, and the like in the camera call processing module for data. The data processing module may include image signal front-end processing, spatial alignment transformation processing, image signal back-end processing, and the like.
[0125] like Figure 6 FIG. 1 is one of the internal logic diagrams of the electronic device implementing the shooting function of the camera application provided by the embodiment of the present application. In the application layer, the camera application can pass the shooting mode and other parameter information selected by the user to the framework layer based on the shooting mode selection operation input by the user.
[0126] In the framework layer, the camera service creates a shooting task based on the shooting mode selected by the user, and determines the camera module associated with the shooting task corresponding to the shooting mode, such as the type of lens that needs to be called. Determine the logiccameraId of the lens that needs to be called and configure it as the display camera. During initialization, the hardware abstraction layer preconfigures each shooting mode and the corresponding logiccameraId of the displayed camera, and the camera application stores the mapping relationship between the shooting mode and the called logiccameraId. After the camera application creates a shooting task, the camera service sends information such as the logiccameraid of the called lens to the hardware abstraction layer according to the pre-stored mapping relationship.
[0127] In the hardware abstraction layer, the interface module receives information such as logcicameraid of the calling lens associated with the shooting task passed by the framework layer. The hardware abstraction layer determines the camera sensor for outputting the image according to the application scenario indicated by the application layer, such as the camera sensor of the front camera or the camera sensor of the rear camera, and the camera sensor of the main camera in the rear camera, the camera sensor of the wide-angle camera, and the camera sensor of the telephoto camera.
[0128] From the hardware abstraction layer to the kernel layer and the bottom hardware layer, the sensor node is a control node for the camera sensor. The sensor node can drive the lens and camera sensor through the camera. The camera sensor collects the original image data, which is then uploaded to the data processing module of the hardware abstraction layer for processing to obtain a preview image, and then the preview image is uploaded to the camera application of the application layer for display.
[0129] In the above process, the shooting mode selection operation input by the user is responded to by the application layer, framework layer, hardware abstraction layer, kernel layer and hardware layer in turn until the shooting task is completed. In order to call the camera module such as the lens to perform the shooting task through the interface module and sensor node, the hardware abstraction layer will create a task thread, and associate the callable camera module and related functions through the task thread.
[0130] Understandably, Figure 6 The layers in the software structure shown and the components contained in each layer do not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer layers than shown in the figure, and each layer may include more or fewer components, which is not limited in the present application.
[0131] In addition, it is understood that in order to implement the shooting mode switching method in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.
[0132] Usually, a shooting mode needs to execute a shooting task. For example, the front camera shooting mode only needs to execute the front camera shooting task, and the rear camera video recording mode only needs to execute the rear camera video recording task. For this single-task shooting mode, only one task thread can be created. In addition, there are some compound shooting modes, such as the front and rear dual-view video recording mode. This shooting mode needs to execute both the front camera video recording task and the rear camera video recording task. Then, for this compound shooting mode, the task thread corresponding to the front camera video recording task and the task thread corresponding to the rear camera video recording task can be created separately.
[0133] A task thread is created when the shooting task starts, and the task thread created at the beginning needs to be released when the shooting task ends. The scenario of ending the shooting task here can be a scenario where the user completes the shooting task and turns off the current shooting mode or directly turns off the camera application, or it can refer to a scenario where the user switches the current shooting mode to another shooting mode. The scenario of switching from the current shooting mode to a new shooting mode can be considered as the end of the shooting task corresponding to the current shooting mode, and the start of the shooting task corresponding to the new shooting mode. Then, it is necessary to release the task thread of the shooting task corresponding to the current shooting mode, and create a task thread of the shooting task corresponding to the new shooting mode.
[0134] Specific as Figure 6 As shown, the hardware abstraction layer may simultaneously have a corresponding task thread 1 created for shooting task 1, and a corresponding task thread 2 created for shooting task 2. Here, shooting task 1 and shooting task 2 may be two shooting tasks in the same shooting mode, such as dual-view recording mode. It may also be shooting tasks corresponding to different shooting modes, for example, shooting task 1 corresponds to shooting mode 1, and shooting task 2 corresponds to shooting mode 2. This situation usually occurs in the shooting mode switching scene, for example, switching from shooting mode 1 to shooting mode 2 or from shooting mode 2 to shooting mode 1. Usually, the shooting mode of a single task is a single-view shooting mode, such as a front selfie mode, a rear wide-angle mode, etc., and the shooting mode of a multi-task is a multi-view shooting mode, such as a multi-view shooting mode, a multi-view recording mode, etc.
[0135] like Figures 7 to 10 As shown, it is a schematic diagram of the coexistence of threads that may exist in the shooting mode switching scenario of the electronic device provided by the embodiment of the present application. The shooting mode before and after the switch may be a single-view shooting mode, or it may be a dual-view or multi-view shooting mode. The following will explain the situations where the single-view shooting mode is switched to the single-view shooting mode, the single-view shooting mode is switched to the multi-view shooting mode, the multi-view shooting mode is switched to the single-view shooting mode, and the multi-view shooting mode is switched to the multi-view shooting mode. For the sake of simplification, the number of tasks of the multi-view shooting mode involved is set to 2. In the actual shooting process, there are situations where the shooting tasks of some shooting modes include 3 or more, then the number of corresponding temporarily coexisting task threads may be 5 or more, without limitation.
[0136] Figure 7 A thread schematic diagram of switching from single-view shooting mode to single-view shooting mode is shown, involving a release operation of task thread 1 corresponding to shooting mode 1 before switching, and a creation operation of task thread corresponding to shooting mode 2 after switching. Figure 8 The second schematic diagram of thread coexistence that may exist in the electronic device provided in the shooting mode switching scenario according to the embodiment of the present application shows a thread schematic diagram of switching from a single-scene shooting mode to a multi-scene shooting mode. Remember the release operation of task thread 1 corresponding to shooting mode 1 before switching, and the creation operation of task thread 2 and task thread 3 corresponding to shooting mode 2 after switching. Fig. 9 The third schematic diagram of thread coexistence that may exist in the electronic device provided in the shooting mode switching scenario according to the embodiment of the present application shows a thread schematic diagram of switching from the multi-scene shooting mode to the single-scene shooting mode, involving the release operation of task thread 1 and task thread 4 corresponding to the shooting mode 1 before the switching, and the creation operation of task thread 2 corresponding to the shooting mode 2 after the switching. Fig.10The fourth schematic diagram of possible coexistence of threads in the electronic device in the shooting mode switching scenario provided by the embodiment of the present application shows a schematic diagram of threads when the multi-view shooting mode is switched to the multi-view shooting mode, involving the release operation of task thread 1 and task thread 4 corresponding to shooting mode 1 before the switching, and the creation operation of task thread 2 and task thread 3 corresponding to shooting mode 2 after the switching. Of course, these figures are only exemplary examples, and there may be many thread situations in the actual shooting mode switching scenario, which are not limited.
[0137] like Figure 7 As shown, the single-view shooting mode is switched to the single-view shooting mode. Before the switch, the task thread 1 of the shooting mode 1 is in the waiting state to be released, and after the switch, the task thread 2 of the shooting mode 2 is in the waiting state to be created. In this process, the task thread 1 has not been completely released, and the task thread 2 has not been completely created, so it is possible that the task thread 1 and the task thread 2 temporarily coexist.
[0138] like Figure 8 As shown, the single-view shooting mode is switched to the multi-view shooting mode. Before the switch, task thread 1 of shooting mode 1 is in a waiting state to be released, and after the switch, task thread 2 and task thread 3 of shooting mode 2 are waiting to be created. In this process, task thread 1 has not been completely released, and task thread 2 and task thread 3 have not been completely created, so it is possible that task thread 1, task thread 2 and task thread 3 temporarily coexist.
[0139] like Fig. 9 As shown, the multi-view shooting mode is switched to the single-view shooting mode. Before the switch, task thread 1 and task thread 3 of shooting mode 1 are in a waiting state to be released, and after the switch, task thread 2 of shooting mode 2 is waiting to be created. In this process, task thread 1 and task thread 3 have not been completely released, and task thread 2 has not been completely created, so it is possible that task thread 1, task thread 2, and task thread 3 temporarily coexist.
[0140] like Fig.10 As shown, the multi-view shooting mode is switched to the multi-view shooting mode. Before the switch, task thread 1 and task thread 4 of shooting mode 1 are in a waiting state to be released, and after the switch, task thread 2 and task thread 3 of shooting mode 2 are waiting to be created. In this process, task thread 1 and task thread 4 have not been completely released, and task thread 2 and task thread 3 have not been completely created, so it is possible that task thread 1, task thread 2, task thread 3 and task thread 4 temporarily coexist.
[0141] In the above Figure 6 and Figure 7In the , different task threads (Camera Device) may contain different node types and quantities, but usually contain basic nodes for threads to implement hardware calls, such as module handles (HAL Device), and basic modules for thread call functions, such as entry functions (HAL Entry). Among them, the hardware module called by the task thread can be defined as the camera module Camera Device, and Camera Device1 and Camera Device2 can represent camera modules in different shooting modes, such as dual-camera video recording and ordinary photo taking.
[0142] The module handle HAL Device is the handle provided by the hardware abstraction layer HAL to the framework layer Framwork to operate the camera module. It has a member variable inside that stores the address of the entry function HAL Entry. HAL Entry is a node provided by the hardware abstraction layer HAL and stored in a global linked list. It is a structure of several function pointers, which is used by HALDevice for internal data flow. It also has a member variable that stores the memory address of HAL Device, which is used to indicate the node on the linked list. The module handle and the entry function are the basic nodes of the thread. When creating a task thread, it is necessary to create the module handle and the entry function and associate them through pointers; when releasing the task thread, it is necessary to release the module handle and the entry function, and cancel the pointer association between the two. The embodiments of this application will mainly take the two basic nodes of the module handle and the entry function as examples. Other nodes in the task thread may also have technical problems such as node confusion caused by the module handle and the entry function during the creation and release process, which cause camera application anomalies. I will not go into details here.
[0143] like Fig.11 As shown, it is a schematic diagram of an internal interaction of an electronic device in a shooting mode switching scenario provided by an embodiment of the present application. After the user opens the camera application of the electronic device, the camera application enters the default shooting mode or the initial shooting mode, which can be used as shooting mode 1. Create a task thread 1Camera Device1 of the shooting mode 1, and create a module handle 1HAL Device1 and an entry function 1HAL Entry1 in the hardware abstraction layer.
[0144] When the user triggers the electronic device to switch the camera application's shooting mode 1 to shooting mode 2, the electronic device needs to release the task thread 1 Camera Device1 of shooting mode 1 and create the task thread 2 Camera Device2 of shooting mode 2. Specifically, in the hardware abstraction layer, a module handle 2 HAL Device2 and an entry function 2 HAL Entry2 are created.
[0145] Fig.11 A schematic diagram of internal interaction of an electronic device in a shooting mode switching scenario provided by an embodiment of the present application, showing four operations involved in the thread interaction process: a. releasing module handle 1, b. releasing entry function 1, c. creating module handle 2, and d. creating entry function 2. Fig.12 The figure is a schematic diagram of the operation execution sequence of the electronic device provided by the embodiment of the present application in the shooting mode switching scenario, which may be as follows: Fig.12 Various execution orders are shown:
[0146] Execution order 1: a→b→c→d; Execution order 2: c→d→a→b; Execution order 3: a→c→d→b.
[0147] In the specific execution node creation operation, available memory will be allocated to the newly created node. The memory that has been allocated to the newly created node cannot be occupied by other nodes before it is released. Correspondingly, in the execution node release operation, the memory previously allocated to the released node will be released synchronously, and the released memory can be allocated to other newly created nodes. The memory space of different memories has different addresses, and nodes can perform data access operations through pointers pointing to the addresses of corresponding memory spaces.
[0148] like Fig.11 and Fig.12 The four operations shown set the memory allocated to module handle 1 when it is created to A, the memory allocated to entry function 1 when it is created to B, the memory allocated to module handle 2 when it is created to C, and the memory allocated to entry function 2 when it is created to B. Under normal circumstances, if these four nodes coexist, that is, module handle 1 and entry function 1 have not been released, and module handle 2 and entry function 2 have been created, then the memory A of module handle 1 and the memory B of entry function 1 have not been released, and the memory C of module handle 2 and the memory D of entry function 2 have been allocated. At this time, memory A, B, C and D do not affect each other. However, due to different execution orders, some memory may be allocated to other nodes after being released. In these cases, there are problematic scenarios that may cause thread exceptions, such as the memory C allocated to module handle 2 is actually the same as the address of the memory A that has just been released. The following will analyze the different execution orders and corresponding results of these operations in detail.
[0149] For the case of execution order 1 (a→b→c→d), Fig.13 As shown, the electronic device first releases the module handle 1 (such as Fig.13 As shown by the symbol ×, the memory A previously allocated for the handle module 1 is released at the same time, and the pointer from the memory A of the module handle 1 to the memory B of the entry function 1 disappears (as shown in Fig.13As shown by the symbol ×, the pointer from A to B disappears); then the memory B of entry function 1 is released (as shown in Fig.13 As shown by the symbol ×, memory B is released), and the pointer of memory B pointing to memory A of entry function 1 disappears (as shown in Fig.13 As shown by the symbol ×, the pointer from B to A disappears), completing the release of task thread 1; then creating module handle 2 (newly allocating memory C for module handle 2), and then creating entry function 2 (newly allocating memory D), the pointer of memory C points to D, and the pointer of memory D points to C, completing the creation of task thread 2. Since the memory A of module handle 1 and the memory B of entry function 1 have been released and disassociated, the memory C allocated for the newly created module handle 2 and the memory D newly allocated for entry function 2, regardless of whether the address of memory C is the same as that of memory A or the address of memory D is the same as that of memory D, will not affect the normal execution of task thread 2. In other words, there is no exception in execution order 1.
[0150] For the case of execution order 2 (c→d→a→b), Fig.14 As shown, the electronic device first creates module handle 2 (newly allocated memory C), then creates entry function 2 (newly allocated memory D), the pointer of memory C points to D and the pointer of memory D points to C, completing the creation of task thread 2; then releases module handle 1 (such as Fig.14 As shown by the symbol ×, memory A is released), and the pointer of memory A of module handle 1 to memory B of entry function 1 disappears (as shown in Fig.14 As shown by the symbol ×, the pointer from A to B disappears); then release the entry function 1 (such as Fig.14 As shown by the symbol ×, memory B is released), and the pointer of memory B pointing to memory A of entry function 1 disappears (as shown in Fig.14 As shown by the symbol ×, the pointer from B to A disappears), and the task thread 1 is released. Since the creation of module handle 2 and entry function 2 is before the release of module handle 1 and entry function 1, the memory C allocated for module handle 2 and the memory D allocated for entry function 2 cannot have the same address as the memory A and memory B released later, which will not affect the normal execution of task thread 2. In other words, there is no exception in execution order 2.
[0151] For the case of execution order 3 (a→c→d→b), Fig.15 and Fig.16 As shown, the electronic device first releases module handle 1 (the symbol × indicates that memory A is released), and then creates module handle 2 (newly allocates memory C). Since memory A has been released, the memory C allocated for the newly created module handle 2 may not be memory A (such as Fig.15 As shown), it is also possible that it is memory A (as shown Fig.16 shown).
[0152] like Fig.15 As shown, the memory C allocated for the newly created module handle 2 is not the memory A that has just been released. If memory C is not A, there is no existing pointer pointing to C, and a new entry function 2 needs to be created to allocate memory D. Module handle 2 is associated with entry function 2, so the pointer of memory C points to D, and the pointer of memory D points to C, and the creation of task thread 2 is completed. After that, the release of memory B of entry function 1 will not affect task thread 2 at all. In other words, there is no exception in the case where the memory C allocated by the newly created module handle 2 in execution order 3 is not the memory A that has just been released.
[0153] like Fig.16 As shown, the memory C allocated for the newly created module handle 2 is the memory A that has just been released. Since the entry function 1 has not been released, the pointer of the memory B of the entry function 1 pointing to the memory A has not disappeared. If the address of the new memory C allocated for the module handle 2 happens to be the same as the address of the memory A that has just been released, then there is an existing pointer from memory B to memory A. Based on this existing pointer, when the electronic device searches for or creates the entry function 2, it may directly use memory B as the memory of the entry function 2 because there is an existing pointer from memory B to memory A, and at this time it will also be considered that the creation of task thread 2 is completed. At this point, there is no problem with task thread 2 for the time being.
[0154] However, the release operation of task thread 1 also needs to execute the release operation of entry function 1. When executing the release operation of entry function 1, the memory B of entry function 1 will be released. At this time, since memory B is also the memory of entry function 2, when memory B of entry function 1 is released, memory B of the newly created entry function 2 is also released, and the pointer of memory C of module handle 2 pointing to memory B of entry function 2 will become a null pointer or a wild pointer (such as Fig.16 The symbol shown in ? The pointer shown), module handle 2 cannot pass this pointer. Figures 12 to 16 Only typical execution orders in 3 are shown. In actual operation, other orders such as a→c→b→d, c→a→b→d, and c→a→d→b may appear. The execution of these types of orders is similar to that of execution order 1 and execution order 2, and the problem scenarios in execution order 3 will not occur, so they will not be described one by one here.
[0155] Fig.16 In the problem scenario shown, the memory A that was just released in the operation of releasing module handle 1 is occupied again in the operation of creating module handle 2. This is usually more likely to occur when the electronic device is short of memory, especially when the electronic device is frequency-limited due to high-frequency load caused by high temperature, memory, etc. Once this task thread abnormality occurs, it may cause the camera application process to crash and flash back, affecting the normal use of the electronic device.
[0156] Based on this, the embodiment of the present application provides a shooting mode switching method. In the scenario of multiple concurrent threads, the memory to be released is marked to avoid the situation where the newly created thread cannot run normally after the memory is released due to the incorrect occupation by the thread to be created, and the problem of crash caused by node crossing between threads is effectively avoided.
[0157] Fig.16 In the problem scenario shown, after creating module handle 2 and occupying memory C (C=A), it is necessary to create entry function 2 and occupy memory. Since there is already a pointer from memory B pointing to memory A, which is memory C, module handle 2 can find the entry function corresponding to memory B through this pointer, and directly use memory B as the memory of entry function 2. Then, in order to avoid this situation, the entry function 1 waiting to be released and the memory B of the entry function 1 can be marked, for example, marked as a pending release state. Fig.17 As shown, it is a schematic diagram of the application execution 3 of the shooting mode switching method provided in the embodiment of the present application. The memory B is marked as a state to be released (such as Fig.17 As shown in the figure, the mark * on memory B indicates that memory B is in a state to be released). Then, even if module handle 2 finds the entry function corresponding to memory B that has not been released through the existing pointer, but finds that memory B is marked as a state to be released, it will not continue to use the entry function corresponding to memory B as the entry function 2 to be created. Instead, a new entry function 2 will be created and occupy another memory D that is not marked as a state to be released. In this way, the release of memory B will not affect the normal operation of task thread 2, reducing the abnormalities caused by the intersection of multiple concurrent thread nodes.
[0158] Fig.18 The figure is a flow chart of a method for switching shooting modes in the prior art when performing a shooting mode switching scene. Fig.19 This is one of the thread diagrams of the shooting mode switching method provided in an embodiment of the present application. Fig.18 In the prior art shown, closing task thread 1 and creating task thread 2 are executed in parallel, and the specific order is not limited. For example, the operation of closing task thread 1 can be executed first, and module handle 1 can be released first, and then entry function 1 can be released. Then the operation of creating task thread 2 is executed again, and module handle 2 is created first, and then entry function 2 is searched. If entry function 2 is found, the entry function 2 can be used directly. If entry function 2 is not found, a new entry function 2 needs to be created, and the memory of the newly created module handle 2 and entry function 2 are associated through the address pointer.
[0159] like Fig.19As shown, it is a flow chart of the shooting mode switching method provided by the embodiment of the present application. In the shooting mode switching scenario, the shooting mode switching scheme provided by the embodiment of the present application is optimized and improved respectively for the task thread release operation of the shooting mode before switching and the task thread creation operation corresponding to the shooting mode after switching, compared with the switching scheme of the prior art.
[0160] The technical solutions provided in the embodiments of this application are as follows: Fig.19 As shown, in the process of closing task thread 1, when module handle 1 is released, entry function 1 associated with the module handle 1 is marked as a pending release state, and the pending release state is used to indicate that the memory corresponding to the entry function 1 is in a pending release state and cannot be currently occupied again. The pending release state is publicly visible and can be queried by other threads except task thread 1. There can be multiple triggering conditions and marking nodes for the electronic device to mark the entry function in the pending release state as a pending release state. For example, it can be executed when the hardware abstraction layer determines that the task thread corresponding to the shooting mode before switching needs to be released, or it can be executed before or when the handle module of the task thread begins to be released, or it can be executed when the handle module of the task thread is completely released (such as Fig.19 ), or when the pointer to the entry function of the handle module disappears. There are many ways for the electronic device to mark the entry function in the to-be-released state as the to-be-released state. For example, the structure of the entry function 1 can be directly marked as the to-be-released state, or the memory of the entry function 1 can be directly marked as the to-be-released state, or the to-be-released state of the entry function 1 can be broadcasted in the process of the camera application, etc., without limitation.
[0161] Correspondingly, when creating task thread 2, after creating module handle 2, entry function 2 can be searched. If not found, a new entry function 2 can be directly created, and memory is allocated for the newly created entry function 2.
[0162] If the entry function 2 is found, it is necessary to further determine whether the entry function 2 is marked as being in a state to be released. If it is not marked as being in a state to be released, it means that the entry function 2 can be used directly. There are many ways to determine whether the entry function 2 is marked as being in a state to be released, and they correspond to the aforementioned way of marking the entry function 1 as being in a state to be released. For example, if the entry function 1 is marked as being in a state to be released by adding a state identifier of a state to be released to the structure, then it can be determined by querying whether the structure of the entry function 2 has a state identifier of a state to be released. If there is a state identifier of a state to be released, it is considered that the entry function 2 is marked as being in a state to be released. In other ways, if the memory of the entry function 1 is marked as being in a state to be released by means of a memory marker, then it is also possible to directly query whether the memory of the entry function 2 is marked as being in a state to be released. If the memory is marked as being in a state to be released, it can be considered that the entry function 2 has been marked as being in a state to be released.
[0163] If the entry function 2 found is marked as being released, it means that the entry function 2 is unavailable because the memory of the entry function 2 will be released later. After the memory is released, the pointer of the entry function 2 pointing to the module handle 2 disappears, and the pointer of the module handle 2 pointing to the entry function 2 is a null pointer or a wild pointer. The module handle 2 is completely unable to implement function calls and data flow, and the task thread 2 cannot run normally, causing the camera application to crash.
[0164] Of course, considering the original logic of the development platform, there may be a situation where the found entry function 2 is not marked as being released. In this case, it can be considered that the entry function 2 is available and there is no need to create a new entry function 2. This situation may occur when the task thread of the previous shooting mode does not need to be closed after switching the shooting mode, or when two task threads of shooting mode 2 share an entry function, etc., without limitation.
[0165] It should be noted that Fig.19 The situation shown is for the case where both the shooting modes before and after the switching are single task threads. In actual execution, there are also cases where the shooting modes before and / or after the switching have two or more task threads, for example Fig. 20 As shown, the default shooting mode 1 after the camera is turned on is switched to the shooting mode 2 of dual-view video recording. The switched shooting mode 2 includes two shooting tasks, and two new threads need to be created. For this situation involving at least two task threads before or after shooting, the status of each task thread to be released can be marked respectively, or the status of each task thread to be created can be checked.
[0166] Specifically, Fig. 20The second flowchart of the shooting mode switching method provided by the embodiment of the present application is shown. When releasing the memory of the module handle 1 of the task thread 1, the entry function 1 is marked as a state to be released. Correspondingly, in the process of creating the task thread 2, the entry function 2 needs to be found or created after the module handle 2 is created. If an entry function 2 is found, it is necessary to determine whether the entry function 2 is marked as a state to be released. If it is marked as a state to be released, it means that the entry function 2 is not available. At this time, the electronic device can create a new entry function 2 and associate the memory of the entry function 2 with the memory of the module handle 2 through a pointer.
[0167] Similarly, for another task thread 3 corresponding to the switched shooting mode 2, after creating the module handle 3, it is necessary to find or create the entry function 3. If an entry function 3 is found, it is necessary to determine whether the entry function 3 is marked as a pending release state. If it is marked as a pending release state, it means that the entry function 3 is unavailable. At this time, the electronic device can create a new entry function 3 and associate the memory of the entry function 3 with the memory of the module handle 3 through a pointer.
[0168] The scenes of switching from single-scene shooting mode to multi-scene shooting mode, or switching from multi-scene shooting mode to single-scene shooting mode, can be applied to the shooting mode switching method provided in the embodiments of the present application. Each task thread of the multi-scene shooting mode can execute the shooting mode switching method provided in the embodiments of the present application.
[0169] It should be noted that in the shooting mode switching method provided in the embodiment of the present application, the order of the task thread release operation of the shooting mode before switching and the task thread creation operation of the shooting mode after switching is not limited. The task thread release operation of the shooting mode before switching can be started first, and then the task thread creation operation of the shooting mode after switching can be started. Alternatively, the task thread release operation of the shooting mode after switching can be started first, and then the task thread release operation of the shooting mode before switching can be started.
[0170] The nodes in a thread usually include global variables and structure variables. Global variables are variables that may run through all threads, and local variables are variables within a thread. For example, in the embodiment of the present application, the module handle is a local variable within a thread, and the entry function is a global variable of the thread. In a multi-concurrent thread scenario, a global variable within a thread will affect the normal state of global variables in other threads. Therefore, the shooting mode switching method provided in the above-mentioned embodiment of the present application, in addition to being applied to marking the entry function as a global variable in the camera shooting mode switching scenario, can also be applied to other global variables. The global variables of the task thread before the switch are marked so that the memory of the global variables of the task thread created after the switch is different from or does not conflict with the memory of the global variables of the task thread before the switch, so as to avoid the abnormal situation that the newly created task thread cannot proceed normally and causes the application to crash.
[0171] In addition, in a multi-concurrent thread scenario, there are other ways to mark nodes in a thread, such as introducing a thread lock to mark and lock. An electronic device may introduce a thread lock in a multi-concurrent thread to lock at least two consecutive operations in a thread with a thread lock to prevent other operations from affecting global variables during the execution of the at least two consecutive operations.
[0172] like Fig.21 , which is a schematic diagram of an electronic device provided by an embodiment of the present application applying thread locks in multiple concurrent threads. For example, for concurrent task thread 1 and task thread 2, task thread 1 and task thread 2 include the same three operation steps, and both involve global variable memory.
[0173] Both task thread 1 and task thread 2 introduce thread locks. If task thread 1 is executed first, the process is:
[0174] Get the initial value 1;
[0175] Execute operations 1.1, 1.2, and 1.3 in sequence. The initial value 1+1=2, and write 2 into the memory.
[0176] Execute thread 2 again, and the process is:
[0177] Get the initial value 1;
[0178] Execute operations 2.1, 2.2, and 2.3 in sequence. The initial value 2+1=2 is written into the memory.
[0179] In this way, the initial value 1 is first passed through task thread 1+1, then through task thread 2+1, and finally gets 3, and 3 is stored in the global variable memory.
[0180] If thread locks are not introduced, the execution process of these steps of thread 1 and these operation steps of the task thread may include:
[0181] Execute operations 1.1 and 1.2 (that is, the initial value 1+1=2), but do not execute operation 1.3 (write 2 to the memory) first; then execute operations 2.1, 2.2, and 2.3 (because 2 has not been written to the memory, the initial value obtained from the memory is still 1, 1+1=2, and finally 2 is obtained, and 2 is written to the memory). Finally, execute operation 1.3 (write 2 to the memory). In this way, the value finally written to the global variable memory is wrong.
[0182] It can be seen that the introduction of thread locks can ensure that some operations in a thread in a multi-concurrency scenario will be executed continuously before switching to other threads. Of course, after the execution of these several consecutive operations that need to be locked is completed, the thread lock is released, and multiple task threads can continue to be executed concurrently.
[0183] like Fig. 22 As shown, it is a flow chart of another shooting mode switching method provided by an embodiment of the present application. In this embodiment, by introducing a thread lock, the handle module release operation and the entry function release operation of the task thread are locked by the thread lock. Fig. 22 , as shown in the dotted box in task thread 1, locks are added before and after the thread is released. In this embodiment, for the release operation of task thread 1 corresponding to shooting mode 1 before switching, a thread lock is introduced before the release operation of release handle module 1, and the release operation of release handle module 1 and the release operation of entry function 1 are locked by the thread lock. In this way, whether the release operation of task thread 1 is started first or the creation operation of task thread 2 is started first, the problem scenario caused by inserting the search / creation operation of entry function 2 between the release operation of release handle module 1 and the release operation of entry function 1 can be avoided.
[0184] The embodiment of the present application introduces a thread lock to lock the handle module release operation and the entry function release operation of the task thread. This can avoid the problem scenario where the existing pointer of the entry function pointing to the handle module causes the memory to be released to be occupied again, resulting in incorrect pointing, after the handle module is released and before the entry function is released.
[0185] In addition, considering that in the shooting scenario of the camera application, since HAL Entry is a resource stored in the global linked list, it is a critical resource for the two threads of HAL, and thread lock protection needs to be introduced. That is to say, when creating a task thread for the shooting task in shooting mode, first obtain the thread lock, then create the module handle HAL Device and the entry function HAL Entry in sequence, and then release the thread lock.
[0186] like Fig.19 , Fig. 20 and Fig. 22 As shown, a thread lock can also be introduced to lock the operation of acquiring or releasing the entry function, a global variable, in the thread. In the operation of releasing task thread 1, the thread lock is first acquired at the beginning of the operation of releasing entry function 1, and the thread lock is released at the end of the operation of releasing entry function 1; similarly, in the operation of creating task thread 2 or task thread 3, the thread lock is first acquired at the beginning of the operation of finding / creating entry function 2 or entry function 3, and the thread lock is released at the end of the operation of finding / creating entry function 2 or entry function 3. The global variable is introduced before and after the operation of releasing or creating the global variable where the thread is located to prevent the global variable from being changed.
[0187] In addition, an embodiment of the present application further provides an electronic device, comprising a camera module, a memory and a processor, wherein the camera module and the memory are both coupled to the processor;
[0188] Memory stores computer-executable instructions;
[0189] The processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the shooting mode switching method provided by the above embodiment. In addition to these main components, the electronic device also includes components for realizing basic functions. Fig.23 Provide specific instructions.
[0190] like Fig.23 The figure shows a schematic diagram of the structure of an electronic device 2300 provided in an embodiment of the present application. The electronic device 2300 may include a processor 2310, a memory 2320, a camera 2330, a display screen 2340, a touch sensing module 2350, a motor 2360, an audio module 2370, a sensor module 2380, a button 2390, etc. The sensor module 2380 may include a gyroscope sensor 2380A, an acceleration sensor 2380B, a distance sensor 2380C, a proximity light sensor 2380D, an ambient light sensor 2380E, etc.
[0191] The structure shown in the embodiment of the present invention does not limit the electronic device 2300. It may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0192] The processor 2310 may include one or more processing units. For example, the processor 2310 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU). Different processing units may be independent devices or integrated into one or more processors.
[0193] The controller can be a decision maker that directs the various components of the electronic device 2300 to work in coordination according to the instructions. It is the nerve center and command center of the electronic device 2300. The controller generates an operation control signal according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0194] The processor 2310 may also be provided with a memory 2320 for storing instructions and data. In some embodiments, the memory 2320 in the processor 2310 is a high-speed cache memory, which can store instructions or data that the processor 2310 has just used or cyclically used. If the processor 2310 needs to use the instruction or data again, it can be directly called from the memory 2320. Repeated access is avoided, the waiting time of the processor 2310 is reduced, and the efficiency of the system is improved.
[0195] In some embodiments, the processor 2310 may include an interface. The interface may include an Inter-Integrated Circuit (I2C) interface, an Inter-Integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver / Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI) interface, a General-Purpose Input / Output (GPIO) interface, a SIM interface, and / or a USB interface, etc.
[0196] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDL) and a serial clock line (SCL). In some embodiments, the processor 2310 may include multiple groups of I2C buses. The processor 2310 may be coupled to the touch sensor, charger, flash, camera 2330, etc. through different I2C bus interfaces. For example: the processor 2310 may be coupled to the touch sensor through the I2C interface, so that the processor 2310 communicates with the touch sensor through the I2C bus interface to realize the touch function of the electronic device 2300.
[0197] The I2S interface can be used for audio communication. In some embodiments, the processor 2310 can include multiple groups of I2S buses. The processor 2310 can be coupled to the audio module 2370 via the I2S bus to achieve communication between the processor 2310 and the audio module 2370. In some embodiments, the audio module 2370 can transmit an audio signal to the communication module via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0198] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 2370 and the communication module can be coupled via a PCM bus interface. In some embodiments, the audio module 2370 can also transmit audio signals to the communication module via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication, and the sampling rates of the two interfaces are different.
[0199] The UART interface is a universal serial data bus for asynchronous communication. The bus is a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 2310 and the communication module. For example, the processor 2310 communicates with the Bluetooth module via the UART interface to implement the Bluetooth function. In some embodiments, the audio module 2370 can transmit an audio signal to the communication module via the UART interface to implement the function of playing music via a Bluetooth headset.
[0200] The MIPI interface can be used to connect the processor 2310 with peripheral devices such as the display screen 2340 and the camera 2330. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 2310 and the camera 2330 communicate via the CSI interface to implement the shooting function of the electronic device 2300. The processor 2310 and the display screen 2340 communicate via the DSI interface to implement the display function of the electronic device 2300.
[0201] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 2310 with the camera 2330, the display 2340, the communication module, the audio module 2370, the sensor module 2380, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0202] The USB interface may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface may be used to connect a charger to charge the electronic device 2300, or may be used to transfer data between the electronic device 2300 and a peripheral device. The USB interface may also be used to connect headphones to play audio through the headphones. The USB interface may also be used to connect other electronic devices, such as AR devices, etc.
[0203] The interface connection relationship between the modules shown in the embodiment of the present invention is only for illustrative purposes and does not constitute a structural limitation on the electronic device 2300. The electronic device 2300 may use different interface connection methods in the embodiment of the present invention, or a combination of multiple interface connection methods.
[0204] The wireless communication function of the electronic device 2300 can be implemented by an antenna, a radio frequency module, a communication module, a modem, and a baseband processor. The antenna is used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 2300 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna.
[0205] The electronic device 2300 implements the display function through a GPU, a display screen 2340, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 2340 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 2310 may include one or more GPUs that execute program instructions to generate or change display information.
[0206] The display screen 2340 is used to display images, videos, etc. The display screen 2340 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLED, Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 2300 may include 1 or N display screens 2340, where N is a positive integer greater than 1.
[0207] The electronic device 2300 can realize the shooting function through an ISP, a camera 2330, a video codec, a GPU, a display screen, and an application processor.
[0208] The ISP is used to process the data fed back by the camera 2330. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and chromaticity of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 2330.
[0209] The camera 2330 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 2300 may include 1 or N cameras 2330, where N is a positive integer greater than 1.
[0210] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 2300 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0211] Video codecs are used to compress or decompress digital videos. Electronic device 2300 may support one or more video codecs. Thus, electronic device 2300 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG23, MPEG4, etc.
[0212] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 2300 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0213] The external memory interface can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 2300. The external memory card communicates with the processor 2310 through the external memory interface to implement a data storage function, such as storing music, video and other files in the external memory card.
[0214] The internal memory can be used to store computer executable program codes, which include instructions. The processor 2310 executes various functional applications and data processing of the electronic device 2300 by running the instructions stored in the internal memory. The memory 2320 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 2300 (such as audio data, a phone book, etc.), etc. In addition, the memory 2320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, other volatile solid-state storage devices, a universal flash memory (Universal Flash Storage, UFS), etc.
[0215] The electronic device 2300 can implement audio functions, such as voice-controlled photography, music playback and recording, etc., through the speaker, receiver, microphone, headphone interface, and application processor of the audio module 2370.
[0216] The audio module 2370 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal. The audio module 2370 can also be used to encode and decode audio signals. In some embodiments, the audio module 2370 can be arranged in the processor 2310, or some functional modules of the audio module 2370 can be arranged in the processor 2310.
[0217] The speaker, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 2300 can listen to music or listen to a hands-free call through the speaker.
[0218] The receiver, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 2300 receives a call or voice message, the voice can be received by placing the receiver close to the human ear.
[0219] A microphone, also known as a "microphone" or "microphone", is used to convert sound signals into audio electrical signals. When making a call or sending a voice message, the user can put their mouth close to the microphone and speak to input the sound signal into the microphone. The electronic device 2300 can be provided with at least one microphone. In some embodiments, the electronic device 2300 can be provided with two microphones, which can not only collect sound signals but also realize noise reduction function. In some embodiments, the electronic device 2300 can also be provided with three, four or more microphones to realize the collection of sound signals, noise reduction, identification of sound sources, and realization of directional recording function, etc.
[0220] The headphone jack is used to connect wired headphones. The headphone jack can be a USB interface, or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0221] The key 2390 includes a power key, a volume key, etc. The key 2390 may be a mechanical key or a touch key. The electronic device 2300 receives the key 2390 input and generates a key signal input related to the user settings and function control of the electronic device 2300.
[0222] Motor 2360 can generate vibration prompts. Motor 2360 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. Touch operations acting on different areas of the display screen 2340 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization. In addition, the motor can also be used in the camera zoom shooting scene to achieve lens switching of different focal lengths by driving the movement of the lens.
[0223] The sensor module 2380 may include a gyro sensor 2380A, an acceleration sensor 2380B, a distance sensor 2380C, a proximity light sensor 2380D, and an ambient light sensor 2380E. The gyro sensor 2380A and the acceleration sensor 2380B may be used for posture correction or horizontal positioning during the photographing process, the distance sensor 2380C may be used for depth of field determination or image processing during the photographing process, and the proximity light sensor 2380D and the ambient light sensor 2380E may be used for sensing ambient light and adjusting image brightness values during the photographing process.
[0224] The display control methods in the aforementioned embodiments can all be implemented in the electronic device 2000 having the aforementioned hardware structure.
[0225] An embodiment of the present application further provides a shooting mode switching device, wherein the control device includes a processor, and the processor is used to execute the shooting mode switching method provided in the above embodiment.
[0226] The embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer is enabled to execute the shooting mode switching method provided in the above embodiment.
[0227] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the shooting mode switching method provided in the above embodiment.
[0228] The embodiment of the present application also provides a chip system, which is applied to an electronic device including a camera module and a memory. The chip system includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by a line. The interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor, and the signal includes a computer instruction stored in the above memory. When the processor executes the computer instruction, the electronic device executes the method described in any possible design method in the above embodiment.
[0229] The specific implementation methods of the electronic device, shooting mode switching device, chip system, computer-readable storage medium, and computer program product containing instructions provided in the embodiments of the present application and the technical effects brought about by them can be found in the specific implementation process of the electronic device method provided in the aforementioned embodiments and the technical effects brought about by them, which will not be repeated here.
[0230] In some embodiments, through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0231] Each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0232] 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 embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk.
[0233] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the embodiment of the present application should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
Claims
1. A shooting mode switching method, characterized in that: Applied to electronic equipment, the method comprises: receiving a first operation, where the first operation is used to trigger the electronic device to capture an image in a first capturing mode; In response to the first operation, a first task thread corresponding to the first shooting mode is created, the first task thread includes a first local variable and a first global variable, and a memory corresponding to the first local variable and a memory corresponding to the first global variable are associated with each other through an address pointer; receiving a second operation, where the second operation is used to trigger the electronic device to switch from the first shooting mode to a second shooting mode, and to shoot an image in the second shooting mode; In response to the second operation, a first mark is added to the first task thread, the first task thread is released, and a second task thread corresponding to the second shooting mode is created, wherein the second task thread includes a second local variable and a second global variable, and a memory corresponding to the second local variable is associated with a memory corresponding to the second global variable through an address pointer; Among them, the first mark is used to indicate that the memory corresponding to the first global variable of the first task thread is unavailable; based on the first mark, the memory allocated to the second global variable of the second task thread in the process of creating the second task thread is different from the memory corresponding to the first global variable of the first task thread.
2. The shooting mode switching method according to claim 1, characterized in that: The first shooting mode and the second shooting mode are both single-view shooting modes.
3. The shooting mode switching method according to claim 1, characterized in that: The first shooting mode is a single-view shooting mode, and the second shooting mode is a multi-view shooting mode; the method further includes: In response to the second operation, creating a third task thread corresponding to the second shooting mode; In response to the second operation, based on the first mark, in the process of creating the third task thread, the memory allocated for the global variables of the third task thread is different from the memory corresponding to the global variables of the first task thread.
4. The shooting mode switching method according to claim 1, characterized in that: The first shooting mode is a multi-view shooting mode, and the second shooting mode is a single-view shooting mode; the method further includes: In response to the first operation, creating a fourth task thread corresponding to the first shooting mode; In response to the second operation, the first mark is added to the fourth task thread and the fourth task thread is released; wherein, based on the first mark, the memory allocated for the global variables of the second task thread during the creation of the second task thread is different from the memory corresponding to the global variables of the fourth task thread.
5. The shooting mode switching method according to any one of claims 1 to 4, characterized in that: The step of releasing the first task thread includes: The first local variable is released, the first global variable is released, and the association between the memory corresponding to the first local variable and the memory corresponding to the second local variable is cancelled.
6. The shooting mode switching method according to claim 5, characterized in that: In response to the second operation, adding a first mark to the first task thread, releasing the first task thread, and creating a second task thread corresponding to the second shooting mode includes: In response to the second operation, adding the first tag to the first global variable, releasing the first local variable, and releasing the first global variable; Create the second local variable, and query whether a third global variable exists; wherein the third global variable is a global variable whose corresponding memory is associated with the memory corresponding to the second local variable through an address pointer; if the memory corresponding to the second local variable is associated with other memories, the third global variable exists; If the third global variable is found to exist, determine whether the third global variable includes the first mark; if the third global variable includes the first mark, create a new second global variable, and associate the memory corresponding to the new second global variable with the memory of the second local variable; if the third global variable does not include the first mark, use the third global variable as the second global variable.
7. The shooting mode switching method according to claim 6, characterized in that: The first local variable is a first module handle, and the second local variable is a second module handle; The first global variable is a first entry function, the second global variable is a second entry function, and the third global variable is a third entry function.
8. The shooting mode switching method according to claim 7, characterized in that: The step of adding the first mark to the first global variable comprises: When releasing the first module handle, the first tag is added to the first entry function.
9. The shooting mode switching method according to claim 8, characterized in that: The step of adding a first mark to the first entry function includes: The structure of the first entry function is marked as a state to be released, or the memory corresponding to the first global variable is marked as a state to be released.
10. The shooting mode switching method according to any one of claims 1 to 4 and 6 to 9, characterized in that: After the step of releasing the first task thread, the method further includes: Delete the first mark of the first task thread.
11. The shooting mode switching method according to any one of claims 3, 4, 6 and 7, characterized in that: The first tag includes a thread lock; The step of adding a first mark to the first task thread and releasing the first task thread in response to the second operation includes: Get thread lock; releasing the first task thread; Release the thread lock.
12. The shooting mode switching method according to any one of claims 6 to 9, characterized in that: The step of creating a first task thread corresponding to the first shooting mode includes: Get thread lock; Create the first global variable; Release the thread lock; and / or, The step of releasing the first task thread also includes: Get thread lock; Release the first global variable; Release the thread lock; and / or, The step of creating a second task thread corresponding to the second shooting mode includes: Get thread lock; Create the second global variable; Release the thread lock.
13. A shooting mode switching device, characterized in that: The method comprises a processor, wherein the processor is used to execute the shooting mode switching method according to any one of claims 1 to 12.
14. An electronic device, characterized in that: It includes a camera module, a memory and a processor, wherein the camera module and the memory are coupled to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the shooting mode switching method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the shooting mode switching method according to any one of claims 1 to 12.
