Algorithm scheduling method and electronic device

By selecting N algorithms whose first time-consuming sum is not greater than the first time duration in the electronic device to process the target image, the problem of excessive load on the central processor caused by simultaneous processing of multiple algorithms is solved, and the image processing efficiency and user experience are improved. .

CN117687772BActive Publication Date: 2024-09-20HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310953194.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2024-09-20
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

In electronic devices, multiple image processing algorithms process the same image frame at the same time, resulting in excessive load on the central processor and affecting image processing efficiency.

Method used

By selecting N algorithms whose sum of the first time consuming is not greater than the first time period as the algorithm for processing the target image, the time consuming for the central processor to process the target image will not exceed the first time period, thus avoiding the load caused by simultaneous scheduling of multiple algorithms. Too high.

Benefits of technology

It improves the efficiency of image processing in the video stream by the central processor and increases the display speed of images, thus improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117687772B
    Figure CN117687772B
Patent Text Reader

Abstract

The present application discloses an algorithm scheduling method and an electronic device, the method comprising: the electronic device obtains a video stream, the video stream includes at least two images; the target image is one of the at least two images; for the target image, based on the first time consumption of each of the M algorithms, N algorithms are determined from the M algorithms; wherein M is an integer greater than 1, and N is less than M; the first time consumption of each of the M algorithms is obtained based on the historical time consumption of the central processing unit executing each algorithm; the sum of the first time consumption of the N algorithms is not greater than the first duration, and the N algorithms are scheduled to process the target image. The method can avoid the situation where multiple algorithms are scheduled to act on a frame of image, resulting in excessive load on the central processing unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic technology, and in particular to an algorithm scheduling method and electronic equipment. Background Art

[0002] With the development of technology, the camera photo and video recording functions in mobile terminals are becoming more and more powerful, and have become an indispensable function for users' daily use.

[0003] In the camera photo or video recording scene, the electronic device can schedule multiple image processing algorithms to process the acquired image and then display the processed image. The image processing algorithms include face detection algorithm, scene detection algorithm, object tracking algorithm, key point detection algorithm, etc.

[0004] Currently, electronic devices often schedule algorithms according to their respective preset frame rates, resulting in multiple algorithms processing the same frame of image at the same time, which can cause the processor of the electronic device to be overloaded, thereby affecting image processing efficiency. Summary of the invention

[0005] The present application provides an algorithm scheduling method and an electronic device, in which the electronic device can select N algorithms whose sum of first time consumption is not greater than a first duration as algorithms for processing a target image, so that the time consumed by a central processing unit to process the target image will not exceed the first duration, thereby avoiding a situation in which multiple algorithms are scheduled to act on one frame of an image, resulting in an excessive load on the central processing unit.

[0006] In a first aspect, an embodiment of the present application provides an algorithm scheduling method, the method comprising:

[0007] The electronic device acquires a video stream, the video stream includes at least two images; the target image is one of the at least two images;

[0008] The electronic device determines N algorithms from the M algorithms based on the first time consumption of each of the M algorithms for the target image;

[0009] Among them, M is an integer greater than 1, and N is less than M; the first time consumption of each of the M algorithms is obtained based on the historical time consumption of the central processor of the electronic device to execute each algorithm; the sum of the first time consumption of the N algorithms is not greater than the first duration, and the N algorithms are scheduled to process the target image.

[0010] In an embodiment of the present application, the electronic device can select N algorithms whose sum of first time consumption is not greater than the first duration from M algorithms as algorithms for processing the target image, so that the time consumed by the central processing unit to process the target image will not exceed the first duration, thereby avoiding the situation where multiple algorithms are scheduled to act on one frame of image, resulting in excessive load on the central processing unit, and can improve the processing efficiency of the central processing unit for images in the video stream.

[0011] In combination with the first method, in a possible implementation, the method further includes:

[0012] After the electronic device determines N algorithms from the M algorithms, it can schedule the N algorithms to process the target image;

[0013] The electronic device displays the processed target image.

[0014] In an embodiment of the present application, N algorithms whose sum of first time consumption is not greater than the first duration are selected from M algorithms as algorithms for processing the target image, so that the time consumed by the central processing unit to process the target image will not exceed the first duration, which can increase the image display speed and thus improve the user experience.

[0015] In combination with the first method, in a possible implementation, the N algorithms include the first algorithm; before determining the N algorithms from the M algorithms, the method further includes:

[0016] The electronic device obtains the time consumed by the central processor for executing the first algorithm for the last L times, and obtains L historical time consumed by the first algorithm; L is an integer greater than 1;

[0017] The electronic device determines an average of the L historical time consumptions of the first algorithm as a first time consumption of the first algorithm.

[0018] In an embodiment of the present application, the electronic device can predict the first time consumption of the first algorithm for a target image based on the L historical time consumptions of the central processor for the last L times to execute the first algorithm before processing the target image. This can improve the data accuracy of the predicted first time consumption of the first algorithm, and can ensure that the actual time consumption of the central processor scheduling N algorithms to process the target image is less than the first time consumption, thereby reducing the time consumption of the central processor to process the target image.

[0019] In combination with the first method, in a possible implementation, when the occupancy rate of the central processing unit is higher than the first threshold, the first duration is a first value, and when the occupancy rate of the central processing unit is not higher than the first threshold, the first duration is a second value, and the first value is less than the second value.

[0020] In an embodiment of the present application, the electronic device may change the first duration based on a high-load scenario and a light-load scenario. The high-load scenario may refer to a high load on the CPU, such as a CPU occupancy rate higher than a first threshold; the light-load scenario may refer to a low load on the CPU, such as a CPU occupancy rate not higher than the first threshold.

[0021] In a high-load scenario, the electronic device can shorten the first duration (i.e., select a first value with a smaller value as the first duration). Then, the number of N algorithms determined by the electronic device based on the first duration is smaller, and the central processing unit takes less time to schedule the N algorithms to process the target head, which can avoid the central processing unit from malfunctioning due to excessive load or slow processing efficiency and jamming. In a light-load scenario, the electronic device can extend the first duration (i.e., select a second value with a larger value as the first duration). Then, the number of N algorithms determined can be greater. The more algorithms there are, the better the image processing effect. In this case, the image processing effect can be improved while ensuring the processing efficiency of the central processing unit.

[0022] In combination with the first method, in a possible implementation, the N algorithms include Q second algorithms, where Q is a positive integer; and the second algorithms are also executed by a digital signal processor of the electronic device when scheduled;

[0023] The sum of the second time consumptions of the Q second algorithms is not greater than the second duration; the second time consumption of each of the Q second algorithms is obtained based on the historical time consumption of the digital signal processor executing each second algorithm.

[0024] In an embodiment of the present application, the electronic device can predict the second time consumption of the second algorithm for the target image based on the historical time consumption of the digital signal processor most recently executing the second algorithm before processing the target image. This can improve the data accuracy of the predicted second time consumption of the second algorithm, and can ensure that the actual time consumption of the digital signal processor scheduling N algorithms to process the target image is less than the second time consumption, thereby reducing the time consumption of the digital signal processor to process the target image.

[0025] In combination with the first method, in a possible implementation, when the occupancy rate of the digital signal processor is higher than the second threshold, the second duration is a third value; when the occupancy rate of the digital signal processor is not higher than the second threshold, the second duration is a fourth value, and the third value is less than the fourth value.

[0026] In a high-load scenario, the electronic device can shorten the second duration (i.e., select a third value with a smaller value as the second duration). Then, the number of N algorithms determined by the electronic device based on the second duration is smaller, and the digital signal processor takes less time to schedule the N algorithms to process the target head, thereby avoiding the digital signal processor from malfunctioning due to excessive load or freezing due to slow processing efficiency. In a light-load scenario, the electronic device can extend the second duration. Then, the number of N algorithms determined can be larger. The more algorithms there are, the better the image processing effect. In this case, the image processing effect can be improved while ensuring the processing efficiency of the digital signal processor.

[0027] In combination with the first method, in a possible implementation, the N algorithms include W third algorithms, where W is a positive integer; and the third algorithms are also executed by an image processor of the electronic device when scheduled;

[0028] The sum of the third time consumptions of the W third algorithms is not greater than the third duration; the third time consumption of each of the W third algorithms is obtained based on the historical time consumption of the image processor executing each third algorithm.

[0029] In an embodiment of the present application, the electronic device can predict the third time consumption of the third algorithm for the target image based on the historical time consumption of the image processor most recently executing the third algorithm before processing the target image. This can improve the data accuracy of the predicted third time consumption of the third algorithm, and can ensure that the actual time consumption of the image processor scheduling N algorithms to process the target image is less than the third time consumption, thereby reducing the time consumption of the image processor to process the target image.

[0030] In combination with the first method, in a possible implementation, when the occupancy rate of the image processor is higher than the third threshold, the third duration is a fifth value; when the occupancy rate of the image processor is not higher than the third threshold, the third duration is a sixth value; and the fifth value is less than the sixth value.

[0031] In a high-load scenario, the electronic device can shorten the third duration (i.e., select a third value with a smaller value as the third duration). Then, the number of N algorithms determined by the electronic device based on the third duration is smaller, and the image processor takes less time to schedule the N algorithms to process the target head, which can avoid the image processor from malfunctioning due to excessive load or causing freezes due to slow processing efficiency. In a light-load scenario, the electronic device can extend the third duration. Then, the number of N algorithms determined can be larger. The more algorithms there are, the better the image processing effect. In this case, the image processing effect can be improved while ensuring the processing efficiency of the image processor.

