Object detection method, electronic device, storage medium and program product

By obtaining the characteristic data of the image stream in the electronic device, determining the object matching relationship and performing smooth processing, the problem of unstable display of the object frame in the image stream is solved, the display stability is improved and the power consumption is reduced.

CN117710697BActive Publication Date: 2024-08-23HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311000823.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-09
Publication Date
2024-08-23
Estimated Expiration
2043-08-09

AI Technical Summary

Technical Problem

In electronic devices, after detecting multiple frames of images in the image stream, the object frame may jump and flicker, resulting in unstable display.

Method used

By obtaining the feature data of each frame in the image stream, the matching relationship between objects is determined, the object frame is displayed using the matching relationship, and smoothing is performed to reduce jitter and avoid unnecessary attribute detection to reduce power consumption.

Benefits of technology

It improves the display stability of the object frame, reduces the jitter and power consumption of the object frame, and optimizes the accuracy and efficiency of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117710697B
    Figure CN117710697B
Patent Text Reader

Abstract

The embodiments of the present application provide an object detection method, an electronic device, a storage medium, and a program product, which are applied in the field of electronic technology. The method obtains a first image stream, the first image stream includes a first image and a second image, the first image is an image frame before the second image, and determines the matching relationship between the first object and the second object according to the feature data of each first object in the first image and the feature data of each second object in the second image. The matching relationship is used to indicate whether the first object and the second object are the same object, and the target object frame corresponding to the second object is displayed according to the matching relationship. Therefore, the embodiments of the present application can display the object frames where the objects in multiple frames of images are located in sequence according to the matching relationship between the first object and the second object, which can improve the stability of the object frame display, thereby improving the problems of jump and flickering of the object frame.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic technology, and in particular to an object detection method, electronic equipment, storage medium and program product. Background Art

[0002] With the continuous development of electronic technology, electronic devices such as mobile phones and tablet computers have gradually become more common tools in people's daily life and work. At present, some electronic devices are provided with cameras, which can provide users with photo or video functions.

[0003] When shooting with an electronic device, objects in multiple frames of images included in an image stream captured by a camera may be detected, for example, faces in multiple frames of images included in the image stream may be detected.

[0004] However, after detecting the objects in the multiple frames of images included in the image stream, when the object frames where the objects in the multiple frames of images included in the image stream are located are displayed in sequence, the object frames may jump, flicker, and other problems. Summary of the invention

[0005] The embodiments of the present application provide an object detection method, an electronic device, a storage medium, and a program product, which can improve the stability of the object frame display when sequentially displaying the object frames where the objects in the multiple frames of images included in the image stream are located, thereby improving the problems of jumping and flickering of the object frame.

[0006] In a first aspect, an embodiment of the present application proposes an object detection method, which is applied to an electronic device, and the method includes: acquiring a first image stream, the first image stream including a first image and a second image, the first image being an image frame before the second image, the first image including at least one first object, and the second image including at least one second object; extracting feature data of each first object and feature data of each second object respectively; determining a matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object, the matching relationship being used to indicate whether the first object and the second object are the same object; and displaying a target object box corresponding to the second object based on the matching relationship.

[0007] In this way, the embodiment of the present application can determine the matching relationship between the first object and the second object based on the feature data of each first object in the first image and the feature data of each second object in the second image. The accuracy of the determined matching relationship is high, so that when the electronic device displays the object frames where the objects in the multiple frames of images included in the first image stream are located in sequence according to the matching relationship between the first object and the second object, the stability of the object frame display can be improved, thereby improving the problems of jumping and flickering of the object frame.

[0008] In a possible implementation, the first image stream also includes a third image, the third image is a previous frame image of the second image, and the third image is an image frame after the first image, and the third image includes the first object. According to the matching relationship, the target object frame corresponding to the second object is displayed, including: when the first object and the second object are the same object, according to the coordinate information of the tracking frame where the first object is located in the third image and the coordinate information of the second object frame where the second object is located, the coordinate information of the target object frame corresponding to the second object is determined; according to the coordinate information of the target object frame corresponding to the second object, the target object frame is displayed. In this way, smoothing is performed based on the position of the object frame in the previous frame image and the position of the object frame in the next frame image, thereby reducing the jitter when the object frame is displayed.

[0009] In a possible implementation, after determining the matching relationship between the first object and the second object according to the feature data of each first object and the feature data of each second object, the method further includes: when the first object and the second object are the same object, not performing the attribute detection operation for the second object. In this way, the power consumption of the electronic device can be reduced.

[0010] In a possible implementation, after determining the matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object, it also includes: performing a target operation based on the matching relationship; the target operation includes at least one of an object tracking operation, a key point detection operation, a beautification operation, and an autofocus operation. In this way, the embodiment of the present application determines the matching relationship between the objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, and uses the coordinate information of the object frame where the object in each frame of detection image is located, and the matching relationship between the objects in the two adjacent frames of detection images as input data for operations such as object tracking, key point detection, beautification, and autofocus, which can improve the stability of the image after the operations such as object tracking, key point detection, beautification, and autofocus when it is displayed.

[0011] In a possible implementation, determining the matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object includes: calculating the feature distance between the feature data of the first object and the feature data of the second object, the feature distance including the cosine distance and / or the Euclidean distance; and determining whether the first object and the second object are the same object based on the feature distance. The feature data is used to represent the similarity between the first object and the second object. In this way, based on calculating the similarity between the first object and the second object, determining whether the first object and the second object are the same object is relatively simple.

[0012] In a possible implementation, the feature distance includes a cosine distance. Determining whether the first object and the second object are the same object based on the feature distance includes: determining that the first object and the second object are the same object when the cosine distance between the feature data of the first object and the feature data of the second object is greater than or equal to a first distance threshold; and determining that the first object and the second object are not the same object when the cosine distance between the feature data of the first object and the feature data of the second object is less than the first distance threshold. In this way, an implementation method for determining whether the first object and the second object are the same object based on the cosine distance is provided.

[0013] In a possible implementation, the feature distance includes the Euclidean distance. Determining whether the first object and the second object are the same object based on the feature distance includes: determining that the first object and the second object are the same object when the Euclidean distance between the feature data of the first object and the feature data of the second object is less than or equal to a second distance threshold; and determining that the first object and the second object are not the same object when the Euclidean distance between the feature data of the first object and the feature data of the second object is greater than the second distance threshold. In this way, an implementation method for determining whether the first object and the second object are the same object based on the Euclidean distance is provided.

[0014] In a possible implementation, extracting the feature data of each first object and the feature data of each second object respectively includes: detecting the coordinate information of the first object frame in the first image and the coordinate information of the second object frame in the second image; extracting the first area image in the first object frame from the first image according to the coordinate information of the first object frame, and extracting the second area image in the second object frame from the second image according to the coordinate information of the second object frame, wherein the first area image includes the first object and the second area image includes the second object; extracting the feature data of the first object in the first area image and the feature data of the second object in the second area image respectively. In this way, the electronic device can obtain the coordinate information of the object frame in each frame of the detected image and the feature data of the object in each frame of the detected image, and provide data support for subsequent processing operations.

[0015] In a possible implementation, the coordinate information of the first object frame where the first object in the first image is located is detected respectively, and the coordinate information of the second object frame where the second object in the second image is located is detected, including: preprocessing the first image to obtain a fourth image; using an object detection model to detect the fourth image to obtain the coordinate information and confidence of multiple first candidate frames; according to the confidence of multiple first candidate frames, at least one first object frame is selected from multiple first candidate frames to obtain the coordinate information of at least one first object frame; preprocessing the second image to obtain a fifth image; using an object detection model to detect the fifth image to obtain the coordinate information and confidence of multiple second candidate frames; according to the confidence of multiple second candidate frames, at least one second object frame is selected from multiple second candidate frames to obtain the coordinate information of at least one second object frame. In this way, preprocessing the image before using the object detection model to detect the image can optimize the detection rate of the object detection model for the object in the image.

[0016] In a possible implementation, preprocessing the first image to obtain the fourth image includes: obtaining a first image parameter of the first image, the first image parameter including a first brightness value and / or a first exposure value; and resizing the first image to obtain the fourth image when the first image parameter does not satisfy a first preset condition. Correspondingly, preprocessing the second image to obtain the fifth image includes: obtaining a second image parameter of the second image, the second image parameter including a second brightness value and / or a second exposure value; and resizing the second image to obtain the fifth image when the second image parameter does not satisfy a second preset condition. Wherein, when the first image parameter includes a first brightness value, when the first brightness value is greater than or equal to a first brightness threshold, the first image parameter does not satisfy the first preset condition; when the first image parameter includes a first exposure value, when the first exposure value is greater than or equal to the first exposure threshold, the first image parameter does not satisfy the first preset condition; when the second image parameter includes a second brightness value, when the second brightness value is greater than or equal to the second brightness threshold, the second image parameter does not satisfy the second preset condition; when the second image parameter includes a second exposure value, when the second exposure value is greater than or equal to the second exposure threshold, the second image parameter does not satisfy the second preset condition. In this way, based on the brightness value and / or exposure value of the image, it is measured whether the image is captured in a normal light scene or in a dark light or backlight scene. When the image is captured in a normal light scene, the size of the image is adjusted so that the size ratio of the image subsequently input to the object detection model is consistent, which facilitates the object detection model to detect the object in the image.

[0017] In a possible implementation, after obtaining the first image parameter of the first image, the method further includes: correcting the first image when the first image parameter satisfies the first preset condition; and resizing the corrected first image to obtain a fourth image. Correspondingly, after obtaining the second image parameter of the second image, the method further includes: correcting the second image when the second image parameter satisfies the second preset condition; and resizing the corrected second image to obtain a fifth image. Wherein, when the first image parameter includes a first brightness value, when the first brightness value is less than a first brightness threshold, the first image parameter satisfies the first preset condition; when the first image parameter includes a first exposure value, when the first exposure value is less than the first exposure threshold, the first image parameter satisfies the first preset condition; when the second image parameter includes a second brightness value, when the second brightness value is less than the second brightness threshold, the second image parameter satisfies the second preset condition; when the second image parameter includes a second exposure value, when the second exposure value is less than the second exposure threshold, the second image parameter satisfies the second preset condition. In this way, based on the brightness value and / or exposure value of the image, it is measured whether the image is an image captured in a normal light scene or an image captured in a dark light or backlight scene. When an image is captured in scenes such as dark light or backlight, a correction operation is performed on the image, and the object detection model is used to detect the corrected image only after the correction operation is performed on the image. This can prevent the object detection model from having to learn a large amount of data in special scenes such as dark light or backlight, and can improve the detection effect of the object detection model, thereby optimizing the detection rate of the object detection model for images captured in scenes such as dark light or backlight.

[0018] In one possible implementation, the first image is resized to obtain a fourth image, including: pixel padding the edge of the first image to obtain the fourth image; the size ratio of the fourth image is a preset ratio. Correspondingly, the second image is resized to obtain a fifth image, including: pixel padding the edge of the second image to obtain the fifth image; the size ratio of the fifth image is a preset ratio. In this way, by padding the edge of the image with pixels, the height and width of the image can be adjusted to avoid the risk of object deformation caused by the resize operation, so that the object detection model does not need to identify elongated or flattened objects, thereby optimizing the detection rate and precision recall rate of the object detection model for objects in the image; and the operation of pixel padding the edge of the image takes a short time, thereby increasing the speed of object detection.

[0019] In a possible implementation, the method further includes: normalizing the first image or the fourth image; and normalizing the second image or the fifth image. In this way, the pixel values ​​in the normalized image can be limited to the range of 0 to 1, so that the consistency of the normalized image can be used to provide the same benchmark for subsequent operations, so as to improve the detection accuracy of the subsequent object detection model.

[0020] In a possible implementation, correcting a first image includes: obtaining first scene information of the first image, the first scene information including a high dynamic range (HDR) scene or a non-HDR scene; when the first scene information is an HDR scene, performing a first correction process on the first image to obtain a corrected first image; when the first scene information is a non-HDR scene, performing a second correction process on the first image to obtain a corrected first image. Correspondingly, correcting a second image includes: obtaining second scene information of the second image, the second scene information including an HDR scene or a non-HDR scene; when the second scene information is an HDR scene, performing a first correction process on the second image to obtain a corrected second image; when the second scene information is a non-HDR scene, performing a second correction process on the second image to obtain a corrected second image. In this way, the correction method when the scene of the image is an HDR scene can be different from the correction method when the scene of the image is a non-HDR scene, so that images of different scenes can be corrected using their appropriate correction methods.

[0021] In a possible implementation, performing a first correction process on a first image to obtain a corrected first image includes: performing a histogram equalization process on the first image to obtain the corrected first image. Correspondingly, performing a first correction process on a second image to obtain a corrected second image includes: performing a histogram equalization process on the second image to obtain the corrected second image. In this way, based on the histogram equalization process, the local contrast of the corrected image can be increased.

[0022] In a possible implementation, the first image is subjected to a second correction process to obtain a corrected first image, including: searching the first gray value comparison table for each pixel in the first image in each color channel for a second gray value corresponding to the first gray value; replacing the first gray value of each pixel in the first image in each color channel with the corresponding second gray value, to obtain the corrected first image. Correspondingly, the second image is subjected to a second correction process to obtain a corrected second image, including: searching the first gray value comparison table for each pixel in the second image in each color channel for a fourth gray value corresponding to the third gray value; replacing the third gray value of each pixel in the second image in each color channel with the corresponding fourth gray value, to obtain the corrected second image. The second gray value and the first gray value conform to a gamma function relationship, and the fourth gray value and the third gray value also conform to a gamma function relationship. In this way, the image is corrected based on the method of looking up the first gray value comparison table, which can improve the image correction speed.

[0023] In a possible implementation, feature data of a first object in a first region image and feature data of a second object in a second region image are extracted respectively, including: using a person re-identification model to extract feature data of the first object in the first region image and feature data of the second object in the second region image respectively; the person re-identification model includes a residual neural network (ResNet) model or a MobileNet model, and the feature data includes a person re-identification feature vector. In this way, feature data of each frame of detection image is extracted based on the person re-identification model, so that the accuracy of the determined matching relationship between objects in two adjacent frames of detection images is higher.

[0024] In a possible implementation, obtaining the first image stream includes: obtaining the second image stream; performing downsampling processing on the images included in the second image stream to obtain the first image stream; the size of the images included in the first image stream is smaller than the size of the images included in the second image stream. In this way, the computational burden of subsequent processing of the images in the first image stream can be effectively reduced, thereby reducing the time and power consumption required for image processing.

[0025] In a possible implementation, before extracting the feature data of each first object and the feature data of each second object respectively, the method further includes: converting the image format of the first image into the RGB format, and converting the image format of the second image into the RGB format.

[0026] In a possible implementation, the first object and the second object include a face. In this way, the embodiment of the present application can be applied to face detection.

[0027] In a second aspect, an embodiment of the present application proposes an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call the computer program to execute the above-mentioned object detection method.

[0028] In a third aspect, an embodiment of the present application proposes a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is executed, the above-mentioned object detection method is implemented.

[0029] In a fourth aspect, an embodiment of the present application proposes a computer program product, including a computer program, which enables a computer to execute the above-mentioned object detection method when the computer program is executed.

