Image processing method, device, equipment and storage medium
By using the face area ratio to obtain distance indication information in image processing, the problems of low image processing efficiency and large calculation amount in the prior art are solved, and more efficient image processing is achieved and equipment cost is reduced.
Patent Information
- Application Number
- CN202010796086.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-10
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2040-08-10
AI Technical Summary
Existing image processing methods require complex geometric calculations after face detection, resulting in low processing efficiency and large calculation volume, which increases the production cost of the equipment.
By performing face detection on the collected image, distance indication information is obtained based on the proportion of the face area in the image, and is used to indicate the discrete distance between the face and the image acquisition device, and then control the device to perform the target function.
This eliminates the precise calculation process of distance, reduces the calculation amount, improves image processing efficiency, and reduces the production cost of the equipment.
Smart Images

Figure CN111753813B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, equipment and storage medium. Background Art
[0002] With the development of image processing technology and the application of artificial intelligence, the terminal can process images by itself, extract some implicit information from the images, and provide corresponding functions based on the information. For example, in some monitoring scenarios, the terminal can detect targets in the collected images, determine the target location, and track them. For another example, in some scenarios, it can determine the user image being captured, determine the distance between the user and the screen, and provide some conveniences based on the distance.
[0003] At present, the image processing method usually collects images through the camera, detects the face of the image, and then performs a series of geometric calculations to obtain the distance between the face and the image, and then displays the corresponding information based on the distance. However, the face detection algorithm usually has a multi-candidate box screening process, which is highly complex and requires a large amount of calculation, resulting in low processing efficiency. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, apparatus, device and storage medium, which can save a lot of calculation, improve image processing efficiency and reduce the production cost of the device. The technical solution is as follows:
[0005] In one aspect, an image processing method is provided, the method comprising:
[0006] Perform face detection on the collected images;
[0007] When it is detected that the image includes a human face, obtaining distance indication information corresponding to the image according to the proportion of the human face area in the image, the distance indication information is used to indicate the distance between the human face and the image acquisition device, and the distance is a discrete distance;
[0008] According to the distance indication information, the image acquisition device is controlled to execute a target function.
[0009] In one aspect, an image processing device is provided, the device comprising:
[0010] A detection module is used to perform face detection on the collected images;
[0011] an acquisition module, configured to acquire distance indication information corresponding to the image according to the ratio of the face area in the image when detecting that the image includes a face, wherein the distance indication information is used to indicate the distance between the face and the image acquisition device, and the distance is a discrete distance;
[0012] A control module is used to control the image acquisition device to execute a target function according to the distance indication information.
[0013] In a possible implementation, the acquisition module is used to classify the distance between the face in the image and the image acquisition device according to the proportion of the face detection frame in the image, and obtain the distance indication information corresponding to the image.
[0014] In one possible implementation, the detection module and the acquisition module are used to input the image into an image processing model, and the image processing model performs face detection on the image. When it is detected that the image includes a face, the distance between the face in the image and the image acquisition device is classified according to the proportion of the face detection frame obtained by the face detection in the image, and the distance indication information corresponding to the image is output.
[0015] In one possible implementation, the training process of the image processing model includes:
[0016] Acquire a sample face image, wherein the sample face image carries corresponding target distance indication information;
[0017] Input the sample face image into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image;
[0018] Acquiring prediction accuracy based on the predicted distance indication information and the target distance indication information;
[0019] Based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target condition is met.
[0020] In a possible implementation, obtaining a sample face image includes:
[0021] Performing face detection on at least two sample images to obtain face detection frames of the at least two sample images;
[0022] Obtaining the proportion of the face detection frames of the at least two sample images in the at least two sample images;
[0023] Determining, according to the ratio, a cropping frame corresponding to the at least two sample images;
[0024] The at least two sample images are cropped according to the cropping frame, the cropped sample images are determined as sample face images, and target distance indication information corresponding to the sample face images is determined according to a size relationship between a face detection frame in the sample image and the cropping frame.
[0025] In a possible implementation manner, determining the cropping frames corresponding to the at least two sample images according to the ratio includes:
[0026] In response to the ratio being greater than a first ratio threshold, determining the size of cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images, determining the position of the cropping frames corresponding to the at least two sample images according to the position of the face detection frames and the target offset, the cropping frame being smaller than the face detection frame;
[0027] In response to the ratio being less than a second ratio threshold, the size of a cropping frame corresponding to the at least two sample images is determined according to the size of the face detection frame in the at least two sample images and the target scaling factor, and the position of the cropping frame is randomly determined in the at least two sample images according to the size of the cropping frame in the at least two sample images, and the cropping frame is larger than the face detection frame.
[0028] In a possible implementation, determining the positions of the cropping frames corresponding to the at least two sample images according to the position of the face detection frame and the target offset includes:
[0029] For a sample image, the vertex position of at least one cropping frame corresponding to the at least two sample images is determined according to the center point position of the face detection frame and the target offset in at least one offset direction.
[0030] In a possible implementation, determining the target distance indication information corresponding to the sample face image according to the size relationship between the face detection frame and the cropping frame in the sample image includes:
[0031] In response to the cropping frame being smaller than the face detection frame, determining that the target distance indication information corresponding to the sample face image is first distance indication information, and the distance indicated by the first distance indication information is smaller than a distance threshold;
[0032] In response to the cropping frame being larger than the face detection frame, determining the distance indication information corresponding to the target zoom factor as the target distance indication information corresponding to the at least two sample images.
[0033] In a possible implementation, obtaining a sample face image includes:
[0034] Performing face detection on at least two sample face images to obtain face detection frames of the at least two sample face images;
[0035] Obtaining the proportion of the face detection frames of the at least two sample face images in the at least two sample face images;
[0036] According to the correspondence between the ratio and the distance indication information, the distance indication information corresponding to the ratio is obtained as the target distance indication information corresponding to the at least two sample face images.
[0037] In a possible implementation, the control module is used to perform any of the following:
[0038] In response to the distance indication information being first distance indication information, controlling the screen of the image acquisition device to light up and display a target interface, and the distance indicated by the first distance indication information is less than a distance threshold;
[0039] In response to the distance indication information being the first distance indication information, prompt information is displayed, where the prompt information is used to prompt that the current distance to the image acquisition device is too short, and the distance indicated by the first distance indication information is less than a distance threshold.
[0040] On the one hand, an electronic device is provided, which includes one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement various optional implementation methods of the above-mentioned image processing method.
[0041] On the one hand, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement various optional implementations of the above-mentioned image processing method.
[0042] In one aspect, a computer program product or a computer program is provided, wherein the computer program product or the computer program comprises one or more program codes, wherein the one or more program codes are stored in a computer-readable storage medium. One or more processors of an electronic device can read the one or more program codes from the computer-readable storage medium, and the one or more processors execute the one or more program codes, so that the electronic device can perform the image processing method of any possible implementation manner described above.
[0043] The embodiment of the present application processes the captured image and analyzes the proportion of the face area in the image to determine the discrete distance between the face in the image and the image acquisition device. By using this discrete distance representation, there is no need to accurately calculate the distance between the face and the image acquisition device, and it is sufficient to estimate the distance between the two. This eliminates the need for accurate distance calculation, saves a lot of calculations, and can also improve image processing efficiency. Moreover, by estimating the distance of the captured image, the target function can be achieved without the need to equip other components, which can reduce the manufacturing cost of the equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments 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 any creative work.
[0045] Figure 1 is a schematic diagram of an implementation environment of an image processing method provided in an embodiment of the present application;
[0046] Figure 2 is a flow chart of an image processing method provided by an embodiment of the present application;
[0047] Figure 3 is a flow chart of an image processing method provided by an embodiment of the present application;
[0048] Figure 4 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;
[0049] Figure 5 It is a schematic diagram of a conversion method of a short-distance conversion module 0 and a short-distance conversion module 1 provided in an embodiment of the present application;
[0050] Figure 6 is a schematic diagram of a method for determining a cropping frame at a long distance provided by an embodiment of the present application;
[0051] Figure 7 This is a schematic diagram of a process for obtaining a sample face image provided by an embodiment of the present application;
[0052] Figure 8 It is a schematic diagram of a process of performing image processing using an image processing model provided in an embodiment of the present application;
[0053] Fig. 9 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;
[0054] Fig.10 It is a structural block diagram of a terminal provided in an embodiment of the present application;
[0055] Fig.11 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0057] In the present application, the terms "first", "second", etc. are used to distinguish between identical or similar items having substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is the quantity and execution order limited. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of the various described examples, a first image can be referred to as a second image, and similarly, a second image can be referred to as a first image. Both the first image and the second image can be images, and in some cases, can be separate and different images.
[0058] The term "at least one" in this application means one or more, and the term "plurality" in this application means two or more, for example, a plurality of data packets means two or more data packets.
[0059] It should be understood that the terms used in the description of the various examples herein are only for describing specific examples and are not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0060] It should also be understood that the term "and / or" used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. The term "and / or" is a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.
[0061] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order 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.
[0062] It should also be understood that determining B based on A does not mean determining B only based on A. B can also be determined based on A and / or other information.
[0063] It should also be understood that the term “comprising” (also known as “inCludes”, “inCluding”, “Comprises” and / or “Comprising”) when used in this specification specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0064] It should also be understood that the term "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, the phrase "if it is determined that ..." or "if [a stated condition or event] is detected" may be interpreted to mean "upon determining that ..." or "in response to determining that ..." or "upon detecting [a stated condition or event]" or "in response to detecting [a stated condition or event]," depending on the context.
[0065] The nouns involved in this application are explained below.
[0066] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0067] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0068] Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to the use of cameras and computers to replace human eyes to identify, track and measure targets, and further process images so that the computer processes them into images that are more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR (Optical Character Recognition), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, three-dimensional (3D) technology, virtual reality, augmented reality, simultaneous positioning and mapping, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0069] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.
[0070] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0071] The solutions provided in the embodiments of the present application involve artificial intelligence computer vision technology, machine learning and other technologies, which are specifically explained through the following embodiments.
[0072] The implementation environment of this application is described below.
[0073] Figure 11 is a schematic diagram of an implementation environment of an image processing method provided in an embodiment of the present application. The implementation environment includes a terminal 101, or the implementation environment includes a terminal 101 and an image processing platform 102. The terminal 101 is connected to the image processing platform 102 via a wireless network or a wired network.
[0074] The terminal 101 can be at least one of a smart phone, a game console, a desktop computer, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player or an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, an intelligent robot, and a self-service payment device. The terminal 101 is installed and runs an application that supports image processing, for example, the application can be a system application, an instant messaging application, a news push application, a shopping application, an online video application, and a social application.
[0075] Exemplarily, the terminal 101 can have image acquisition and image processing functions, can process the acquired images, and execute corresponding functions according to the processing results. The terminal 101 can complete the work independently, and can also provide data services for it through the image processing platform 102. The embodiments of the present application are not limited to this.
[0076] The image processing platform 102 includes at least one of a server, multiple servers, a cloud computing platform, and a virtualization center. The image processing platform 102 is used to provide background services for applications that support image processing. Optionally, the image processing platform 102 undertakes the main processing work, and the terminal 101 undertakes the secondary processing work; or, the image processing platform 102 undertakes the secondary processing work, and the terminal 101 undertakes the main processing work; or, the image processing platform 102 or the terminal 101 can undertake the processing work separately. Alternatively, the image processing platform 102 and the terminal 101 use a distributed computing architecture for collaborative computing.
[0077] Optionally, the image processing platform 102 includes at least one server 1021 and a database 1022 , where the database 1022 is used to store data. In an embodiment of the present application, the database 1022 can store sample images or sample facial images to provide data services for at least one server 1021 .
[0078] The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0079] Those skilled in the art will appreciate that the number of the above-mentioned terminals 101 and servers 1021 can be more or less. For example, the above-mentioned terminal 101 and server 1021 can be only one, or the above-mentioned terminals 101 and servers 1021 can be dozens or hundreds, or more. The embodiment of the present application does not limit the number and device type of the terminals or servers.
[0080] In the scenario where the image processing service is provided by the server, the embodiment of the present application can apply the cloud computing service in the cloud technology, and multiple servers can process the images in parallel or in batches. In an optional method of the embodiment of the present application, the image processing is performed by an image processing model, and the image processing model can be trained based on a large number of sample face images. The sample face images can be stored in a database. When it is necessary to train the image processing model, the sample face images can be extracted from the database. Of course, after the image processing is performed by the image processing model, the processing results and images can also be sent to the database for storage.
[0081] As for cloud technology, cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to realize data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application, which can form a resource pool and be used on demand, flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0082] Optionally, the present application specifically relates to artificial intelligence cloud services, which are also generally referred to as AIaaS (AI as a Service, Chinese for "AI as a Service"). This is a mainstream service mode of artificial intelligence platforms. Specifically, the AIaaS platform will split several common AI services and provide independent or packaged services in the cloud. This service model is similar to opening an AI theme mall: all developers can access and use one or more artificial intelligence services provided by the platform through an API (Application Programming Interface). Some senior developers can also use the AI framework and AI infrastructure provided by the platform to deploy and operate their own cloud artificial intelligence services.
[0083] Figure 2 is a flowchart of an image processing method provided in an embodiment of the present application. The method is applied to an electronic device, which is a terminal or a server. Figure 2 Taking the method applied to a terminal as an example, the method includes the following steps.
[0084] 201. The terminal performs face detection on the collected image.
[0085] Face detection refers to the process of searching an image using a certain strategy to determine whether it contains a face. If so, the position, size and posture of the face, that is, the information of the face area, can be marked by a face detection frame. The face area is the area where the face is in the image.
[0086] The collected image can be collected by the terminal, that is, the terminal is an image collection device. Specifically, the terminal can periodically collect images, and when collecting images, it can perform face detection to determine whether the image includes a face, whether subsequent analysis is required, whether the person is very close to itself, and whether the target function needs to be executed.
[0087] Optionally, the collected image can also be collected by other devices and sent to the terminal, which is not limited in the embodiment of the present application. The terminal provides image processing services.
[0088] This embodiment is described by taking the application of the method to a terminal as an example. Optionally, the image processing step can also be executed by a server. The terminal sends the collected image to the server, which processes the image and feeds back the image processing result.
[0089] 202. When the terminal detects that the image includes a face, the terminal obtains distance indication information corresponding to the image according to the proportion of the face area in the image. The distance indication information is used to indicate the distance between the face and the image acquisition device, and the distance is a discrete distance.
[0090] Discrete distance refers to the discrete distance calculated by the device when the target moves continuously from the device. The discrete distance is compared with the continuous distance. The continuous distance refers to the continuous distance calculated by the device when the target moves continuously from the device. For example, the discrete distance can be a distance level, such as near, far, far, far, very far, and very far. For example, the continuous distance is 45 cm.
[0091] 203. The terminal controls the image acquisition device to execute a target function according to the distance indication information.
[0092] In this embodiment, if the terminal is the image acquisition device, through the above steps, the distance between the face in the image and the image acquisition device is analyzed to be close or far, and the distance indication information is a representation of the degree of distance, not a numerical value of the distance. The terminal can perform a corresponding function according to the setting when the distance between the face and the image acquisition device meets the requirements.
[0093] In one possible implementation, when the distance between the face and the image acquisition device is relatively close, the terminal may control the image acquisition device to perform a corresponding function. Specifically, the distance indication information may include first distance indication information, and the first distance indication information is used to indicate that the distance between the face and the image acquisition device is less than a distance threshold, that is, the first distance indication information is used to indicate that the face is relatively close to the image acquisition device.
[0094] Optionally, the distance threshold may be set by relevant technicians according to requirements. Optionally, the distance threshold may not be set, and here, being less than the distance threshold is used to indicate that the distance indicated by the first distance indication information is relatively small.
[0095] When the distance indication information is the first distance indication information, the terminal can execute the corresponding function, for example, displaying a prompt message to remind the user that the distance is too close. For another example, waking up the screen, displaying the corresponding function interface, etc. If the terminal is not the image acquisition device, the terminal can send the distance indication information to the image acquisition device or send a control instruction to the image acquisition device to control the image acquisition device to execute the target function.
[0096] The embodiment of the present application processes the captured image and analyzes the proportion of the face area in the image to determine the discrete distance between the face in the image and the image acquisition device. By using this discrete distance representation, there is no need to accurately calculate the distance between the face and the image acquisition device, and it is sufficient to estimate the distance between the two. This eliminates the need for accurate distance calculation, saves a lot of calculations, and can also improve image processing efficiency. Moreover, by estimating the distance of the captured image, the target function can be achieved without the need to equip other components, which can reduce the manufacturing cost of the equipment.
[0097] Figure 3 is a flowchart of an image processing method provided in an embodiment of the present application, see Figure 3 , the method comprises the following steps.
[0098] 301. The terminal obtains a sample face image, where the sample face image carries corresponding target distance indication information.
[0099] The terminal can obtain sample face images and train the image processing model based on the sample face images. The trained image processing model can process the input image and analyze the distance between the face in the image and the image acquisition device. Among them, the sample face image is an image containing a face, and whether the image includes a face can be determined by face detection, that is, the sample face image is an image determined to contain a face by face detection.
[0100] Specifically, the sample face image can be obtained in a variety of ways, and the embodiments of the present application can use any method to obtain the sample face image. Two methods are provided below. In method one, the terminal can obtain the sample image, determine the sample image including the face in the sample image and the screen ratio of the face detection frame in the sample image including the face through face detection, and crop the sample image according to the screen ratio to obtain the sample face image required for training. In method two, the terminal can directly obtain the sample face image, perform face recognition on the sample face image, divide the sample face image according to the screen ratio of the obtained face detection frame, and determine the target distance indication information carried by each sample face image.
[0101] The difference between the second method and the first method is that in the first method, the terminal obtains the sample image, which is not used directly, but through the face detection and cropping steps, the sample image that is determined to contain a face and obtained by cropping is used as the sample face image required for training. In the second method, the sample face image is directly obtained, and it is only necessary to classify the sample face image.
[0102] The following is a detailed description of the two methods.
[0103] Method 1: The terminal performs face detection on at least two sample images to obtain face detection frames of the at least two sample images; obtains the ratio of the face detection frames of the at least two sample images in the at least two sample images; determines the cropping frames corresponding to the at least two sample images according to the ratio; crops the at least two sample images according to the cropping frames, determines the cropped sample images as sample face images, and determines the target distance indication information corresponding to the sample face images according to the size relationship between the face detection frames in the sample images and the cropping frames.
[0104] In the first method, the terminal can analyze the sample images, screen and process the sample images containing faces whose screen ratios meet certain conditions, and crop the sample face images based on the screened sample images. By cropping to obtain samples, the distribution of sample face images with different screen ratios can be well controlled. The screen ratio refers to the ratio between the area of the face region and the area of the sample image. Optionally, the area of the face region can be represented by the area of the face detection frame. Optionally, the area of the face region can be represented by the area of the largest circular region in the face detection frame.
[0105] Specifically, the terminal can filter out images that occupy a larger screen area and images that occupy a smaller screen area from the sample images, and use the images that occupy a larger screen area as the cropping data basis for sample face images at a close distance, and use the images that occupy a smaller screen area as the cropping data basis for sample face images at a long distance.
[0106] In this way, by cropping sample images in which the faces of the sample images are closer to the image acquisition device to obtain sample face images at close range, it is possible to obtain sufficiently clear sample face images. When cropping sample images that occupy a relatively small portion of the screen are used, sample face images with a variety of screen-occupying ratios can be cropped, and while ensuring that the distribution of sample face images with each screen-occupying ratio is similar, it is possible to obtain as many sample face images with screen-occupying ratios as possible. The types of sample face images obtained in this way are comprehensive, and the number is controllable. Optionally, the sample face images at a long distance can also be classified in a more diverse manner, for example, extremely far, relatively far, not too far, etc. Or the levels can be directly identified by numbers, such as 1, 2, 3, 4, etc.
[0107] In one possible implementation, when different distance indication information is desired, the process of determining the cropping frame through the face detection frame is also different. It can be understood that for a close-range cropping frame, the cropping frame is smaller than the face detection frame so as to crop a face image at a very close distance. For a long-range cropping frame, the cropping frame needs to be larger than the face detection frame, so that the distance between the cropped image face and the image acquisition device is also far, and the long-range distance indication information can be given to it. That is, the above-mentioned close-range distance indication information is referred to as the first distance indication information. The long-range distance indication information is the distance indication information other than the first distance indication information.
[0108] For close distances, the process of determining the cropping frame can be as follows: in response to the ratio being greater than a first ratio threshold, the terminal determines the size of the cropping frame corresponding to the at least two sample images according to the size of the face detection frame in the at least two sample images, and determines the position of the cropping frame corresponding to the at least two sample images according to the position of the face detection frame and the target offset, and the cropping frame is smaller than the face detection frame.
[0109] Among them, the first ratio threshold can be set by relevant technical personnel according to needs, for example, 0.6, and the embodiment of the present application is not limited to this.
[0110] Optionally, the terminal determines the width of the face detection frame as the width of the cropping frame, and determines the product of the height of the face detection frame and the target coefficient as the height of the cropping frame. The target coefficient can be set by relevant technicians according to requirements, for example, the target coefficient is 0.8, which is not limited in the embodiments of the present application.
[0111] Optionally, the terminal can also determine the product of the width of the face detection frame and the target coefficient as the width of the cropping frame, and determine the height of the face detection frame as the height of the cropping frame. Alternatively, the terminal can also determine the product of the width of the face detection frame and the first target coefficient as the width of the cropping frame, and determine the product of the height of the face detection frame and the second target coefficient as the height of the cropping frame. The first target coefficient and the second target coefficient can be set by relevant technicians according to needs, and the embodiments of the present application are not limited to this.
[0112] After the size of the cropping frame is determined, the specific position of the cropping frame can be determined. In one possible implementation, the position of the cropping frame can be identified by the vertex position of the cropping frame. For example, the position of the cropping frame can be represented by the vertex position of the upper left corner and the vertex position of the lower right corner of the cropping frame. Of course, it can also be identified by other methods, which is not limited in the embodiments of the present application.
[0113] Specifically, for a sample image, the terminal determines the vertex position of at least one cropping frame corresponding to the at least two sample images according to the center point position of the face detection frame and the target offset in at least one offset direction.
[0114] The number of the offset directions is one or more. For example, in a specific example, the cropping method of the close-range sample face image is as follows: Figure 4 As shown, Figure 4 The effect diagram after being processed by the close-range conversion module is shown, and specifically the schematic diagram showing the nine relative position relationships between the target frame (that is, the face area) and the cropping frame, that is, including 9 offset directions. Among them, u0, u1, u2 means that the target frame is located in the upper left, right above, and upper right of the cropping frame; m0, m1, m2 means that the target frame is located in the middle left, right in the middle, and right middle of the cropping frame; u0, u1, u2 means that the target frame is located in the lower left, right below, and lower right of the cropping frame.
[0115] Optionally, the step of determining the cropping frame can be performed by one or more close distance conversion modules, and different close distance conversion modules may perform different calculations.
[0116] For example, Figure 5 As shown, Figure 5 The close-range conversion module 0 and the close-range conversion module 1 are shown, where the close-range conversion module 0 is used to process the four cases of u0, u2, b0, and b2. The close-range conversion module 1 is used to process the two cases of m0 and m2. For the three cases of u1, m1, and b1, based on u0, m0, and b0, the cropping frame is translated to the left by a certain distance so that the cropping frame can overlap with the face detection frame in the width direction, that is, the offset of the horizontal coordinates in the two cases is obtained, and the horizontal coordinates of the above u0, m0, and b0 can be offset, which will not be repeated here.
[0117] Assume that the circular area represents the target (that is, the face area), such as a head portrait, and point O represents the center point of the circle (that is, the center point of the face detection frame). The dotted rectangle represents the face detection frame that just surrounds the head portrait, with the corresponding width being width and the corresponding height being height. The solid rectangle represents the cropping frame, with the upper left corner of the cropping frame being p0 and the lower right corner being p1.
[0118] The following is an explanation of the process of processing u0, u2, b0, and b2 using the short-distance conversion module 0. Here, the conversion process of u0 is taken as an example. It is assumed that p0 is located on the boundary of the circle, so that the corresponding β angle is 45 degrees. Through the following first three steps, the position of the cropping frame can be determined. After the position of the cropping frame is obtained, the fourth step is performed to assign a label to it. The label is the above-mentioned distance indication information, and then after subsequent cropping, the image also carries the label.
[0119] 1) Find the position O = (anchor_x, anchor_y) of the center point of the face detection frame relative to the upper left corner origin of the video frame.
[0120] 2) From the geometric relationship of the circle, we know that the distance D between point p0 and point o is p0-o = 0.5*width, and angle β is 45 degrees, then the horizontal coordinate offset of point p0 relative to point o is m*0.5*width, and the solution is m=√2 / 2≈0.7. Therefore, the position of the upper left corner of the cropping box can be solved as p0=(x0_u0, y0_u0)=(anchor_x-m*0.5*width, anchor_y-m*0.5*height).
[0121] 3) Let the width of the cropping box be expand_w = width, and the height be expand_h = 0.8*height, and solve the position of the lower right corner point of the cropping box p1 = (x1_u0, y1_u0) = (x0_u0 + expand_w, y0_u0 expand_h).
[0122] 4) The corresponding tag is set as a short-distance tag, represented by 0.
[0123] The following describes the process of using the close-range conversion module 1 to process m0 and m2. The following describes the process of processing m0 as an example to obtain the coordinates of the cropping frame containing the face and the corresponding label.
[0124] 1) According to the value of m obtained by the short-distance conversion module 0, the position of the upper left corner point of the cropping frame can be determined as p0 = (x0_m0, y0_m0) = (anchor_x-m*0.5*width, anchor_y-1*0.5*height).
[0125] 2) Let the width of the cropping box be expand_w=width, and the height be expand=0.8*height.
[0126] Solve the position of the upper left corner of the cropping box: p1 = (x1_m0, y1_m0) = (x0_m0 + expand_w, y0_m0 + expand_h).
[0127] 3) The corresponding tag is set as a short-distance tag, represented by 0.
[0128] For long distances, in response to the ratio being less than a second ratio threshold, the terminal determines the size of a cropping frame corresponding to the at least two sample images according to the size of the face detection frame in the at least two sample images and the target scaling factor, and randomly determines the position of the cropping frame in the at least two sample images according to the size of the cropping frame in the at least two sample images, and the cropping frame is larger than the face detection frame.
[0129] Among them, the second ratio threshold can be set by relevant technical personnel according to needs. For example, the second ratio threshold is 0.2, which is not limited in the embodiment of the present application.
[0130] For the target zoom factor, the target zoom factor can be set by relevant technical personnel according to needs. The number of the target zoom factor can be one or more. When the target zoom factor is different, the screen ratio of the face in the cropped sample face image is different. For example, the target zoom factor includes a width zoom factor α_w and a height zoom factor α_h. Assuming that the combined zoom factor (α_h, α_w) = (1.25, 2), the screen ratio of the cropped face detection frame and the cropping frame is 1 / (1.25*2) = 0.4. Therefore, a target zoom factor can determine a cropping frame corresponding to a screen ratio.
[0131] In a possible implementation, the target scaling factor includes a target width scaling factor and a target height scaling factor. The terminal obtains the product of the size of the face detection frame and the target scaling factor, and uses the product as the size of the cropping frame. For example, the terminal obtains a first product of the width of the face detection frame and the target width scaling factor, uses the first product as the width of the cropping frame, obtains a second product of the height of the face detection frame and the target height scaling factor, and uses the second product as the height of the cropping frame.
[0132] Optionally, for a target zoom factor, the position of at least one cropping frame can be randomly determined in the at least two sample images. The number of cropping frames is one or more. By randomly determining multiple cropping frames, multiple different sample face images with the same screen ratio can be obtained, thereby improving the diversity of the sample face images.
[0133] Specifically, the terminal can randomly determine the position of the upper left corner vertex of the cropping frame from the upper left corner edge area of the sample image according to the size of the cropping frame, and can determine the position of the lower right corner vertex of the cropping frame according to the position of the upper left corner vertex and the size of the cropping frame.
[0134] The size of the upper left corner edge area is negatively correlated with the size of the cropping frame. For example, the sum of the width of the upper left corner edge area and the width of the cropping frame is the width of the sample image, and the sum of the height of the upper left corner edge area and the height of the cropping frame is the height of the sample image.
[0135] For example, in one specific example, Figure 6 (a) shows a schematic diagram of a long-distance cropping frame. Figure 6 It illustrates the inclusion relationship between the original video frame (that is, the frame of the sample image) (HW), the long-distance cropping frame (h0-w0) and the face detection frame (height-width), that is, the cropping frame should contain all the face detection frames and should also be contained by the original video frame.
[0136] Figure 6 (b) shows the schematic diagram of solving the upper left corner point of the cropping box at a long distance. Specifically, assuming the width w and height h of the cropping box, for the upper left corner point of the cropping box, Figure 6 In the rectangle abcd in (b), the sum of the width W-w0 of the rectangle abcd and the width w0 of the cropping frame is the width W of the original video frame, and the sum of the height H-h0 of the rectangle abcd and the height h0 of the cropping frame is the width H of the original video frame. One or more points are randomly selected as the upper left corner point of the cropping frame. If one point is selected as the upper left corner point, it corresponds to one cropping frame. If multiple points are selected as the upper left corner points, they correspond to multiple cropping frames, that is, the number of corresponding cropping frames is the same as the number of upper left corner points. This is to ensure the diversity of long-distance samples generated by the same long-distance level (that is, distance indication information).
[0137] Figure 6 (c) shows the flow chart for solving the width and height of the long-distance cropping frame. Therefore, the long-distance level (that is, the distance indication information) of the long-distance sample to be generated can be determined first. 1 represents the minimum level in the long-distance sample. The larger the number, the higher the level, indicating that the target represented by the obtained long-distance sample is farther from the lens. After determining the long-distance level, the target zoom factor can be determined, and the position of the upper left corner and the position of the lower right corner can be selected in the subsequent cropping frame position solution step.
[0138] For the long-distance level 1, the corresponding target scaling factors (α_h, α_w) = (1.25, 2), and the width and height of the uncorrected cropping box are (h0, w0) = (1.25 * height, 2 * width), where height and width are the height and width of the face detection box respectively. Thus, the screen occupancy ratio of the cropped face detection box in the cropping box is 1 / (1.25 * 2) = 0.4. The label corresponding to this cropping box is the long-distance label (distance indication information), represented by 1.
[0139] When the long-distance level is 2, if it is desired that the screen occupancy ratio after cropping is 0.3, then the target scaling factors should be multiplied by a step amplification factor n = √(4 / 3). The corresponding target scaling factors are (1.25, 2) * √(4 / 3), and the width and height of the uncorrected cropping box are (1.25 * √(4 / 3) * height, 2 * √(4 / 3) * width). The label corresponding to this cropping box is the long-distance label, represented by 2. The remaining distance levels can be deduced by analogy and will not be elaborated here.
[0140] It should be noted that when generating labels for multiple long-distance levels, the screen occupancy ratio represented by this basic level of long-distance level 1 can be determined according to the actual application scenario, and the screen occupancy ratio of the next level can also be determined according to actual needs to represent the distances of different target distance lenses. For example, the long-distance level 2 can also be set to have a corresponding screen occupancy ratio of 0.3. As the long-distance level increases, the area of the uncorrected cropping box will become larger and larger. If it becomes larger than the range of the original video frame, data and labels for larger long-distance levels should be stopped from being generated at this time.
[0141] In view of this, a stop condition can be set to determine whether the width and height of the uncorrected cropping box satisfy h0 < H && w0 < W, and whether to stop cropping is determined according to the judgment result. Here, && means "and", indicating that the two conditions before and after need to be satisfied simultaneously, that is, h0 < H and w0 < W. Specifically, if the width and height of the uncorrected cropping box do not satisfy the condition "h0 < H && w0 < W", then this group of cropping boxes is discarded; otherwise, the width and height (h, w) of the final cropping box = (h0, w0).
[0142] For the above process of obtaining the sample face image, the process of obtaining the sample face image is as Figure 7 shown. For the above process of obtaining the sample face image, the process of obtaining the sample face image is as Figure 7As shown, taking the continuously collected images as video frames as an example, the terminal can input the video frame 701 containing the face into the face detection module 702, use the face detection module 702 to perform face detection on the video frame 701 containing the face, obtain the face detection frame 703, and then calculate the position and size of the cropping frame (that is, the above-mentioned cropping frame) surrounding the face detection frame through the discrete distance conversion module. Specifically, the step of calculating the cropping frame can be: if the screen ratio (that is, the ratio of the face area in the image - the area of the face detection frame / the area of the video frame border) is greater than the first ratio threshold (for example, thr_=0.6) condition 704 is met, then it is sent to the short-distance conversion module 705, otherwise it is met. The screen ratio is less than the second ratio threshold (for example, thr_=0.2) condition 706, then it is sent to the long-distance conversion module 707. Through the discrete distance conversion module (the short distance conversion module 705 and the long distance conversion module 707), a series of cropping frames surrounding the face and corresponding labels 708 can be obtained. Then, through the image cropping module 709, each video frame is cropped according to each cropping frame to obtain the cropped video frame and the corresponding discrete distance label (that is, the target distance indication information) 710. Through this process, the production of discrete distance data is completed, and the discrete distance data is the sample face image carrying the target distance indication information.
[0143] Method 2: The terminal performs face detection on at least two sample face images to obtain face detection frames of the at least two sample face images; obtains the ratio of the face detection frames of the at least two sample face images in the at least two sample face images; and obtains the distance indication information corresponding to the ratio as the target distance indication information corresponding to the at least two sample face images according to the corresponding relationship between the ratio and the distance indication information. The distance label (target distance indication information) corresponding to each sample face image can be determined by directly setting the corresponding relationship between the screen ratio and the distance indication information.
[0144] In the second method, the correspondence between the ratio and the distance indication information can be set, that is, the correspondence between the screen ratio and the distance indication information. The terminal can directly obtain the sample face image, determine the discrete distance between the face and the image acquisition device in each image for the sample face image according to the screen ratio, and add the distance indication information, that is, the distance label.
[0145] For example, the ratio can be divided into multiple intervals, each interval corresponds to a distance indication information (for example, a distance label), and after obtaining the ratio of the face detection frame of any sample face image in at least two sample face images, the distance indication information corresponding to the interval to which the ratio belongs is determined as the distance indication information corresponding to the sample face image.
[0146] 302. The terminal inputs the sample face image into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image.
[0147] The image processing model can be an initial model, and the model parameters are initial values. The terminal can train it based on the sample face image, adjust the model parameters, and improve the feature extraction and classification capabilities of the image processing model. Specifically, the image processing model can perform convolution processing on the sample face image, extract image features, and then classify the image features to determine the predicted distance indication information.
[0148] Optionally, for a sample face image, the image processing model classifies to obtain a feature vector, which corresponds to a label space, which refers to a space composed of multiple distance labels. For example, the label space includes two distance labels: close distance (represented by 0) and long distance (represented by 1). For another example, the label space includes five distance labels: close distance (represented by 0), long distance (represented by 1), relatively long distance (represented by 2), very long distance (represented by 3), and extremely long distance (represented by 4). Each element in the feature vector corresponds to a distance indication information (for example, distance levels 0, 1, 2, 3, 4, 5). This element is the probability that the distance between the face and the image acquisition device in the sample face image is at this distance level. The terminal obtains the distance indication information corresponding to the largest probability in the feature vector, which is the distance label. For example, the image processing model classifies a sample face image and obtains a feature vector of [0.09, 0.11, 0.05, 0.05, 0.9]. The terminal can obtain the distance indication information "4" corresponding to the fifth element of the feature vector, which means a very long distance.
[0149] For example, taking the distance indication information as a distance label as an example, after obtaining a short distance label represented by 0 and a long distance label of different long distance levels represented by a number greater than 0, the discrete distance can be modeled through a multi-classification algorithm, so that the image processing model can determine which level the corresponding input image belongs to. If the multi-classification algorithm predicts that the category of the input image is 1, it means that the face of the image is far away from the camera lens, but is at a relatively close position in the long distance. The larger the number of the predicted category label, the farther the face is from the camera lens.
[0150] The discrete distance is represented by the category labels of the multi-classification algorithm. This modeling method is suitable for scenarios where the actual distance does not need to be very accurate. For example, when the smart robot at the door of a restaurant uses a face detection algorithm to determine whether a customer has arrived at the door, it does not need to know the exact distance between the customer and the robot. It only needs to know how close or far the customer is from the robot. By using discrete distances to model the fuzzy distance boundary of how close or far, the purpose of reducing computational complexity is achieved. In addition, this modeling method is more in line with the human eye's visual judgment of distance. When people judge the distance of an object, it is difficult to estimate the specific accuracy, but they judge the approximate distance of the object from themselves by feeling.
[0151] In one possible implementation, Figure 8 As shown, the image processing model can include a neural network and a classifier. The input (input) 801 of the image processing model is a video frame or an image frame, etc. The backbone network (backbone) 802 of the image processing model can be a neural network, for example, a backbone neural network such as the Visual Geometry Group (VGG) and Alexnet, wherein AlexNet is a neural network designed by Hinton, the winner of the 2012 ImageNet competition, and his student Alex Krizhevsky. ImageNet is the name of the computer vision system recognition project. The classifier can execute a multi-classification algorithm (classifier) 803, which can be implemented by a neural network or a machine learning method, such as a support vector machine (Support Vector Machine, SVM), etc.
[0152] 303. The terminal obtains prediction accuracy based on the predicted distance indication information and the target distance indication information.
[0153] During the training process, the prediction accuracy can be used to measure whether the model parameters are appropriate. If they are not appropriate, they can be adjusted until the model parameters enable the model to accurately classify. The prediction accuracy is a loss value or other value, for example, the prediction accuracy is the value of the target loss function, and for example, the prediction accuracy is a reward value, etc., which is not limited in the embodiments of the present application.
[0154] 304. The terminal adjusts the model parameters of the image processing model based on the prediction accuracy until the target condition is met.
[0155] The target condition can be set by relevant technical personnel according to needs. For example, the target condition is that the prediction accuracy is less than a threshold, or the prediction accuracy converges, or the number of iterations reaches a target number. The embodiments of the present application do not limit this.
[0156] The above steps 302 to 304 are an iterative process. After adjusting the model parameters, the terminal can re-execute steps 302 and 303 based on the adjusted model parameters, and then adjust the model parameters based on the prediction accuracy of the next iterative process. After multiple iterations, the model parameters are continuously adjusted to improve the classification ability of the image processing model. After the training stops, a trained image processing model is obtained. At this time, the classification accuracy of the image processing model is relatively good. If there is an image processing requirement later, the image can be input into the image processing model for accurate classification.
[0157] The above steps 301 to 304 are the training process of the image processing model. In the above steps 301 to 304, taking the step of executing the model training by the terminal as an example, the terminal can obtain sample face images and train the image processing model. After the image is subsequently collected, the collected image is processed based on the trained image processing model to determine the distance between the person in the image and the terminal.
[0158] In another possible implementation, the model training process is performed on the server. In this implementation, the terminal executes steps 301 to 304, obtains a sample face image, trains the image processing model based on the sample face image, and obtains a trained image processing model.
[0159] After the model is trained, there are two cases:
[0160] In case 1, the terminal can obtain a trained image processing model from the server and store the image processing model locally in the terminal. After the terminal captures the image, it can call the image processing model locally to process the image and realize the embedded image processing function. When the terminal calls the local image processing model for image processing, it can be executed online or offline, which is not limited in the embodiments of the present application.
[0161] In the second scenario, after the server has trained the image processing model, it can provide the terminal with background services for image processing. The terminal can send the collected image to the server, and the server calls the trained image processing model to process the image sent by the terminal and feeds back the processing result to the terminal. In this way, the terminal can realize the image processing function by calling the image processing service of the server.
[0162] In summary, the execution entities of the model training process and the image processing process may include a variety of situations, and the embodiments of the present application do not limit which specific situation is adopted.
[0163] 305. The terminal collects images.
[0164] The terminal has image acquisition and image processing functions. It can acquire images, process the acquired images, analyze the distance between the face in the image and itself, and execute the target function when the distance is close.
[0165] Optionally, the terminal is equipped with a camera, and the terminal can collect images based on the camera. The camera can be a front camera or a rear camera, and optionally, the camera can also be a depth camera, an infrared camera, etc. The embodiment of the present application does not limit the type of the camera.
[0166] In this embodiment, the terminal captures images, that is, the terminal is the image capture device, for example. Optionally, if the terminal is not the image capture device, the terminal can receive images sent by the image capture device.
[0167] 306. The terminal inputs the image into an image processing model, and the image processing model performs face detection on the image. When a face is detected in the image, the terminal classifies the distance between the face in the image and the image acquisition device according to the ratio of the face detection frame obtained by the face detection in the image, and outputs the distance indication information corresponding to the image.
[0168] The image processing model is trained to learn the distance indication information corresponding to face images of various screen ratios. When there is a need for image processing, the image can be input into the image processing model to perform image processing and output the distance indication information corresponding to the image. The image processing process in step 306 is the same as that in step 302 above, and will not be described in detail here.
[0169] Step 306 is a process of classifying the distance between the face in the image and the image acquisition device according to the proportion of the face detection frame in the image, and obtaining the distance indication information corresponding to the image. The process can also be implemented without using an image processing model, but by calling a feature extraction algorithm and a classification algorithm. The embodiment of the present application does not limit the specific method.
[0170] 307. The terminal controls the image acquisition device to execute a target function according to the distance indication information.
[0171] In this embodiment, the terminal is taken to capture images, that is, the terminal is the image capture device as an example. Optionally, if the terminal is not the image capture device, the terminal can send the distance indication information to the image capture device or send a control instruction to the image capture device to control the image capture device to perform the target function.
[0172] The target function is set by relevant technicians according to requirements, and the embodiment of the present application does not specifically limit the target function. Several examples of target functions are provided below.
[0173] Example 1: In response to the distance indication information being the first distance indication information, the terminal controls the screen of the image acquisition device to light up and display the target interface.
[0174] In order to save power consumption, the terminal is usually in the screen-off state when not in use. It automatically detects the close distance between a person and the image acquisition device, wakes up the screen and displays an interface with corresponding functions to the user. The user does not need to wake it up manually or manually operate on the device to trigger the device to display the target interface. This provides convenience for the user, reduces user operations, and improves user operating efficiency.
[0175] Among them, the target interface is set according to actual needs. For example, in the payment scenario, the target interface is the payment interface. That is, the image acquisition device detects that a person is close to itself, can wake up the screen, and display the payment interface. For another example, in the express application scenario, the target interface is the express pick-up interface or the express delivery interface. That is, the image acquisition device detects that a person is close to itself, can wake up the screen, and display the express pick-up interface or the express delivery interface.
[0176] Example 2: In response to the distance indication information being the first distance indication information, the terminal displays prompt information, where the prompt information is used to prompt that the current distance to the image acquisition device is too short.
[0177] The prompt information is displayed in a pop-up window or by jumping the interface. For example, the terminal detects that the user is too close to the screen and displays a prompt information to remind the user that the user is too close to the screen and keeps a distance from the screen to protect his eyes.
[0178] Optionally, an eye protection mode may be provided. This function may be executed when the terminal turns on the eye protection mode, but not executed in some specific modes, for example, the specific mode may be a game mode. Optionally, the mode may not be distinguished, and the function may be executed when the terminal detects that the distance between the face and the terminal is small. This embodiment of the application is not limited to this.
[0179] In a possible implementation, the distance indication information includes first distance indication information and distance indication information, the first distance indication information is used to indicate that the distance between the face and the image acquisition device is less than a distance threshold, and the second distance indication information is used to indicate that the distance between the face and the image acquisition device is greater than the distance threshold;
[0180] Correspondingly, in step 307, the terminal controls the image acquisition device to execute the target function in response to the distance indication information corresponding to the image being the first distance indication information.
[0181] If the distance between the face and the image acquisition device is far, the image acquisition device may not execute the target function, that is, the terminal responds to the distance indication information corresponding to the image as the second distance indication information, ignores the image, and does not execute the target function.
[0182] The discrete distance modeling method based on the multi-classification algorithm provided in the embodiment of the present application uses the multi-classification algorithm to perform discrete modeling on the continuous distance between the target and the camera, thereby reducing the computational complexity of the distance algorithm. It does not need to be equipped with a posture sensor, and can collect images through the camera and perform image processing, so that low-end and mid-end devices can also enjoy the function of "too close to the mobile phone screen, send a reminder", or wake up and display the payment interface or express interface when the user approaches without user operation. Of course, this method can also be applied to other scenarios, which are not listed here one by one.
[0183] In a possible implementation, other distance indication information may also correspond to other functions, and the terminal may execute other functions corresponding to the other distance indication information. For example, in the manner in which the distance indication information includes the first distance indication information and the second distance indication information, the terminal may respond to the distance indication information being the second distance indication information and execute the function corresponding to the second distance indication information. For example, it may be set to automatically shut down when the distance is far, or automatically turn off the screen, or automatically return to the home page, etc.
[0184] The embodiment of the present application processes the captured image and analyzes the proportion of the face area in the image to determine the discrete distance between the face in the image and the image acquisition device. By using this discrete distance representation, there is no need to accurately calculate the distance between the face and the image acquisition device, and it is sufficient to estimate the distance between the two. This eliminates the need for accurate distance calculation, saves a lot of calculations, and can also improve image processing efficiency. Moreover, by estimating the distance of the captured image, the target function can be achieved without the need to equip other components, which can reduce the manufacturing cost of the equipment.
[0185] All the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.
[0186] Fig. 9 is a structural diagram of an image processing device provided in an embodiment of the present application, see Fig. 9 , the device comprises:
[0187] Detection module 901, used to perform face detection on the collected image;
[0188] An acquisition module 902 is used to acquire distance indication information corresponding to the image according to the ratio of the face area in the image when detecting that the image includes a face, wherein the distance indication information is used to indicate the distance between the face and the image acquisition device, and the distance is a discrete distance;
[0189] The control module 903 is used to control the image acquisition device to execute a target function according to the distance indication information.
[0190] In a possible implementation, the acquisition module 902 is used to classify the distance between the face in the image and the image acquisition device according to the proportion of the face detection frame in the image, and obtain the distance indication information corresponding to the image.
[0191] In one possible implementation, the detection module 901 and the acquisition module 902 are used to input the image into an image processing model, and the image processing model performs face detection on the image. When it is detected that the image includes a face, the distance between the face in the image and the image acquisition device is classified according to the proportion of the face detection frame obtained by the face detection in the image, and the distance indication information corresponding to the image is output.
[0192] In one possible implementation, the training process of the image processing model includes:
[0193] Acquire a sample face image, the sample face image carrying corresponding target distance indication information;
[0194] The sample face image is input into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image;
[0195] Obtaining prediction accuracy based on the prediction distance indication information and the target distance indication information;
[0196] Based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target conditions are met.
[0197] In a possible implementation, obtaining a sample face image includes:
[0198] Performing face detection on at least two sample images to obtain face detection frames of the at least two sample images;
[0199] Obtaining the proportion of the face detection frames of the at least two sample images in the at least two sample images;
[0200] Determining a cropping frame corresponding to the at least two sample images according to the ratio;
[0201] The at least two sample images are cropped according to the cropping frame, the cropped sample images are determined as sample face images, and target distance indication information corresponding to the sample face images is determined according to a size relationship between a face detection frame in the sample image and the cropping frame.
[0202] In a possible implementation, determining, according to the ratio, a cropping frame corresponding to the at least two sample images includes:
[0203] In response to the ratio being greater than a first ratio threshold, determining the size of a cropping frame corresponding to the at least two sample images according to the size of the face detection frame in the at least two sample images, and determining the position of the cropping frame corresponding to the at least two sample images according to the position of the face detection frame and the target offset, the cropping frame being smaller than the face detection frame;
[0204] In response to the ratio being less than a second ratio threshold, the size of a cropping frame corresponding to the at least two sample images is determined according to the size of the face detection frame in the at least two sample images and the target scaling factor, and the position of the cropping frame is randomly determined in the at least two sample images according to the size of the cropping frame in the at least two sample images, and the cropping frame is larger than the face detection frame.
[0205] In a possible implementation, determining the position of the cropping frame corresponding to the at least two sample images according to the position of the face detection frame and the target offset includes:
[0206] For a sample image, the vertex position of at least one cropping frame corresponding to the at least two sample images is determined according to the center point position of the face detection frame and the target offset in at least one offset direction.
[0207] In a possible implementation, determining the target distance indication information corresponding to the sample face image according to the size relationship between the face detection frame and the cropping frame in the sample image includes:
[0208] In response to the cropping frame being smaller than the face detection frame, determining that the target distance indication information corresponding to the sample face image is first distance indication information, and the distance indicated by the first distance indication information is smaller than a distance threshold;
[0209] In response to the cropping frame being larger than the face detection frame, determining the distance indication information corresponding to the target scaling factor as the target distance indication information corresponding to the at least two sample images.
[0210] In a possible implementation, obtaining a sample face image includes:
[0211] Performing face detection on at least two sample face images to obtain face detection frames of the at least two sample face images;
[0212] Obtaining the proportion of the face detection frames of the at least two sample face images in the at least two sample face images;
[0213] According to the correspondence between the ratio and the distance indication information, the distance indication information corresponding to the ratio is obtained as the target distance indication information corresponding to the at least two sample face images.
[0214] In a possible implementation, the control module 903 is used to perform any of the following:
[0215] In response to the distance indication information being first distance indication information, controlling the screen of the image acquisition device to light up and display a target interface, and the distance indicated by the first distance indication information is less than a distance threshold;
[0216] In response to the distance indication information being the first distance indication information, a prompt information is displayed, the prompt information being used to prompt that the current distance from the image acquisition device is too short, and the distance indicated by the first distance indication information is less than the distance threshold. The device provided in the embodiment of the present application processes the acquired image and analyzes the proportion of the face area in the image to determine the discrete distance between the face in the image and the image acquisition device. By using this discrete distance representation, it is not necessary to accurately calculate the distance between the face and the image acquisition device, and it is sufficient to estimate the distance between the two. This eliminates the need for accurate distance calculation, saves a lot of calculations, and can also improve image processing efficiency. By estimating the distance of the acquired image, the target function can be achieved without the need to equip other components, which can reduce the manufacturing cost of the device.
[0217] It should be noted that: when the image processing device provided in the above embodiment processes an image, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the image processing device is divided into different functional modules to complete all or part of the functions described above. In addition, the image processing device provided in the above embodiment and the image processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0218] The electronic device in the above method embodiment can be implemented as a terminal. For example, Fig.101 is a block diagram of a terminal provided in an embodiment of the present application. The terminal 1000 can be: a smart phone, a tablet computer, an MP3 (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Compression Standard Audio Layer 3) player, an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) player, a laptop computer, a desktop computer, an intelligent robot or a self-service payment device. The terminal 1000 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0219] Typically, the terminal 1000 includes: one or more processors 1001 and one or more memories 1002 .
[0220] The processor 1001 can include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 can also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 can be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 can also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0221] The memory 1002 can include one or more computer-readable storage media, which can be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction, which is used to be executed by the processor 1001 to implement the image processing method provided in the method embodiment of the present application.
[0222] In some embodiments, the terminal 1000 may further optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1003 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007, a positioning assembly 1008 and a power supply 1009.
[0223] The peripheral device interface 1003 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0224] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 can also include circuits related to NFC (Near Field Communication, short-distance wireless communication), which is not limited in this application.
[0225] The display screen 1005 is used to display the UI (User Interface). The UI can include graphics, text, icons, videos and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input to the processor 1001 as a control signal for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1005 can be one, and the front panel of the terminal 1000 is set; in other embodiments, the display screen 1005 can be at least two, which are respectively set on different surfaces of the terminal 1000 or are folded; in other embodiments, the display screen 1005 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 1000. Even, the display screen 1005 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0226] The camera assembly 1006 is used to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 can also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0227] The audio circuit 1007 can include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1001 for processing, or input them into the radio frequency circuit 1004 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there can be multiple microphones, which are respectively arranged at different parts of the terminal 1000. The microphone can also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker can be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1007 can also include a headphone jack.
[0228] The positioning component 1008 is used to locate the current geographical location of the terminal 1000 to implement navigation or LBS (Location Based Service). The positioning component 1008 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system or Russia's Galileo system.
[0229] The power supply 1009 is used to power various components in the terminal 1000. The power supply 1009 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1009 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0230] In some embodiments, the terminal 1000 further includes one or more sensors 1010 , including but not limited to: an acceleration sensor 1011 , a gyroscope sensor 1012 , a pressure sensor 1013 , a fingerprint sensor 1014 , an optical sensor 1015 , and a proximity sensor 1016 .
[0231] The acceleration sensor 1011 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1000. For example, the acceleration sensor 1011 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1001 can control the display screen 1005 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1011. The acceleration sensor 1011 can also be used for collecting game or user motion data.
[0232] The gyro sensor 1012 can detect the body direction and rotation angle of the terminal 1000, and the gyro sensor 1012 can cooperate with the acceleration sensor 1011 to collect the user's 3D actions on the terminal 1000. The processor 1001 can implement the following functions based on the data collected by the gyro sensor 1012: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0233] The pressure sensor 1013 can be set in the side frame of the terminal 1000 and / or the lower layer of the display screen 1005. When the pressure sensor 1013 is set in the side frame of the terminal 1000, it can detect the user's holding signal of the terminal 1000, and the processor 1001 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 1013. When the pressure sensor 1013 is set in the lower layer of the display screen 1005, the processor 1001 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 1005. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0234] The fingerprint sensor 1014 is used to collect the user's fingerprint, and the processor 1001 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 1014, or the fingerprint sensor 1014 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 1001 authorizes the user to perform relevant sensitive operations, which include unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 1014 can be set on the front, back, or side of the terminal 1000. When a physical button or a manufacturer logo is set on the terminal 1000, the fingerprint sensor 1014 can be integrated with the physical button or the manufacturer logo.
[0235] The optical sensor 1015 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the display screen 1005 according to the ambient light intensity collected by the optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the display screen 1005 is decreased. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 according to the ambient light intensity collected by the optical sensor 1015.
[0236] The proximity sensor 1016, also called a distance sensor, is usually arranged on the front panel of the terminal 1000. The proximity sensor 1016 is used to collect the distance between the user and the front of the terminal 1000. In one embodiment, when the proximity sensor 1016 detects that the distance between the user and the front of the terminal 1000 is gradually decreasing, the processor 1001 controls the display screen 1005 to switch from the screen-on state to the screen-off state; when the proximity sensor 1016 detects that the distance between the user and the front of the terminal 1000 is gradually increasing, the processor 1001 controls the display screen 1005 to switch from the screen-off state to the screen-on state.
[0237] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation on the terminal 1000, and the terminal 1000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0238] The electronic device in the above method embodiment can be implemented as a server. For example, Fig.11 1 is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 1100 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1101 and one or more memories 1102, wherein the memory 1102 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 1101 to implement the image processing methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface and an input and output interface for input and output, and the server may also include other components for implementing device functions, which will not be described in detail here.
[0239] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including at least one instruction, and the at least one instruction is executable by a processor to complete the image processing method in the above embodiment. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0240] In an exemplary embodiment, a computer program product or a computer program is also provided, wherein the computer program product or the computer program includes one or more program codes, and the one or more program codes are stored in a computer-readable storage medium. One or more processors of an electronic device can read the one or more program codes from the computer-readable storage medium, and the one or more processors execute the one or more program codes, so that the electronic device can perform the above-mentioned image processing method.
[0241] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order 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.
[0242] It should be understood that determining B based on A does not mean determining B only based on A. B can also be determined based on A and / or other information.
[0243] A person of ordinary skill in the art will understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.
[0244] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. An image processing method, characterized in that: The method comprises: Perform face detection on the collected images; Input the image into an image processing model, and the image processing model performs face detection on the image. When it is detected that the image includes a face, classify the distance between the face in the image and the image acquisition device according to the proportion of the face detection frame obtained by the face detection in the image, and output distance indication information corresponding to the image, where the distance is a discrete distance; According to the distance indication information, controlling the image acquisition device to execute a target function; The image processing model is trained by the following process: performing face detection on at least two sample images to obtain face detection frames of the at least two sample images; obtaining the ratio of the face detection frames of the at least two sample images in the at least two sample images; in response to the ratio being greater than a first ratio threshold, determining the size of the cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images, determining the position of the cropping frames corresponding to the at least two sample images according to the position of the face detection frames and the target offset, the cropping frame being smaller than the face detection frame; in response to the ratio being less than a second ratio threshold, determining the size of the cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images and the target scaling factor, and randomly selecting the cropping frames according to the size of the cropping frames in the at least two sample images. The position of the cropping frame is determined in the at least two sample images, and the cropping frame is larger than the face detection frame; the at least two sample images are cropped according to the cropping frame, and the cropped sample images are determined as sample face images, and the target distance indication information corresponding to the sample face images is determined according to the size relationship between the face detection frame in the sample image and the cropping frame, and the sample face images carry the corresponding target distance indication information; the sample face images are input into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image; based on the predicted distance indication information and the target distance indication information, the prediction accuracy is obtained; based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target conditions are met and stopped.
2. The method according to claim 1, characterized in that The method further includes: classifying the distance between the face in the image and the image acquisition device according to the proportion of the face detection frame in the image, and obtaining distance indication information corresponding to the image.
3. The method according to claim 1, characterized in that The controlling the image acquisition device to execute a target function according to the distance indication information includes any one of the following: In response to the distance indication information being first distance indication information, controlling the screen of the image acquisition device to light up and display a target interface, wherein the distance indicated by the first distance indication information is less than a distance threshold; In response to the distance indication information being the first distance indication information, prompt information is displayed, where the prompt information is used to prompt that the current distance to the image acquisition device is too short, and the distance indicated by the first distance indication information is less than a distance threshold.
4. The method according to claim 1, characterized in that: The step of determining the positions of the cropping frames corresponding to the at least two sample images according to the position of the face detection frame and the target offset comprises: For a sample image, the vertex position of at least one cropping frame corresponding to the at least two sample images is determined according to the center point position of the face detection frame and the target offset in at least one offset direction.
5. The method according to claim 1, characterized in that The determining, according to the size relationship between the face detection frame and the cropping frame in the sample image, the target distance indication information corresponding to the sample face image comprises: In response to the cropping frame being smaller than the face detection frame, determining that the target distance indication information corresponding to the sample face image is first distance indication information, and the distance indicated by the first distance indication information is smaller than a distance threshold; In response to the cropping frame being larger than the face detection frame, determining the distance indication information corresponding to the target zoom factor as the target distance indication information corresponding to the at least two sample images.
6. The method according to claim 1, characterized in that The method further comprises: Performing face detection on at least two sample face images to obtain face detection frames of the at least two sample face images; Obtaining the proportion of the face detection frames of the at least two sample face images in the at least two sample face images; According to the correspondence between the ratio and the distance indication information, the distance indication information corresponding to the ratio is obtained as the target distance indication information corresponding to the at least two sample face images.
7. A training method for an image processing model, characterized in that: The method comprises: Performing face detection on at least two sample images to obtain face detection frames of the at least two sample images; Obtaining the proportion of the face detection frames of the at least two sample images in the at least two sample images; In response to the ratio being greater than a first ratio threshold, determining the size of cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images, determining the position of the cropping frames corresponding to the at least two sample images according to the position of the face detection frames and the target offset, the cropping frame being smaller than the face detection frame; In response to the ratio being less than a second ratio threshold, determining the size of a cropping frame corresponding to the at least two sample images according to the size of the face detection frame in the at least two sample images and the target scaling factor, and randomly determining the position of the cropping frame in the at least two sample images according to the size of the cropping frame in the at least two sample images, wherein the cropping frame is larger than the face detection frame; Cropping the at least two sample images according to the cropping frame, determining the cropped sample images as sample face images, and determining target distance indication information corresponding to the sample face images according to a size relationship between a face detection frame in the sample images and the cropping frame, wherein the sample face images carry the corresponding target distance indication information; Input the sample face image into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image; Acquiring prediction accuracy based on the predicted distance indication information and the target distance indication information; Based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target condition is met.
8. The method according to claim 7, characterized in that The step of determining the positions of the cropping frames corresponding to the at least two sample images according to the position of the face detection frame and the target offset comprises: For a sample image, the vertex position of at least one cropping frame corresponding to the at least two sample images is determined according to the center point position of the face detection frame and the target offset in at least one offset direction.
9. The method according to claim 7, characterized in that: The determining, according to the size relationship between the face detection frame and the cropping frame in the sample image, the target distance indication information corresponding to the sample face image comprises: In response to the cropping frame being smaller than the face detection frame, determining that the target distance indication information corresponding to the sample face image is first distance indication information, and the distance indicated by the first distance indication information is smaller than a distance threshold; In response to the cropping frame being larger than the face detection frame, determining the distance indication information corresponding to the target zoom factor as the target distance indication information corresponding to the at least two sample images.
10. The method according to claim 7, characterized in that The method further comprises: Performing face detection on at least two sample face images to obtain face detection frames of the at least two sample face images; Obtaining the proportion of the face detection frames of the at least two sample face images in the at least two sample face images; According to the correspondence between the ratio and the distance indication information, the distance indication information corresponding to the ratio is obtained as the target distance indication information corresponding to the at least two sample face images.
11. An image processing device, characterized in that: The device comprises: A detection module is used to perform face detection on the collected images; an acquisition module, configured to input the image into an image processing model, and the image processing model performs face detection on the image. When a face is detected in the image, the distance between the face in the image and the image acquisition device is classified according to the proportion of the face detection frame obtained by the face detection in the image, and the distance indication information corresponding to the image is output, wherein the distance is a discrete distance; A control module, used to control the image acquisition device to perform a target function according to the distance indication information; The image processing model is trained by the following process: performing face detection on at least two sample images to obtain face detection frames of the at least two sample images; obtaining the ratio of the face detection frames of the at least two sample images in the at least two sample images; in response to the ratio being greater than a first ratio threshold, determining the size of the cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images, determining the position of the cropping frames corresponding to the at least two sample images according to the position of the face detection frames and the target offset, the cropping frame being smaller than the face detection frame; in response to the ratio being less than a second ratio threshold, determining the size of the cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images and the target scaling factor, and randomly selecting the cropping frames according to the size of the cropping frames in the at least two sample images. The position of the cropping frame is determined in the at least two sample images, and the cropping frame is larger than the face detection frame; the at least two sample images are cropped according to the cropping frame, and the cropped sample images are determined as sample face images, and the target distance indication information corresponding to the sample face images is determined according to the size relationship between the face detection frame in the sample image and the cropping frame, and the sample face images carry the corresponding target distance indication information; the sample face images are input into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image; based on the predicted distance indication information and the target distance indication information, the prediction accuracy is obtained; based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target conditions are met and stopped.
12. A training device for an image processing model, characterized in that: The training device is used for: Performing face detection on at least two sample images to obtain face detection frames of the at least two sample images; Obtaining the proportion of the face detection frames of the at least two sample images in the at least two sample images; In response to the ratio being greater than a first ratio threshold, determining the size of cropping frames corresponding to the at least two sample images according to the size of the face detection frames in the at least two sample images, determining the position of the cropping frames corresponding to the at least two sample images according to the position of the face detection frames and the target offset, the cropping frame being smaller than the face detection frame; In response to the ratio being less than a second ratio threshold, determining the size of a cropping frame corresponding to the at least two sample images according to the size of the face detection frame in the at least two sample images and the target scaling factor, and randomly determining the position of the cropping frame in the at least two sample images according to the size of the cropping frame in the at least two sample images, wherein the cropping frame is larger than the face detection frame; Cropping the at least two sample images according to the cropping frame, determining the cropped sample images as sample face images, and determining target distance indication information corresponding to the sample face images according to a size relationship between a face detection frame in the sample images and the cropping frame, wherein the sample face images carry the corresponding target distance indication information; Input the sample face image into the image processing model, and the image processing model classifies the distance between the face in the sample face image and the image acquisition device, and outputs the predicted distance indication information corresponding to the sample face image; Acquiring prediction accuracy based on the predicted distance indication information and the target distance indication information; Based on the prediction accuracy, the model parameters of the image processing model are adjusted until the target condition is met.
13. An electronic device, characterized in that: The electronic device includes one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the image processing method as described in any one of claims 1 to 6 or the training method of the image processing model as described in any one of claims 7 to 10.
14. A computer-readable storage medium, characterized in that: The storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the image processing method as described in any one of claims 1 to 6 or the training method of the image processing model as described in any one of claims 7 to 10.
Citation Information
Patent Citations
Control method, control system and electronic equipment
CN103425443A
Systems and methods for monitoring distance of human face to smart device
CN111192319A