[0032] In combination with the first method, in a possible implementation, the N algorithms include Q second algorithms, where Q is a positive integer; the second algorithm is also executed by a digital signal processor of the electronic device when it is scheduled; the sum of the second time consumptions of the Q second algorithms is not greater than the second duration; the second time consumption of each of the Q second algorithms is obtained based on the historical time consumption of the digital signal processor executing each second algorithm;

[0033] Moreover, the N algorithms include W third algorithms, where W is a positive integer; the third algorithm is also executed by the image processor of the electronic device when scheduled; the sum of the third time consumptions of the W third algorithms is not greater than the third duration; the third time consumption of each third algorithm in the W third algorithms is obtained based on the historical time consumption of the image processor to execute each third algorithm.

[0034] In the embodiment of the present application, the situation of multiple computing units (central processing unit, digital signal processor and image processor) is collaboratively considered, and by selecting N algorithms, it is ensured that the time consumption of each computing unit is within the time limit, thereby ensuring the processing efficiency of each computing unit.

[0035] In combination with the first method, in a possible implementation, the determining of N algorithms from M algorithms includes:

[0036] The electronic device sorts the M algorithms to obtain a first sequence; the algorithms in the first sequence are sorted from large to small according to the current weight of each algorithm in the M algorithms;

[0037] When the sum of the first time consumptions of the first N algorithms in the first sequence is equal to the first duration, the electronic device determines the first N algorithms as N algorithms;

[0038] When the sum of the first time consumptions of the first j algorithms in the first sequence is not greater than the first duration and the sum of the first time consumptions of the first j+1 algorithms is greater than the first duration, the sum of the first time consumptions of the algorithms ordered after the j+1th algorithm and the first j algorithms is compared with the first duration, and at least one algorithm is determined from the algorithms ordered after the j+1th algorithm, and the sum of the first time consumptions of the at least one algorithm and the first j algorithms is not greater than the first duration; j is an integer greater than 0 and less than M, and the N algorithms include the first j algorithms and at least one algorithm.

[0039] In combination with the first method, in a possible implementation, the algorithms with equal weights in the first sequence are sorted from large to small according to the preset frame rate, and the algorithms with equal weights and preset frame rates in the first sequence are sorted from small to large according to the first time consumption.

[0040] In combination with the first method, in a possible implementation, the current weight of each of the M algorithms is determined by a preset frame rate of each algorithm, a preview frame rate of the video stream, and the number of times each algorithm is scheduled; the number of times each algorithm is scheduled is the number of times each algorithm is scheduled before processing a target image in the video stream;

[0041] The current weight of each algorithm is used to indicate the expected degree of each algorithm being currently scheduled, and the weight of each algorithm is directly proportional to the expected degree of each algorithm being scheduled.

[0042] In the embodiment of the present application, the algorithm scheduling not only takes into account the preset frame rate, but also takes into account the performance overhead (time consumption) of each algorithm; sorting based on weight and preset frame rate can ensure that the algorithm with greater impact on image processing is preferably selected as the above-mentioned N algorithms, and selecting N algorithms based on the performance of the algorithm can ensure that the time consumption for processing the image meets the preset conditions. This method can ensure the image processing efficiency while ensuring the image display effect.

[0043] In a second aspect, the present application provides an algorithm scheduling module, which is used to execute the method shown in the first aspect or any possible implementation of the first aspect.

[0044] Exemplarily, the algorithm scheduling module may be a functional module in a hardware abstraction layer.

[0045] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method in the first aspect or any possible implementation of the first aspect.

[0046] In a fourth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions so that the electronic device executes the method shown in the first aspect or any possible implementation of the first aspect.

[0047] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the method shown in the first aspect or any possible implementation of the first aspect.

[0048] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, characterized in that when the instructions are executed on an electronic device, the electronic device executes the method shown in the first aspect or any possible implementation of the first aspect.

[0049] It is understandable that the algorithm scheduling module provided in the second aspect, the electronic device provided in the third aspect, the chip provided in the fourth aspect, the computer program product provided in the fifth aspect, and the computer storage medium provided in the sixth aspect are all used to execute the method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 is a schematic structural diagram of an electronic device 100 provided in an embodiment of the present application;

[0051] Figure 2 is a software structure block diagram of the electronic device 100 according to an embodiment of the present application;

[0052] Figure 3 It is a schematic diagram of the data flow of an algorithm scheduling process provided in an embodiment of the present application;

[0053] Figure 4 is a method flow chart of an algorithm scheduling method provided by an embodiment of the present application;

[0054] Figure 5 is a method flow chart of another algorithm scheduling method provided by an embodiment of the present application;

[0055] Figure 6 It is a schematic diagram of data flow of another algorithm scheduling process provided in an embodiment of the present application;

[0056] Figure 7 This is a method flow chart of another algorithm scheduling method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described below in conjunction with the accompanying drawings.

[0058] The terms "first" and "second" in the specification, claims and drawings of this application are only used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0059] The "embodiment" mentioned in the embodiments of the present application means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It can be explicitly and implicitly understood by those skilled in the art that the embodiment described in the embodiments of the present application can be combined with other embodiments.

[0060] In the present application, "at least one (item)" means one or more, "more than one" means two or more, "at least two (items)" means two or three and more than three, and "and / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c".

[0061] First, the technical terms involved in the embodiments of the present application are introduced.

[0062] (1) Image processing algorithm

[0063] An image processing algorithm refers to an algorithm for processing an image, wherein the processing may include recognition, denoising, etc. It should be understood that algorithms acting on images all belong to the image processing algorithms in the embodiments of the present application.

[0064] Exemplarily, the image processing algorithm may include a perception algorithm, which refers to a series of algorithms used to process images, such as a face detection algorithm, a scene detection algorithm, an object tracking algorithm, a key point detection algorithm, etc. The perception algorithm may also be called a preview algorithm, which is not limited in the present application.

[0065] (2) Preview frame rate of video stream

[0066] The preview frame rate of a video stream refers to the playback frame rate of the video stream.

[0067] Exemplarily, in response to a user operation of clicking an application icon of a camera application, the electronic device displays a preview interface of the camera application, the preview interface including a preview window, the preview window being used to display a video stream; the preview frame rate of the video stream is the number of frames of an image displayed per unit time (such as 1s) in the preview window. Assume that the preview frame rate of the video stream is 30 frames per second, that is, the preview window displays 30 frames of images per second.

[0068] In an embodiment of the present application, the preview frame rate of the video stream may be a camera preview frame rate. The camera preview frame rate is a parameter set when the camera module leaves the factory, and the number of camera preview frame rates may be one or more. Exemplarily, the electronic device may set different preview frame numbers for different video streams based on parameters such as processor load. For example, the electronic device may use a camera preview frame rate with a lower frame rate among the camera preview frame rates as the preview frame rate of the current video stream when the processor load is high; and use a camera preview frame rate with a higher frame rate among the camera preview frame rates as the preview frame rate of the current video stream when the processor load is low.

[0069] (3) Frame rate (frames per second, FPS) of the image processing algorithm

[0070] The frame rate of an image processing algorithm is the number of frames that the algorithm acts on (is scheduled on) in a video stream within a unit time (such as 1s). The embodiments of the present application mainly relate to image processing algorithms. For the convenience of description, the image processing algorithm is referred to as an algorithm below.

[0071] For example, if the frame rate of the algorithm is 30 frames per second, that is, the algorithm is scheduled 30 times per second, acting on 30 frames of images in the video stream. Assuming that the preview frame rate of the video stream is also 30 frames per second, then the algorithm is scheduled for each frame of the video stream.

[0072] For another example, the frame rate of the algorithm is 15 frames per second, that is, the algorithm is scheduled 15 times per second, that is, the algorithm acts on 15 frames of images in the video stream. Assuming that the preview frame rate of the video stream is also 30 frames per second, then the algorithm is scheduled for each frame of the video stream. Assuming that the preview frame rate of the video stream is also 30 frames per second, then the algorithm is scheduled for 15 frames of images in the video stream, and the other 15 frames of images in the video stream are not processed by the algorithm.

[0073] The electronic device may store the frame rates of various image processing algorithms. For example, the electronic device may store configuration files of various perception algorithms, and the configuration files may include the frame rates corresponding to the algorithms. It should be noted that the frame rates in the configuration files may also be referred to as ideal frame rates.

[0074] The embodiment of the present application is to coordinate the scheduling of various algorithms, and will not schedule the algorithms completely according to the frame rate corresponding to the algorithms in the configuration files. Therefore, for the convenience of description, the embodiment of the present application refers to the frame rate of the algorithms in the configuration files as the preset frame rate, and the frame rate of the algorithms in the actual scheduling process as the scheduling frame rate.

[0075] It should be noted that the preset frame rate of the algorithm in the electronic device can be configured by the staff before the electronic device leaves the factory. It is understandable that if the staff believes that the algorithm is more important (such as the user has high requirements for the functions implemented by the algorithm or the display effect of the image is greatly affected), the preset frame rate of the algorithm will be set higher, otherwise, the preset frame rate of the algorithm will be set lower.