[0030] The possible implementation methods of the second to fourth aspects have effects similar to those of the first aspect and the possible designs of the first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A schematic diagram of an interface for starting a camera application provided in an embodiment of the present application;

[0032] Figure 2 A schematic diagram of an image effect shown for related technology;

[0033] Figure 3 A schematic diagram showing another image effect of the related technology;

[0034] Figure 4 A schematic diagram showing another image effect of the related art;

[0035] Figure 5 A schematic diagram of the hardware system structure of an electronic device provided in an embodiment of the present application;

[0036] Figure 6 A schematic diagram of the software system structure of an electronic device provided in an embodiment of the present application;

[0037] Figure 7 A schematic diagram of a process for detecting an object frame where an object is located from an image provided by an embodiment of the present application;

[0038] Figure 8 A schematic diagram of a first grayscale value comparison table provided in an embodiment of the present application;

[0039] Fig. 9 A schematic diagram of the structure of an object detection model provided in an embodiment of the present application;

[0040] Fig.10 A flowchart of an object detection method provided in an embodiment of the present application;

[0041] Fig.11 A schematic diagram of the structure of a pedestrian re-identification model provided in an embodiment of the present application;

[0042] Fig.12 A schematic diagram of sequentially processing multiple frames of images in a first image stream provided by an embodiment of the present application;

[0043] Fig.13 A schematic diagram of an image effect displayed in an embodiment of the present application;

[0044] Fig.14 A schematic diagram of another image effect displayed in an embodiment of the present application;

[0045] Fig.15 A schematic diagram of another image effect displayed in an embodiment of the present application;

[0046] Fig.16 A schematic diagram of the structure of an object detection device provided in an embodiment of the present application;

[0047] Fig.17 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first" and "second" are used to distinguish the same items or similar items with basically the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit them to be different.

[0049] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0050] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0051] Currently, some electronic devices are provided with cameras. When a user uses the electronic device, the camera in the electronic device can be used to take photos or videos.

[0052] When shooting with an electronic device, the camera will collect an image stream in real time, and the electronic device can detect objects in multiple frames of images included in the image stream. The object frame where the detected object is located can be displayed on the screen of the electronic device, and the coordinate information of the object frame where the detected object is located can also provide data support for subsequent processing.

[0053] Taking a human face as an example, the face frame where the face is located can be displayed on the screen of the electronic device, and the electronic device can use the coordinate information of the detected face frame as input data for subsequent face tracking, face attribute detection, face key point detection, beauty processing, autofocus and other operations to provide data support.

[0054] Let's take a mobile phone as an example of an electronic device. Figure 1 The user interface shown is used to schematically illustrate the scenarios involved in the embodiments of the present application.

[0055] When the user turns on the screen of the electronic device and controls the electronic device to be in an unlocked state, the electronic device may display the following Figure 1 The first interface 101 shown in (a) of FIG. The first interface 101 may be a desktop of an electronic device, on which icons of multiple installed applications are displayed, such as a file management application icon, an email application icon, a weather application icon, a calculator application icon, a clock application icon, a recorder application icon, a music application icon, a setting application icon, an address book application icon, a phone application icon, a message application icon, and a camera application icon 1011.

[0056] The user can perform a touch operation on the camera application icon 1011, and the touch operation can be a click operation, a long press operation, etc., so that the electronic device receives the user's touch operation on the camera application icon 1011, and the electronic device starts the camera application in response to the touch operation.

[0057] After the camera application is started, the electronic device may display the following Figure 1 The second interface 102 shown in (b) of FIG. The second interface 102 may be a preview interface provided by a camera application for implementing a shooting function, which includes a preview box 1021, a shooting control 1022, a camera switching control 1023, and function controls 1024 corresponding to a plurality of shooting modes.

[0058] The preview box 1021 is used to display multiple frames of images included in the image stream collected by the camera in real time. The shooting control 1022 is used to trigger the shooting operation of the electronic device. The camera switching control 1023 is used to switch the front camera or the rear camera for image acquisition. The function controls 1024 corresponding to the various shooting modes may include night scene mode controls, portrait mode controls, photo mode controls, video mode controls, professional mode controls, and more controls for opening more functions in the camera application.

[0059] Therefore, the camera application can be started by touching the camera application icon 1011. After the camera application is started, and in the process of displaying multiple frames of images included in the image stream captured by the camera in real time on the preview interface of the camera application, the electronic device can detect objects in the multiple frames of images included in the image stream.

[0060] Understandably, Figure 1 (a) and Figure 1 The interface shown in (b) is merely an example of a user interface in the process of launching a camera application by touching the camera application icon of an electronic device, and does not constitute a limitation on the embodiments of the present application.

[0061] In another scenario, the user can also call the corresponding interface through a third-party application installed on the electronic device to access the camera application of the electronic device to start the camera application. After the camera application is started, and in the process of displaying multiple frames of images included in the image stream captured by the camera in real time on the preview interface of the camera application, the electronic device can detect objects in the multiple frames of images included in the image stream.

[0062] However, after the electronic device detects the object in the multiple frames of images included in the image stream, when the electronic device sequentially displays the object frames where the object is located in the multiple frames of images included in the image stream, the object frames may jump, flicker, and other problems.

[0063] In the following, a mobile phone is used as an example of an electronic device. The object in the image is a human face, and the object frame is a human face frame. Figures 2 to 4 The user interface shown is used to schematically illustrate the problem that after detecting faces in multiple frames of images included in an image stream, an electronic device in the related art has a problem of jumping and flashing when the face frames containing the faces in the multiple frames of images included in the image stream are displayed in sequence.

[0064] The first scenario, such as Figure 2 As shown, multiple frames of images included in the image stream can be displayed in sequence in the preview box 1021 of the preview interface of the electronic device. Figure 2 The first frame detection image shown in (a) is as follows: Figure 2 The second frame detection image shown in (b) and Figure 2 Taking the third frame detection image shown in (c) as an example, the first frame detection image, the second frame detection image and the third frame detection image all include two characters displayed in the preview frame 1021, one of which is located on the left side of the preview frame 1021 when displayed, and the other is located on the right side of the preview frame 1021 when displayed.

[0065] like Figure 2 As shown in (a), the electronic device can perform face detection on the first frame detection image to obtain the coordinate positions of the face frames where the faces of the two characters are located, and based on the coordinate positions of the face frames where the faces of the two characters are located, display the first face frame 201 corresponding to the character on the left and the second face frame 202 corresponding to the character on the right in the preview frame 1021.

[0066] like Figure 2 As shown in (b), the electronic device can perform face detection on the second frame detection image to obtain the coordinate positions of the face frames where the faces of the two characters are located, such as the coordinate position of the third face frame 203 where the face of the character on the left is located, and the coordinate position of the fourth face frame 204 where the face of the character on the right is located.

[0067] Since the relevant technology does not determine the matching relationship between each face in two adjacent detection image frames, or uses intersection over union (IOU) and other methods to determine the matching relationship between each face in two adjacent detection image frames, its accuracy is low. Therefore, it may cause the face in the third face frame 203 detected in the second detection image frame to be mistakenly regarded as the same face as the face in the second face frame 202 detected in the first detection image frame, and the face in the fourth face frame 204 detected in the second detection image frame to be mistakenly regarded as the same face as the face in the first face frame 201 detected in the first detection image frame.

[0068] If there is a tracking image between the first detection image and the second detection image, and the face in the third face frame 203 detected in the second detection image is mistakenly regarded as the same face as the face in the second face frame 202 detected in the first detection image, the electronic device will jointly determine the coordinate position of the fifth face frame 205 corresponding to the person on the left in the second detection image based on the coordinate position of the third face frame 203 and the coordinate position of the face frame corresponding to the person on the right in the previous tracking image of the second detection image, and display the fifth face frame 205 corresponding to the person on the left in the preview frame 1021. At this time, the display position of the fifth face frame 205 corresponding to the person on the left is deviated to the right by a certain distance relative to the position of the face of the person on the left.

[0069] Accordingly, when the face in the fourth face frame 204 detected in the second detection image is mistakenly regarded as the same face as the face in the first face frame 201 detected in the first detection image, the electronic device will jointly determine the coordinate position of the sixth face frame 206 corresponding to the person on the right in the second detection image based on the coordinate position of the fourth face frame 204 and the coordinate position of the face frame corresponding to the person on the left in the previous tracking image of the second detection image, and display the sixth face frame 206 corresponding to the person on the right in the preview frame 1021. At this time, the display position of the sixth face frame 206 corresponding to the person on the right is deviated to the left by a certain distance relative to the position of the face of the person on the right.

[0070] It should be noted that when the electronic device displays the second frame detection image, it will display the fifth face frame 205 corresponding to the person on the left and the sixth face frame 206 corresponding to the person on the right, but will not display the third face frame 203 and the fourth face frame 204.

[0071] like Figure 2 As shown in (c) in the figure, the electronic device can perform face detection on the third frame detection image to obtain the coordinate positions of the face frames where the faces of the two characters are located. If the faces detected in the third frame detection image accurately match the faces detected in the second frame detection image, it can be determined that the face in the face frame corresponding to the character located on the left side detected in the third frame detection image is the same face as the face in the third face frame 203 detected in the second frame detection image, and the face in the face frame corresponding to the character located on the right side detected in the third frame detection image is the same face as the face in the fourth face frame 204 detected in the second frame detection image.

[0072] If there is a tracking image between the third detection image and the second detection image, and the face in the face frame corresponding to the person on the left detected in the third detection image is the same face as the face in the third face frame 203 detected in the second detection image, the electronic device will jointly determine the coordinate position of the seventh face frame 207 corresponding to the person on the left in the third detection image based on the coordinate position of the face frame corresponding to the person on the left detected in the third detection image and the coordinate position of the face frame corresponding to the person on the left in the previous tracking image of the third detection image, and display the seventh face frame 207 corresponding to the person on the left in the preview frame 1021. At this time, the display position of the seventh face frame 207 corresponding to the person on the left is substantially consistent with the position of the face of the person on the left.

[0073] Correspondingly, when the face in the face frame corresponding to the person on the right detected in the third frame detection image is the same face as the face in the fourth face frame 204 detected in the second frame detection image, the electronic device will jointly determine the coordinate position of the eighth face frame 208 corresponding to the person on the right in the third frame detection image based on the coordinate position of the face frame corresponding to the person on the right detected in the third frame detection image and the coordinate position of the face frame corresponding to the person on the right in the previous frame tracking image of the third frame detection image, and display the eighth face frame 208 corresponding to the person on the right in the preview frame 1021. At this time, the display position of the eighth face frame 208 corresponding to the person on the right is basically consistent with the position of the face of the person on the right.

[0074] Therefore, combined with Figure 2 (a) Figure 2 (b) and Figure 2 From the interface shown in (c), it can be seen that if the matching relationship between the faces in two adjacent frames of detected images is not determined, or the accuracy of the determined matching relationship is low, it is possible that when the face frames containing the faces in multiple frames of images are displayed in sequence, the face frames corresponding to the same face will jump or flash.

[0075] The second scenario, such as Figure 3 As shown, multiple frames of images included in the image stream can be displayed in sequence in the preview box 1021 of the preview interface of the electronic device. Figure 3 The first frame detection image shown in (a) is as follows: Figure 3 The second detection image shown in (b) and Figure 3Taking the third detection image shown in (c) as an example, the first detection image, the second detection image and the third detection image all include 11 characters displayed in the preview box 1021, five of which are distributed in the front row and the other six are distributed in the back row.

[0076] When the electronic device outputs and displays the face frames, it sets the maximum number of face frames that can be displayed, such as 10. Therefore, when the number of face frames detected is greater than 10, if the matching relationship between the faces in two adjacent frames of detection images is not determined, the electronic device will output the coordinate information of the face frames where the 10 faces are located in order from large to small according to the size of the face frames where the faces are located detected in each frame of detection image, and display the 10 face frames according to the output coordinate information of the face frames where the 10 faces are located. The size of the face frame is positively correlated with the size of the face in the face frame. When the face is larger, the size of the face frame is larger, and when the face is smaller, the size of the face frame is smaller.

[0077] Taking the sizes of the face frames corresponding to the 11 characters as an example, the difference between the size of the face frame corresponding to the leftmost character in the back row and the size of the face frame corresponding to the rightmost character in the back row is very small, and the sizes of the face frames corresponding to the remaining characters are all larger than the sizes of the face frames corresponding to the leftmost character in the back row and the sizes of the face frames corresponding to the rightmost character in the back row, illustrating the problem of jumping and flickering of the face frames in this scene.

[0078] like Figure 3 As shown in (a) in the figure, the electronic device can perform face detection on the first frame of the detection image to obtain the coordinate positions of the face frames corresponding to the 11 characters. Due to factors such as detection errors, it is possible that the size of the face frame corresponding to the leftmost character in the back row is larger than the size of the face frame corresponding to the rightmost character in the back row. In this case, the electronic device will output the coordinate positions of the face frames corresponding to the other 10 characters except the rightmost character in the back row, and display the 10 face frames based on the output coordinate information of the face frames corresponding to the 10 characters. In this way, Figure 3 In the first detection image shown in (a) in FIG. 5 , no face frame is displayed at the face position of the person on the far right in the back row, while face frames are displayed at the face positions of the other 10 persons.

[0079] like Figure 3As shown in (b) in the figure, the electronic device can perform face detection on the second frame detection image to obtain the coordinate positions of the face frames corresponding to the 11 characters. Due to factors such as detection errors, it is possible that the size of the face frame corresponding to the rightmost character in the back row is larger than the size of the face frame corresponding to the leftmost character in the back row. In this case, the electronic device will output the coordinate information of the face frames corresponding to the other 10 characters except the leftmost character in the back row, and display the 10 face frames based on the output coordinate information of the face frames corresponding to the 10 characters. In this way, Figure 3 In the second detection image shown in (b) in FIG. 5 , no face frame is displayed at the face position of the leftmost person in the back row, while face frames are displayed at the face positions of the other 10 persons.

[0080] like Figure 3 As shown in (c) in the figure, the electronic device can perform face detection on the third frame detection image to obtain the coordinate positions of the face frames corresponding to the 11 characters. Due to factors such as detection errors, it is possible that the size of the face frame corresponding to the leftmost character in the back row is larger than the size of the face frame corresponding to the rightmost character in the back row. In this case, the electronic device will output the coordinate information of the face frames corresponding to the other 10 characters except the rightmost character in the back row, and display the 10 face frames based on the output coordinate information of the face frames corresponding to the 10 characters. In this way, Figure 3 In the third detection image shown in (c), the face frame of the person on the far right in the back row is not displayed with a face frame, while the faces of the other 10 people are displayed with face frames.

[0081] Therefore, combined with Figure 3 (a) Figure 3 (b) and Figure 3 From the interface shown in (c), it can be seen that if the matching relationship between the faces in two adjacent frames of detection images is not determined, and the coordinate information of the face frames where multiple faces are located is output in sequence from large to small only according to the size of the face frames where the faces are located obtained by detecting each frame of detection images, it may cause the face frames displayed to jump or flicker when the face frames where the faces in multiple frames of images are located are displayed in sequence.

