Image detection method, device and electronic equipment
By detecting the light source and foreground area of the mobile terminal device, the problem of image blur under backlight conditions is solved, the image clarity under backlight conditions is improved, and the accuracy of facial skin condition evaluation is improved.
Patent Information
- Application Number
- CN201911159693.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2039-11-22
AI Technical Summary
Existing mobile terminal devices cannot effectively detect whether there is blur in images taken under backlight conditions, resulting in poor clarity of the captured images.
By detecting the light source area and foreground area of the image to be detected, the impact of the light source on the image clarity is determined, the light source area is determined based on color space conversion and threshold segmentation methods, and the degree of blur is determined in combination with foreground target detection to determine whether the image is blurred, thereby Switch shooting modes to improve image clarity.
It effectively detects and solves the image blur problem under backlight conditions, improving the clarity of the image. Especially when shooting in Torch mode, it can switch to Flash mode to reduce blur and improve the accuracy of facial skin condition evaluation.
Smart Images

Figure CN112950525B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of electronic technology, and in particular, relates to an image detection method, device and electronic device based on an artificial intelligence (AI) terminal. Background Art
[0002] When taking pictures, existing mobile terminals (such as mobile phones, tablets, and cameras) can only detect whether there is a backlight source during the shooting process, but cannot detect whether the captured image is backlight blurred. Summary of the invention
[0003] The embodiments of the present application provide an image detection method, device and electronic device based on an artificial intelligence terminal, which can effectively detect whether an image taken under backlight conditions is blurred.
[0004] In a first aspect, an embodiment of the present application provides an image detection method, comprising:
[0005] Acquire the image to be detected;
[0006] Determining a light source area of the image to be detected and a foreground area of the image to be detected;
[0007] The blur degree of the image to be detected is determined based on the light source area and the foreground area.
[0008] In the first aspect, the influence of the light source on the clarity of the image to be detected is determined by performing light source area detection and foreground area detection on the image to be detected, thereby effectively detecting whether the image taken under backlight conditions is blurred.
[0009] In a possible implementation manner of the first aspect, determining the light source area of the image to be detected includes:
[0010] Performing color space conversion on the image to be detected, and obtaining the brightness value of each pixel of the image after the color space conversion;
[0011] The region of pixels whose brightness values are greater than a preset brightness threshold is determined as the light source region of the image to be detected.
[0012] Exemplarily, the image to be detected is converted into an HSV (Hue, Saturation, Value) color space or a LAB (CIELab color model) color space through color space conversion.
[0013] It should be understood that the image to be detected may also be converted into other color spaces to determine the brightness value of each pixel of the image to be detected.
[0014] By converting the image to be detected into a color space to determine the brightness of each pixel, the light source area of the image to be detected can be determined based on the threshold segmentation method. The light source area can be determined accurately and quickly, thereby improving the efficiency of image detection.
[0015] In a possible implementation manner of the first aspect, determining the foreground area of the image to be detected includes:
[0016] Detecting a foreground object of the image to be detected;
[0017] The position of the foreground object in the image to be detected is determined, and the position of the foreground object in the image to be detected is determined as the foreground area of the image to be detected.
[0018] It should be understood that the foreground target may refer to a target with dynamic features in the image to be detected, such as a person or an animal; the foreground target may also refer to a scene that is close to the viewer and has static features, such as flowers or food.
[0019] In a possible implementation manner of the first aspect, determining the blur degree of the image to be detected based on the light source area and the foreground area includes:
[0020] The blur degree of the image to be detected is determined based on the number of all pixel points in the light source area and the number of all pixel points in the foreground area.
[0021] In combination with the above possible implementation manner, determining the blur degree of the image to be detected based on the number of all pixels in the light source area and the number of all pixels in the foreground area includes:
[0022] Determine whether a function value of an increasing function of a ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold;
[0023] If the function value of the increasing function of the ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold, it is determined that the image to be detected is a blurred image.
[0024] In a possible implementation manner of the first aspect, determining the blur degree of the image to be detected based on the light source area and the foreground area includes:
[0025] The blur degree of the image to be detected is determined based on the number of all pixel points in the light source area and the area of the foreground area.
[0026] In a possible implementation manner of the first aspect, acquiring the image to be detected includes:
[0027] In the first shooting mode, obtaining a preview frame image;
[0028] Correspondingly, determining the blur degree of the image to be detected based on the light source area and the foreground area includes:
[0029] If the preview frame image is determined to be a blurred image based on the light source area and the foreground area, the current shooting mode is switched from the first shooting mode to the second shooting mode, wherein the first shooting mode and the second shooting mode are different shooting modes.
[0030] Exemplarily, the first shooting mode is Torch mode, and the second shooting mode is Flash mode. The current shooting mode is switched from the first shooting mode to the second shooting mode, specifically: the electronic device sends a control instruction to the flash module of the electronic device to switch the flash from a constant light mode to a mode that flashes once during shooting.
[0031] In a second aspect, an embodiment of the present application provides an image detection device, including:
[0032] An image acquisition module, used for acquiring an image to be detected;
[0033] A first determination module, used to determine the light source area of the image to be detected and the foreground area of the image to be detected;
[0034] The second determination module is used to determine the blur degree of the image based on the light source area and the foreground area.
[0035] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image detection method described in the first aspect when executing the computer program.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image detection method described in the first aspect are implemented.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the image detection method described in any one of the above-mentioned first aspects.
[0038] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0039] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by performing light source area detection and foreground area detection on the image to be detected, the influence of the light source on the clarity of the image to be detected is determined, thereby effectively detecting whether the image taken under backlight conditions is blurred. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0041] Figure 1a It is a schematic diagram of an image captured by an existing electronic device based on the Torch mode without a backlight source;
[0042] Figure 1b It is a schematic diagram of an image obtained by shooting with an existing electronic device in Flash mode under the backlight light source condition where the light intensity of the backlight light source is 23 lux and the light intensity area is 50%;
[0043] Figure 1c It is a schematic diagram of an image captured by an existing electronic device based on the Torch mode without a backlight source;
[0044] Figure 1d It is a schematic diagram of an image obtained by shooting with an existing electronic device in Flash mode under the backlight light source condition where the light intensity of the backlight light source is 23 lux and the light intensity area is 50%;
[0045] Figure 2 is a schematic diagram of the structure of an electronic device to which the image detection method provided in one embodiment of the present application is applicable;
[0046] Figure 3 It is a schematic diagram of the software architecture of an electronic device to which the image detection method provided in one embodiment of the present application is applicable;
[0047] Figure 4a is a set of display interface schematic diagrams provided in an embodiment of the present application;
[0048] Figure 4b is another set of display interface schematic diagrams provided in an embodiment of the present application;
[0049] Figure 5 is a flowchart of an image detection method provided by an embodiment of the present application;
[0050] Figure 6aIt is a schematic diagram of the image to be detected in the current color space;
[0051] Figure 6b It is a schematic diagram of an image after light source segmentation is performed on the image to be detected;
[0052] Figure 7 is a schematic diagram of a prospect target provided by an embodiment of the present application;
[0053] Figure 8a is a schematic diagram of an image in which a foreground object provided by the present application is a foam box;
[0054] Figure 8b is a schematic diagram of another foreground object provided by the present application, which is a foam box;
[0055] Fig. 9 is an image schematic diagram of an image to be detected in the image detection method provided in an embodiment of the present application;
[0056] Fig.10 is a schematic diagram of the structure of an image detection device provided in an embodiment of the present application;
[0057] Fig.11 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0059] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0060] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0061] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0062] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0063] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0064] It should be noted that the backlight referred to in this application refers to the situation where the subject is located between the light source and the camera (camera), which can easily cause the subject to be underexposed, resulting in the captured image not being able to clearly reflect facial skin details, such as fine lines, nasolabial folds, dark circles, red areas, acne, pores, spots, blackheads and other detailed features. Images captured in different shooting modes will show different levels of clarity due to the presence of backlight sources. The above-mentioned shooting modes include a first shooting mode (Torch mode) in which the flash is always on and a second shooting mode (Flash mode) in which the flash is turned off during shooting. Figure 1a and Figure 1c These are images captured by existing electronic devices in the absence of backlight source based on Torch mode and Flash mode respectively; Figure 1b and Figure 1d These are images taken by existing electronic devices under the same light intensity (23 Lux) and the same light intensity area (50%) backlight conditions based on Torch mode and Flash mode. Figure 1a and Figure 1cIt can be seen that in the absence of backlight, both Torch mode and Flash mode can capture the details (acne) clearly. Figure 1c and Figure 1d It can be seen that the presence of backlight has little effect on the image taken in Flash mode, and the details (acne) can still be captured. Figure 1a and Figure 1b It can be seen that the presence of a backlight source has a significant effect on the clarity of the image captured in Torch mode, which will cause the detailed features (acne) to be blurred. Therefore, the image detection method of the embodiment of the present application is mainly used to detect the image captured in Torch mode, and can switch the current shooting mode from the above-mentioned Torch mode to the Flash mode when it is detected that the image to be detected is a blurred image. In practical applications, the light intensity of 23Lux and the light source area of 25% are determined as the critical value of whether the image captured based on Torch mode is blurred by shooting based on different light intensities and different light source areas through dichotomy. Among them, the light source area is the most important factor affecting whether the foreground is blurred. For the same foreground (the same face in different photos can be approximately regarded as the same foreground), the larger the light source area, the greater the impact on the clarity of the foreground. If the foreground is large enough and the light source area is small enough, the impact of the light source area on the clarity of the foreground can also be ignored. Therefore, the important parameter for detecting whether the feature details of the image to be detected are blurred is the relationship between the light source area and the foreground area. Based on the detection of the light source area and the detection of the foreground area, it is possible to determine whether the image to be detected has a backlight blur problem. If it is detected that the image to be detected has a backlight blur problem, the image will not be used as the object of facial skin condition evaluation, thereby improving the accuracy of facial skin condition evaluation. It should be noted that the foreground refers to a person or object in front of the subject or close to the front in the lens. The foreground in the embodiments of the present application can include various types of objects, such as people, vehicles, plants, animals, buildings, ground, sky, tables, chairs, door frames and other items.
[0065] The image detection method provided in the embodiments of the present application can be applied to terminal devices such as electronic devices, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific types of terminal devices.
[0066] As an example but not limitation, when the electronic device is a wearable device, the wearable device can also be a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not just hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include devices that are fully functional, large in size, and can achieve complete or partial functions without relying on smart electronic devices, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smart electronic devices, such as various types of smart bracelets and smart jewelry for vital sign monitoring.
[0067] Figure 2 What is shown is a block diagram of a partial structure of an electronic device provided in an embodiment of the present application. Referring to FIG2 , the electronic device includes: a radio frequency (RF) circuit 110, a memory 120, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a wireless fidelity (WiFi) module 170, a processor 180, a power supply 190, and a camera 191 and other components. Those skilled in the art will appreciate that the electronic device structure shown in FIG1 does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0068] Combine the following Figure 2 A detailed introduction to the various components of electronic equipment:
[0069] The RF circuit 110 can be used for receiving and sending signals during information transmission or calls, in particular, after receiving the downlink information of the base station, it is sent to the processor 180 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 110 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE)), email, Short Messaging Service (SMS), etc.
[0070] The memory 120 can be used to store software programs and modules. The processor 180 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area, wherein 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 according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 120 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, or other volatile solid-state storage devices.
[0071] The input unit 130 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the electronic device 100. Specifically, the input unit 130 may include a touch panel 131 and other input devices 132. The touch panel 131, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 131 or near the touch panel 131 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 131 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, and converts it into the touch point coordinates, and then sends it to the processor 180, and can receive and execute the command sent by the processor 180. In addition, the touch panel 131 can be implemented in various types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch panel 131, the input unit 130 may also include other input devices 132. Specifically, other input devices 132 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0072] The display unit 140 can be used to display information input by the user or information provided to the user and various menus of the electronic device. The display unit 140 may include a display panel 141, and optionally, the display panel 141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 131 may cover the display panel 141, and when the touch panel 131 detects a touch operation on or near it, it is transmitted to the processor 180 to determine the type of touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of touch event. Although in Figure 1, the touch panel 131 and the display panel 141 are used as two independent components to realize the input and output functions of the electronic device, in some embodiments, the touch panel 131 and the display panel 141 can be integrated to realize the input and output functions of the electronic device.
[0073] The electronic device 100 may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 141 and / or the backlight when the electronic device is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the electronic device, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0074] The audio circuit 160, the speaker 161, and the microphone 162 can provide an audio interface between the user and the electronic device. The audio circuit 160 can transmit the received audio data to the speaker 161 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, and then the audio data is output to the processor 180 for processing, and then sent to another electronic device through the RF circuit 110, or the audio data is output to the memory 120 for further processing.
[0075] WiFi is a short-range wireless transmission technology. The electronic device can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 170, which provides users with wireless broadband Internet access. Although FIG. 1 shows the WiFi module 170, it is understandable that it is not a necessary component of the electronic device 100 and can be omitted as needed without changing the essence of the invention.
[0076] The processor 180 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, so as to monitor the electronic device as a whole. Optionally, the processor 180 may include one or more processing units; preferably, the processor 180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 180.
[0077] The electronic device 100 further includes a power source 190 (eg, a battery) for supplying power to various components. Preferably, the power source may be logically connected to the processor 180 via a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0078] The electronic device 100 may also include a camera 191. The camera 191 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 may 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 for conversion 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. Optionally, the position of the camera on the electronic device 100 may be front-mounted or rear-mounted, which is not limited in the embodiments of the present application.
[0079] Optionally, the electronic device 100 may include a single camera, a dual camera, or a triple camera, etc., which is not limited in the embodiments of the present application.
[0080] For example, the electronic device 100 may include three cameras, one of which is a main camera, one is a wide-angle camera, and one is a telephoto camera.
[0081] Optionally, when the electronic device 100 includes multiple cameras, all of the multiple cameras may be front-mounted, or all of the cameras may be rear-mounted, or some of the cameras may be front-mounted and others may be rear-mounted, which is not limited in the embodiments of the present application.
[0082] In addition, although not shown, the electronic device 100 may further include a flash module, etc., which will not be described in detail here.
[0083] In addition, although not shown, the electronic device 100 may also include a Bluetooth module, etc., which will not be described in detail here.
[0084] In addition, although not shown, the electronic device 100 may also include a neural network (NN) computing processor (NPU), which can quickly process input information and continuously self-learn by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. The NPU can realize applications such as intelligent cognition of the electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0085] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture or a cloud architecture. Figure 3 1 is a schematic diagram of the software structure of the electronic device 100 of the embodiment of the present application. Taking the operating system of the electronic device 100 as an example, in some embodiments, the Android system is divided into four layers, namely, the application layer, the application framework layer (framework, FWK), the system layer and the hardware abstraction layer, and the layers communicate with each other through software interfaces.
[0086] like Figure 3 As shown, the application layer can be a series of application packages, and the application packages can include short message, calendar, camera, video, navigation, gallery, call and other applications.
[0087] The application framework layer provides an application programming interface (API) and a programming framework for the application programs of the application layer. The application framework layer may include some predefined functions, such as a function for receiving events sent by the application framework layer.
[0088] like Figure 3 As shown, the application framework layer may include a window manager, a resource manager, a notification manager, and the like.
[0089] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0090] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0091] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0092] The application framework layer may also include:
[0093] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures.
[0094] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0095] The system layer may include multiple functional modules, such as sensor service module, physical state recognition module, 3D graphics processing library (such as OpenGL ES), etc.
[0096] The sensor service module is used to monitor the sensor data uploaded by various sensors at the hardware layer and determine the physical state of the electronic device 100;
[0097] Physical state recognition module, used to analyze and recognize user gestures, faces, etc.;
[0098] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0099] The system layer may also include:
[0100] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0101] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0102] The hardware abstraction layer is a layer between hardware and software. The hardware abstraction layer can include display drivers, camera drivers, sensor drivers, etc., which are used to drive related hardware of the hardware layer, such as display screens, cameras, sensors, etc.
[0103] The system layer may also include an image processing library. After starting the camera application, the camera application can obtain the image to be detected captured by the camera of the electronic device. Based on the image to be detected, light source area detection and foreground area detection are performed to determine the influence of the light source on the clarity of the image to be detected, and then determine whether the image to be detected has a backlight blur problem.
[0104] The following embodiments can be implemented on the electronic device 100 having the above hardware structure / software structure. The following embodiments will take the electronic device 100 as an example to illustrate the image detection method provided by the embodiments of the present application.
[0105] Figure 4a It shows that Figure 2 , Figure 3 A graphical user interface (GUI) of an electronic device (such as a mobile phone) is shown. The GUI may be a desktop 401 of the electronic device. When the electronic device detects that a user clicks an icon 402 of a facial skin condition evaluation application (Application, APP) on the desktop 401, the facial skin condition evaluation application may be started. Figure 4b Another GUI is shown, which can be called a processing interface 403 of a facial skin condition evaluation APP. When the electronic device detects that the user clicks on an icon 404 for obtaining photos on the processing interface 403, the electronic device can open an album, and the user selects a picture from the album and loads it into an image frame 405. Alternatively, when the user clicks on the icon 404, the camera is started and the user shoots in the first shooting mode, and then the shot image is loaded into the image frame 405. A preview screen in the first shooting mode after the camera is started can also be displayed in the image frame 405.
[0106] After the image to be detected is loaded into the image frame 405 , the electronic device can automatically start to detect the image to be detected in the image frame 405 to detect whether the image to be detected is blurred.
[0107] In a possible implementation, the processing interface 403 includes a first control for instructing blur detection. When the electronic device 100 detects that the user clicks the first control, the electronic device detects the image to be detected in the image frame 405 to detect whether the image to be detected is blurred. Specifically, the light source area of the image to be detected and the foreground area of the image to be detected can be determined, and the blur degree of the image can be determined based on the light source area and the foreground area, and whether the image is blurred can be determined based on the blur degree of the image.
[0108] Specifically, when performing blur detection, the electronic device 100 determines the light source area by converting the color space of the image to be detected to obtain the brightness value of each pixel in the image after color space conversion, and determines the number of pixels exceeding the preset brightness threshold after comparing the brightness value of each pixel with the preset brightness threshold. Then, the foreground target of the image to be detected is determined by the feature point detection method, and the foreground area is determined by determining the position of the foreground target in the image to be detected. The blur degree of the image to be detected is calculated based on the number of all pixels in the light source area and the number of all pixels in the foreground area, and the blur degree of the image to be detected is compared with the preset threshold. If the blur degree of the image is greater than or equal to the preset threshold, it is determined that the image to be detected has a backlight blur problem; if the blur degree of the image is less than the preset threshold, it is determined that the image to be detected does not have a backlight blur problem.
[0109] If it is detected that the image shot under the backlight condition or a frame of the preview screen under the backlight condition is blurred, the current shooting mode is switched from the first shooting mode to the second shooting mode, wherein the first shooting mode and the second shooting mode are different shooting modes. Or if it is detected that the image to be detected obtained from the album is blurred under the condition, the user is prompted to select another image or retake an image.
[0110] See also Figure 5 , Figure 5 is a schematic implementation flow chart of the image detection method provided in the embodiment of the present application, and the method can be used in Figure 2 , Figure 3 The electronic device (such as a mobile phone, tablet computer, etc.) shown in the figure is implemented. Figure 5 As shown, the method may include the following steps:
[0111] S101: Acquire an image to be detected.
[0112] The image to be detected may be a currently captured image, or a frame of image in a preview screen after starting the camera, or an image in an album, etc.
[0113] For example, when a user clicks Figure 4bAfter the icon 404 is shown, the electronic device will open the photo album for the user to select the photos that have been taken to obtain the image to be detected, and the obtained image to be detected can be loaded into the image frame 405; or when the user clicks the icon 404, the camera is started and in the first shooting mode, the image is shot by the camera to obtain the image to be detected, and then the shot image to be detected is loaded into the image frame 405, and the preview picture in the first shooting mode after starting the camera can be displayed in the image frame 405, and a frame image of the preview picture is used as the image to be detected.
[0114] Specifically, in order to evaluate the facial skin condition, the acquired image should include a face image. After acquiring an image including a face image, a portion of the image including only the face image can be captured as the image to be detected. That is, the image to be detected acquired in this embodiment may refer to an image to be detected including a face image.
[0115] S102: Determine the light source area of the image to be detected and the foreground area of the image to be detected.
[0116] Specifically, the light source area of the image to be detected is determined by performing light source area detection on the image to be detected. The brightness of all pixels in the image after color space conversion is determined after the image to be detected is converted into a color space, and the light source area is determined based on the brightness of all pixels. The image after color space conversion is then converted back to the original color space, and the foreground target of the image to be detected is detected based on the feature point detection mode, and the position of the foreground target in the image to be detected is determined, so as to determine the foreground area.
[0117] Exemplarily, when the electronic device 100 detects that the image to be detected has been loaded into the image frame 405 , it will automatically perform blur detection on the image to be detected loaded in the image frame 405 .
[0118] Exemplarily, when the user clicks the first control, blur detection can be triggered for the image to be detected loaded in the image frame 405, and the electronic device 100 will perform light source area detection on the image to be detected to determine the light source area. The light source area detection can be performed by converting the image into a color space to obtain the brightness value of each pixel, and determining the light source area based on a threshold segmentation method, and then converting the image that has undergone color space conversion back to the original color space, detecting the foreground target of the image to be detected based on a feature point detection mode, and determining the position of the foreground target in the image to be detected, so as to determine the foreground area.
[0119] In one embodiment, the above-mentioned determining the light source area of the image to be detected includes:
[0120] Performing color space conversion on the image to be detected, and obtaining the brightness value of each pixel of the image after the color space conversion;
[0121] The region of pixels whose brightness values are greater than a preset brightness threshold is determined as the light source region of the image to be detected.
[0122] Specifically, based on the brightness value of each pixel of the image to be detected, the light source area can be determined by using the threshold segmentation method. First, the image is converted into the HSV (Hue, Saturation, Value) color space or the LAB (CIELab color model) color space by color space conversion, and the brightness value of each pixel in the image can be obtained. It is understandable that the image can also be converted into other color spaces to determine the brightness value of each pixel of the image, which is not limited here.
[0123] Specifically, if the image is converted to the HSV color space, the V value of each pixel is the brightness value of the pixel; if the image is converted to the LAB color space, the L value of each pixel is the brightness value of the pixel. It should be noted that the above brightness value can also be a monotonically increasing / decreasing mathematical transformation of the original brightness value, such as L'=2L.
[0124] Specifically, the preset brightness threshold can be determined based on viewing the segmented light source image through the mask generation method. Figure 6a and Figure 6b , as shown Figure 6a is the image in the current color space; Figure 6b The image after light source segmentation is performed. The brightness value of each pixel of the image after light source segmentation is compared with the preset brightness threshold. If the brightness value of the pixel is greater than the preset brightness threshold, the pixel is determined to be a pixel of the light source area. Therefore, only the area of the pixels whose brightness value is greater than the preset brightness threshold needs to be determined as the light source area of the image to be detected.
[0125] In one embodiment, the foreground area of the image to be detected is determined as follows:
[0126] Detecting a foreground object of the image to be detected;
[0127] The position of the foreground object in the image to be detected is determined, and the position of the foreground object in the image to be detected is determined as the foreground area of the image to be detected.
[0128] It should be noted that the foreground target may refer to a target with dynamic features in the image to be detected, such as a person or an animal; the foreground target may also refer to a scene that is close to the viewer and has static features, such as flowers or food.
[0129] In this embodiment, the trained foreground detection model can be used to detect the foreground target in the image to be detected. Exemplarily, the foreground detection model can be a model with foreground target detection function such as Single Shot Multibox Detection (SSD). Of course, other foreground detection methods can also be used, such as detecting whether there is a foreground target (such as a face) in the image to be detected by a pattern recognition algorithm, and after detecting the presence of the foreground target, determining the position of the foreground target in the image to be detected by a target positioning algorithm or a target tracking algorithm.
[0130] It should be noted that other solutions for detecting foreground targets that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should also be within the protection scope of the present invention and will not be described in detail here.
[0131] Taking the foreground detection model after training to detect the foreground target in the image to be detected as an example, the specific training process of the foreground detection model is explained:
[0132] Pre-acquire a sample image and a detection result corresponding to the sample image, wherein the detection result corresponding to the sample image includes the category and position of each foreground object in the sample image;
[0133] Detecting the foreground target in the sample image using the initial foreground detection model, and calculating the detection accuracy of the initial foreground detection model according to the detection result corresponding to the sample image obtained in advance;
[0134] If the detection accuracy is less than the preset first detection threshold, the parameters of the initial foreground detection model are adjusted, and the sample image is detected by the foreground detection model after the parameter adjustment, until the detection accuracy of the adjusted foreground detection model is greater than or equal to the first detection threshold, and the foreground detection model is used as the trained foreground detection model. The method of adjusting the parameters includes but is not limited to the stochastic gradient descent algorithm, the dynamic update algorithm, etc.
[0135] The foreground target is determined by performing foreground target detection on the image to be detected that is converted to the original color space based on the foreground detection model, and then the foreground area is determined based on the position of the foreground target in the image to be detected.
[0136] Exemplarily, the foreground target is a face image area, and the foreground detection model can be based on the HIA276 feature point detection method to perform face feature detection, and then select the foreground area containing the face. In this embodiment, the foreground area detection can be implemented by the neural network (NN) computing processor (NPU) of the electronic device 100, and the NPU performs face recognition on the image to be detected and selects the foreground area containing the face (foreground target) with a rectangular frame, and automatically outputs the area of the target rectangular area.
[0137] For example, Figure 7 The rectangular area shown is the foreground area, and the specific position of the foreground area can be determined by determining the position coordinates of the pixels of the four vertices of the rectangle in the image to be detected. It should be understood that the foreground area containing the face (foreground target) can also be framed by a circle, a triangle, a pentagon or other shapes.
[0138] The area of the foreground area can be determined by calculating the area of the rectangular area, and the length and width of the rectangular area can be determined by determining the position coordinates of the four vertices of the rectangular area, and then the area of the rectangular area is determined, that is, the area of the foreground area is obtained.
[0139] It should be noted that the foreground target may also be other objects. For example, Figure 8a As shown in Figure 8b, the foreground object is a foam box.
[0140] S103: Determine the blur degree of the image to be detected based on the light source area and the foreground area.
[0141] Specifically, the blur degree of the image to be detected is determined based on the number of all pixel points in the light source area and the number of all pixel points in the foreground area.
[0142] Specifically, since the size of the light source area is the most important factor affecting whether the image to be detected is blurred, and the size of the foreground area is also an important factor affecting whether the image to be detected is blurred, in order to determine the degree of blur of the image to be detected, the function value of a strictly increasing function of the ratio of all pixels in the light source area to all pixels in the foreground area can be used as the degree of influence of whether the backlight light source will cause blur to the image to be detected, that is, the function value of a strictly increasing function of the ratio of the number of pixels whose brightness values are greater than a preset brightness threshold to all pixels in the foreground area is the degree of blur S of the image to be detected.
[0143] In one embodiment, the calculation formula of the blur level S is: S=f(a, b)=a / b, where a is the number of all pixels in the light source area, b is the number of all pixels in the foreground area, and S is the blur level.
[0144] In another embodiment, the calculation formula of the blur degree S is: S=f(a, b)=log(a / b), where a is the number of all pixels in the light source area, b is the number of all pixels in the foreground area, and S is the blur degree.
[0145] It should be noted that as long as the blur degree is a strictly increasing function of a / b, the influence of the light source area and the foreground area on the blur degree can be reflected. Therefore, the above f(a, b) has infinite variations, such as f(a, b) = log2(ab), etc., which are not listed here one by one.
[0146] In another embodiment, the blur degree of the image to be detected is determined based on the number of all pixels in the light source area and the area of the foreground area. The function value of a strictly increasing function of the ratio of all pixels in the light source area to the area of the foreground area is used as the influence degree of whether the backlight source will cause blurring of the image to be detected, that is, the function value of a strictly increasing function of the ratio of the number of pixels with brightness values greater than a preset brightness threshold to the area of the foreground area is used as the blur degree S of the image to be detected.
[0147] The calculation formula of the above blur degree S is S=f(a, b)=a / b, where a is the number of all pixels in the above light source area, b is the area of the above foreground area, and S is the blur degree.
[0148] In another embodiment, the calculation formula of the blur level S is: S=f(a, b)=log(a / b), where a is the number of all pixels in the light source area, b is the area of the foreground area, and S is the blur level.
[0149] In one embodiment, the above S103 includes:
[0150] Determine whether a function value of an increasing function of a ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold;
[0151] If the function value of the increasing function of the ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold, it is determined that the image to be detected is a blurred image.
[0152] Specifically, based on the blur degree of the image to be detected (i.e., the function value of an increasing function of the ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area), a comparison is made with a predetermined threshold. If the blur degree of the image is greater than or equal to the predetermined threshold, the detection result is determined to be: the image to be detected is a blurred image; if the blur degree of the image is less than the predetermined threshold, the detection result is determined to be: the image to be detected is a clear image.
[0153] It should be noted that the above-mentioned predetermined threshold can be a predetermined threshold obtained by adjusting parameters after training and testing based on a large number of sample images, that is, if the blur degree of the image to be detected is greater than or equal to the predetermined threshold, it can be determined that the image to be detected is a blurred image.
[0154] Specifically, an image classifier can be constructed based on a KNN (K-Nearest Neighbor) classifier. The principle of the KNN classifier is to compare the image in the test set with each image in the training set, and assign the label value of the most similar training set image to this image. For example, in CIFAR-10, it is to compare 32x32x3 pixel blocks. The simplest method is to compare pixel by pixel, and finally add up all the difference values to obtain the difference value of the two images, and then determine the category of the image according to the classification decision principle (such as majority voting). When constructing an image classifier, the initial model parameters and initial predetermined thresholds of the image classifier will be pre-assigned. Training and testing the image classifier is the process of adjusting the parameters of the initial model parameters and the predetermined thresholds, so that an image classifier that meets the classification accuracy requirements can be obtained.
[0155] Specifically, a traversal search may be performed based on the sample images of the training set to find a trainer or a combination of trainers with the best classification effect, and the trainer or the combination of trainers may be used as the image classifier of this embodiment.
[0156] Specifically, the image classifier is trained and tested based on sample images to determine a predetermined threshold.
[0157] Specifically, the sample images include training set sample images and test set sample images, the training set sample images include first training set sample images and second training set sample images, and the test set sample images include first test set sample images and second test set sample images. The first training set sample images are training set sample images labeled as clear, the second training set sample images are training set sample images labeled as blurred, the first test set sample images are test set sample images labeled as clear, and the second test set sample images are test set sample images labeled as blurred. For example, 100 sample images are divided into two groups, the first group is 50 sample images labeled as "blurred", and the second group is 50 sample images labeled as "clear". Then, 30 sample images out of the 50 sample images labeled “blurred” are used as the first training set sample images, 20 sample images out of the 50 sample images labeled “blurred” are used as the first test set sample images, 30 sample images out of the 50 sample images labeled “clear” are used as the second training set sample images, and 20 sample images out of the 50 sample images labeled “clear” are used as the second test set sample images.
[0158] There are many methods for training image classifiers, such as the AadaBboost method based on Hhaar features, the SVM (Support Vector Machine) method, etc. Specifically, first, construct a training set sample image and a test set sample image; then, based on the training set sample image, perform traversal optimization to find the trainer or combination of trainers with the best classification effect, and use the trainer or combination of trainers as the image classifier of this embodiment; finally, use the test set sample image to verify the classification accuracy of the found image classifier, and it can be used after meeting the accuracy requirement (for example, the accuracy is 70%); if the requirement is not met, adjust the initial model parameters and the predetermined threshold, and repeat the whole process in a cycle until the accuracy requirement is finally met, so that the classifier can determine the predetermined threshold.
[0159] In this embodiment, after the above-mentioned parameter adjustment process, it is determined that when the above-mentioned blur degree S=a / b, the above-mentioned predetermined threshold value can be 0.12; when the blur degree S=log(a / b), the above-mentioned preset blur threshold value is determined to be -0.3269.
[0160] It should be noted that the image detection method provided in this embodiment can be used not only for backlight blur detection of human faces, but also for backlight blur detection of other objects.
[0161] For example, Figure 8a and Figure 8b As shown, respectively Figure 8a and Figure 8b After the image is loaded into the image frame 405, the first control is clicked to trigger the detection operation of the image. Figure 8a The corresponding detection results are: the image is clear (the image does not have the problem of backlight blur); Figure 8b The corresponding detection result is: the image is blurred (the image is blurred due to backlighting).
[0162] In this embodiment, the electronic device can automatically perform backlight blur detection on the acquired image to be detected after acquiring the image to be detected, and can also perform backlight blur detection after the user clicks the first control to output the corresponding detection result. If backlight blur is detected in the image, the user is prompted to re-acquire the image, such as selecting other images or converting to Flash mode to shoot again to acquire the image, so as to improve the accuracy of facial skin evaluation.
[0163] For example, Fig. 9 As shown, Fig. 9 After the image to be detected is loaded into the image frame 405, the first control is clicked to trigger the detection operation of the image to be detected. Fig. 9 The corresponding detection result is: the image is blurred (the image is blurred due to backlighting).
[0164] In one embodiment, the acquiring of the image to be detected refers to acquiring a preview frame image in the first shooting mode. Correspondingly, determining the blur degree of the image to be detected based on the light source area and the foreground area includes:
[0165] If the preview frame image is determined to be a blurred image based on the light source area and the foreground area, the current shooting mode is switched from the first shooting mode to the second shooting mode, wherein the first shooting mode and the second shooting mode are different shooting modes.
[0166] In this embodiment, the image to be detected is a preview frame image in the first shooting mode. Since the preview frame image in the first shooting mode is a blurred image, if the image captured in the first shooting mode is bound to be blurred, the current shooting mode needs to be switched from the first shooting mode to the second shooting mode.
[0167] Exemplarily, the first shooting mode is Torch mode, and the second shooting mode is Flash mode. The current shooting mode is switched from the first shooting mode to the second shooting mode, specifically: the electronic device 100 sends a control instruction to the flash module of the electronic device to switch the flash from a constant light mode to a mode that flashes once during shooting.
[0168] The image detection method provided in the embodiment of the present application can effectively detect whether the image taken under backlighting conditions is blurred based on an artificial intelligence terminal. It determines the influence of the light source on the clarity of the image by performing light source area detection and foreground area detection on the image, thereby effectively detecting whether the image taken under backlighting conditions is blurred.
[0169] It should be understood that the order of execution of the steps in the above embodiments does not imply a sequence of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0170] Corresponding to the image detection method described in the above embodiment, Fig.10 A structural block diagram of an image detection device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0171] Reference Fig.10 , the image detection device comprises:
[0172] The image acquisition module 11 is used to acquire the image to be detected;
[0173] The first determination module 12 is used to determine the light source area of the image to be detected and the foreground area of the image to be detected;
[0174] The second determining module 13 is used to determine the blur degree of the image based on the light source area and the foreground area.
[0175] Optionally, the first determining module 12 includes:
[0176] A conversion unit, used to perform color space conversion on the image to be detected, and obtain the brightness value of each pixel point of the image after the color space conversion;
[0177] The first determining unit is used to determine a region of pixels whose brightness values are greater than a preset brightness threshold as a light source region of the image to be detected.
[0178] Optionally, the first determining module 12 includes:
[0179] A detection unit, used to detect a foreground target in the image to be detected;
[0180] The second determining unit is used to determine the position of the foreground object in the image to be detected, and determine the position of the foreground object in the image to be detected as the foreground area of the image to be detected.
[0181] Optionally, the second determining module 13 includes:
[0182] The third determining unit is used to determine the blur degree of the image to be detected based on the number of all pixel points in the light source area and the number of all pixel points in the foreground area.
[0183] Optionally, the third determining unit includes:
[0184] A judging unit, configured to judge whether a function value of an increasing function of a ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold;
[0185] The fourth determination unit is used to determine that the image to be detected is a blurred image if the function value of the increasing function of the ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold.
[0186] Optionally, the third determination unit is further configured to determine the blur degree of the image to be detected based on the number of all pixels in the light source area and the area of the foreground area.
[0187] Optionally, the image acquisition module 11 includes:
[0188] The first image acquisition unit is used to acquire a preview frame image in a first shooting mode.
[0189] Correspondingly, the second determination module 13 is also used to switch the current shooting mode from the first shooting mode to the second shooting mode if the preview frame image is determined to be a blurred image based on the light source area and the foreground area, wherein the first shooting mode and the second shooting mode are different shooting modes.
[0190] It should be noted that the information interaction, execution process, etc. between the above-mentioned modules / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0191] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0192] Therefore, the image detection device provided in this embodiment can also determine the impact of the light source on the clarity of the image by performing light source area detection and foreground area detection on the image, and then determine whether the image has a backlight blur problem, thereby improving the accuracy of the evaluation results of the facial skin condition.
[0193] Fig.11 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Fig.11 As shown, the electronic device 11 of this embodiment includes: at least one processor 110 ( Fig.11 Only one is shown in the figure), a memory 111 and a computer program 112 stored in the memory 111 and executable on the at least one processor 110, wherein the processor 110 implements the steps of any of the above-mentioned image detection method embodiments when executing the computer program 112.
[0194] The electronic device 11 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The electronic device may include, but is not limited to, a processor 110 and a memory 111. Those skilled in the art will appreciate that Fig.11 This is only an example of the electronic device 11 and does not constitute a limitation on the electronic device 11 . The electronic device 11 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0195] The processor 110 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0196] In some embodiments, the memory 111 may be an internal storage unit of the electronic device 11, such as a hard disk or memory of the electronic device 11. In other embodiments, the memory 111 may also be an external storage device of the electronic device 11, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 11. Further, the memory 111 may also include both an internal storage unit of the electronic device 11 and an external storage device. The memory 111 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory 111 may also be used to temporarily store data that has been output or is to be output.
[0197] An embodiment of the present application further provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above method embodiments when executing the computer program.
[0198] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0199] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0200] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0201] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0202] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0203] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0204] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0205] The embodiments described above 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, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An image detection method, characterized in that: include: Acquire an image to be detected, where the image to be detected is a preview frame image in a first shooting mode; Determining a light source area of the image to be detected and a foreground area of the image to be detected; Determining the blur degree of the image to be detected based on the light source area and the foreground area; If the image to be detected is determined to be a blurred image based on the light source area and the foreground area, the current shooting mode is switched from the first shooting mode to the second shooting mode, wherein the first shooting mode includes a Torch mode in which the flash is always on, and the first shooting mode and the second shooting mode are different shooting modes.
2. The image detection method according to claim 1, characterized in that: The determining of the light source area of the image to be detected includes: Performing color space conversion on the image to be detected, and obtaining the brightness value of each pixel of the image after the color space conversion; The region of pixels whose brightness values are greater than a preset brightness threshold is determined as the light source region of the image to be detected.
3. The image detection method according to claim 1, characterized in that: The step of determining the foreground area of the image to be detected includes: Detecting a foreground object of the image to be detected; The position of the foreground object in the image to be detected is determined, and the position of the foreground object in the image to be detected is determined as the foreground area of the image to be detected.
4. The image detection method according to claim 1, characterized in that: The determining the blur degree of the image to be detected based on the light source area and the foreground area includes: The blur degree of the image to be detected is determined based on the number of all pixel points in the light source area and the number of all pixel points in the foreground area.
5. The image detection method according to claim 4, characterized in that: The determining the blur degree of the image to be detected based on the number of all pixels in the light source area and the number of all pixels in the foreground area includes: Determine whether a function value of an increasing function of a ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold; If the function value of the increasing function of the ratio of the number of all pixels in the light source area to the number of all pixels in the foreground area is greater than a predetermined threshold, it is determined that the image to be detected is a blurred image.
6. The image detection method according to claim 1, characterized in that: The determining the blur degree of the image to be detected based on the light source area and the foreground area includes: The blur degree of the image to be detected is determined based on the number of all pixel points in the light source area and the area of the foreground area.
7. An image detection device, characterized in that: include: An image acquisition module, used to acquire an image to be detected, wherein the image to be detected is a preview frame image in a first shooting mode; A first determination module, used to determine the light source area of the image to be detected and the foreground area of the image to be detected; A second determination module, configured to determine a blur degree of the image based on the light source area and the foreground area; If the image to be detected is determined to be a blurred image based on the light source area and the foreground area, the current shooting mode is switched from the first shooting mode to the second shooting mode, wherein the first shooting mode includes a Torch mode in which the flash is always on, and the first shooting mode and the second shooting mode are different shooting modes.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the image detection method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image detection method according to any one of claims 1 to 6 is implemented.