[0076] In an embodiment of the present application, when the weights of multiple algorithms are consistent, an algorithm with a preset higher frame rate can be scheduled preferentially. This method can ensure that a more important algorithm is scheduled to ensure the display effect of the image in the video stream.

[0077] In the embodiment of the present application, the algorithm scheduling method provided in the embodiment of the present application can be executed by any electronic device with image processing function. The form of the electronic device may include but is not limited to a mobile phone terminal, a tablet terminal, a notebook computer, a desktop computer, a laptop computer, or a handheld computer, etc., and the present application does not limit this.

[0078] See also Figure 1 ,by Figure 1 Taking the electronic device 100 as an example, the structural diagram of the electronic device provided by the present application is described in detail.

[0079] The electronic device 100 may include a processor 110, an external memory 120, an internal storage area 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, a sensor module 170, a button 180, a camera 190, and a display screen 191. The sensor module 170 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.

[0080] It is to be understood that the structure shown in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include: Figure 1 More or fewer components may be shown, or some components may be combined or separated, or the components may be arranged differently. Figure 1The components shown may be implemented in hardware, software or a combination of software and hardware. For example, the electronic device 100 may also include an audio module (speaker, receiver, microphone, headphone jack, etc.), a subscriber identification module (SIM) card interface, and a motor, etc.

[0081] The processor 110 may include one or more processing units, for example, the processor 110 may include a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application processor (AP), a modem processor, an image signal processor (ISP), a controller, a memory, a video codec, a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or may be integrated into one or more processors.

[0082] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0083] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0084] In some embodiments, the processor 110 may include one or more interfaces. 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), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc. It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0085] 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 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0086] Exemplarily, the electronic device cooperates with the processor and hardware modules with related functions to execute the algorithm scheduling method provided in the present application, for example, cooperates with one or more related hardware modules including the processor and hardware modules related to the camera application, the wired transmission module (such as a USB module, etc.), and the wireless transmission module (Bluetooth, wifi, near-field communication, etc.) to execute the algorithm scheduling method provided in the present application.

[0087] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0088] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0089] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0090] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device, or displays an image or video through the display screen 191. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0091] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0092] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0093] The electronic device 100 implements the display function through a GPU, a display screen 191, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 191 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0094] The electronic device 100 can realize the shooting function through the ISP, the camera 190, the video codec, the GPU, the display screen 191 and the application processor.

[0095] The external memory 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory 120 to implement a data storage function. For example, files such as music and videos are stored in the external memory card.

[0096] The internal storage area 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal storage area 121. The internal storage area 121 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 100 (such as audio data, a phone book, etc.), etc. In addition, the internal storage area 121 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, a universal flash storage (UFS), etc.

[0097] The camera 193 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 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0098] 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 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0099] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0100] 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 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0101] The algorithm deployment in the embodiment of the present application can be performed on the CPU, that is, executed by the CPU.

[0102] Optionally, the execution of some algorithms in the embodiments of the present application may also be deployed on at least one of a digital signal processor and a graphics processor.

[0103] Exemplarily, the electronic device 100 can obtain a video stream through the camera 190; then, for the image in the video stream, the processor 110 makes a decision on M algorithms to obtain N algorithms corresponding to each image; then, the electronic device 100 can run the processors deployed by the N algorithms to process the image; and the processed image is displayed through the display screen 191. The detailed decision method can refer to the relevant content of the method embodiment below, which will not be described in detail here.

[0104] Figure 2 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0105] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers, from top to bottom: application layer, application framework layer, runtime and system library, hardware abstract layer (HAL), and kernel layer.

[0106] The application layer may include a series of application packages.

[0107] like Figure 2 As shown, the application package in the application layer may include but is not limited to camera, gallery and other applications. The application layer may also include applications such as calls, music, videos, and text messages, which are not limited in the present embodiment of the application.

[0108] The application framework layer provides an application programming interface (API) and a programming framework for the application programs in the application layer. The application framework layer includes some predefined functions.

[0109] like Figure 2As shown, the application framework layer includes but is not limited to a window manager, a content provider, a notification manager, and a battery manager. The application framework layer may also include a phone manager, a resource manager, etc., which are not limited in the present embodiment of the application.

[0110] The window manager is used to manage window programs. The content provider is used to store and obtain data and make the data accessible to applications. The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. The phone manager is used to provide communication functions for the electronic device 100. The resource manager provides various resources for applications, such as localized strings, icons, images, 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.

[0111] The runtime includes the core library and the virtual machine. The runtime is responsible for the scheduling and management of the system.

[0112] The core library consists of two parts: one part is the function that the programming language (for example, Java language) needs to call, and the other part is the core library of the system.

[0113] The application layer and the application framework layer can run in a virtual machine. The virtual machine can execute the programming files (e.g., java files) of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0114] The system library includes but is not limited to multiple functional modules, such as a surface manager, a two-dimensional graphics engine (such as SGL, a media library, etc.). The system library may also include a three-dimensional graphics processing library (such as OpenGL ES), etc., which is not limited in the embodiments of the present application.

[0115] The hardware abstraction layer may include but is not limited to an algorithm scheduling engine and a hardware synthesizer.

[0116] The algorithm scheduling engine is used to obtain the configuration information of the algorithm (such as a preset frame rate, etc.) and schedule the algorithm to process the image. The algorithm scheduling engine may include multiple engines, and different engines may be used to schedule different algorithms. Exemplarily, the algorithm scheduling engine may include a semantic engine algorithm, which is used to obtain the configuration information of the semantic algorithm (such as a preset frame rate, etc.) and schedule the semantic algorithm to process the image.

[0117] In some possible implementations, the hardware abstraction layer may also include Figure 2 The graphics module, Bluetooth library module, camera module, etc. not shown are not limited in the embodiments of the present application.

[0118] In an embodiment of the present application, the hardware abstraction layer may further include an algorithm scheduling module, which is used to execute the algorithm scheduling method provided by the present application. Exemplarily, the camera application of the application layer and the algorithm scheduling module cooperate to execute the algorithm scheduling method provided by the present application.

[0119] In some other possible implementations, the algorithm scheduling module may also be located in other levels of the software architecture, which is not limited here.

[0120] The kernel layer is a layer between hardware and software. The kernel layer includes but is not limited to display drivers, camera drivers, sensor drivers, device drivers, etc. The kernel layer can also be audio drivers, virtual card drivers, etc., which are not limited in the embodiments of the present application.

[0121] Exemplarily, the electronic device can obtain a video stream by taking a photo based on a camera application in the application layer and a camera driver in the kernel layer, and determine the algorithm that needs to be scheduled to process a target image in the video stream based on an algorithm scheduling module in the hardware abstraction layer.

[0122] Exemplarily, the electronic device can also obtain the video stream in a data transmission manner based on a wireless application module or a wired application module in the application layer (such as a wifi application, a Bluetooth application, a near field communication application, etc.), and then determine the algorithm that needs to be scheduled to process the target image in the video stream based on the algorithm scheduling module in the hardware abstraction layer.

[0123] Generally, after the camera application is enabled, some perception algorithms will be called to process the captured images in the photo mode (photo preview mode), video mode (video preview mode, preview means displaying the image to the user throughout the photo process or video recording process), and video recording process to complete the corresponding functions (such as object tracking function, etc.). The specific number of perception algorithms called is set by the developer according to the corresponding design and requirements.

[0124] The number of perception algorithms called in different modes (such as portrait mode, night mode, etc.) can be the same or different, and the embodiments of the present application do not limit this.

[0125] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0126] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture static images or videos through the camera 193.

[0127] based on Figure 1 and Figure 2 The electronic device shown first introduces a method for determining algorithm scheduling based on a preset frame rate of the algorithm.

[0128] See also Figure 3 , Figure 3 The data flow of an algorithm scheduling process is exemplified. It should be understood that the electronic device performs an algorithm scheduling for each frame of image in the video stream, and the current frame is used as an example for explanation.

[0129] like Figure 3 As shown, the algorithm scheduling module of the electronic device can obtain the preset frame rate (FPS) of each algorithm in M ​​algorithms through the algorithm scheduling engine (such as the perception algorithm engine), where M is an integer greater than 1; then, a decision is made based on the preset frame rate of each algorithm (the decision process can be seen in Figure 4 ), and obtain the decision result (Decision) of the current frame, wherein the decision result includes the scheduling algorithm of the current frame (the decision result may also include Figure 4 any data involved in S403 to S411); based on the decision result of the current frame, output the smart scheduling strategy (Smart schedule) of the current frame, wherein the smart scheduling strategy may include the decision result of each of the M algorithms. For example, the decision result of the algorithm may be scheduling or not scheduling, and the decision result of the algorithm is scheduling is used to instruct the electronic device to schedule the algorithm to process the current frame, and the decision result of the algorithm is scheduling is used to instruct the electronic device to process the current frame without scheduling the algorithm. In the embodiment of the present application, for the convenience of description, the algorithm that is decided to be scheduled for processing the image is referred to as the scheduling algorithm of the image. Exemplarily, the Smart schedule may be as shown in Table 2, which exemplarily shows the scheduling algorithms for 10 frames of images in the first video stream, and the scheduling algorithms in Table 2 are represented by a check mark, such as the scheduling algorithms for the 0th frame are A2, A3, B3 and D2.