[0082] The third scenario, such as Figure 4 As shown, multiple frames of images included in the image stream can be displayed in sequence in the preview box 1021 of the preview interface of the electronic device. Figure 4 The first frame detection image shown in (a) is as follows: Figure 4 The second frame detection image shown in (b) and Figure 4Taking the third detection image shown in (c) in FIG. 1 as an example, the first detection image, the second detection image and the third detection image all include a person and a dog displayed in the preview box 1021 .

[0083] like Figure 4 As shown in (a) in FIG. 1 , the electronic device can perform face detection on the first detection frame image to obtain the coordinate position of a face frame where a person's face is located, and based on the coordinate position of the face frame where the person's face is located, display a ninth face frame 401 corresponding to the person in the preview frame 1021. At this time, no face frame is displayed at the position where the dog's face is located.

[0084] like Figure 4 As shown in (b) in FIG. 1 , the electronic device can perform face detection on the second detection image. Since face detection may have a certain probability of false detection or missed detection, the electronic device may mistake the dog's face for a human face after performing face detection on the second detection image, and then detect the coordinate position of the tenth face frame 402 corresponding to the person and the coordinate position of the eleventh face frame 403 where the dog's face is located. If the matching relationship between the faces in the two adjacent detection images is not determined, or the accuracy of the determined matching relationship is low, the electronic device may display the tenth face frame 402 corresponding to the person and the eleventh face frame 403 where the dog's face is located in the preview frame 1021.

[0085] like Figure 4 As shown in (c) in FIG. 1 , the electronic device can perform face detection on the third detection frame image to obtain the coordinate position of a face frame where a person's face is located, and based on the coordinate position of the face frame where the person's face is located, display the twelfth face frame 404 corresponding to the person in the preview frame 1021. At this time, no face frame is displayed at the position where the dog's face is located.

[0086] Therefore, combined with Figure 4 (a) Figure 4 (b) and Figure 4 From the interface shown in (c), it can be seen that if the matching relationship between the faces in two adjacent frames of detected images is not determined, or the accuracy of the determined matching relationship is low, it is possible that when the face frames containing the faces in multiple frames of images are displayed in sequence, the displayed face frames may jump or flicker.

[0087] Based on this, an embodiment of the present application provides an object detection method, an electronic device, a storage medium and a program product, by acquiring a first image stream, the first image stream includes a first image and a second image, the first image is an image frame before the second image, the first image includes at least one first object, and the second image includes at least one second object; extracting feature data of each first object and feature data of each second object respectively; determining a matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object, the matching relationship is used to indicate whether the first object and the second object are the same object; displaying a target object box corresponding to the second object based on the matching relationship.

[0088] In this way, the embodiment of the present application can determine the matching relationship between the first object and the second object based on the feature data of each first object in the first image and the feature data of each second object in the second image. The accuracy of the determined matching relationship is high, so that when the electronic device displays the object frames where the objects in the multiple frames of images included in the first image stream are located in sequence according to the matching relationship between the first object and the second object, the stability of the object frame display can be improved, thereby improving the problems of jumping and flickering of the object frame.

[0089] In some embodiments, the first object and the second object include a face, the target object frame may be a target face frame, the object detection model may be a face detection model, and the electronic device may use the face detection model to detect coordinate information of the face frame where the face is located.

[0090] Of course, in other embodiments, the first object and the second object may also be other objects, such as a human body, a gesture, etc. If the first object and the second object include a human body, the target object frame may be a target human body frame, the object detection model may be a human body detection model, and the electronic device may use the human body detection model to detect the coordinate information of the human body frame where the human body is located. If the first object and the second object include a gesture, the target object frame may be a target gesture frame, the object detection model may be a gesture detection model, and the electronic device may use the gesture detection model to detect the coordinate information of the gesture frame where the gesture is located.

[0091] The object detection method provided in the embodiment of the present application can be applied to an electronic device with a camera. The electronic device includes a terminal device, which can also be called a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The electronic device can be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with a wireless transceiver function, a virtual reality (VR) electronic device, an augmented reality (AR) electronic device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiment of the present application does not limit the specific technology and specific device form adopted by the electronic device.

[0092] In order to better understand the embodiments of the present application, the structure of the electronic device according to the embodiments of the present application is introduced below.

[0093] Figure 5 The structure diagram of the electronic device 500 is shown. The electronic device 500 may include a processor 510, an external memory interface 520, an internal memory 521, a universal serial bus (USB) interface 530, a charging management module 540, a power management module 541, a battery 542, an antenna 1, an antenna 2, a mobile communication module 550, a wireless communication module 560, an audio module 570, a speaker 570A, a receiver 570B, a microphone 570C, an earphone interface 570D, a sensor module 580, a button 590, a motor 591, an indicator 592, a camera 593, a display screen 594, and a subscriber identification module (SIM) card interface 595.

[0094] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 500. In other embodiments of the present application, the electronic device 500 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

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

[0096] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

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

[0098] The charging management module 540 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 540 may receive charging input from a wired charger through the USB interface 530. In some wireless charging embodiments, the charging management module 540 may receive wireless charging input through a wireless charging coil of the electronic device 500. While the charging management module 540 is charging the battery 542, it may also power the electronic device through the power management module 541.

[0099] The power management module 541 is used to connect the battery 542, the charging management module 540 and the processor 510. The power management module 541 receives input from the battery 542 and / or the charging management module 540, and supplies power to the processor 510, the internal memory 521, the display screen 594, the camera 593, and the wireless communication module 560. In some other embodiments, the power management module 541 may also be disposed in the processor 510. In other embodiments, the power management module 541 and the charging management module 540 may also be disposed in the same device.

[0100] The wireless communication function of the electronic device 500 can be implemented through the antenna 1, the antenna 2, the mobile communication module 550, the wireless communication module 560, the modem processor and the baseband processor.

[0101] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 550 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 500. The mobile communication module 550 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. In some embodiments, at least some functional modules of the mobile communication module 550 may be set in the processor 510.

[0102] The wireless communication module 560 can provide wireless communication solutions for application in the electronic device 500, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.

[0103] In some embodiments, antenna 1 of electronic device 500 is coupled to mobile communication module 550, and antenna 2 is coupled to wireless communication module 560, so that electronic device 500 can communicate with the network and other devices through wireless communication technology.

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

[0105] The display screen 594 is used to display images, display videos, and receive sliding operations, etc. The display screen 594 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 500 may include one or more display screens 594.

[0106] The electronic device 500 can realize the shooting function through ISP, camera 593, video codec, GPU, display screen 594 and application processor.

[0107] The ISP is used to process the data fed back by the camera 593. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise and brightness of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 593.

[0108] The camera 593 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 500 may include one or more cameras 593.

[0109] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 500 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

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

[0111] NPU is a neural network (NN) computing processor, which can quickly process input information and continuously self-learn by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. NPU can realize applications such as intelligent cognition of electronic device 500, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0112] The external memory interface 520 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 500. The external memory card communicates with the processor 510 through the external memory interface 520 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0113] The internal memory 521 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 521 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 500 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 521 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 510 executes various functional applications and data processing of the electronic device 500 by running instructions stored in the internal memory 521, and / or instructions stored in a memory provided in the processor.

[0114] The electronic device 500 can implement audio functions such as music playing and recording through the audio module 570, the speaker 570A, the receiver 570B, the microphone 570C, the headphone jack 570D, and the application processor.

[0115] The key 590 includes a power key, a volume key, etc. The electronic device 500 can receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 500. The motor 591 can generate vibration prompts. The motor 591 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 592 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 595 is used to connect a SIM card.

[0116] The software system of the electronic device 500 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, etc. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 500.

[0117] Figure 6 : is a software structure block diagram of the electronic device 500 of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Androidruntime) and the system library, the hardware abstraction layer and the kernel layer.

[0118] The application layer can include a series of application packages. Figure 6 As shown, the application package may include applications such as camera, settings, and calendar.

[0119] The camera application is an application with shooting and video recording functions, and the electronic device can respond to the user's operation of opening the camera application to take photos or videos. It is understandable that the camera application's shooting and video recording functions can also be called by other applications.

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

[0121] Among them, Figure 6 As shown, the application framework layer may include a camera service, a window manager, a content provider, a resource manager, a view system, and the like.

[0122] The camera service can be called by the camera application to realize functions such as taking photos or recording videos.

[0123] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0124] Content providers are used to store and retrieve data and make it accessible to applications. This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0125] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0126] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0127] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0128] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0129] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0130] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0131] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0132] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG2, H.262, MP3, AAC, AMR, JPG, PNG, etc.

[0133] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.

[0134] The hardware abstraction layer is an abstract structure between the kernel layer and the Android runtime. The hardware abstraction layer can be a package of the hardware driver of the kernel layer, providing a calling interface for the application framework layer.

[0135] In an embodiment of the present application, the hardware abstraction layer may include a camera hardware abstraction module (camera HAL). In a possible implementation, the camera hardware abstraction module is used to process multiple frames of images included in the second image stream captured by the camera to determine a matching relationship between a first object in a first image included in the first image stream and a second object in a second image included in the first image stream, wherein the matching relationship is used to indicate whether the first object and the second object are the same object.

[0136] The kernel layer is a layer between hardware and software. The kernel layer includes at least a camera driver, a sensor driver, and a display driver. In some embodiments, the camera driver is used to control the operation of the camera, the sensor driver is used to control the operation of the sensor module, and the display driver is used to control the display screen to display images.

[0137] The hardware may be a camera, a sensor module, a display screen, etc. In the embodiment of the present application, the camera may be a rear camera or a front camera.

[0138] In some embodiments, when the electronic device is executing the object detection method of the embodiment of the present application, the camera hardware abstraction module needs to obtain the first image parameters of the first image, so as to resize the first image if the first image parameters do not satisfy the first preset condition, and to correct the first image if the first image parameters satisfy the first preset condition, and to resize the corrected first image. Correspondingly, the camera hardware abstraction module needs to obtain the second image parameters of the second image, so as to resize the second image if the second image parameters do not satisfy the second preset condition, and to correct the second image if the second image parameters satisfy the second preset condition, and to resize the corrected second image.

[0139] It should be understood that after the camera captures the second image stream, the second image stream can be sent to the camera hardware abstraction module through the camera driver, and each frame of the second image stream can carry its corresponding image parameters. In this way, after the camera hardware abstraction module downsamples the image included in the second image stream to obtain the first image stream, the camera hardware abstraction module obtains the first image parameter of the first image in the first image stream and the second image parameter of the second image in the first image stream.

[0140] In some embodiments, when the electronic device is executing the object detection method of the embodiments of the present application, the camera hardware abstraction module also needs to obtain first scene information of the first image and second scene information of the second image, where the first scene information includes an HDR scene or a non-HDR scene, and the second scene information also includes an HDR scene or a non-HDR scene.

[0141] In one possible implementation, a perception module may be set in a hardware abstraction layer, and based on the perception module, it may be determined whether the first scene information of the first image is an HDR scene or a non-HDR scene, and based on the perception module, it may be determined whether the second scene information of the second image is an HDR scene or a non-HDR scene.

[0142] When the perception module determines that the first scene information of the first image is an HDR scene, the perception module determines that the HDR flag of the first image is true, and the perception module sends data containing the HDR flag as true to the camera hardware abstract module. When the perception module determines that the first scene information of the first image is a non-HDR scene, the perception module determines that the HDR flag of the first image is false, and the perception module sends data containing the HDR flag as false to the camera hardware abstract module.

[0143] Correspondingly, when the perception module determines that the second scene information of the second image is an HDR scene, the perception module determines that the HDR flag of the second image is true, and the perception module sends the data containing the HDR flag as true to the camera hardware abstract module. When the perception module determines that the second scene information of the second image is a non-HDR scene, the perception module determines that the HDR flag of the second image is false, and the perception module sends the data containing the HDR flag as false to the camera hardware abstract module.

[0144] It should be noted that although the embodiments of the present application are described using the Android system, the principles of the object detection method are also applicable to electronic devices with operating systems such as iOS or Windows.

[0145] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be implemented independently or in combination with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0146] It should be noted that the object detection method provided in the embodiment of the present application can perform real-time processing on the image stream captured by the camera, and the embodiment of the present application can be executed in the preview scene of the camera application, which can be a preview scene when taking pictures or a preview scene when recording videos.

[0147] For example, Figure 7 An embodiment of the present application provides a flow chart of detecting an object frame where an object is located from an image, which can be applied to an electronic device and may specifically include the following steps:

[0148] S701: The electronic device obtains a second image stream.

[0149] In some embodiments, the second image stream is the original image stream captured by the camera in real time, and the second image stream includes multiple consecutive frames of images.

[0150] S702, the electronic device downsamples the images included in the second image stream to obtain a first image stream; the first image stream includes a first image and a second image, and the first image is an image frame before the second image.

[0151] In some embodiments, the electronic device may downsample each frame image included in the second image stream to obtain each frame image included in the first image stream, so that the size of the image included in the first image stream is smaller than the size of the image included in the second image stream.

[0152] The first image stream may also be referred to as a tiny stream, which refers to an image stream including images of smaller size and retaining valid information necessary for image processing.

[0153] Therefore, by downsampling the images included in the second image stream to obtain the first image, when the images in the first image stream are subsequently processed, the overall computational burden of the images in the first image stream is less than the overall computational burden of the images in the second image stream. In this way, the computational burden when processing the images in the first image stream can be effectively reduced, thereby reducing the time and power consumption required for image processing.

[0154] For example, the size of the image included in the second image stream may be 1920 pixels*1080 pixels, and the size of the image included in the first image stream may be 640 pixels*360 pixels.

[0155] The first image stream includes a first image and a second image, the first image is an image frame before the second image, the first image includes at least one first object, and the second image includes at least one second object.

[0156] It can be understood that the second image stream in the embodiment of the present application includes multiple frames of images, the first image stream also includes multiple frames of images, and the number of images included in the second image stream is equal to the number of images included in the first image stream. The embodiment of the present application mainly takes two frames of images in the first image stream as an example to illustrate the specific implementation process of the object detection method, and the two frames of images in the first image stream are respectively the first image and the second image.

[0157] It is worth noting that the following S703 to S710 mainly take the second image in the first image stream as an example to explain in detail the specific implementation method of the electronic device detecting the coordinate information of the second object frame where the second object in the second image is located.

[0158] S703: The electronic device converts the image format of the second image into an RGB format.

[0159] In some embodiments, the image format of the images included in the second image stream captured by the camera in the electronic device can be in RAW format. Correspondingly, the image format of the images included in the first image stream obtained after downsampling processing can also be in RAW format. Then the image format of the second image in the first image stream is also in RAW format.

[0160] The electronic device may convert the image format of the second image to convert the image format of the second image from the RAW format to the RGB format, wherein the image in the RGB format may be an image formed by superposition of three primary colors (ie, red, blue and green).

[0161] The specific principle of the electronic device converting the image format of the second image from the RAW format to the RGB format can be referred to the relevant technology, and the embodiment of the present application is not limited to this.

[0162] S704, the electronic device obtains second image parameters of the second image; the second image parameters include a second brightness value and / or a second exposure value.

[0163] S705: The electronic device determines whether a second image parameter of the second image meets a second preset condition.

