Search

CN-121985226-A - Model training method, focusing processing method and electronic equipment

CN121985226ACN 121985226 ACN121985226 ACN 121985226ACN-121985226-A

Abstract

The embodiment of the application provides a model training method and a focusing processing method, and relates to the technical field of terminals. The method includes training a focus model using moire enhanced image data and applying the model in a focus process flow. When a user shoots an electronic screen by using a terminal and the traditional automatic focusing method is limited due to the occurrence of moire in an image, the phase difference can be obtained by reasoning through the model or based on laser ranging. Thus, the motor is adjusted to a corresponding position according to the obtained phase difference, the focusing is realized, the picture in the terminal is prevented from focusing and shaking, and a user can shoot a clear image.

Inventors

  • JIANG KAIYUAN
  • Hou Linkai

Assignees

  • 荣耀终端股份有限公司

Dates

Publication Date
20260505
Application Date
20241025

Claims (15)

  1. 1. A method of model training, comprising: selecting a plurality of images to be processed from a plurality of original training images contained in a first training set; respectively carrying out the processing of overlapping mole patterns on the plurality of images to be processed so as to obtain a plurality of enhanced training images; inputting the enhanced training image to a first model aiming at any one enhanced training image in the plurality of enhanced training images, so that the first model outputs a prediction target phase difference corresponding to the enhanced training image; and adjusting model parameters of the first model according to the predicted target phase difference corresponding to the enhanced training image and the actual target phase difference corresponding to the enhanced training image.
  2. 2. The method according to claim 1, wherein the processing of overlaying moire for each of the plurality of images to be processed to obtain a plurality of enhanced training images includes: Generating a moire image corresponding to any one of the images to be processed; And carrying out superposition processing according to the moire image and the image to be processed to obtain an enhanced training image corresponding to the image to be processed.
  3. 3. The method according to claim 2, wherein the generating the moire image corresponding to the image to be processed includes: generating a first sine wave and a second sine wave for the image to be processed; and superposing the first sine wave and the second sine wave to generate a moire image corresponding to the image to be processed.
  4. 4. A focusing processing method, characterized by comprising: Determining a first focusing frame in the first preview image; Inputting the first preview image and the first focusing frame into a first model, so that the first model outputs a first target phase difference corresponding to the first focusing frame, wherein the first model is trained according to the method of any one of claims 1-3; and adjusting the position of the first motor in the terminal equipment according to the first target phase difference.
  5. 5. The method of claim 4, wherein prior to inputting the first preview image and the position of the focus frame into the first model, the method further comprises: Processing a plurality of second preview images according to a preset algorithm to obtain second target phase differences corresponding to second focusing frames in the second preview images, wherein the acquisition time of the second preview images is before the acquisition time of the first preview images; processing the first preview image according to the preset algorithm to obtain a third target phase difference corresponding to the first focusing frame in the first preview image; Detecting whether the third target phase difference is abnormal or not according to the second target phase difference corresponding to each of the plurality of second preview images and the third target phase difference corresponding to the first preview image, and/or detecting whether the third target phase difference is abnormal or not according to the sub-target phase difference corresponding to each of the plurality of sub-regions included in the first focusing frame.
  6. 6. The method of claim 5, wherein detecting whether an anomaly exists in the third target phase difference based on the second target phase differences corresponding to each of the plurality of second preview images and the third target phase difference corresponding to the first preview image, comprises: Sorting the second target phase differences corresponding to the second preview images and the third target phase differences corresponding to the first preview images according to the image acquisition time to obtain a first sequence; In the first sequence, determining a first amount of a target phase difference at a peak location and determining a second amount of a target phase difference at a trough location; comparing the sum of the first quantity and the second quantity with a first preset threshold value to detect whether the third target phase difference is abnormal or not.
  7. 7. The method according to claim 5 or 6, wherein the detecting whether the third target phase difference is abnormal according to the sub-target phase differences corresponding to the sub-regions included in the first focusing frame, includes: calculating standard deviation aiming at sub-target phase differences corresponding to a plurality of sub-regions included in the first focusing frame; And comparing the standard deviation with a second preset threshold value to detect whether the third target phase difference is abnormal.
  8. 8. The method according to any one of claims 5-7, wherein inputting the first preview image and the first focusing frame into a first model so that the first model outputs a first target phase difference corresponding to the first focusing frame includes: and under the condition that the third target phase difference is abnormal, inputting the first preview image and the first focusing frame into a first model so that the first model outputs the first target phase difference corresponding to the first focusing frame.
  9. 9. The method of any of claims 5-8, wherein determining a first focus frame in the first preview image comprises: Detecting whether the first preview image contains a human face or not; Under the condition that the first preview image contains a human face, determining the first focusing frame according to the human face area in the first preview image; and under the condition that the first preview image does not contain a human face, determining the first focusing frame according to a preset area in the first preview image.
  10. 10. The method of claim 9, wherein in the case where no face is included in the first preview image and there is an abnormality in the third phase difference, the method further comprises: and adjusting the position of the first motor in the terminal equipment according to the first laser ranging result corresponding to the first preview image and the second laser ranging results corresponding to the plurality of second preview images.
  11. 11. The method of claim 10, wherein adjusting the position of the first motor in the terminal device according to the first laser ranging result corresponding to the first preview image and the second laser ranging result corresponding to each of the plurality of second preview images comprises: determining fluctuation parameters of the laser ranging results according to the first laser ranging result and the plurality of second laser ranging results; If the fluctuation parameter is smaller than a third preset threshold value, determining a target flight time TOF corresponding to a first focusing frame in the first preview image according to the first laser ranging result; and adjusting the position of the first motor in the terminal equipment according to the target TOF.
  12. 12. An electronic device, the electronic device comprising: one or more processors and memory; the memory being coupled to the one or more processors, the memory being for storing computer program code comprising computer instructions that are invoked by the one or more processors to cause the electronic device to perform the method of any one of claims 1 to 11.
  13. 13. A chip system for application to an electronic device, the chip system comprising one or more processors configured to invoke computer instructions to cause the electronic device to perform the method of any of claims 1-11.
  14. 14. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of any one of claims 1 to 11.
  15. 15. A computer program product, characterized in that the computer program product comprises computer program code which, when run on an electronic device, causes the electronic device to perform the method of any one of claims 1 to 11.