[0130] Figure 4 The flow of the algorithm scheduling method is exemplified. Taking the first video stream as an example, the method may include the following steps:

[0131] S401: When the electronic device obtains the first image of the first video stream, the electronic device uses the first image as the current frame.

[0132] Optionally, the first video stream may be captured by the electronic device through a camera, or may be obtained by the electronic device based on some data transmission methods, for example, it may be obtained through a wired transmission method (universal serial bus interface USB, etc.) or a wireless transmission method (wireless fidelity WIFI, Bluetooth, near field communication, etc.), and the embodiments of the present application do not limit this.

[0133] The first image is the first frame image processed by the algorithm in the first video stream. It should be noted that the first image may not be the first frame image in the first video stream.

[0134] S402: Initializing the weight of each algorithm in the M algorithms to the camera preview frame rate, and determining the preset frame rate of each algorithm as the step size of each algorithm.

[0135] Wherein, M is an integer greater than 1.

[0136] The weight of the algorithm is used to indicate the expected degree of scheduling of the algorithm. In the embodiment of the present application, the greater the weight of the algorithm, the greater the expected degree of scheduling of the algorithm, and vice versa.

[0137] S403: Determine whether the weight of each algorithm among the M algorithms is not less than the camera preview frame rate.

[0138] S404: Sort the algorithms whose weights are not less than the camera preview frame rate (referred to as multiple first algorithms) among the M algorithms according to their weights from large to small.

[0139] S405: updating the weight of an algorithm whose weight is less than the camera preview frame rate among the M algorithms based on the step size of the algorithm.

[0140] In one implementation, the electronic device may add the weight of the algorithm to the step size of the algorithm to obtain a first weight; and update the weight of the algorithm to the first weight.

[0141] In some embodiments, when the weight of an algorithm is less than the camera preview frame rate, the electronic device determines that the algorithm will not be scheduled when processing the current frame this time. It is understandable that since the algorithm is not scheduled this time, the electronic device can increase the weight of the algorithm (i.e., add the step size of the algorithm) to increase the expected degree of scheduling of the algorithm next time, that is, it can increase the possibility of the algorithm being scheduled next time, avoid the algorithm not being scheduled for a long time, and ensure that the scheduling frame rate of the algorithm is close to the preset frame rate of the algorithm, thereby ensuring the display effect of the image.

[0142] S406: Sort the algorithms with the same weight among the multiple first algorithms from large to small according to the preset frame rates.

[0143] It should be noted that when the first image is the current frame, the weight of each of the M algorithms is equal to the camera preview frame rate, and the M algorithms are sorted from large to small according to the preset frame rate.

[0144] S407: Obtain first K algorithms from the plurality of first algorithms.

[0145] Wherein, K is a positive integer.

[0146] S408: Determine whether each algorithm among the multiple first algorithms belongs to the top K algorithms.

[0147] S409: Reset the weights of the algorithms belonging to the first K algorithms among the multiple first algorithms to the camera preview frame rate.

[0148] S410: updating the weights of the multiple first algorithms that do not belong to the first K algorithms based on the step length corresponding to the algorithm.

[0149] In one implementation, the electronic device may add the weight of the algorithm to the step size of the algorithm to obtain a first weight; and update the weight of the algorithm to the first weight.

[0150] In some embodiments, when the weight of an algorithm is less than the camera preview frame rate, the electronic device determines that the algorithm will not be scheduled when processing the current frame this time. It is understandable that since the algorithm is not scheduled this time, the electronic device can increase the weight of the algorithm (i.e., add the step size of the algorithm) to increase the expected degree of scheduling of the algorithm next time, that is, it can increase the possibility of the algorithm being scheduled next time, avoid the algorithm not being scheduled for a long time, and ensure that the scheduling frame rate of the algorithm is close to the preset frame rate of the algorithm, thereby ensuring the display effect of the image.

[0151] S411: Determine the algorithms of the first set as the algorithms scheduled to process the current frame.

[0152] S412: Wait for the next frame of the first video stream, take the next frame as the current frame, and then execute part or all of the above steps S403 to S411.

[0153] Figure 4In the illustrated embodiment, the weight of each algorithm is determined based on the preset frame rate of each algorithm, and thus the scheduling algorithm for each frame of the first video stream is determined based on the weight of the algorithm. Wherein, K is less than M, that is, the number of scheduling algorithms for each frame of the image is a preset number, i.e., K. This method can avoid too many algorithms being scheduled to act on one frame of the image, resulting in excessive processor load, and can also ensure the display effect of the image. This method can avoid problems such as preview frame loss and freeze caused by the lengthening of the algorithm time due to resource competition when multiple algorithms are deployed in the same computing unit.

[0154] However, since each algorithm has different effects on the performance of different processors, K in the above method is a constant, and K different algorithms have different effects on the load of the processor. In some cases, the K algorithms may cause an excessive load on a certain processor, resulting in low processing efficiency of the processor for the frame image and slow image display.

[0155] In view of this, an embodiment of the present application provides an algorithm scheduling method. In the method, an electronic device can obtain a video stream, the video stream includes at least two images; the target image is one of the at least two images; the electronic device determines N algorithms from M algorithms based on the first time consumption of each of the M algorithms for the target image; wherein M is an integer greater than 1, and N is less than M; the first time consumption of each of the M algorithms is obtained based on the historical time consumption of the central processor executing each algorithm; the sum of the first time consumption of the N algorithms is not greater than the first duration, and the N algorithms are scheduled to process the target image.

[0156] The method selects N algorithms whose first time consumption sum is not greater than the first duration as algorithms for processing the target image, so that the time consumption of the central processing unit for processing the target image will not exceed the first duration, thereby avoiding the situation where multiple algorithms are scheduled to act on one frame of image, causing the load of the central processing unit to be too high. The method can improve the processing efficiency of the central processing unit for images in the video stream, increase the display speed of the image, and thus improve the user experience.

[0157] Below through Figure 5 , introduces an algorithm scheduling method provided in an embodiment of the present application, the method comprising some or all of the following steps:

[0158] S501: The electronic device obtains a first video stream, where the first video stream includes at least two images; the target image is one of the at least two images.

[0159] In this embodiment of the present application, the first video stream includes at least two image frames.

[0160] Optionally, the first video stream can be obtained by the electronic device through a camera, or can be obtained by the electronic device from other devices through data transmission. For example, it can be obtained through a wired transmission method (universal serial bus interface USB, etc.) or a wireless transmission method (wireless fidelity WIFI, Bluetooth, near-field communication, etc.), and the embodiments of the present application are not limited to this.

[0161] Exemplarily, after the electronic device starts the camera application, it starts to capture images, and the above-mentioned first video stream is a collection of images captured after the camera application is started. The length of the first video stream (which can also be understood as the total number of images) can be fixed or variable, and the embodiments of the present application are not limited to this. For example, in the camera preview screen, the length of the first video stream can change as the number of images captured by the camera application changes according to time, or the length of the first video stream can also be fixed, for example, the first video stream is the default duration of the camera application recording video.

[0162] In addition, it should be noted that the first frame (starting image) of the first video stream is the i-th frame image obtained after the camera application is started, where i is greater than or equal to 1, or i is greater than or equal to 2. The embodiment of the present application does not limit this. That is to say, the first frame of the first video stream is not necessarily the first frame image captured after the camera application is started.

[0163] In an embodiment of the present application, the electronic device obtains a target image of the first video stream, and the electronic device determines N algorithms from M algorithms for the target image. These two tasks can be executed in parallel or successively, and the embodiment of the present application does not limit this.

[0164] S502: The electronic device determines N algorithms from M algorithms for a target image based on the first time consumption of each of the M algorithms; wherein the sum of the first time consumptions of the N algorithms is not greater than the first duration, and the N algorithms are scheduled to process the target image.

[0165] Wherein, M is an integer greater than 1, and N is less than M; the first time consumption of each of the M algorithms is obtained based on the historical time consumption of the central processing unit executing each algorithm.

[0166] In one implementation, when an algorithm scheduling module of an electronic device receives an algorithm scheduling request for a target image, it obtains the historical time consumption of each processor for the most recent one or more executions of M algorithms, and the algorithm scheduling request is used to request an algorithm for processing the target image; based on the above historical time consumption, the first time consumption of each of the current M algorithms is predicted; further, based on the first time consumption of each of the M algorithms, the above N algorithms are determined from the M algorithms; further, the electronic device can schedule the above N algorithms to process the target image and display the processed target image. In the embodiment of the present application, for the convenience of description, the algorithm determined to be scheduled for processing an image is referred to as the scheduling algorithm of the image. For example, the N algorithms determined for a target image can be referred to as the scheduling algorithm of the target image.

[0167] In some embodiments, the electronic device may predict the first time consumption of each of the M algorithms corresponding to each frame of the image in the first video stream. That is, for each frame of the image, the first time consumption of each of the M algorithms predicted may be different.

[0168] Taking the first algorithm included in the N algorithms as an example, a method for predicting the first time consumption is introduced as an example. First, the electronic device can obtain the time consumption of the central processor for the last L1 times to execute the first algorithm, and obtain L1 historical time consumptions of the first algorithm; L1 is an integer greater than 1; the electronic device determines the average of the L1 historical time consumptions of the first algorithm as the first time consumption of the first algorithm. For example, L1 can be 30.