[0164] Users can use the camera in electronic devices to capture images under different lighting conditions. The camera can capture images in normal light scenes, or in dark or backlit scenes. For example, the image captured by the camera is a face image. In a dark or backlit scene, the face image will be dark and unclear.

[0165] Therefore, in order to improve the brightness and clarity of images captured in dark or backlit scenes, the electronic device of the embodiment of the present application can first obtain the second image parameters of the second image, and then determine whether the second image parameters of the second image meet the second preset condition to determine whether the second image is an image captured in a normal light scene or an image captured in a dark or backlit scene, and then determine whether the second image needs to be corrected.

[0166] The image brightness (LV) is used to evaluate the ambient brightness during image acquisition. The image exposure value refers to a value that represents the light transmission capability of the camera lens, which is a combination of the exposure time and the aperture value.

[0167] Exposure time refers to the time the shutter needs to be open in order to project light onto the photosensitive surface of the camera's photosensitive material. The exposure time is determined by the sensitivity of the photosensitive material and the illumination on the photosensitive surface. The longer the exposure time, the more light enters the camera, and the shorter the exposure time, the less light enters the camera. The aperture value refers to the ratio of the focal length of the lens in the camera to the diameter of the lens. The larger the aperture value, the more light enters the camera, and the smaller the aperture value, the less light enters the camera.

[0168] In one implementation, when the second image parameter includes a second brightness value, when the second brightness value is greater than or equal to a second brightness threshold, the second image parameter does not satisfy the second preset condition. When the second image parameter includes a second brightness value, when the second brightness value is less than the second brightness threshold, the second image parameter satisfies the second preset condition.

[0169] In this case, when the second brightness value is greater than or equal to the second brightness threshold, it means that the brightness of the second image is relatively high, and the second image may be an image captured in a normal light scene, and the second image parameter does not meet the second preset condition, so the second image does not need to be corrected. When the second brightness value is less than the second brightness threshold, it means that the brightness of the second image is dim, and the second image may be an image captured in a dark light or backlight scene, and the second image parameter meets the second preset condition, so the second image needs to be corrected.

[0170] In another implementation, when the second image parameters include a second exposure value, when the second exposure value is greater than or equal to a second exposure threshold, the second image parameters do not satisfy the second preset condition. When the second image parameters include a second exposure value, when the second exposure value is less than the second exposure threshold, the second image parameters satisfy the second preset condition.

[0171] In this case, when the second exposure value is greater than or equal to the second exposure threshold, it means that the brightness of the second image is relatively high, and the second image may be an image captured in a normal light scene, and the second image parameter does not meet the second preset condition, so the second image does not need to be corrected. When the second exposure value is less than the second exposure threshold, it means that the brightness of the second image is dark, and the second image may be an image captured in a dark light or backlight scene, and the second image parameter meets the second preset condition, so the second image needs to be corrected.

[0172] In summary, when the second image parameter meets the second preset condition, the electronic device sequentially executes the following S706 and S707; when the second image parameter does not meet the second preset condition, the electronic device directly executes the following S707.

[0173] S706: When the second image parameter meets the second preset condition, the electronic device corrects the second image.

[0174] When the second image parameter satisfies the second preset condition, the electronic device may correct the second image to improve the brightness and clarity of the image captured in a dark or backlit scene.

[0175] Since image acquisition scenes include a large number of dark or backlit scenes, and the training set used when training the object detection model is difficult to cover special scenes such as dark or backlit, blindly adding difficult data to improve the object detection model's detection of objects in special scenes such as dark or backlit will lead to a weakened object detection effect of the object detection model in normal light scenes, such as prone to false detection and other problems.

[0176] Therefore, the embodiment of the present application determines whether the image is captured in a dark light or backlight scene by judging the brightness value and / or exposure value of the image, thereby triggering the correction operation of the image in these specific scenes; and the object detection model is used to detect the corrected image only after the correction operation is performed on the image. In this way, the object detection model does not need to learn a large amount of data in special scenes such as dark light or backlight, and can improve the detection effect of the object detection model, and optimize the detection rate of the object detection model for images captured in scenes such as dark light or backlight.

[0177] In some embodiments, the scene of the second image may be an HDR scene or a non-HDR scene. Compared with a non-HDR scene, when the scene of the second image is an HDR scene, the second image can provide more dynamic range and image details.

[0178] Therefore, the electronic device may first obtain the second scene information of the second image, the second scene information including an HDR scene or a non-HDR scene; when the second scene information is an HDR scene, the electronic device performs a first correction process on the second image to obtain a corrected second image; when the second scene information is a non-HDR scene, the electronic device performs a second correction process on the second image to obtain a corrected second image. In other words, the correction method when the scene of the second image is an HDR scene is different from the correction method when the scene of the second image is a non-HDR scene.

[0179] When the second scene information of the second image is an HDR scene, a possible implementation manner of the electronic device performing the first correction processing on the second image is: the electronic device performs histogram equalization processing on the second image to obtain a corrected second image.

[0180] Among them, the histogram equalization processing can be specifically mapped to the new pixel intensity according to the pixel average value by using histogram equalization, so as to perform image synthesis. Histogram equalization processing is a method of adjusting the contrast by using the image histogram in the field of image processing. This method is usually used to increase the local contrast of the image, especially when the contrast of the useful data of the image is quite close. Through this method, the brightness can be better distributed on the histogram, so that it can be used to enhance the local contrast without affecting the overall contrast.

[0181] Specifically, histogram equalization is a transformation based on the probability density function of a random variable. Assume that the grayscale value variable of the image before histogram equalization is r, and the grayscale value variable of the image after histogram equalization is s. Let P r (r) represents the probability density function of the gray value variable r, let P s(s) represents the probability density function of the gray value variable s. The number of pixels of the gray value of the image before histogram equalization processing in the interval [r, dr] is P r (r)dr, the number of pixels of the grayscale value of the image after histogram equalization processing in the interval [s, ds] is P s (s)ds, then P s (s)ds=P r (r)dr. Integrating both sides and performing equalization gives Discretize the above formula to get Among them, k represents the discrete gray level, n j represents the number of pixels with gray level j, N represents the total number of pixels in the image, S k Represents the kth gray level after histogram equalization.

[0182] In the case where the second scene information of the second image is an HDR scene, another possible implementation of the electronic device performing the first correction processing on the second image is: the electronic device searches the second grayscale value comparison table for the eighth grayscale value corresponding to the seventh grayscale value of each pixel in the second image in each color channel; the electronic device replaces the seventh grayscale value of each pixel in the second image in each color channel with the corresponding eighth grayscale value to obtain the corrected second image. The eighth grayscale value and the seventh grayscale value have a gamma-like function relationship.

[0183] The second grayscale value comparison table includes multiple input grayscale values ​​and output grayscale values ​​corresponding to each input grayscale value, and the corresponding relationship between the output grayscale value and the input grayscale value conforms to a gamma function-like relationship. For the second image, an input grayscale value equal to the seventh grayscale value can be found in the second grayscale value comparison table, and the output grayscale value corresponding to the input grayscale value is used as the eighth grayscale value.

[0184] Exemplarily, the second grayscale value comparison table can be calculated by referring to the following gamma-like function relationship:

[0185]

[0186] Where x represents the grayscale value of each pixel in each color channel of the image before correction, f(x) represents the grayscale value of each pixel in each color channel of the image after correction, int represents the rounding operation of the result, bias_x 0 Indicates the first offset value of the piecewise function corresponding to the grayscale value interval [0, α], bias_y 0 Indicates the second offset value of the piecewise function corresponding to the grayscale value interval [0, α], bias_y 1Indicates the third offset value of the piecewise function corresponding to the gray value interval (α, β], bias_x 2 Indicates the fourth offset value of the piecewise function corresponding to the grayscale value interval (β, 255], bias_y 2 represents the fifth offset value of the piecewise function corresponding to the grayscale value interval (β, 255], and the first offset value bias_x 0 , the second offset value bias_y 0 , the third offset value bias_y 1 , the fourth offset value bias_x 2 and the fifth offset value bias_y 2 α represents the first preset grayscale value, and α is an integer greater than 0; β represents the second preset grayscale value, and β is an integer greater than α and less than 255.

[0187] In some possible implementations, since the above-mentioned gamma-like function relationship is in different gray value intervals, different piecewise functions are used to correct the gray value of the image. If the above-mentioned offset value is not added to the different piecewise functions, it may cause the piecewise function curve corresponding to the gray value interval [0, α] to be discontinuous with the piecewise function curve corresponding to the gray value interval (α, β], and it may also cause the piecewise function curve corresponding to the gray value interval (α, β] to be discontinuous with the piecewise function curve corresponding to the gray value interval (β, 255].

[0188] Therefore, the first offset value bias_x is added to the piecewise function corresponding to the gray value interval [0, α] 0 and the second offset value bias_y 0 , add the third offset value bias_y to the piecewise function corresponding to the gray value interval (α, β] 1 , and add a fourth offset value bias_x to the piecewise function corresponding to the gray value interval (β, 255] 2 and the fifth offset value bias_y 2 In this way, the piecewise function curve corresponding to the gray value interval [0, α] can be made continuous with the piecewise function curve corresponding to the gray value interval (α, β], and the piecewise function curve corresponding to the gray value interval (α, β] can be made continuous with the piecewise function curve corresponding to the gray value interval (β, 255].

[0189] For example, α can be 215, and the first offset value bias_x 0 Can be 0, the second offset value bias_y when the gray value x is not equal to 0 0 Can be -20, the second offset value bias_y when the gray value x is equal to 0 0 Can be 0, the third offset value bias_y 1It can be 0. Thus, in the second grayscale value comparison table, when the input grayscale value is 0, the corresponding output grayscale value is 0; when the input grayscale value is 1, the corresponding output grayscale value is 0; when the input grayscale value is 2, the corresponding output grayscale value is 8; when the input grayscale value is 215, the corresponding output grayscale value is 215. Therefore, the piecewise function curve corresponding to the grayscale value interval [0, α] can be made continuous with the piecewise function curve corresponding to the grayscale value interval (α, β].

[0190] It can be understood that when α is not 215, the second offset value bias_y added to the piecewise function corresponding to the gray value interval [0, α] is 0 It can also be an integer value other than -20.

[0191] The above gives a gamma-like function relationship as a piecewise function corresponding to different grayscale value intervals to generate an implementation method of a second grayscale value comparison table. Of course, other piecewise functions other than the piecewise functions included in the gamma-like function relationship can also be used to generate the second grayscale value comparison table in different grayscale value intervals, but it is necessary to make the slope of the piecewise function corresponding to the grayscale value interval [0, α] and the slope of the piecewise function corresponding to the grayscale value interval (β, 255] smaller than the slope of the piecewise function corresponding to the grayscale value interval (α, β], so that when the second grayscale value comparison table is used to correct the image later, the distribution of the grayscale value of the corrected image is more uniform.

[0192] Therefore, when the scene of the image is an HDR scene, there are particularly bright and particularly dark areas in the image. Therefore, a second grayscale value comparison table is generated using a gamma-like function relationship, so that after the image is corrected using the second grayscale value comparison table, the bright areas in the image can be darkened and the dark areas in the image can be brightened. In addition, relative to the method of using the above-mentioned gamma-like function relationship to perform real-time calculations to correct the image, the embodiment of the present application corrects the image based on a lookup method of the second grayscale value comparison table, which can improve the correction speed of the image. Among them, the second grayscale value comparison table can be pre-stored in the electronic device, and the second grayscale value comparison table can be a hash table.

[0193] In the case where the second scene information of the second image is a non-HDR scene, a possible implementation method of the electronic device performing the second correction processing on the second image is: the electronic device searches the first grayscale value comparison table for the fourth grayscale value corresponding to the third grayscale value of each pixel in the second image in each color channel; the electronic device replaces the third grayscale value of each pixel in the second image in each color channel with the corresponding fourth grayscale value to obtain the corrected second image. The fourth grayscale value and the third grayscale value conform to the gamma function relationship.

[0194] The first grayscale value comparison table includes multiple input grayscale values ​​and output grayscale values ​​corresponding to each input grayscale value, and the corresponding relationship between the output grayscale value and the input grayscale value conforms to the gamma function relationship. For the first image, an input grayscale value equal to the third grayscale value can be found in the first grayscale value comparison table, and the output grayscale value corresponding to the input grayscale value is used as the fourth grayscale value.

[0195] Exemplarily, the first grayscale value comparison table can be calculated by referring to the following gamma function relationship:

[0196] f(x) = int[255×(x / 255) 1 / 2.2 ]

[0197] Where x represents the gray value of each pixel in each color channel of the image before correction, which is in the gray value interval [0, 255], f(x) represents the gray value of each pixel in each color channel of the image after correction, and int represents rounding the result. At this time, the gamma value in the gamma function relationship can be 1 / 2.2.

[0198] Therefore, when the scene of the image is a non-HDR scene, a first grayscale value comparison table is generated using a gamma function relationship, so that after the image is corrected using the first grayscale value comparison table, the image can be brightened. Moreover, compared with the method of using the above-mentioned gamma function relationship to perform real-time calculations to correct the image, the embodiment of the present application corrects the image based on a lookup table of the first grayscale value comparison table, which can improve the correction speed of the image. Among them, the first grayscale value comparison table can be pre-stored in the electronic device, and the first grayscale value comparison table can be a hash table.

[0199] like Figure 8 As shown, the first grayscale value comparison table may include multiple input grayscale values ​​and output grayscale values ​​corresponding to each input grayscale value. The numerical range of the multiple input grayscale values ​​may be [0, 255], and the output grayscale value corresponding to each input grayscale value actually includes the output grayscale value corresponding to the color channel where each input grayscale value is located, such as the output grayscale value corresponding to the input grayscale value in the red channel (i.e., R channel), the output grayscale value corresponding to the input grayscale value in the green channel (i.e., G channel), and the output grayscale value corresponding to the input grayscale value in the blue channel (i.e., B channel).

[0200] For example, when the input gray value of the red channel is 0, the corresponding output gray value of the red channel is Gray10; when the input gray value of the green channel is 0, the corresponding output gray value of the green channel is Gray20; when the input gray value of the blue channel is 0, the corresponding output gray value of the blue channel is Gray30. When the input gray value of the red channel is 1, the corresponding output gray value of the red channel is Gray11; when the input gray value of the green channel is 1, the corresponding output gray value of the green channel is Gray21; when the input gray value of the blue channel is 1, the corresponding output gray value of the blue channel is Gray31. By analogy, when the input grayscale value of the red channel is 255, the corresponding output grayscale value of the red channel is Gray1y; when the input grayscale value of the green channel is 255, the corresponding output grayscale value of the green channel is Gray2y; when the input grayscale value of the blue channel is 255, the corresponding output grayscale value of the blue channel is Gray3y.

[0201] In this way, the gamma function relationship is directly mapped to a 256-dimensional value, and the image is corrected by directly looking up the first gray value comparison table.

[0202] S707: The electronic device resizes the second image to obtain a fifth image.

[0203] When the second image parameter meets the second preset condition, after correcting the second image, the electronic device may resize the corrected second image to obtain a fifth image. That is, after executing the above S706, S707 is to resize the corrected second image.