Description

Model training method, focusing processing method and electronic equipment Technical Field The present application relates to the field of terminal technologies, and in particular, to a model training method, a focusing processing method, and an electronic device. Background In daily life and work, people often take pictures with a mobile phone, and in some cases take the mobile phone to take a picture of an electronic screen to record important information or to keep a wonderful moment. Along with the development of technology, an automatic focusing function is generally carried in the existing smart phone, wherein one automatic focusing method is based on detecting light intensity signal distribution corresponding to two types of pixel points in an image, judging whether the current focusing is performed or not by calculating phase differences of the distribution, and adjusting a motor according to the phase differences so as to achieve the focusing. However, when an electronic screen exists in a picture shot by a user, moire is likely to occur, and the moire affects the light intensity signal distribution, thereby causing an abnormality in calculated phase difference, and difficulty in automatic focusing. Disclosure of Invention The embodiment of the application provides a model training method and a focusing processing method, which are applied to the technical field of terminals. According to the model training method, a model capable of coping with mole marks can be obtained, and the model is applied to a focusing processing method, so that the quasi-focusing can still be realized under the condition that the mole marks appear on an electronic screen shot by a user, the shot image is prevented from being blurred, and the user experience is improved. In a first aspect, an embodiment of the present application provides a model training method, including: selecting a plurality of images to be processed from a plurality of original training images contained in a first training set; respectively carrying out the processing of overlapping mole patterns on the plurality of images to be processed so as to obtain a plurality of enhanced training images; inputting the enhanced training image to a first model aiming at any one enhanced training image in the plurality of enhanced training images, so that the first model outputs a prediction target phase difference corresponding to the enhanced training image; and adjusting model parameters of the first model according to the predicted target phase difference corresponding to the enhanced training image and the actual target phase difference corresponding to the enhanced training image. In this implementation, mole pattern enhancement is performed by randomly extracting a portion of the images from a plurality of original training images, and then training a first model with image data comprising the enhanced training images. In this way, the first model can learn the corresponding mode even if the mole pattern exists in the image, and the predicted target phase difference consistent with or close to the actual target phase difference can be output after reasoning. And the first model does not output a predicted target phase difference having a large difference from the actual target phase difference because of the inclusion of moire in the input image. In one possible implementation manner, the processing of overlaying mole patterns on the multiple images to be processed to obtain multiple enhanced training images includes: Generating a moire image corresponding to any one of the images to be processed; And carrying out superposition processing according to the moire image and the image to be processed to obtain an enhanced training image corresponding to the image to be processed. In one possible implementation manner, the generating the moire image corresponding to the image to be processed includes: generating a first sine wave and a second sine wave for the image to be processed; and superposing the first sine wave and the second sine wave to generate a moire image corresponding to the image to be processed. In this implementation, a method of how to simulate moire images and superimpose the simulated moire images on an image to be processed is described. In this embodiment, two sine waves are used to simulate moire, and in order to ensure randomness of moire, the position of the sine wave and the period or frequency in each direction may be randomly determined at each generation. In addition, the present implementation is not particularly limited, and may be according to actual situations, as to whether a sine wave or a pattern of another shape is used, or whether one or a plurality of patterns are used to superimpose the analog mole patterns. Compared with a method for manually collecting a real image with moire, the method can easily obtain a large number of training images with the moire enhancement in a short time, and can add the moire on a clear image