[0169] Optionally, the first duration may be dynamically adjusted according to the load of the central processing unit. That is, the first duration corresponding to each frame of the first video stream may be different. For example, when the occupancy rate of the central processing unit is higher than the first threshold, the first duration is a first value, and when the occupancy rate of the central processing unit is not higher than the first threshold, the first duration is a second value, and the first value is less than the second value.

[0170] In other embodiments of the present application, the above-mentioned N algorithms may include Q algorithms deployed on a digital signal processor (referred to as the second algorithm), that is, the second algorithm is also executed by the digital signal processor when it is scheduled; Q is a positive integer; the sum of the second time consumption of the Q second algorithms is not greater than the second duration; the second time consumption of each of the Q second algorithms is obtained based on the historical time consumption of the digital signal processor to execute each second algorithm.

[0171] Taking the second algorithm included in the N algorithms as an example, a method for predicting the second time consumption is exemplified. First, the electronic device can obtain the time consumption of the digital signal processor executing the second algorithm for the last L2 times, and obtain L2 historical time consumptions of the second algorithm; L2 is an integer greater than 1; the electronic device determines the average of the L2 historical time consumptions of the second algorithm as the second time consumption of the second algorithm.

[0172] Optionally, the second duration may be dynamically adjusted according to the load of the digital signal processor. That is, the second duration corresponding to each frame of the first video stream may be different. For example, when the occupancy rate of the digital signal processor is higher than the second threshold, the second duration is a third value, and when the occupancy rate of the digital signal processor is not higher than the second threshold, the second duration is a fourth value, and the third value is less than the fourth value.

[0173] In other embodiments of the present application, the above-mentioned N algorithms may include W algorithms deployed on the image processor (referred to as the third algorithm), that is, the third algorithm is also executed by the image processor when it is scheduled; W is a positive integer; the sum of the third time consumption of the W third algorithms is not greater than the third duration; the third time consumption of each of the W third algorithms is obtained based on the historical time consumption of the image processor to execute each third algorithm.

[0174] Taking the third algorithm included in the N algorithms as an example, a method for predicting the third time consumption is exemplified. First, the electronic device can obtain the time consumption of the image processor executing the third algorithm for the last L3 times, and obtain L3 historical time consumptions of the third algorithm; L3 is an integer greater than 1; the electronic device determines the average of the L3 historical time consumptions of the third algorithm as the third time consumption of the third algorithm.

[0175] Optionally, the values ​​of L1, L2, and L3 may be the same or different. The specific values ​​may be determined based on the occupancy rate of each processor and other conditions, which is not limited in the embodiment of the present application.

[0176] Optionally, the third duration may be dynamically adjusted according to the load of the image processor. That is, the third duration corresponding to each frame of the first video stream may be different. For example, when the occupancy rate of the image processor is higher than the third threshold, the third duration is a fifth value, and when the occupancy rate of the image processor is not higher than the third threshold, the third duration is a sixth value, and the fifth value is less than the sixth value.

[0177] It should be noted that the above-mentioned first duration, second duration and third duration may be the same or different, and the specific values ​​may be determined by the image processing efficiency requirements, etc., and the embodiment of the present application does not limit this.

[0178] The following is an exemplary introduction to a specific implementation of determining N algorithms from M algorithms.

[0179] In one implementation, the electronic device may first sort M algorithms to obtain a first sequence; the algorithms in the first sequence are sorted from large to small according to the current weight of each algorithm in the M algorithms; when the sum of the first time consumptions of the first N algorithms in the first sequence is equal to the first duration, the electronic device determines the first N algorithms as the N algorithms; when the sum of the first time consumptions of the first j algorithms in the first sequence is not greater than the first duration and the sum of the first time consumptions of the first j+1 algorithms is greater than the first duration, the sum of the first time consumptions of the algorithms sorted after the j+1 algorithm and the first j algorithms is compared with the first duration, and at least one algorithm is determined from the algorithms sorted after the j+1 algorithm, and the sum of the first time consumptions of the at least one algorithm and the first j algorithms is not greater than the first duration; j is an integer greater than 0 and less than M, and the N algorithms include the first j algorithms and at least one algorithm.

[0180] Optionally, the algorithms with equal weights in the first sequence are sorted from large to small according to the preset frame rate, and the algorithms with equal weights and preset frame rates in the first sequence are sorted from small to large according to the first time consumption. For the specific process of sorting, please refer to the specific contents of steps S705, S707 and S708 below; the sorted first sequence can be shown in Tables 3 to 5. It should be noted that the above description of the position of the first algorithm in the first sequence is reflected in the table as the upper and lower positions, that is, the first algorithm in the first sequence is the first algorithm from top to bottom in the table, and the first N algorithms in the first sequence are the first N algorithms from top to bottom in the table.

[0181] Optionally, the algorithms with equal weights in the first sequence are sorted from large to small according to the preset frame rate, and the algorithms with equal weights and preset frame rates in the first sequence are randomly arranged. Alternatively, the algorithms with equal weights in the first sequence are randomly arranged, and the algorithms with equal weights and preset frame rates in the first sequence are also randomly arranged.

[0182] Optionally, the current weight of each algorithm in the M algorithms is determined by the preset frame rate of each algorithm, the preview frame rate of the first video stream, and the number of times each algorithm is scheduled; the number of times each algorithm is scheduled is the number of times each algorithm is scheduled before processing the target image in the first video stream; the current weight of each algorithm is used to indicate the expected degree of each algorithm being currently scheduled, and the weight of each algorithm is proportional to the expected degree of each algorithm being scheduled. For the specific calculation of the current weight of the algorithm, please refer to Figure 4 and Figure 7 As well as the relevant contents of the following Tables 2 to 5, they will not be repeated here.

[0183] Among them, the preview frame rate of the above-mentioned first video stream can be a camera preview frame rate, or it can be other values, and the embodiments of the present application are not limited to this. For example, when previewing a scene, the preview frame rate of the above-mentioned first video stream can be a camera preview frame rate. Among them, the preview scene can refer to an electronic device starting a camera application, and displaying the captured video stream through the camera application. For example, the preview interface displayed after the camera application is started shows that the playback frame rate of the video acquired by the camera can be the above-mentioned camera preview frame rate, and the image displayed on the preview interface can be obtained by processing the scheduling algorithm of the image determined by the algorithm scheduling method provided in this application.

[0184] The embodiments of the present application can be applied to preview scenarios or other scenarios that require video processing. The scenarios involve scheduling multiple algorithms to process images. The algorithm scheduling method provided in the embodiments of the present application can be executed to schedule multiple algorithms. For example, after sorting multiple algorithms, several algorithms are selected from the sorted algorithms as scheduling algorithms for the image.

[0185] based on Figure 1 and Figure 2 The electronic equipment shown, through Figure 6 and Figure 7 Exemplary pair Figure 5 The algorithm scheduling method shown is introduced in detail.

[0186] See also Figure 6 , Figure 6 The data flow of an algorithm scheduling process is exemplified. It should be understood that the electronic device performs an algorithm scheduling for each frame of image in the video stream, and the current frame is used as an example for explanation.

[0187] like Figure 6 As shown, the algorithm scheduling module of the electronic device can obtain the preset frame rate (FPS) of each algorithm in the M algorithms and the performance (Performance) of each algorithm for at least one of the CPU, DSP and GPU through the algorithm scheduling engine (such as the perception algorithm engine), where M is an integer greater than 1; then, based on the preset frame rate of each algorithm and the performance of each algorithm for at least one of the CPU, DSP and GPU, a decision is made (the decision process can be referred to Figure 7 ), and obtain the decision result (Decision) of the current frame, wherein the decision result includes the N scheduling algorithms corresponding to the current frame (the decision result may also include Figure 7any data involved in S703 to S713); based on the decision result of the current frame, output the smart scheduling strategy (Smart schedule) of the current frame, wherein the smart scheduling strategy may include the decision result of each of the M algorithms. For example, the decision result of the algorithm may be scheduling or not scheduling, the decision result of the algorithm is scheduling is used to instruct the electronic device to schedule the algorithm to process the current frame, and the decision result of the algorithm is scheduling is used to instruct the electronic device to process the current frame without scheduling the algorithm. Furthermore, after the algorithm scheduling module of the electronic device obtains the above-mentioned smart scheduling strategy, the electronic device can schedule the scheduling algorithm of the current frame through the above-mentioned algorithm scheduling engine to process the current frame image.

[0188] Figure 7 The flow of the algorithm scheduling method is exemplified. Taking the first video stream as an example, the method may include the following steps:

[0189] S701: When the electronic device obtains the first image of the first video stream, the electronic device uses the first image as the current frame.

[0190] For example, after the electronic device starts the camera application, the camera application can call the camera to capture an image; when the electronic device captures the first frame of the image that needs to be processed by the scheduling algorithm (ie, the first image), the image is used as the current frame.

[0191] In one implementation, when receiving an algorithm scheduling request for a first image, the algorithm scheduling module of the electronic device determines the first image as a current frame.