[0204] When the second image parameter does not satisfy the second preset condition, the electronic device does not need to perform correction processing on the second image, but directly resizes the second image to obtain the fifth image. That is, after executing the above S705, when it is determined that the second image parameter does not satisfy the second preset condition, the electronic device directly executes S707 to directly resize the second image.

[0205] In some embodiments, a specific implementation method of the electronic device resizing the second image may be: the electronic device fills pixels on the edge of the second image to obtain a fifth image; and the size ratio of the fifth image is a preset ratio.

[0206] Specifically, the pixel values ​​of the pixels filled at the edge of the second image may all be 0, or may be the pixel average value of all pixels in the second image, which is not limited in the embodiment of the present application.

[0207] Furthermore, when pixel padding is performed on the edge of the second image, pixel padding may be performed in the width direction or the height direction of the second image as required. When pixel padding is performed in the width direction of the second image, pixel padding may actually be performed on the left edge and / or the right edge of the second image; when pixel padding is performed in the height direction of the second image, pixel padding may actually be performed on the upper edge and / or the lower edge of the second image.

[0208] Exemplarily, the size of the second image may include 480 pixels * 480 pixels, 640 pixels * 480 pixels, and 640 pixels * 360 pixels. The size ratio of the input image of the object detection model is relatively fixed, and the size ratio of the input image of the object detection model may be a preset ratio, which may be a size ratio of 3:4. The preset ratio refers to the size ratio of the image in the width direction and the height direction when the image is displayed in the vertical screen state, and may also refer to the size ratio of the image in the height direction and the width direction when the image is displayed in the horizontal screen state.

[0209] Take the case where the image is displayed in portrait mode and the preset ratio is 3:4 as an example. When the size of the second image is 480 pixels * 480 pixels, it means that the number of pixels of the second image in the height direction is 480, and the number of pixels of the second image in the width direction is also 480. The electronic device can fill pixels at the upper edge and / or lower edge of the second image, and the total number of rows of filled pixels can be 160 rows, so that the size of the fifth image obtained after pixel filling can be 640 pixels * 480 pixels, that is, the number of pixels of the fifth image in the height direction is 640, and the number of pixels of the fifth image in the width direction is 480. In this case, the size ratio of the fifth image in the width direction to the height direction is 3:4.

[0210] Take the case where the image is displayed in portrait mode and the preset ratio is 3:4 as an example. When the size of the second image is 640 pixels * 360 pixels, it means that the number of pixels of the second image in the height direction is 640, and the number of pixels of the second image in the width direction is 360. The electronic device can fill pixels on the left edge and / or right edge of the second image, and the total number of columns of filled pixels can be 120 columns, so that the size of the fifth image obtained after pixel filling can be 640 pixels * 480 pixels. In this case, the size ratio of the fifth image in the width direction to the height direction is 3:4.

[0211] It is understandable that the preset ratio includes but is not limited to the above-mentioned 3:4. For example, the preset ratio can also be a size ratio of 1:1.

[0212] In summary, the embodiment of the present application obtains the fifth image by filling pixels on the edge of the second image, that is, using a padding operation to adjust the height and width of the second image to obtain the fifth image, rather than using a resize operation (i.e., a scaling operation) to adjust the height and width of the second image to obtain the fifth image.

[0213] If the height and width of the image are adjusted by the resize operation, the objects in the image may be deformed, which reduces the detection rate of the subsequent object detection model for the objects in the image; and when the height and width of the image are adjusted by the resize operation, the resize operation is relatively time-consuming. Therefore, the embodiment of the present application adopts the padding operation to adjust the height and width of the image to avoid the risk of object deformation caused by the resize operation, so that the object detection model does not need to identify elongated or flattened objects, thereby optimizing the detection rate and precision recall rate of the object detection model for the objects in the image; and the embodiment of the present application adopts the padding operation to adjust the height and width of the image, and the padding operation takes a short time, so the speed of object detection can be improved.

[0214] S708: The electronic device performs normalization processing on the fifth image.

[0215] In some embodiments, after the electronic device resizes the second image to obtain the fifth image, the electronic device may perform normalization processing on the fifth image.

[0216] In a possible implementation, the electronic device may subtract the pixel average from the pixel value of each pixel in the image and then divide the result by the pixel value variance as the pixel value of each pixel in the normalized image to normalize the fifth image. The pixel average refers to the average value of the pixel values ​​of all pixels in the image, and the pixel value variance refers to the variance of the pixel values ​​of all pixels in the image.

[0217] In this way, the pixel values ​​in the normalized image can be limited to the range of 0 to 1, so as to utilize the consistency of the normalized image to provide the same benchmark for subsequent operations to improve the detection accuracy of subsequent object detection models.

[0218] In some other embodiments, the electronic device may also perform normalization processing on the second image before resizing. Specifically, when the second image parameters meet the second preset condition, after the electronic device corrects the second image, the electronic device may first perform normalization processing on the corrected second image, and then resize the normalized second image to obtain the fifth image; when the second image parameters do not meet the second preset condition, the electronic device first performs normalization processing on the second image, and then resizes the normalized second image to obtain the fifth image.

[0219] Of course, the electronic device can also perform resizing and normalization processing at the same time. Specifically, when the second image parameter meets the second preset condition, after the electronic device corrects the second image, the electronic device can simultaneously perform resizing and normalization processing on the corrected second image to obtain the fifth image; when the second image parameter does not meet the second preset condition, the electronic device can simultaneously perform resizing and normalization processing on the second image to obtain the fifth image.

[0220] In summary, the electronic device in the embodiments of the present application may execute S707 first and then S708, or may execute S708 first and then S707, or may execute S707 and S708 at the same time. The embodiments of the present application do not limit the execution order of S707 and S708.

[0221] Therefore, according to the above S704 to S708, the electronic device pre-processes the second image to obtain the fifth image.

[0222] S709, the electronic device detects the fifth image using the object detection model to obtain coordinate information and confidence levels of multiple second candidate boxes.

[0223] Taking the example of an electronic device first resizing the second image to obtain the fifth image and then normalizing the fifth image, the electronic device can input the normalized fifth image into the object detection model, so that the object detection model detects the fifth image to obtain the coordinate information and confidence of multiple second candidate boxes.

[0224] The second candidate frame may contain a second object in the second image, and the coordinate information of the second candidate frame is used to indicate the position of the detected second object. The confidence of the second candidate frame is used to indicate the credibility of the detected object belonging to a certain category.

[0225] In some embodiments, the object detection model may be a RetinaNet model or a RetinaFace model. Exemplarily, when the object in the image is a face, the object detection model may actually be a face detection model.

[0226] For example, Fig. 9 A schematic diagram of the structure of an object detection model provided in an embodiment of the present application. Taking the RetinaFace model as an example, the object detection model may include a backbone feature extraction network, a feature pyramid net (FPN) network, a single stage headless (SSH) network, and a Head (prediction head) network that are cascaded in sequence.

[0227] Specifically, when an object detection model is used to detect an object in an input image, the input image can be first input into a backbone feature extraction network, which can preliminarily extract object features in the input image. Then, the FPN network and the SSH network are used to enhance feature extraction. Specifically, the FPN network can adjust the number of channels of the last three first feature maps output by the backbone feature extraction network, and after adjustment, upsampling and tensor addition are used to perform upsampling feature fusion to obtain three second feature maps respectively. In order to further enhance feature extraction, the RetinaFace model uses an SSH network to enhance the receptive field. The SSH network improves the detection of small-sized objects by introducing contextual information in the second feature map to obtain three third feature maps respectively. The Head network can obtain prediction results through the three third feature maps output by the SSH network, and the prediction results include the coordinate information and confidence of multiple candidate boxes in the input image.

[0228] Taking the input image as the normalized fifth image as an example, the RetinaFace model is used to detect the normalized fifth image, and the coordinate information and confidence of multiple second candidate boxes in the normalized fifth image can be obtained.

[0229] It should be noted that, since the object detection model may include an SSH module, the SSH network may improve the detection of small-sized objects, thereby enabling the object detection model to reduce missed detection of small-sized objects.

[0230] It should be understood that the object detection model set in the electronic device can be trained by a cloud server, and it can also be updated in real time according to the update operation of the cloud server.

[0231] S710: The electronic device selects at least one second object frame from the multiple second candidate frames according to the confidence levels of the multiple second candidate frames to obtain coordinate information of the at least one second object frame.

[0232] In some embodiments, the electronic device uses a non-maximum suppression (NMS) algorithm to screen the multiple second candidate frames according to the confidence of the multiple second candidate frames, and screens out at least one second object frame from the multiple second candidate frames to obtain coordinate information of the at least one second object frame, wherein the second object frame contains the second object located in the second image.

[0233] The non-maximum suppression algorithm mainly suppresses elements that are not maximum values, and its main purpose is to reduce the number of candidate boxes. The specific implementation process of the non-maximum suppression algorithm is as follows: determine the target candidate box with the highest confidence among multiple candidate boxes; determine the overlap between the target candidate box and other candidate boxes among multiple candidate boxes except the target candidate box; delete the candidate boxes with an overlap greater than the overlap threshold, and retain the target candidate box; then repeat the above steps to filter out the object box.

[0234] Exemplarily, it is assumed that the object detection model detects and obtains the coordinate information and confidence of 6 candidate frames. In order of confidence from low to high, the 6 candidate frames are candidate frame A, candidate frame B, candidate frame C, candidate frame D, candidate frame E and candidate frame F. Starting from candidate frame F with the highest confidence, determine the overlap (such as intersection ratio) of candidate frame A, candidate frame B, candidate frame C, candidate frame D and candidate frame E with candidate frame F respectively. Assuming that the overlap between candidate frame B and candidate frame F is greater than the overlap threshold, and the overlap between candidate frame D and candidate frame F is greater than the overlap threshold, then delete candidate frame B and candidate frame D, and retain candidate frame F as the first preferred frame. Next, select candidate frame E with the highest confidence from the remaining candidate frames A, candidate frame C and candidate frame E, and then determine the overlap between candidate frame A and candidate frame C and candidate frame E respectively. Assuming that the overlap between candidate frame C and candidate frame E is greater than the overlap threshold, delete candidate frame C and retain candidate frame E as the second preferred frame. Finally, only candidate box A is left. If candidate box A is not suppressed by any candidate box, candidate box A is taken as the third preferred box.

[0235] In one implementation, the selected preferred frame can be directly used as the object frame. For example, from candidate frame A, candidate frame B, candidate frame C, candidate frame D, candidate frame E and candidate frame F, candidate frame F, candidate frame E and candidate frame A are selected as the preferred frames, and candidate frame F, candidate frame E and candidate frame A are also the selected object frames.

[0236] Another implementation method is to select a preferred frame from multiple candidate frames, and then select a preferred frame with a confidence greater than a confidence threshold from the preferred frame as an object frame. For example, the confidence threshold may be 0.7, and candidate frame F, candidate frame E, and candidate frame A are selected as preferred frames. If the confidences of candidate frame F and candidate frame E are greater than 0.7, and the confidence of candidate frame A is less than 0.7, then candidate frame F and candidate frame E are selected as object frames. In this way, the confidence of the object frame selected from multiple candidate frames may be greater than the confidence threshold.

[0237] Alternatively, before selecting the preferred frame from multiple candidate frames, the candidate frames whose confidence is less than or equal to the confidence threshold may be deleted, and then the preferred frame may be selected from the remaining candidate frames. In this case, the preferred frame selected by the non-maximum suppression algorithm is also the object frame.

[0238] In some scenarios, taking the maximum number of object frames that can be displayed by the electronic device as 10 as an example, the number of object frames screened out by the non-maximum suppression algorithm is M, and M in this case may be an integer greater than 10. In this case, the number of second object frames output by S710 may be M; or, the top 10 object frames may be screened out from the M object frames in descending order according to the sizes of the screened object frames, so that the number of second object frames output by S710 is equal to 10.

[0239] In other scenarios, taking the maximum number of object frames that can be displayed by the electronic device as 10 as an example, the number of object frames screened out by the non-maximum suppression algorithm is M, where M is an integer less than or equal to 10. In this case, the number of second object frames output by S710 may be M.

[0240] Exemplarily, the object frame may be a rectangular frame or a circular frame. Taking the object frame as a rectangular frame as an example, the coordinate information of the object frame includes the coordinates of the upper left corner vertex of the rectangular frame, the length of the rectangular frame, and the width of the rectangular frame; or, the coordinate information of the object frame includes the coordinates of the upper left corner vertex of the rectangular frame and the coordinates of the lower right corner vertex of the rectangular frame. Taking the object frame as a circular frame as an example, the coordinate information of the object frame includes the coordinates of the center of the circular frame and the length of the radius.

[0241] It is worth noting that the above S703 to S710 are specific implementation methods for detecting the coordinate information of the second object frame where the second object in the second image is located, with respect to the second image in the first image stream. Of course, the embodiment of the present application can also detect the coordinate information of the first object frame where the first object in the first image is located, with respect to the first image in the first image stream, and the specific implementation methods thereof can refer to the above S703 to S710.

[0242] Specifically, for the first image in the first image stream, the electronic device may also convert the image format of the first image into the RGB format according to the specific implementation manner of S703 above.

[0243] Moreover, for the first image in the first image stream, the electronic device may also obtain first image parameters of the first image according to the specific implementation method of S704 and S705 above, where the first image parameters include a first brightness value and / or a first exposure value; and determine whether the first image parameters of the first image meet a first preset condition.

[0244] In one implementation, when the first image parameter includes a first brightness value, when the first brightness value is greater than or equal to a first brightness threshold, the first image parameter does not satisfy the first preset condition. When the first image parameter includes a first brightness value, when the first brightness value is less than the first brightness threshold, the first image parameter satisfies the first preset condition. The first brightness threshold may be equal to or different from the second brightness threshold.

[0245] In another implementation, when the first image parameter includes a first exposure value, when the first exposure value is greater than or equal to a first exposure threshold, the first image parameter does not satisfy the first preset condition. When the first image parameter includes a first exposure value, when the first exposure value is less than the first exposure threshold, the first image parameter satisfies the first preset condition. The first exposure threshold may be equal to or different from the second exposure threshold.

[0246] For the first image in the first image stream, the electronic device may also correct the first image according to the specific implementation manner of S706 above, when the first image parameter meets the first preset condition.

[0247] The scene of the first image can be an HDR scene or a non-HDR scene. Therefore, the electronic device can first obtain the first scene information of the first image, and the first scene information includes an HDR scene or a non-HDR scene; when the first scene information is an HDR scene, the electronic device performs a first correction process on the first image to obtain a corrected first image; when the first scene information is a non-HDR scene, the electronic device performs a second correction process on the first image to obtain a corrected first image.

[0248] When the first scene information of the first image is an HDR scene, a possible implementation manner of the electronic device performing the first correction processing on the first image is: the electronic device performs histogram equalization processing on the first image to obtain a corrected first image.

[0249] In the case where the first scene information of the first image is an HDR scene, another possible implementation of the electronic device performing the first correction processing on the second image is: the electronic device searches the second grayscale value comparison table for the sixth grayscale value corresponding to the fifth grayscale value of each pixel in the first image in each color channel; the electronic device replaces the fifth grayscale value of each pixel in the first image in each color channel with the corresponding sixth grayscale value to obtain the corrected first image. The sixth grayscale value and the fifth grayscale value have a gamma-like function relationship.

