Method and apparatus for detecting subject, electronic device, and computer readable storage medium
AssigneeGuangdong Oppo Mobile Telecommunications Corp., Ltd.
InventorYuhu Jia
Life of this patent
Estimating the term…
Abstract
The present disclosure relates to a method and an apparatus for detecting a subject, an electronic device, and a computer readable storage medium. The method includes the following. A current image and a previous image are obtained. A transformation matrix between the current image and the previous image is obtained in response to determining that the current image indicates the shaking state. The previous image is corrected based on the transformation matrix. The subject detection model is updated based on the corrected previous image. The subject detection is performed on the current image based on the updated subject detection model, to obtain a target subject.
Claims18
A method for detecting a subject, comprising:
- obtaining a current image and a previous image adjacent to the current image;
- obtaining a transformation matrix between the current image and the previous image in response to determining that the current image indicates a shaking state;
- correcting the previous image based on the transformation matrix to obtain a corrected previous image;
- and
- updating a subject detection model based on the corrected previous image to obtain an updated subject detection model, and performing subject detection on the current image based on the updated subject detection model to obtain a target subject,
- wherein determining that the current image indicates the shaking state comprises:
- performing difference processing on the current image and the previous image and performing binarization processing to obtain a binary difference image;
- calculation a sum of values of each pixel point in the binary difference image;
- and determining that the current image indicates the shaking state in cases that the sum is greater than a sum threshold;
- or
- obtaining a pixel value of each pixel point comprised in the current image, and obtaining a pixel value of each pixel point comprised in the previous image;
- generating a first vector of pixel values for the current image based on the pixel value of each pixel point comprised in the current image, the first vector of pixel values representing a distribution of each pixel value of the current image;
- generating a second vector of pixel values for the previous image based on the pixel value of each pixel point comprised in the previous image, the second vector of pixel values representing a distribution of each pixel value of the previous image;
- determining a vector distance between the current image and the previous image based on the first vector of pixel values and the second vector of pixel values;
- and determining that the current image indicates the shaking state in cases that the vector distance is greater than a distance threshold.
An electronic device, comprising:
- a processor;
- and
- a memory, configured to a computer program;
- wherein the processor is configured to:
- obtain a current image and a previous image adjacent to the current image;
- obtain a transformation matrix between the current image and the previous image in response to determining that the current image indicates a shaking state;
- correct the previous image based on the transformation matrix to obtain a corrected previous image;
- and
- update a subject detection model based on the corrected previous image to obtain an updated subject detection model, and perform subject detection on the current image based on the updated subject detection model, to obtain a target subject,
- wherein the processor is configured to determine that the current image indicates the shaking state by:
- performing difference processing on the current image and the previous image and performing binarization processing to obtain a binary difference image;
- calculation a sum of values of each pixel point in the binary difference image;
- and determining that the current image indicates the shaking state in cases that the sum is greater than a sum threshold;
- or
- obtaining a pixel value of each pixel point comprised in the current image, and obtaining a pixel value of each pixel point comprised in the previous image;
- generating a first vector of pixel values for the current image based on the pixel value of each pixel point comprised in the current image, the first vector of pixel values representing a distribution of each pixel value of the current image;
- generating a second vector of pixel values for the previous image based on the pixel value of each pixel point comprised in the previous image, the second vector of pixel values representing a distribution of each pixel value of the previous image;
- determining a vector distance between the current image and the previous image based on the first vector of pixel values and the second vector of pixel values;
- and determining that the current image indicates the shaking state in cases that the vector distance is greater than a distance threshold.
A non-transitory computer readable storage medium, having a computer program stored thereon, wherein the computer program is executed by a processor to detect a subject by:
- obtaining a current image and a previous image adjacent to the current image;
- obtaining a transformation matrix between the current image and the previous image in response to determining that the current image indicates a shaking state;
- correcting the previous image based on the transformation matrix to obtain a corrected previous image;
- and
- updating a subject detection model based on the corrected previous image to obtain an updated subject detection model, and performing subject detection on the current image based on the updated subject detection model, to obtain a target subject,
- wherein determining that the current image indicates the shaking state comprises:
- performing difference processing on the current image and the previous image and performing binarization processing to obtain a binary difference image;
- calculation a sum of values of each pixel point in the binary difference image;
- and determining that the current image indicates the shaking state in cases that the sum is greater than a sum threshold;
- or
- obtaining a pixel value of each pixel point comprised in the current image, and obtaining a pixel value of each pixel point comprised in the previous image;
- generating a first vector of pixel values for the current image based on the pixel value of each pixel point comprised in the current image, the first vector of pixel values representing a distribution of each pixel value of the current image;
- generating a second vector of pixel values for the previous image based on the pixel value of each pixel point comprised in the previous image, the second vector of pixel values representing a distribution of each pixel value of the previous image;
- determining a vector distance between the current image and the previous image based on the first vector of pixel values and the second vector of pixel values;
- and determining that the current image indicates the shaking state in cases that the vector distance is greater than a distance threshold.
Dependencies are inferred from the claim text.