[0192] S702: The electronic device initializes the weight of each algorithm in the M algorithms to the camera preview frame rate; determines the preset frame rate of each algorithm as the step size of each algorithm; and initializes the performance requirements of the calculation unit.

[0193] In one implementation, after the electronic device determines the first image as the current frame, it initializes the weight of each algorithm in the M algorithms to the camera preview frame rate; determines the preset frame rate of each algorithm as the step size of each algorithm; and initializes the performance requirements of the computing unit.

[0194] The step size of the algorithm is the value that increases or decreases each time the weight of the algorithm is updated. Exemplarily, the step size of the algorithm can be the preset frame rate of the algorithm. Exemplarily, the electronic device can obtain the preset frame rate of each algorithm from the stored factory configuration file.

[0195] The computing unit includes a CPU, that is, the performance requirements of the computing unit include CPU performance requirements.

[0196] Optionally, the computing unit may further include at least one of a DSP and a GPU, that is, the performance requirements of the computing unit may further include a DSP performance requirement and a GPU performance requirement.

[0197] For example, if the M algorithms are all deployed only on the CPU, the performance requirements of the above-mentioned computing unit may only include the CPU performance requirements; if the M algorithms include algorithms deployed on the CPU and GPU (that is, the algorithm needs to be executed by the CPU and GPU), the performance requirements of the above-mentioned computing unit may include CPU performance requirements and GPU performance requirements; if the M algorithms include algorithms deployed on the CPU and DSP (that is, the algorithm needs to be executed by the CPU and DSP), the performance requirements of the above-mentioned computing unit may include CPU performance requirements and DSP performance requirements; if the M algorithms include algorithms deployed on the CPU and DSP and algorithms deployed on the CPU and GPU, or, the M algorithms include algorithms deployed on the CPU, DSP and GPU, the performance requirements of the above-mentioned computing unit may include CPU performance requirements, DSP performance requirements and GPU performance requirements.

[0198] Exemplarily, the M algorithms may include perception algorithms.

[0199] Exemplarily, the camera preview frame rate is 30fps. It is understandable that the camera preview frame rate is not limited to 30fps, and can also be other suitable values ​​according to specific scenarios or requirements, such as 24fps, 60fps, etc., which is not limited in this application.

[0200] S703: The electronic device predicts the algorithm performance of each algorithm in the M algorithms, where the algorithm performance includes CPU performance.

[0201] The algorithm performance of an algorithm includes the performance corresponding to at least one processor (also called a computing unit) deployed on the algorithm. Since the M algorithms are all deployed on the CPU, the algorithm performance of each of the M algorithms includes the CPU performance.

[0202] Optionally, the algorithm performance of the algorithm may also include DSP performance and GPU performance. In the embodiment of the present application, CPU performance may also be referred to as CPU time consumption, DSP performance may also be referred to as DSP time consumption, and GPU performance may also be referred to as GPU time consumption. For example, the M algorithms may include algorithms deployed on both the CPU and the DSP, and the algorithm performance of the algorithm includes CPU performance and DSP performance. For another example, the M algorithms may include algorithms deployed on both the CPU and the GPU, and the algorithm performance of the algorithm includes CPU performance and GPU performance.

[0203] In one implementation, the electronic device may use the predicted time taken by the CPU to execute the algorithm (i.e., the first time taken) as the CPU performance of the algorithm. For example, the electronic device may obtain the historical time taken by the central processor for the most recent 30 times to execute each of the M algorithms, and determine the average of the 30 historical time taken by each algorithm as the CPU performance of each algorithm.

[0204] In one implementation, the electronic device may use the predicted time consumption of the DSP to execute the algorithm (ie, the second time consumption mentioned above) as the DSP performance of the algorithm.

[0205] In one implementation, the electronic device may use the predicted time consumption of the GPU to execute the algorithm (ie, the third time consumption mentioned above) as the GPU performance of the algorithm.

[0206] The following table 1 exemplifies the algorithm performance of each algorithm and the performance requirements of the computing unit.

[0207] Table 1

[0208] Computing unit / algorithm A B C CPU a1 b1 c1 GPU a2 b2 c2 DSP a3 b3 c3

[0209] Table 1 exemplarily shows that the M algorithms are 3 algorithms, namely, algorithm A, algorithm B and algorithm C; the CPU performance of algorithm A is a1, the GPU performance of algorithm A is a2, and the DSP performance of algorithm A is a3; the CPU performance of algorithm B is b1, the GPU performance of algorithm B is b2, and the DSP performance of algorithm B is b3; the CPU performance of algorithm C is c1, the GPU performance of algorithm C is c2, and the DSP performance of algorithm C is c3. Among them, if the algorithm is not deployed in a certain algorithm unit, the performance can be considered to be 0, for example, if algorithm A is not deployed in DSP, the DSP performance a3 of algorithm A can be considered to be 0.

[0210] The performance requirements of the above algorithm units can be: (1) a1+b1+c1≤Climit; (2) a2+b2+c2≤Glimit; (3) a3+b3+c3≤Dlimit; wherein Climit is the maximum time consumption limited by the CPU (i.e. the first time duration mentioned above); Glimit is the maximum time consumption limited by the GPU (i.e. the second time duration mentioned above); Dlimit is the maximum time consumption limited by the DSP (i.e. the third time duration mentioned above).

[0211] Among them, a1+b1+c1 is the sum of the first time consumption of the M algorithms shown as an example, a2+b2+c2 is the sum of the second time consumption of the M algorithms shown as an example, and a3+b3+c3 is the sum of the third time consumption of the M algorithms shown as an example.

[0212] Optionally, the performance requirement of the above-mentioned computing unit may be changed. For example, when processing different images in a video stream, the performance requirement of the computing unit for each frame of image may be different or the same.

[0213] For example, the electronic device may update the performance requirements of the computing unit when obtaining an algorithm scheduling request for each image; the performance requirements of the computing unit may also be updated periodically, which is not limited in the embodiments of the present application.

[0214] Among them, the electronic device can update the performance requirements of the above computing unit based on the load condition of the computing unit. For example, in a high-load scenario, the electronic device can limit the performance of the computing unit to a lower level, and in a light-load scenario, the performance restriction conditions can be relaxed. For example, the electronic device can update at least one of the above Climit, Glimit and Dlimit based on the load condition of the CPU; it can also update the above Climit based on the load condition of the CPU, update the above Glimit based on the load condition of the GPU, and update the above Dlimit based on the load condition of the Dlimit.

[0215] S704: The electronic device determines whether the weight of each algorithm in the M algorithms is not less than the camera preview frame rate.

[0216] In one implementation, when the first image is the current frame, the weight of each of the M algorithms is the initial weight, that is, the camera preview frame rate, and the weight of each of the M algorithms is equal to the camera preview frame rate.

[0217] S705: The electronic device sorts the algorithms whose weights are not less than the camera preview frame rate (referred to as multiple first algorithms for short) among the M algorithms according to their weights from large to small.

[0218] In one implementation, when the first image is the current frame, the weight of each of the M algorithms is the initial weight, that is, the camera preview frame rate, and the multiple first algorithms are the M algorithms.

[0219] S706: The electronic device updates the weight of the algorithm whose weight is less than the camera preview frame rate among the M algorithms based on the step size of the algorithm.

[0220] In one implementation, the electronic device may add the weight of an algorithm among the M algorithms whose weight is less than the camera preview frame rate to the step size of the algorithm to obtain a first weight; and update the weight of the algorithm to the first weight.

[0221] In some embodiments, when the weight of an algorithm is less than the camera preview frame rate, the electronic device may determine not to schedule the algorithm when processing the current frame this time. Understandably, since the algorithm is not scheduled this time, the electronic device may increase the weight of the algorithm (i.e., add the step size of the algorithm) to increase the expected degree of scheduling of the algorithm the next time, that is, it may increase the possibility of the algorithm being scheduled next time, avoid the algorithm not being scheduled for a long time, and ensure that the scheduling frame rate of the algorithm is close to the preset frame rate of the algorithm, thereby ensuring the display effect of the image.

[0222] S707: The electronic device sorts the algorithms with the same weight among the multiple first algorithms from large to small according to the preset frame rates.

[0223] It is understandable that the higher the preset frame rate of an algorithm, the greater the number of times the algorithm expects to be scheduled to process image frames. Therefore, when the weights are equal, the algorithm with a higher preset frame rate is given priority. This can improve the frame drop problem caused by restricted scheduling of the algorithm, and maximize the actual scheduling frame rate of the algorithm with a high preset frame rate to be close to its preset frame rate, further taking into account the image effect.

[0224] For example, see Table 3 below, which exemplarily shows the sorting result of the electronic device sorting the M algorithms for the first image. As shown in Table 3, the preset frame rate of the algorithm in the front order is larger, and the preset frame rate of the algorithm in the back order is smaller, and the preset frame rate of each algorithm gradually decreases from front to back (also referred to as from top to bottom).

[0225] S708: The electronic device sorts the algorithms with equal weights and preset frame rates among the multiple first algorithms in ascending order according to CPU performance.

[0226] In the embodiment of the present application, CPU performance may also be referred to as CPU time consumption.

[0227] For example, see Table 3 below, in which algorithms with equal weights and preset frame rates are sorted from small to large according to CPU performance (i.e., CPU time consumption). As shown in Table 3, the preset frame rates of the first five algorithms are all 30, the CPU time consumption of the algorithms ranked in the front is small, and the CPU time consumption of the algorithms ranked in the back is large, and the time consumption of each algorithm gradually increases from front to back (also called from top to bottom).