[0250] In the case where the first scene information of the first image is a non-HDR scene, a possible implementation method of the electronic device performing the second correction processing on the first image is: the electronic device searches the first grayscale value comparison table for each pixel in the first image and the second grayscale value corresponding to the first grayscale value of each color channel; the electronic device replaces the first grayscale value of each pixel in the first image in each color channel with the corresponding second grayscale value to obtain the corrected first image. The second grayscale value and the first grayscale value conform to the gamma function relationship.

[0251] For the first image in the first image stream, the electronic device may also resize the first image according to the specific implementation manner of S707 to obtain a fourth image.

[0252] When the first image parameter satisfies the first preset condition, after correcting the first image, the electronic device may resize the corrected first image to obtain a fourth image. When the first image parameter does not satisfy the first preset condition, the electronic device does not need to correct the first image, but directly resizes the first image to obtain a fourth image.

[0253] In some embodiments, the electronic device may resize the first image in a specific manner as follows: the electronic device fills the edge of the first image with pixels to obtain a fourth image; the size ratio of the fourth image is a preset ratio. The pixel values ​​of the pixels filled with the edge of the first image may all be 0, or may be the average pixel value of all pixels in the first image, which is not limited in the embodiments of the present application.

[0254] Furthermore, when pixel padding is performed on the edge of the first image, pixel padding may be performed in the width direction or the height direction of the first image as required. When pixel padding is performed in the width direction of the first image, pixel padding may actually be performed on the left edge and / or the right edge of the first image; when pixel padding is performed in the height direction of the first image, pixel padding may actually be performed on the upper edge and / or the lower edge of the first image.

[0255] For the first image in the first image stream, the electronic device may also perform normalization processing on the fourth image according to the specific implementation manner of S708 above.

[0256] In some embodiments, after the electronic device resizes the first image to obtain the fourth image, the electronic device may perform normalization processing on the fourth image. Alternatively, the electronic device may perform normalization processing on the first image before resizing. Alternatively, the electronic device may perform resizing and normalization processing simultaneously.

[0257] For the first image in the first image stream, the electronic device may also use the object detection model to detect the fourth image according to the specific implementation method of S709 and S710 above to obtain coordinate information and confidence levels of multiple first candidate frames; based on the confidence levels of the multiple first candidate frames, screen out at least one first object frame from the multiple first candidate frames to obtain coordinate information of at least one first object frame.

[0258] In summary, the electronic device performs the following steps: preprocessing the first image to obtain the fourth image; using the object detection model to detect the fourth image to obtain the coordinate information and confidence of multiple first candidate frames; and screening at least one first object frame from the multiple first candidate frames according to the confidence of the multiple first candidate frames to obtain the coordinate information of at least one first object frame. The electronic device detects the coordinate information of the first object frame where the first object in the first image is located.

[0259] Furthermore, the electronic device performs preprocessing on the first image to obtain the fourth image by the following steps: obtaining the first image parameter of the first image; determining whether the first image parameter of the first image satisfies the first preset condition; if the first image parameter does not satisfy the first preset condition, resizing the first image to obtain the fourth image; if the first image parameter satisfies the first preset condition, correcting the first image and resizing the corrected first image to obtain the fourth image; and normalizing the fourth image.

[0260] Therefore, for each detection image frame in the first image stream, such as the first image and the second image, the electronic device needs to execute the above S703 to S710 to obtain the coordinate information of the object frame where the object in each detection image frame is located. For example, the detection image can be the first image or the second image, the object in the first image is the first object, and the object in the second image is the second object.

[0261] For example, Fig.10 A flowchart of an object detection method provided in an embodiment of the present application, which can be applied to an electronic device, may specifically include the following steps:

[0262] S1001, an electronic device obtains a first image stream; the first image stream includes a first image and a second image, and the first image is an image frame before the second image.

[0263] It should be noted that, according to the above S701 and S702, the electronic device can obtain the first image stream. The specific implementation process can refer to the specific implementation process of the above S701 and S702, and will not be described again to avoid repetition.

[0264] S1002: The electronic device detects coordinate information of a second object frame where a second object in a second image is located.

[0265] It should be noted that, according to the above S703 to S710, the electronic device can detect the coordinate information of the second object frame where the second object in the second image is located. The specific implementation process can refer to the specific implementation process of the above S703 to S710, and will not be repeated here to avoid repetition.

[0266] S1003: The electronic device extracts a second region image within the second object frame from the second image according to coordinate information of the second object frame, where the second region image includes the second object.

[0267] After acquiring the coordinate information of the second object frame, the electronic device may extract the second area image within the second object frame from the second image according to the coordinate information of the second object frame, that is, capture the image within the second object frame in the second image.

[0268] S1004, the electronic device uses a pedestrian re-identification model to extract feature data of a second object in the second area image; the feature data includes a pedestrian re-identification feature vector.

[0269] In some embodiments, the second region image may be directly input into a person re-identification (ReID) model, so that the person re-identification model extracts feature data of the second object from the second region image.

[0270] In some other embodiments, the second region image may be resized, and then the resized second region image is input into the person re-identification model, so that the person re-identification model extracts the feature data of the second object from the resized second region image. For example, the size of the resized second region image may be 112 pixels*112 pixels.

[0271] The pedestrian re-identification model can also be called a pedestrian re-identification model. The pedestrian re-identification feature vector is also called a ReID feature vector. Taking the face as an example, the pedestrian re-identification feature vector refers to the pedestrian re-identification feature vector with face information.

[0272] In an embodiment of the present application, the pedestrian re-identification model includes a ResNet model or a MobileNet model.

[0273] For example, Fig.11 A schematic diagram of the structure of a person re-identification model provided in an embodiment of the present application. Taking the person re-identification model including the ResNet model as an example, Fig.11 As shown in (a) of FIG. 1 , the person re-identification model includes a first convolutional layer, a first pooling layer, a first residual unit, a second residual unit, a third residual unit, a fourth residual unit, a second pooling layer, and a fully connected layer, which are cascaded in sequence. The convolution kernel size of the first convolutional layer can be 7*7, the number of channels of the first convolutional layer can be 16; the first pooling layer can be a maximum pooling layer; and the second pooling layer can be an average pooling layer.

[0274] like Fig.11 As shown in (b), the first residual unit includes the second convolutional layer, the third convolutional layer, the fourth convolutional layer and the fifth convolutional layer connected in sequence. The output of the first pooling layer is used as the input of the second convolutional layer, the output of the second convolutional layer is used as the input of the third convolutional layer, the output of the third convolutional layer is added to the input of the second convolutional layer according to the channel dimension and used as the input of the fourth convolutional layer, the output of the fourth convolutional layer is used as the input of the fifth convolutional layer, and the output of the fifth convolutional layer is added to the input of the fourth convolutional layer according to the channel dimension and used as the input of the sixth convolutional layer in the second residual unit.

[0275] Among them, the convolution kernel sizes of the second convolution layer, the third convolution layer, the fourth convolution layer, and the fifth convolution layer are all 3*3, and the number of channels of the second convolution layer, the third convolution layer, the fourth convolution layer, and the fifth convolution layer are all 16.

[0276] like Fig.11 As shown in (c), the second residual unit, the third residual unit and the fourth residual unit all include: a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a ninth convolutional layer and a tenth convolutional layer.

[0277] The output of the sixth convolutional layer is used as the input of the seventh convolutional layer, and the input of the sixth convolutional layer is also used as the input of the tenth convolutional layer. The tenth convolutional layer is mainly used to adjust the channel dimension. The output of the seventh convolutional layer and the output of the tenth convolutional layer are added according to the channel dimension and used as the input of the eighth convolutional layer. The output of the eighth convolutional layer is used as the input of the ninth convolutional layer.

[0278] In the second residual unit, the output of the ninth convolutional layer and the input of the eighth convolutional layer are added according to the channel dimension and used as the input of the sixth convolutional layer in the third residual unit. In the third residual unit, the output of the ninth convolutional layer and the input of the eighth convolutional layer are added according to the channel dimension and used as the input of the sixth convolutional layer in the fourth residual unit. In the fourth residual unit, the output of the ninth convolutional layer and the input of the eighth convolutional layer are added according to the channel dimension and used as the input of the second pooling layer.

[0279] Among them, the convolution kernel size of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the second residual unit is 3*3, and the number of channels of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the second residual unit is 32; the convolution kernel size of the tenth convolution layer included in the second residual unit is 1*1, and the number of channels of the tenth convolution layer included in the second residual unit is 32.

[0280] The convolution kernel size of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the third residual unit is 3*3, and the number of channels of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the third residual unit is 64; the convolution kernel size of the tenth convolution layer included in the third residual unit is 1*1, and the number of channels of the tenth convolution layer included in the third residual unit is 64.

[0281] The convolution kernel size of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the fourth residual unit is 3*3, and the number of channels of the sixth convolution layer, the seventh convolution layer, the eighth convolution layer and the ninth convolution layer included in the fourth residual unit is 128; the convolution kernel size of the tenth convolution layer included in the fourth residual unit is 1*1, and the number of channels of the tenth convolution layer included in the fourth residual unit is 128.

[0282] like Fig.11As shown in the figure, the image size of the regional image is 3*112*112, which means that the height of the regional image is 112 pixels, the width is 112 pixels, and the number of channels is 3. The regional image is input to the first convolution layer, the first convolution layer performs convolution processing on the regional image, and the feature map output by the first convolution layer is input to the first pooling layer; the first pooling layer performs pooling processing on the feature map output by the first convolution layer, and the feature map output by the first pooling layer is input to the first residual unit; the first residual unit processes the feature map output by the first pooling layer, and the feature map output by the first residual unit is input to the second residual unit; the second residual unit processes the feature map output by the first residual unit, and the feature map output by the second residual unit is input to the third residual unit; the third residual unit The unit processes the feature map output by the second residual unit, and the feature map output by the third residual unit is input to the fourth residual unit; the fourth residual unit processes the feature map output by the third residual unit, and the feature map output by the fourth residual unit is input to the second pooling layer; the second pooling layer performs pooling on the feature map output by the fourth residual unit, and the pooling result output by the second pooling layer is input to the fully connected layer; the fully connected layer processes the pooling result output by the second pooling layer, and outputs a pedestrian re-identification feature vector, which can be a 256-dimensional feature vector.

[0283] Therefore, the embodiment of the present application can adopt the ResNet model as the pedestrian re-identification model, because the ResNet model can improve the network performance by increasing the network depth, thereby making the extracted pedestrian re-identification feature vector more accurate.

[0284] Understandably, Fig.11 The ResNet model shown is only an example of a pedestrian re-identification model, and can also be replaced by other network models as a pedestrian re-identification model, which is not limited in the embodiments of the present application. In addition, the pedestrian re-identification model set in the electronic device can be trained by a cloud server, and it can also be updated in real time according to the update operation of the cloud server.

[0285] Therefore, according to the above S1002 to S1004, the electronic device extracts feature data of each second object in the second image.

[0286] S1005: The electronic device obtains feature data of each first object in the first image.

[0287] In some embodiments, for the first image in the first image stream, the electronic device may also refer to the implementation principles of S703 to S710 above to detect the coordinate information of the first object frame in which the first object in the first image is located. The electronic device may refer to the implementation principle of S1003 above to extract the first area image in the first object frame from the first image according to the coordinate information of the first object frame, and the first area image includes the first object. The electronic device may also refer to the implementation principle of S1004 above to extract the feature data of the first object in the first area image using a pedestrian re-identification model. In this way, the electronic device extracts the feature data of each first object in the first image.

[0288] When the electronic device extracts the feature data of the object in each frame of the detection image, it processes the feature data in units of one frame of the image. Therefore, after the electronic device extracts the feature data of each first object in the first image, in addition to determining the matching relationship between the first object in the first image and the object in the previous frame of the detection image of the first image based on the feature data of each first object in the first image and the feature data of each object in the previous frame of the detection image of the first image, it also stores the feature data of each first object in the first image in the dynamic memory.

[0289] In this way, after the electronic device extracts the feature data of each second object in the second image, if it needs to determine the matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object, the electronic device needs to search the feature data of each first object in the first image from the dynamic memory by means of a table lookup.

[0290] For example, the dynamic memory stores feature data of five first objects in the first image, such as feature data 1 of the first first object, feature data 2 of the second first object, feature data 3 of the third first object, feature data 4 of the fourth first object, and feature data 5 of the fifth first object.

[0291] S1006, the electronic device determines a matching relationship between the first object and the second object according to the feature data of each first object and the feature data of each second object; the matching relationship is used to indicate whether the first object and the second object are the same object.

[0292] In some embodiments, after extracting the feature data of each second object in the second image and finding the feature data of each first object in the previously saved first image, the electronic device can match the feature data of each second object with the feature data of each first object to obtain a matching relationship between the first object and the second object, where the matching relationship is used to indicate whether the first object and the second object are the same object.

[0293] Specifically, the electronic device calculates a characteristic distance between characteristic data of the first object and characteristic data of the second object, wherein the characteristic distance includes a cosine distance and / or a Euclidean distance; and determines whether the first object and the second object are the same object according to the characteristic distance. The characteristic data is used to indicate the similarity between the first object and the second object.

[0294] In a possible implementation, the feature distance includes a cosine distance. When the cosine distance is larger, it indicates that the similarity between the first object and the second object is higher; when the cosine distance is smaller, it indicates that the similarity between the first object and the second object is lower. Therefore, when the cosine distance between the feature data of the first object and the feature data of the second object is greater than or equal to a first distance threshold, the electronic device determines that the first object and the second object are the same object; when the cosine distance between the feature data of the first object and the feature data of the second object is less than the first distance threshold, the electronic device determines that the first object and the second object are not the same object.

[0295] In another possible implementation, the feature distance includes the Euclidean distance. When the Euclidean distance is larger, the similarity between the first object and the second object is lower; when the Euclidean distance is smaller, the similarity between the first object and the second object is higher. Therefore, when the Euclidean distance between the feature data of the first object and the feature data of the second object is less than or equal to the second distance threshold, the electronic device determines that the first object and the second object are the same object; when the Euclidean distance between the feature data of the first object and the feature data of the second object is greater than the second distance threshold, the electronic device determines that the first object and the second object are not the same object.

[0296] Among them, the first distance threshold and the second distance threshold can be set according to actual conditions, and the embodiments of the present application do not limit this.

[0297] S1007: The electronic device displays a target object frame corresponding to the second object according to the matching relationship.

[0298] After the electronic device determines the matching relationship between the first object and the second object, it can jointly determine the coordinate information of the target object frame corresponding to the second object based on the coordinate information of the second object frame where the second object is located and the matching relationship between the first object and the second object, and display the target object frame corresponding to the second object based on the coordinate information of the target object frame.

[0299] In some scenarios, the first image stream also includes a third image, the third image is a previous frame of the second image, and the third image is an image frame after the first image, and the third image includes the first object. A possible implementation method for the electronic device to display the target object frame corresponding to the second object according to the matching relationship is: when the first object and the second object are the same object, the coordinate information of the target object frame corresponding to the second object is determined according to the coordinate information of the tracking frame where the first object is located in the third image and the coordinate information of the second object frame where the second object is located; and the target object frame is displayed according to the coordinate information of the target object frame corresponding to the second object.