[0228] S709: The electronic device selects an algorithm that meets the performance requirements of the computing unit according to the ranking to obtain a first set.

[0229] In some embodiments, the electronic device determines the first algorithm in the ranking as the algorithm that meets the performance requirements of the computing unit; and then, sequentially judges the algorithms ranked after the first algorithm. In the embodiments of the present application, the first set may also be referred to as algorithm set α.

[0230] For example, the judgment process for an algorithm may be: adding the CPU time consumption of the algorithm and the algorithms in the current first set, if the added CPU time consumption is less than or equal to the first duration, then adding the algorithm to the first set; if the added CPU time consumption is greater than the first duration, then determining that the algorithm does not meet the performance requirements of the computing unit. Then, the next algorithm of the algorithm is judged until all algorithms are judged or the added CPU time consumption is equal to the first duration.

[0231] For another example, the judgment process for an algorithm may be: adding the CPU time of the algorithm to the algorithms in the current first set, and adding the DSP time of the algorithm to the algorithms in the current first set; if the added CPU time is less than or equal to the first duration and the added DSP time is less than or equal to the second duration, then adding the algorithm to the first set; if the added CPU time is greater than the first duration and / or the added DSP time is greater than the second duration, then determining that the algorithm does not meet the performance requirements of the computing unit. Then, the next algorithm of the algorithm is judged until any one of the following conditions is met: all algorithms are judged, the added CPU time is equal to the first duration, and the added DSP time is equal to the second duration.

[0232] For another example, the judgment process for an algorithm may be: adding the CPU time of the algorithm to the algorithms in the current first set, adding the GPU time of the algorithm to the algorithms in the current first set, if the added CPU time is less than or equal to the first duration and the added GPU time is less than or equal to the third duration, then adding the algorithm to the first set; if the added CPU time is greater than the first duration and / or the added GPU time is greater than the third duration, then determining that the algorithm does not meet the performance requirements of the computing unit. Then, the next algorithm of the algorithm is judged until any one of the following conditions is met: all algorithms are judged, the added CPU time is equal to the first duration, and the added GPU time is equal to the third duration.

[0233] For another example, the judgment process for an algorithm may be: adding the CPU time of the algorithm to the algorithms in the current first set, adding the GPU time of the algorithm to the algorithms in the current first set, and adding the DSP time of the algorithm to the algorithms in the current first set; if the added CPU time, the added GPU time, and the added DSP time meet the preset conditions, wherein the preset conditions are that the added CPU time is less than or equal to the first duration, the added GPU time is less than or equal to the third duration, and the added DSP time is less than or equal to the second duration, then the algorithm is added to the first set; if any one of the added CPU time, the added GPU time, and the added DSP time does not meet the preset conditions, then it is determined that the algorithm does not meet the performance requirements of the computing unit. Then, the next algorithm of the algorithm is judged until any one of the following conditions is met: all algorithms are judged, the added CPU time is equal to the first duration, the added GPU time is equal to the third duration, and the added DSP time is equal to the second duration.

[0234] S710: The electronic device determines whether each algorithm among a plurality of first algorithms belongs to a first set.

[0235] In one implementation, the electronic device updates the weight of each first algorithm based on whether each algorithm among the multiple first algorithms belongs to the first set.

[0236] S711: The electronic device resets the weights of the algorithms belonging to the first set among the plurality of first algorithms to the camera preview frame rate.

[0237] Exemplarily, when the current frame is the first image, the weights of the algorithms in the first set are the camera preview frame rate, so the electronic device may not change the weights of the algorithms in the first set; when the current frame is not the first image, the electronic device may reset the weights of the algorithms belonging to the first set among multiple first algorithms to the camera preview frame rate.

[0238] S712: The electronic device updates an algorithm that does not belong to the first set among the multiple first algorithms based on a step size corresponding to the algorithm.

[0239] In one implementation, the electronic device may add the weight of the algorithm to the step size of the algorithm to obtain a first weight; and update the weight of the algorithm to the first weight.

[0240] In some embodiments, when the weight of an algorithm is less than the camera preview frame rate, the electronic device may determine not to schedule the algorithm when processing the current frame this time. Understandably, since the algorithm is not scheduled this time, the electronic device may increase the weight of the algorithm (i.e., add the step size of the algorithm) to increase the expected degree of scheduling of the algorithm the next time, that is, it may increase the possibility of the algorithm being scheduled next time, avoid the algorithm not being scheduled for a long time, and ensure that the scheduling frame rate of the algorithm is close to the preset frame rate of the algorithm, thereby ensuring the display effect of the image.

[0241] S713: The electronic device determines the algorithms of the first set as the algorithms scheduled to process the current frame.

[0242] Exemplarily, the electronic device may generate an intelligent scheduling strategy based on the first set, and the intelligent scheduling strategy may include an identifier of each algorithm among M algorithms, wherein the identifier of the algorithm among the M algorithms that belongs to the first set is used to indicate scheduling; and the identifier of the algorithm among the M algorithms that does not belong to the first set is used to indicate non-scheduling.

[0243] S714: The electronic device waits for the next frame of the first video stream, takes the next frame as the current frame, and then executes part or all of the above steps S703 to S713.

[0244] In some embodiments, after executing S714, the algorithm scheduling module of the electronic device may wait for an algorithm scheduling request for the next frame image of the first video stream; upon receiving the algorithm scheduling request, the frame image is used as the current frame to execute part or all of the above steps S703 to S713.

[0245] In the embodiment of the present application, when the algorithm scheduling module of the electronic device receives the algorithm scheduling request for the current frame of the video stream, it can obtain the historical time consumption of the corresponding processors of the M algorithms during the recent multiple schedulings; based on the historical time consumption, predict the current algorithm performance of the M algorithms; when sorting the M algorithms, first sort them according to the weight of each algorithm; then, according to the sorted order and the current algorithm performance of the M algorithms, select the algorithm that meets the current performance limit requirements as the algorithm to be scheduled this time. This method takes into account the parallel problem of multiple algorithms deployed on different computing units, and intelligently schedules the algorithms from three dimensions: the preset frame rate of the algorithm, the deployment of the computing unit, and the algorithm performance.

[0246] For example, the above-mentioned Figures 5 to 7 The method shown corresponds to a specific embodiment.

[0247] It should be understood that the specific data of algorithm performance, algorithm deployment and hardware performance overhead shown in Tables 2 to 4 are only for illustrative purposes of this solution and are not actual data. The units of the following preset frame rates and weights may be fps. For the convenience of description, the units of the preset frame rates and weights are not shown below.

[0248] In the embodiment of the present application, the performance requirement of the algorithm unit is exemplarily set to: the sum of the CPU time consumption, the sum of the GPU time consumption, and the sum of the DSP time consumption of the scheduling algorithm for each frame of the video stream is no more than 10ms. That is, the first duration, the second duration, and the third duration in the above text are all set to 10ms.

[0249] Table 2

[0250]

[0251] Table 2 exemplifies the deployment locations, preset frame rates, and algorithm performance of M algorithms (the first 6 columns from left to right in Table 2); as well as the algorithm decision results of 10 frames of images in the first video stream determined by an embodiment of the present application and the predicted total time consumed by each hardware when executing based on the algorithm decision results (the last 10 columns from left to right in Table 2).

[0252] Table 2 exemplarily shows that the M algorithms are the 10 algorithms in Table 2, namely A1, A2, A3, B1, B2, B3, C, D1, D2, and D3. Among them, A1 to A3 are deployed on the CPU, B1 to B3 are deployed on the CPU and DSP, D1 to D3 are deployed on the GPU, and C is deployed on the CPU&DSP&GPU.

[0253] Among them, the preset frame rate column exemplifies the preset frame rate of each algorithm, and the three time consumption columns (CPU time consumption, DSP time consumption and GPU time consumption) exemplify the performance overhead (ms) of scheduling each algorithm once on each hardware.

[0254] Among them, the columns numbered 0-9 in Table 2 are used to indicate the scheduling of the 0th to 9th frames in the first video stream, wherein a check mark indicates that the frame schedules the algorithm of the column. For example, the embodiment of the present application exemplarily shows that the N algorithms for the 0th frame determined by the algorithm scheduling method of the embodiment of the present application are A2, A3, B3 and D2 respectively. Among them, the 0th frame is the above-mentioned first image.

[0255] The last three rows from top to bottom in Table 2 are used to identify the performance overhead of all scheduling algorithms corresponding to frames 0-9 on various hardware. Table 2 exemplarily shows that the performance overhead of each hardware is limited to within 10 ms.

[0256] The above algorithm scheduling method is exemplarily introduced below through Tables 3 to 5.

[0257] Table 3 exemplarily shows the sorting results of M algorithms sorted by the electronic device for the 0th frame image using the algorithm scheduling method provided by the present application.

[0258] Table 3

[0259]

[0260] As shown in Table 3, since the 0th frame is the first image mentioned above, the electronic device initializes the weight of each algorithm to the camera preview frame rate before sorting the first image. Table 3 exemplarily shows that the camera preview frame rate is 30, and the weights of all algorithms are equal for the first image.

[0261] As shown in the fourth column of Table 3, the algorithms in Table 3 are sorted according to the preset frame rates. It can be seen that the preset frame rates of D2, A3, A2, B3 and C are the largest among all algorithms, all 30, so D2, A3, A2, B3 and C are ranked in the front, and the other algorithms are ranked in order according to the frame rate.

[0262] As can be seen from the second and fourth columns of Table 3, the algorithms with the same preset frame rate in Table 3 are arranged according to the CPU time consumption.

[0263] The following describes the process of determining the scheduling algorithm for frame 0 based on the algorithm sorting results for frame 0. First, the electronic device determines that the CPU time of D2, A3, A2, and B3 of the first four algorithms in Table 3 is equal to 10ms, and the DSP time and GPU time of these four algorithms do not exceed 10ms, then the electronic device determines D2, A3, A2, and B3 as the scheduling algorithms for the frame 0 image.

[0264] Table 4

[0265]

[0266] In one implementation, after the electronic device determines that the scheduling algorithm for the 0th frame image is D2, A3, A2, and B3, the weight of the unscheduled algorithm can be added to the step size of the algorithm (i.e., the preset frame rate of the algorithm), and the weight of the scheduling algorithm remains unchanged. For example, if the step size of C is 30, the updated weight of C is 60, which is the initial weight 30 plus the step size 30.

[0267] Optionally, the electronic device may also update the CPU time, DSP time and GPU time based on the execution status of frame 0. That is, the average of the historical time taken by each hardware to execute the scheduling algorithm on frame 0 and the historical time taken to execute the scheduling algorithm on 29 frames before frame 0 is calculated to obtain the updated CPU time, DSP time and GPU time.

[0268] Then, the electronic device re-sorts all algorithms based on the updated weights, preset frame rates and updated CPU time consumption, and Table 4 can be obtained.

[0269] The following describes the process of determining the scheduling algorithm for the first frame based on the algorithm ranking result for the first frame in conjunction with Table 4.

[0270] First, when the electronic device determines that the sum of the CPU times of the first three algorithms C, D1 and A1 in Table 3 is not greater than 10ms (i.e., 5+1+2=8<10) and the sum of the CPU times of the first four algorithms C, D1, A1 and B2 is greater than 10ms (i.e., 5+1+2+6=14>10), the electronic device traverses downward from the fifth algorithm until it finds that the sum of the CPU times of A3 and the first three algorithms is equal to 10ms and the DSP times and GPU times of these four algorithms are less than 10ms, then the electronic device determines that C, D1, A1 and A3 are the scheduling algorithms for the 0th frame image.

[0271] Table 5

[0272]

[0273] In one implementation, after the electronic device determines that the scheduling algorithm for the first frame of the image is C, D1, A1, and A3, the weight of the unscheduled algorithm can be added to the step size of the algorithm (i.e., the preset frame rate of the algorithm), and the weight of the scheduling algorithm can be reset to the initial weight (i.e., the camera preview frame rate). For example, the weight of C in Table 4 (for the first frame) is 60. Since C is determined to be the scheduling algorithm for the first frame, the weight of C is reset from 60 to 30 in Table 5.

[0274] Optionally, the electronic device may also update the CPU time, DSP time and GPU time based on the execution of the first frame. That is, the historical time taken by each hardware to execute the scheduling algorithm for the first frame and the average of the historical time taken to execute the scheduling algorithm for the 29 frames before the first frame (including the 0th frame) are calculated to obtain the updated CPU time, DSP time and GPU time.

[0275] Then, the electronic device re-sorts all algorithms based on the updated weights, preset frame rates and updated CPU time consumption, and Table 5 can be obtained.

[0276] The following describes the process of determining the scheduling algorithm for the second frame based on the algorithm ranking result of the second frame in conjunction with Table 5.

[0277] First, when the electronic device determines that the sum of the CPU time consumption of the first three algorithms D2, A2, and B3 in Table 5 is not greater than 10ms (i.e., 1+3+4=8<10) and the sum of the CPU time consumption of the first four algorithms D2, A2, B3, and B2 is greater than 10ms (i.e., 1+3+4+6=14>10), the electronic device traverses downward from the fifth algorithm until it finds that the sum of the CPU time consumption of A3 and the first three algorithms is equal to 10ms and the DSP time consumption and GPU time consumption of these four algorithms are less than 10ms, then the electronic device determines that D2, A2, B3, and A3 are the scheduling algorithms for the first frame of the image. As shown in Table 2, algorithms D2, A2, B3, and A3 in the column numbered 2 of Table 2 are checked.

[0278] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0279] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0280] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0281] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An algorithm scheduling method, It is characterized in that The method comprises: The electronic device acquires a video stream, wherein the video stream includes at least two images; the target image is one of the at least two images; The electronic device determines, for the target image, N algorithms from the M algorithms based on a first time consumption of each of the M algorithms; Wherein, M is an integer greater than 1, and N is less than M; the first time consumption of each of the M algorithms is obtained based on the historical time consumption of the central processor of the electronic device executing each of the algorithms; the sum of the first time consumptions of the N algorithms is not greater than the first duration, and the N algorithms are scheduled to process the target image; The N algorithms include the first j algorithms in the first sequence, the sum of the first time consumptions of the first j algorithms is equal to or less than the first duration, the sum of the first time consumptions of the first j+1 algorithms in the first sequence is greater than the first duration, and the algorithms in the first sequence are sorted from large to small according to the current weight of each algorithm in the M algorithms.

2. The method according to claim 1, It is characterized in that The N algorithms include a first algorithm; before determining the N algorithms from the M algorithms, the method further includes: The electronic device obtains the time consumed by the central processor for executing the first algorithm for the last L times, and obtains L historical time consumed by the first algorithm; L is an integer greater than 1; The electronic device determines an average of L historical time consumptions of the first algorithm as a first time consumption of the first algorithm.

3. The method according to claim 1 or 2, It is characterized in that When the occupancy rate of the central processing unit is higher than a first threshold, the first duration is a first value; when the occupancy rate of the central processing unit is not higher than the first threshold, the first duration is a second value, and the first value is smaller than the second value.

4. The method according to claim 1 or 2, It is characterized in that The N algorithms include Q second algorithms, where Q is a positive integer; the second algorithms are also executed by the digital signal processor of the electronic device when scheduled; The sum of the second time consumptions of the Q second algorithms is not greater than the second duration; the second time consumption of each of the Q second algorithms is obtained based on the historical time consumption of the digital signal processor executing each of the second algorithms.

5. The method according to claim 4, It is characterized in that When the occupancy rate of the digital signal processor is higher than the second threshold, the second duration is a third value; when the occupancy rate of the digital signal processor is not higher than the second threshold, the second duration is a fourth value, and the third value is smaller than the fourth value.

6. The method according to any one of claims 1, 2 and 5, It is characterized in that The N algorithms include W third algorithms, where W is a positive integer; the third algorithms are also executed by the image processor of the electronic device when scheduled; The sum of the third time consumptions of the W third algorithms is not greater than the third duration; the third time consumption of each of the W third algorithms is obtained based on the historical time consumption of the image processor executing each of the third algorithms.

7. The method according to claim 6, It is characterized in that When the occupancy rate of the image processor is higher than a third threshold, the third duration is a fifth value; when the occupancy rate of the image processor is not higher than the third threshold, the third duration is a sixth value; and the fifth value is smaller than the sixth value.

8. The method according to claim 1, It is characterized in that The determining of N algorithms from the M algorithms comprises: The electronic device sorts the M algorithms to obtain a first sequence; When the sum of the first time consumptions of the first j algorithms in the first sequence is equal to the first duration, the electronic device determines the first j algorithms as the N algorithms; When the sum of the first time consumptions of the first j algorithms in the first sequence is not greater than the first duration and the sum of the first time consumptions of the first j+1 algorithms is greater than the first duration, the sum of the first time consumptions of the algorithms ordered after the j+1th algorithm and the first j algorithms is compared with the first duration, and at least one algorithm is determined from the algorithms ordered after the j+1th algorithm, and the sum of the first time consumptions of the at least one algorithm and the first j algorithms is not greater than the first duration; j is an integer greater than 0 and less than M, and the N algorithms include the first j algorithms and the at least one algorithm.

9. The method according to claim 8, It is characterized in that The algorithms with equal current weights in the first sequence are sorted from large to small according to the preset frame rate, and the algorithms with equal current weights and preset frame rates in the first sequence are sorted from small to large according to the first time consumption.

10. The method according to claim 8 or 9, It is characterized in that The current weight of each of the M algorithms is determined by a preset frame rate of each algorithm, a preview frame rate of the video stream, and a number of times each algorithm is scheduled; the number of times each algorithm is scheduled is the number of times each algorithm is scheduled before processing the target image in the video stream; The current weight of each algorithm is used to indicate the expected degree of each algorithm being currently scheduled, and the weight of each algorithm is directly proportional to the expected degree of each algorithm being scheduled.

11. An electronic device, It is characterized in that The electronic device includes: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 10.

12. A chip system, It is characterized in that The chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-11.

13. A computer program product comprising instructions, It is characterized in that When the computer program product is executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 10.

14. A computer-readable storage medium comprising instructions, It is characterized in that When the instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 10.