[0300] In the first image stream, the first image and the second image are two adjacent frames of detection images, and the third image is a previous frame of tracking image of the second image.

[0301] For example, Fig.12 A schematic diagram of sequentially processing multiple frames of images in a first image stream provided by an embodiment of the present application. Fig.12 As shown, the first image stream may include the 1st frame image, the 2nd frame image, the 3rd frame image, the 4th frame image, the 5th frame image, the 6th frame image and the 7th frame image. Among them, the 1st frame image and the 6th frame image are two adjacent detection frames, the 2nd frame image, the 3rd frame image, the 4th frame image and the 5th frame image are all tracking images of the 1st frame image, and the 7th frame image is the tracking image of the 6th frame image.

[0302] Take the first frame image in the first image stream as the first image, the sixth frame image in the first image stream as the second image, and the fifth frame image in the first image stream as the third image as an example. The electronic device can detect the coordinate information of the first object frame where each first object in the first frame image is located, and extract the pedestrian re-identification feature vector of each first object in the first frame image; the electronic device can also use the object tracking algorithm to track the first object in the second frame image, the third frame image, the fourth frame image and the fifth frame image in real time based on the first object detected in the first frame image, so as to obtain the coordinate information of the tracking frame where the first object in each frame image is located; the electronic device can also detect the coordinate information of the second object frame where each second object in the sixth frame image is located, and extract the pedestrian re-identification feature vector of each second object in the sixth frame image.

[0303] In this way, the electronic device determines the matching relationship between the first object and the second object based on the pedestrian re-identification feature vector of each first object in the first frame image and the pedestrian re-identification feature vector of each second object in the sixth frame image.

[0304] If it is determined based on the matching relationship that there is at least one second object in the 6th frame image, which is the same object as the first object in the 1st frame image, then for the first object and the second object belonging to the same object, the electronic device can perform smoothing processing based on the coordinate information of the tracking frame where the first object in the 5th frame image is located, and the coordinate information of the second object frame where the second object in the 6th frame image is located, so as to calculate the coordinate information of the target object frame corresponding to the second object in the 6th frame image.

[0305] Since the position of the same object in the previous and next frames of images may change, in order to reduce the jitter when the object frame is displayed, when the electronic device displays the object frame, the position of the object frame display will not jump directly from the display position of the previous frame image to the display position of the next frame image. Instead, smoothing is performed based on the position of the object frame in the previous frame image and the position of the object frame in the next frame image, and the smoothed object frame is displayed at a position between the display position of the previous frame image and the display position of the next frame image, thereby reducing the jitter when the object frame is displayed.

[0306] Taking the object box as a rectangular box, the coordinate information of the object box includes the coordinates of the upper left corner vertex of the rectangular box, and the tracking box is also a rectangular box, and the coordinate information of the tracking box also includes the coordinates of the upper left corner vertex of the rectangular box as an example, the electronic device performs weighted summation of the coordinates of the upper left corner vertex of the tracking box where the first object in the third image is located and the coordinates of the upper left corner vertex of the second object box where the second object is located to achieve smoothing processing, so as to obtain the coordinates of the upper left corner vertex of the target object box corresponding to the second object.

[0307] Assume that the coordinates of the upper left corner vertex of the tracking box where the first object in the third image is located are (x 1 ,y 1 ), the coordinates of the upper left corner of the second object frame where the second object is located are (x 2 ,y 2 ), then the coordinates of the upper left corner of the target object frame corresponding to the second object are (x 3 ,y 3 ), and x 3 =w 1 × 1 +w 2 × 2 ,y 3 =w 3 ×y 1 +w 4 ×y 2 .w 1 、w 2 、w 3 and w 4 They represent weights, which are values ​​greater than 0 and less than 1. For example, w 1and w 3 It can be 0.2, w 2 and w 4 It can be 0.8.

[0308] It should be understood that Fig.12 The interval of 4 tracking images between two adjacent detection images in the first image stream shown is used as an exemplary processing method for multiple frames of images in the first image stream, which can constitute a limitation on the embodiments of the present application. The number of frames of tracking images spaced between two adjacent detection images can be other numbers, which is not limited by the embodiments of the present application. In addition, since the computational complexity of the object tracking algorithm is lower than the computational complexity of the object detection algorithm, the computational burden of the electronic device can be reduced by using part of the images in the first image stream as detection images for object detection and using part of the images in the first image stream as tracking images for object tracking.

[0309] by Fig.13 Take the scenario shown in the figure as an example. Fig.13 The first frame detection image shown in (a) in FIG. 1 can display a first face frame 201 corresponding to the person on the left and a second face frame 202 corresponding to the person on the right in the preview frame 1021 .

[0310] against Fig.13 In the second detection image shown in (b), since the embodiment of the present application can determine the matching relationship between the first object and the second object based on the feature data of each first object in the first detection image and the feature data of each second object in the second detection image, and the accuracy of the determined matching relationship is high, it can be determined that the face in the face frame corresponding to the person located on the left detected in the second detection image is the same face as the face in the first face frame 201 detected in the first detection image, and the face in the face frame corresponding to the person located on the right detected in the second detection image is the same face as the face in the second face frame 202 detected in the first detection image.

[0311] In this way, the coordinate position of the fifth face frame 205 corresponding to the person on the left in the second detection image can be determined based on the coordinate position of the face frame corresponding to the person on the left detected by the second detection image and the coordinate position of the face frame corresponding to the person on the left in the previous tracking image of the second detection image, and the fifth face frame 205 corresponding to the person on the left is displayed in the preview frame 1021. At this time, the display position of the fifth face frame 205 corresponding to the person on the left is basically consistent with the position of the face of the person on the left.

[0312] Accordingly, the coordinate position of the sixth face frame 206 corresponding to the person on the right in the second detection image can be determined based on the coordinate position of the face frame corresponding to the person on the right detected by the second detection image and the coordinate position of the face frame corresponding to the person on the right in the previous tracking image of the second detection image, and the sixth face frame 206 corresponding to the person on the right is displayed in the preview frame 1021. At this time, the display position of the sixth face frame 206 corresponding to the person on the right is basically consistent with the position of the face of the person on the right.

[0313] against Fig.13 The third frame detection image shown in (c) can also determine, based on the feature data of each first object in the second frame detection image and the feature data of each second object in the third frame detection image, that the face in the face frame corresponding to the person located on the left side detected in the third frame detection image is the same face as the face in the face frame corresponding to the person located on the left side detected in the second frame detection image, and that the face in the face frame corresponding to the person located on the right side detected in the third frame detection image is the same face as the face in the face frame corresponding to the person located on the right side detected in the second frame detection image.

[0314] In this way, the coordinate position of the seventh face frame 207 corresponding to the person on the left in the third detection image can be determined based on the coordinate position of the face frame corresponding to the person on the left detected by the third detection image and the coordinate position of the face frame corresponding to the person on the left in the previous tracking image of the third detection image, and the seventh face frame 207 corresponding to the person on the left is displayed in the preview frame 1021. At this time, the display position of the seventh face frame 207 corresponding to the person on the left is basically consistent with the position of the face of the person on the left.

[0315] Accordingly, the coordinate position of the eighth face frame 208 corresponding to the person on the right in the third frame detection image can be determined based on the coordinate position of the face frame corresponding to the person on the right detected by the third frame detection image and the coordinate position of the face frame corresponding to the person on the right in the previous frame tracking image of the third frame detection image, and the eighth face frame 208 corresponding to the person on the right is displayed in the preview frame 1021. At this time, the display position of the eighth face frame 208 corresponding to the person on the right is basically consistent with the position of the face of the person on the right.

[0316] Therefore, combined with Fig.13 (a) Fig.13 (b) and Fig.13 From the interface shown in (c), we can see that relative to Figure 2In the interface shown, the embodiment of the present application can determine the matching relationship between objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, so that when the electronic device sequentially displays the face frames where each face in multiple frames of images is located, the display stability of the face frames corresponding to the same face can be improved, thereby improving the problem of jumping and flashing of the face frames corresponding to the same face.

[0317] by Fig.14 Take the scenario shown in the figure as an example, the electronic device detects Fig.14 After detecting the facial feature data of the 11 characters in the first frame of the image shown in (a), the facial feature data of the first 10 characters will be saved in descending order according to the size of the facial frames where the faces of the 11 characters are located. For example, the facial feature data of the other 10 characters except the character on the far right in the back row will be saved. In addition, the electronic device will output the coordinate positions of the facial frames corresponding to the other 10 characters except the character on the far right in the back row, and display the 10 facial frames based on the output coordinate information of the facial frames corresponding to the 10 characters. In this way, Fig.14 In the first detection image shown in (a), no face frame is displayed at the face position of the person on the far right in the back row within the preview frame 1021, while face frames are displayed at the face positions of the other 10 persons.

[0318] against Fig.14 In the second detection image shown in (b) of FIG. 1 , the embodiment of the present application can determine the matching relationship between the first object and the second object based on the feature data of each second object in the second detection image and the feature data of the first object stored in the first detection image, and the accuracy of the determined matching relationship is high. Therefore, when the electronic device detects Fig.14 After obtaining the feature data of the faces of the 11 people in the second frame detection image shown in (b), the feature data of the faces of the 11 people in the second frame detection image will be matched with the feature data of the 10 faces saved in the first frame detection image, so as to determine that the faces of the other 10 people in the second frame detection image except the person on the far right in the back row correspond one-to-one to the faces corresponding to the 10 feature data saved for the first frame detection image, and are the same face, while the face of the person on the far right in the back row in the second frame detection image is not the same face as the face corresponding to the 10 feature data saved for the first frame detection image.

[0319] Therefore, the electronic device will output the coordinate information of the face frames corresponding to the other 10 characters except the character on the far right of the back row, and display the 10 face frames according to the output coordinate information of the face frames corresponding to the 10 characters. In addition, the electronic device will also save the feature data of the faces of the other 10 characters except the character on the far right of the back row. Fig.14 In the second detection image shown in (b), no face frame is displayed at the face position of the person on the far right in the back row within the preview frame 1021, while face frames are displayed at the face positions of the other 10 persons.

[0320] against Fig.14 The third detection image shown in (c) can also determine, based on the feature data of each second object in the third detection image and the feature data of the first object saved for the second detection image, that the faces of the other 10 people in the third detection image, except for the person on the far right in the back row, correspond one-to-one with the faces corresponding to the 10 feature data saved for the second detection image, and are the same face, while the face of the person on the far right in the back row in the third detection image is not the same face as the face corresponding to the 10 feature data saved for the second detection image. In this way, for Fig.14 In the third detection image shown in (c), no face frame is displayed at the face position of the person on the far right in the back row within the preview frame 1021, while face frames are displayed at the face positions of the other 10 persons.

[0321] Therefore, combined with Fig.14 (a) Fig.14 (b) and Fig.14 From the interface shown in (c), we can see that relative to Figure 3 In the interface shown, the embodiment of the present application can determine the matching relationship between objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, so that when the electronic device displays the face frames where each face in multiple frames of images is located in sequence, the display stability of the face frames corresponding to each face can be improved, thereby improving the problem of jumping and flashing of the face frames corresponding to each face.

[0322] by Fig.15 Take the scenario shown in the figure as an example. Fig.15 The first detection image shown in (a) in FIG. 1 can display the ninth face frame 401 corresponding to the person in the preview frame 1021 . At this time, no face frame is displayed at the position where the dog face is located.

[0323] against Fig.15In the second detection image frame shown in (b), since face detection may have a certain probability of false detection or missed detection, the electronic device may mistake the dog's face for a human face after performing face detection on the second detection image frame.

[0324] However, since the embodiment of the present application can determine the matching relationship between the first object and the second object based on the feature data of each first object in the first frame detection image and the feature data of each second object in the second frame detection image, and the accuracy of the determined matching relationship is relatively high, it can be determined that the face in the tenth face frame 402 detected in the second frame detection image is the same face as the face in the ninth face frame 401 detected in the first frame detection image, and the dog face mistakenly identified as a human face detected in the second frame detection image is not the same face as the faces in the various face frames detected in the first frame detection image. In this way, Fig.15 In the second detection image frame shown in (b), the electronic device may display the tenth face frame 402 corresponding to the person in the preview frame 1021. At this time, no face frame is displayed at the position where the dog face is located.

[0325] against Fig.15 In the third detection image shown in (c) of FIG. 1 , the coordinate position of the face frame where a person's face is located is detected, and the twelfth face frame 404 corresponding to the person is displayed in the preview frame 1021. At this time, the face frame is not displayed at the position where the dog's face is located.

[0326] Therefore, combined with Fig.15 (a) Fig.15 (b) and Fig.15 From the interface shown in (c), we can see that relative to Figure 4 In the interface shown, the embodiment of the present application can determine the matching relationship between objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, so that when the electronic device displays the face frames where each face in multiple frames of images is located in sequence, the stability of the face frame display can be improved, thereby improving the problem of jumping and flashing of the face frames corresponding to each face.

[0327] In addition, taking the object in the image as a face as an example, after determining the matching relationship between each first object in the first image and each second object in the second image, the embodiment of the present application can also use the coordinate information of the object frame where the object in each frame of the detected image is located (such as the first object frame where the first object in the first image is located, or the second object frame where the second object in the second image is located) and the matching relationship between the first object and the second object as input data for subsequent face tracking, face attribute detection, face key point detection, beautification processing, and autofocus operations to provide data support.

[0328] In one case, when the first object and the second object are the same object, the electronic device does not perform an attribute detection operation on the second object.

[0329] If the electronic device determines, based on the matching relationship, that there is at least one second object in the second image that is the same object as the first object in the first image, the electronic device does not detect attribute information of the second object that is the same object as the first object, thereby reducing power consumption of the electronic device.

[0330] If the electronic device determines that there is a second object that is not the same object as the first object in the second image based on the matching relationship, the electronic device needs to use an attribute detection algorithm to detect attribute information of the second object that is not the same object as the first object.

[0331] Taking a human face as an example, the attribute information of the face includes attributes such as gender, age, and skin color.

[0332] In another case, the electronic device performs a target operation according to a matching relationship between the first object and the second object; the target operation includes at least one of an object tracking operation, a key point detection operation, a beautification operation, and an autofocus operation.

[0333] Among them, the key point detection operation is used to detect the position and other information of the key points of the object in the image. Taking the object as a face as an example, the key point operation operation is used to detect the position information of the key points such as eyebrows, eyes, nose, mouth, facial contour, etc. of the face in the face image.

[0334] Taking a human face as an example, a beautification operation can also be called a beauty operation. The beauty operation includes one or more operations such as skin whitening, skin smoothing, face slimming, eye size adjustment, and adding lipstick to the lips.

[0335] Taking a human face as an example, the auto focus operation can automatically focus according to the face frame where the face is located.

[0336] In some preview scenes, the image stream captured by the camera includes multiple frames of images, each of which includes a male face and a female face. If the relevant technology does not determine the matching relationship between the faces in two adjacent detection images, or the accuracy of the determined matching relationship is low, it is possible that in the two adjacent detection images, the male face in the Zth detection image and the female face in the Z-1th detection image are mistakenly regarded as the same face, and the female face in the Zth detection image and the male face in the Z-1th detection image are mistakenly regarded as the same face. Z is an integer greater than 1.

[0337] Usually, when performing beauty processing, electronic devices will add lipstick to women's lips, but not to men's lips. In this way, when it is detected that the gender attribute of the female face in the Z-1 frame detection image is female, the electronic device can add lipstick to the lips of the female face in the Z-1 frame detection image; and the female face in the Z frame detection image is mistakenly regarded as the same face as the male face in the Z-1 frame detection image, and the gender attribute of the male in the Z-1 frame detection image has been detected, so that the gender attribute of the female in the Z frame detection image will be defaulted to male, then the electronic device does not add lipstick to the lips of the female face in the Z frame detection image. Therefore, when the electronic device displays the image stream captured by the camera, lipstick is added to the lips of the female in some frames of the image, while lipstick is not added to the lips of the female in the next few frames of the image, resulting in unstable display effect of the preview screen.

[0338] Therefore, the embodiments of the present application can determine the matching relationship between objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, so that the electronic device can accurately determine the gender attributes of each face in each frame of detection image, so that when the electronic device displays the image stream captured by the camera, it will add lipstick to the lips of the woman in each frame of the image in the image stream, thereby improving the stability of the preview screen display.

[0339] In summary, the embodiments of the present application can determine the matching relationship between objects in two adjacent frames of detection images based on the feature data of the objects in the two adjacent frames of detection images, and use the coordinate information of the object frame where the object in each frame of the detection image is located, and the matching relationship between the first object and the second object as input data for object tracking operations, key point detection, beautification processing, autofocus and other operations, which can improve the stability of the image after object tracking operations, key point detection, beautification processing, autofocus and other operations when displayed.

[0340] Combined with the above Figures 7 to 15 , the object detection method provided in the embodiment of the present application is described, and the device for executing the above method provided in the embodiment of the present application is described below. Fig.16 As shown, Fig.16 A schematic diagram of the structure of an object detection device provided in an embodiment of the present application. The object detection device may be an electronic device in an embodiment of the present application, or a chip or chip system in an electronic device.

[0341] like Fig.16As shown, the object detection device 1600 may include: a display unit 1601 and a processing unit 1602. The display unit 1601 is used to support the object detection device 1600 to perform the above display steps; the processing unit 1602 is used to support the object detection device 1600 to perform the above processing steps.

[0342] Specifically, the processing unit 1602 is used to obtain a first image stream, the first image stream includes a first image and a second image, the first image is an image frame before the second image, the first image includes at least one first object, and the second image includes at least one second object; the processing unit 1602 is used to extract feature data of each first object and feature data of each second object respectively; the processing unit 1602 is used to determine a matching relationship between the first object and the second object based on the feature data of each first object and the feature data of each second object, the matching relationship is used to indicate whether the first object and the second object are the same object; the display unit 1601 is used to display a target object box corresponding to the second object based on the matching relationship.

[0343] In a possible implementation, the object detection device 1600 further includes a storage unit 1603. The storage unit 1603 is connected to the processing unit 1602 via a line. The storage unit 1603 may include one or more memories, and the memory may be a device used to store programs or data in one or more devices or circuits. The storage unit 1603 may exist independently and be connected to the processing unit 1602 via a communication bus. The storage unit 1603 may also be integrated with the processing unit 1602.

[0344] The storage unit 1603 can store computer-executable instructions of the method in the electronic device so that the processing unit 1602 executes the method in the above embodiment. The storage unit 1603 can be a register, a cache, or a random access memory (RAM), etc. The storage unit 1603 can be integrated with the processing unit 1602. The storage unit 1603 can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, and the storage unit 1603 can be independent of the processing unit 1602.

[0345] Fig.17 This is a schematic diagram of the structure of a chip provided in an embodiment of the present application. Fig.17 As shown, the chip 1700 includes one or more (including two) processors 1701 , a communication line 1702 and a communication interface 1703 . Optionally, the chip 1700 also includes a memory 1704 .

[0346] In some implementations, the memory 1704 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.

[0347] The method described in the above embodiment of the present application can be applied to the processor 1701, or implemented by the processor 1701. The processor 1701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 1701 or an instruction in the form of software. The above-mentioned processor 1701 can be a general-purpose processor (for example, a microprocessor or a conventional processor), a digital signal processor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 1701 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.

[0348] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 1704, and the processor 1701 reads the information in the memory 1704 and completes the steps of the above method in combination with its hardware.

[0349] The processor 1701 , the memory 1704 , and the communication interface 1703 may communicate with each other via the communication line 1702 .

[0350] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.

[0351] The present application embodiment also provides a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server, a data center, etc. that includes one or more available media integrated. For example, the available medium can include a magnetic medium (e.g., a floppy disk, a hard disk or a tape), an optical medium (e.g., a digital versatile disc (digital versatiledisc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.

[0352] An embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above-mentioned object detection method.

[0353] The embodiment of the present application provides a chip. The chip includes a processor, and the processor is used to call a computer program in a memory to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.

[0354] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program or instruction. The above method is implemented when the computer program or instruction is executed by the processor. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

[0355] As a possible design, the computer-readable medium may include a compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM or other optical disc storage; the computer-readable medium may include a magnetic disk storage or other magnetic disk storage device. Moreover, any connecting line may also be appropriately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of the medium. Disks and optical discs as used herein include compact discs (CDs), laser discs, optical discs, DVDs, floppy disks and Blu-ray discs, where disks generally reproduce data magnetically, while optical discs reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer-readable media.

[0356] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0357] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above are only specific implementation methods of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the protection scope of the present application.

Claims

1. An object detection method, It is characterized in that Applied to electronic equipment, the method comprises: Acquire a first image stream; the first image stream includes a first image, a second image, and a third image, the first image is an image frame before the second image, the third image is an image frame before the second image, and the third image is an image frame after the first image, the first image includes at least one first object, the third image includes the first object, and the second image includes at least one second object; extracting feature data of each of the first objects and feature data of each of the second objects respectively; determining a matching relationship between the first object and the second object according to the feature data of each of the first objects and the feature data of each of the second objects; the matching relationship is used to indicate whether the first object and the second object are the same object; In the case that the first object and the second object are the same object, the coordinate information of the target object frame corresponding to the second object is determined based on the coordinate information of the tracking frame where the first object is located in the third image and the coordinate information of the second object frame where the second object is located; and the target object frame is displayed based on the coordinate information of the target object frame corresponding to the second object.

2. The method according to claim 1, It is characterized in that After determining the matching relationship between the first object and the second object according to the feature data of each of the first objects and the feature data of each of the second objects, the method further includes: In the case that the first object and the second object are the same object, the attribute detection operation for the second object is not performed.

3. The method according to claim 1, It is characterized in that After determining the matching relationship between the first object and the second object according to the feature data of each of the first objects and the feature data of each of the second objects, the method further includes: According to the matching relationship, a target operation is performed; the target operation includes at least one of an object tracking operation, a key point detection operation, a beautification operation, and an auto-focus operation.

4. The method according to claim 1, It is characterized in that The determining, according to the feature data of each of the first objects and the feature data of each of the second objects, a matching relationship between the first objects and the second objects includes: Calculating a characteristic distance between the characteristic data of the first object and the characteristic data of the second object; the characteristic distance includes a cosine distance and / or a Euclidean distance; It is determined whether the first object and the second object are the same object according to the characteristic distance.

5. The method according to claim 4, It is characterized in that The characteristic distance includes the cosine distance; and determining whether the first object and the second object are the same object according to the characteristic distance includes: When a cosine distance between the feature data of the first object and the feature data of the second object is greater than or equal to a first distance threshold, determining that the first object and the second object are the same object; When the cosine distance between the feature data of the first object and the feature data of the second object is less than the first distance threshold, it is determined that the first object and the second object are not the same object.

6. The method according to claim 4, It is characterized in that The characteristic distance includes the Euclidean distance; and determining whether the first object and the second object are the same object according to the characteristic distance includes: When the Euclidean distance between the feature data of the first object and the feature data of the second object is less than or equal to a second distance threshold, determining that the first object and the second object are the same object; When the Euclidean distance between the feature data of the first object and the feature data of the second object is greater than the second distance threshold, it is determined that the first object and the second object are not the same object.

7. The method according to claim 1, It is characterized in that The extracting the feature data of each first object and the feature data of each second object respectively includes: Respectively detecting coordinate information of a first object frame in which the first object is located in the first image, and coordinate information of a second object frame in which the second object is located in the second image; Extracting a first area image within the first object frame from the first image according to the coordinate information of the first object frame, and extracting a second area image within the second object frame from the second image according to the coordinate information of the second object frame; the first area image includes the first object, and the second area image includes the second object; Feature data of the first object in the first area image and feature data of the second object in the second area image are extracted respectively.

8. The method according to claim 7, It is characterized in that The detecting the coordinate information of a first object frame in the first image where the first object is located, and the coordinate information of a second object frame in the second image where the second object is located, respectively, includes: Preprocessing the first image to obtain a fourth image; Using an object detection model to detect the fourth image, and obtaining coordinate information and confidence levels of multiple first candidate boxes; Filtering at least one first object frame from the multiple first candidate frames according to the confidences of the multiple first candidate frames to obtain coordinate information of the at least one first object frame; preprocessing the second image to obtain a fifth image; Using the object detection model to detect the fifth image, and obtaining coordinate information and confidence levels of multiple second candidate boxes; At least one second object frame is selected from the plurality of second candidate frames according to the confidences of the plurality of second candidate frames to obtain coordinate information of the at least one second object frame.

9. The method according to claim 8, It is characterized in that The preprocessing of the first image to obtain a fourth image includes: Acquire a first image parameter of the first image; the first image parameter includes a first brightness value and / or a first exposure value; If the first image parameter does not satisfy the first preset condition, resizing the first image to obtain the fourth image; Accordingly, the preprocessing of the second image to obtain a fifth image includes: Acquire second image parameters of the second image; the second image parameters include a second brightness value and / or a second exposure value; If the second image parameter does not satisfy a second preset condition, resizing the second image to obtain the fifth image; Wherein, in the case where the first image parameter includes the first brightness value, when the first brightness value is greater than or equal to a first brightness threshold, the first image parameter does not meet the first preset condition; in the case where the first image parameter includes the first exposure value, when the first exposure value is greater than or equal to a first exposure threshold, the first image parameter does not meet the first preset condition; In the case where the second image parameters include the second brightness value, when the second brightness value is greater than or equal to the second brightness threshold, the second image parameters do not satisfy the second preset condition; in the case where the second image parameters include the second exposure value, when the second exposure value is greater than or equal to the second exposure threshold, the second image parameters do not satisfy the second preset condition.

10. The method according to claim 9, It is characterized in that After acquiring the first image parameter of the first image, the method further includes: When the first image parameter satisfies the first preset condition, correcting the first image; resizing the corrected first image to obtain the fourth image; Correspondingly, after acquiring the second image parameter of the second image, the method further includes: When the second image parameter satisfies the second preset condition, correcting the second image; resizing the corrected second image to obtain the fifth image; Wherein, in the case where the first image parameter includes the first brightness value, when the first brightness value is less than the first brightness threshold, the first image parameter satisfies the first preset condition; in the case where the first image parameter includes the first exposure value, when the first exposure value is less than the first exposure threshold, the first image parameter satisfies the first preset condition; In the case where the second image parameters include the second brightness value, when the second brightness value is less than the second brightness threshold, the second image parameters satisfy the second preset condition; in the case where the second image parameters include the second exposure value, when the second exposure value is less than the second exposure threshold, the second image parameters satisfy the second preset condition.

11. The method according to claim 9, It is characterized in that The step of resizing the first image to obtain the fourth image includes: Filling pixels on the edge of the first image to obtain the fourth image; the size ratio of the fourth image is a preset ratio; Accordingly, the step of resizing the second image to obtain the fifth image includes: The edge of the second image is filled with pixels to obtain the fifth image; the size ratio of the fifth image is the preset ratio.

12. The method according to claim 9 or 10, It is characterized in that The method further comprises: performing normalization processing on the first image or the fourth image; Normalization processing is performed on the second image or the fifth image.

13. The method according to claim 10, It is characterized in that The correcting the first image comprises: Acquire first scene information of the first image; the first scene information includes an HDR scene or a non-HDR scene; When the first scene information is the HDR scene, performing a first correction process on the first image to obtain a corrected first image; When the first scene information is the non-HDR scene, performing a second correction process on the first image to obtain a corrected first image; Accordingly, the correcting the second image includes: Acquire second scene information of the second image; the second scene information includes the HDR scene or the non-HDR scene; When the second scene information is the HDR scene, performing the first correction processing on the second image to obtain a corrected second image; When the second scene information is the non-HDR scene, the second correction process is performed on the second image to obtain a corrected second image.

14. The method according to claim 13, It is characterized in that The performing a first correction process on the first image to obtain a corrected first image includes: Performing histogram equalization processing on the first image to obtain a corrected first image; Correspondingly, performing the first correction process on the second image to obtain a corrected second image includes: Performing histogram equalization processing on the second image to obtain a corrected second image.

15. The method according to claim 13, It is characterized in that The performing a second correction process on the first image to obtain a corrected first image includes: Searching the first gray value comparison table for each pixel in the first image for a second gray value corresponding to the first gray value in each color channel; Replacing the first grayscale value of each pixel in each color channel of the first image with the corresponding second grayscale value to obtain a corrected first image; Correspondingly, performing the second correction process on the second image to obtain a corrected second image includes: Searching the first gray value comparison table for each pixel in the second image for a fourth gray value corresponding to the third gray value in each color channel; Replacing the third grayscale value of each pixel in each color channel of the second image with the corresponding fourth grayscale value to obtain a corrected second image; The second grayscale value and the first grayscale value conform to a gamma function relationship, and the fourth grayscale value and the third grayscale value also conform to the gamma function relationship.

16. The method according to claim 7, It is characterized in that The extracting the feature data of the first object in the first area image and the feature data of the second object in the second area image respectively includes: A pedestrian re-identification model is used to extract feature data of the first object in the first area image and feature data of the second object in the second area image respectively; the pedestrian re-identification model includes a ResNet model or a MobileNet model, and the feature data includes a pedestrian re-identification feature vector.

17. The method according to claim 1, It is characterized in that The obtaining of the first image stream comprises: Acquire a second image stream; Downsampling is performed on the images included in the second image stream to obtain the first image stream; the size of the images included in the first image stream is smaller than the size of the images included in the second image stream.

18. The method according to claim 1, It is characterized in that Before respectively extracting the feature data of each of the first objects and the feature data of each of the second objects, the method further includes: An image format of the first image is converted into an RGB format, and an image format of the second image is converted into an RGB format.

19. The method according to claim 1, It is characterized in that The first object and the second object include human faces.

20. An electronic device, It is characterized in that The device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call the computer program to execute the object detection method according to any one of claims 1 to 19.

21. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program or instruction, and when the computer program or instruction is executed, the object detection method according to any one of claims 1 to 19 is implemented.

22. A computer program product, It is characterized in that The invention comprises a computer program, which, when being executed, enables a computer to perform the object detection method according to any one of claims 1 to 19.