Detection frame adjustment method and device for target detection algorithm and storage medium
By comparing the image characteristics of the detection box of the object detection algorithm in the historical frame and the current frame, the detection box is adjusted to achieve a smoother transition, which solves the problem that the detection box is instability affects computer vision applications and improves the stability and continuity of the detection box.
Patent Information
- Application Number
- CN202311282716.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-03-28
AI Technical Summary
In non-still images, the detection box of the object detection algorithm is prone to instability, resulting in excessive changes in the image features selected by the box, affecting the effect of subsequent computer vision applications.
In the object detection algorithm, the image features selected by the detection box in the history frame and the current frame are compared, the change differences are evaluated, and the detection box of the current frame is adjusted with the box selection area corresponding to the history frame as a reference to achieve a smoother transition.
It improves the stability and continuity of the detection frame, reduces the changes in the box-selected image features, and improves the effect of subsequent computer vision applications.
Smart Images

Figure CN119723011A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field, and in particular to a detection frame adjustment method, device and storage medium for a target detection algorithm. Background Art
[0002] Object Detection algorithm is used to find objects in images and is the core technology of computer vision applications such as face recognition and vehicle recognition.
[0003] The target detection algorithm will use a bounding box to select the target area in the image to facilitate the subsequent computer vision application to extract image features. The current mainstream target detection algorithms have the ability to lock the target, that is, the detection box will follow the position of the target. When performing target detection in non-static images (such as videos), it is difficult to maintain the position of the target in the image, which will cause the detection box to jump around. Once the detection box is unstable, the difference in image features extracted from the previous and next frames will be too large, which will cause a huge difference in subsequent computer vision applications, not only generating a lot of computing power overhead, but also affecting the final effect of the computer vision application.
[0004] Therefore, how to improve the stability of the detection frame of the target detection algorithm, thereby improving the negative impact on subsequent computer vision applications, is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The purpose of this application is to provide a detection frame adjustment method, device and storage medium for a target detection algorithm, which can improve the stability of the detection frame during the target detection process, thereby improving the impact of detection frame jumping on subsequent computer vision applications.
[0006] In order to achieve the above purpose, the embodiment of the present application is implemented as follows:
[0007] In a first aspect, a detection frame adjustment method for a target detection algorithm is provided, characterized by comprising:
[0008] When performing target detection based on a target detection algorithm, obtaining a first image feature corresponding to a detection frame of the target detection algorithm in a historical frame and a second image feature corresponding to a current frame; wherein the number of frames between the historical frame and the current frame is not greater than a preset frame value;
[0009] determining a comparison result between the first image feature and the second image feature;
[0010] With reference to the first framed area corresponding to the historical frame, and based on an adjustment degree that matches the comparison result, the detection frame is adjusted in the second framed area corresponding to the current frame.
[0011] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory configured to store computer-executable instructions, wherein the computer-executable instructions, when executed, cause the processor to execute the method described in the first aspect.
[0012] According to a third aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store computer-executable instructions, and the computer-executable instructions implement the method described in the first aspect when executed by a processor.
[0013] When performing target detection based on the target detection algorithm, the present application compares the image features selected by the detection box in the historical frame and the current frame to evaluate the difference in changes in the detection box from the historical frame to the current frame. Afterwards, taking the first framed area corresponding to the historical frame as a reference, the second framed area corresponding to the detection box in the current frame is adjusted based on the degree of adjustment that matches the comparison result, so that the second framed area of the current frame transitions more smoothly relative to the first framed area of the historical frame, avoiding excessive changes in the image features of the frame that affect subsequent computer vision applications. Based on the solution of the present application, when performing target detection in multiple frames of images, the stability and continuity of the detection frame frames can be improved, providing better support for subsequent computer vision applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0015] Figure 1 Schematic diagram of the flow of a detection frame adjustment method for a target detection algorithm according to an embodiment of the present application.
[0016] Figure 2 Schematic diagram of the changes corresponding to the transition of the detection frame from the historical frame to the current frame.
[0017] Figure 3 This is a flow chart of the detection frame adjustment method in a specific application according to an embodiment of the present application.
[0018] Figure 4 Schematic diagram of the structure of a detection frame adjustment device for a target detection algorithm according to an embodiment of the present application.
[0019] Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] As mentioned above, the target detection algorithm will use a bounding box to select the target area in the image to facilitate the subsequent computer vision application to extract image features. Currently, mainstream target detection algorithms have the ability to lock the target, that is, the detection box will follow the position of the target. When performing target detection in non-static images, it is difficult to maintain the position of the target in the image, which will cause the detection box to jump around.
[0021] Here we take computer vision applications involving face recognition as an example. When a user starts image acquisition using his or her terminal device, the target detection algorithm finds the user's face area in multiple frames of acquired images. During normal acquisition, the user's body shakes to a greater or lesser extent, which causes the face area in the acquisition interface to change, and the detection frame to jump around. Finally, some image features (such as texture, grayscale, etc.) selected by the frame have large differences, which has a great impact on computer vision applications (such as face beautification, face replacement, etc.).
[0022] To this end, the present application aims to propose a detection frame adjustment scheme for target detection algorithms, which can improve the stability of the detection frame during the target detection process, thereby improving the impact of detection frame jumping on subsequent computer vision applications.
[0023] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0024] On the one hand, an embodiment of the present application provides a detection frame adjustment method for a target detection algorithm. Figure 1 The flowchart of the detection frame adjustment method includes the following steps:
[0025] S102, when performing target detection based on the target detection algorithm, obtain the first image feature of the detection frame of the target detection algorithm corresponding to the historical frame and the second image feature corresponding to the current frame; wherein the number of frames between the historical frame and the current frame is not greater than a preset frame value.
[0026] In this embodiment, the detection frame of the historical frame is used as a reference to adjust the detection frame of the current frame. Therefore, the number of frames between the historical frame and the current frame should not be too large, and should be less than or equal to a preset frame value (such as 3 frames). As a preferred solution, the historical frame and the current frame can be two adjacent continuous frames.
[0027] Among them, the image features (first image features and second image features) selected by the detection box can be but are not limited to image-related texture features, color features, deep learning features, and grayscale features, etc. These are commonly used input parameters for computer vision applications and are not specifically limited in this article.
[0028] S104: Determine a comparison result between the first image feature and the second image feature.
[0029] In this embodiment, the first image feature and the second image feature can be firstly vectorized and encoded to obtain a first feature vector corresponding to the first image feature and a second feature vector corresponding to the second image feature; then, the similarity between the first feature vector and the second feature vector is calculated to obtain a comparison result between the first image feature and the second image feature.
[0030] Specifically, the similarity algorithm may be a cosine similarity algorithm, a variance similarity algorithm, etc., which is not specifically limited in this document.
[0031] S106, taking the first frame selection area corresponding to the historical frame as a reference, and adjusting the second frame selection area corresponding to the detection frame in the current frame based on an adjustment degree that matches the comparison result.
[0032] It should be understood that the similarity between the first image feature and the second image feature can reflect the change of the detection frame between the historical frame and the current frame extracted image.
[0033] If the change is small, that is, the comparison result indicates that the similarity between the first image feature and the second image feature reaches the first threshold, it means that the main part of the target presenting the image feature is still in the first frame selection area. At this time, it is not appropriate to change the detection frame, and the region parameters corresponding to the second frame selection area are directly adjusted to the region parameters corresponding to the first frame selection area. That is, after the detection frame transitions from the historical frame to the current frame, the first frame selection area remains unchanged.
[0034] If the change is too large, that is, the comparison result indicates that the similarity between the first image feature and the second image feature does not reach the second threshold (the second threshold is less than or equal to the first threshold), it means that the main part of the target presenting the image feature is outside the first framed area. In this case, it is no longer appropriate for the detection frame to continue to use the first framed area. In order to avoid the detection frame abruptly jumping from the first framed area to the second framed area, it is necessary to adjust the area parameters corresponding to the second framed area to values close to the area parameters of the first framed area to achieve a smooth transition.
[0035] As an exemplary introduction, this embodiment can perform weighted averaging on the area parameters (such as center coordinates, width and height) corresponding to the first framed area and the second framed area, and adjust the area parameters corresponding to the second framed area to the area parameters after weighted averaging to achieve a smooth transition.
[0036] Among them, the similarity between the first image feature and the second image feature is negatively correlated with the weight of the regional parameter corresponding to the second frame selection area when performing weighted averaging. That is, a high similarity indicates that the jitter of the detection frame transitioning from the historical frame to the current frame is small. At this time, in order to reduce the computing power overhead of subsequent computer vision applications for the change of the detection frame, it is not advisable to make too large changes to the frame selection area of the detection frame. Therefore, the weight of the regional parameter corresponding to the second frame selection area in the weighted average is appropriately reduced; on the contrary, a low similarity indicates that the jitter of the detection frame transitioning from the historical frame to the current frame is large, and the target in the image has moved away from the first frame selection area. At this time, it is not advisable to adjust the second frame selection area too much with reference to the first frame selection area. Therefore, the weight of the regional parameter corresponding to the second frame selection area in the weighted average is increased to ensure that the adjusted second frame selection area can frame the main part of the image features presenting the target.
[0037] For easy understanding, reference Figure 2 The application scenario based on face recognition is shown in the figure. Here, the transition of the detection frame from the historical frame to the current frame is divided into the following two scenarios:
[0038] Scenario 1 is that the difference in image features between the original detection frame (historical frame) and the current detection frame (current frame) is small; that is, after the face position changes, the original detection frame can still select the user's facial features in the current frame. At this time, the area parameters of the current detection frame can be adjusted to the area parameters of the original detection frame, so that the current frame still uses the original detection frame.
[0039] Scenario 2 is that the difference in image features between the original detection frame and the current detection frame is too large; that is, after the face position changes, the original detection frame can no longer select the user's facial features in the current frame. At this time, the area parameters of the current detection frame can be adjusted to be close to the area parameters of the original detection frame, so that the adjusted current detection frame is closer to the original detection frame than the current detection frame before adjustment, so as to avoid the change being too abrupt.
[0040] In summary, when the method of this embodiment performs target detection based on the target detection algorithm, the image features selected by the detection box in the historical frame and the current frame are compared to evaluate the difference in changes in the detection box from the historical frame to the current frame. Afterwards, taking the first framed area corresponding to the historical frame as a reference, the second framed area corresponding to the detection box in the current frame is adjusted based on the degree of adjustment that matches the comparison result, so that the second framed area of the current frame transitions more smoothly relative to the first framed area of the historical frame, thereby avoiding excessive changes in the image features of the frame that affect subsequent computer vision applications. Based on the method of this embodiment, when performing target detection in multiple frames of images, the stability and continuity of the detection frame frames can be improved, providing better support for subsequent computer vision applications.
[0041] The specific implementation of the method in this embodiment is introduced below.
[0042] The method of this embodiment uses the frame selection area corresponding to the detection frame in the previous frame as a reference to adjust the frame selection area corresponding to the detection frame in the current frame. The corresponding process includes:
[0043] S1, set the initialization parameters of the target detection algorithm, including the area parameters of the detection box of the previous frame (center coordinates, width and height), the image data address of the previous frame, the first frame flag, the feature matching threshold and the weighting coefficient alpha, etc.
[0044] The feature matching threshold and weighting coefficient alpha will be flexibly set according to actual conditions, and the value range of alpha is [0,1].
[0045] S2, use the target detection algorithm to try to detect the target of the input frame image; if the number of detected targets is 0, re-execute S2; if the number of targets is greater than 0, output the initial area parameters of the detection box, including the center coordinates, width and height.
[0046] S3, determine the first frame flag of the initial regional parameters of the detection frame; if the first frame flag is 0 (not marked), it means that the regional parameters corresponding to the detection frame in the previous frame are not available at this time, and the initial regional parameters of the detection frame are used as the regional parameters corresponding to the current frame, and then jump to S4; if the first frame flag is 1 (marked), enter the next frame and jump to S5.
[0047] The result detection frame refers to the detection frame whose selected area is no longer adjusted. After entering the next frame, the next frame becomes the new current frame.
[0048] S4, updating the area parameters of the result detection frame to the area parameters of the detection frame of the previous frame; then, entering the next frame to execute S5.
[0049] S5, extracting image features of the current frame and the previous frame based on the area parameters of the detection boxes corresponding to the current frame and the previous frame.
[0050] S6, calculate the similarity of the image features of the current frame and the previous frame to determine the comparison result; if the similarity sim indicated by the comparison result reaches the feature matching threshold, jump to S7, otherwise jump to S8.
[0051] Among them, if there are multiple types of image features, such as texture features, color features, deep learning features and grayscale features, the similarity can be calculated for each type of image feature separately, and finally the calculation results are weighted to determine an overall similarity.
[0052] S7, taking the detection frame of the previous frame as the result detection frame of the current frame; then jumping to S4.
[0053] S8, weighted average the initial regional parameters of the detection frame of the previous frame and the detection frame of the current frame to obtain the result detection frame of the current frame; then jump to S4.
[0054] The calculation formula of weighted average is:
[0055] The area information of the result detection frame of the current frame = alpha × the area information of the detection frame of the previous frame + (1-alpha) × the initial area information of the detection frame of the current frame.
[0056] In addition, based on the above, if the negative correlation between similarity and (1-alpha) is introduced, the calculation formula of weighted average can be:
[0057] The area information of the result detection frame of the current frame = alpha × the area information of the detection frame of the previous frame + (1-alpha) × beta × the initial area information of the detection frame of the current frame.
[0058] Among them, beta is used to correct (1-alpha), beta = a-b / similarity; a and b are custom coefficients.
[0059] The following is a summary of the different business scenarios. Figure 3 The process shown is introduced as an example.
[0060] Business scenario 1
[0061] This business scenario is a computer vision application based on face detection. The corresponding process includes:
[0062] S1, Set the system initialization parameters to 0, including the region information preRect of the face detection box in the previous frame, the image data preData of the previous frame, the first frame flag bit isNotFirstFrame, the feature matching threshold thresh is 4.0, and the weighting coefficient alpha is 0.5.
[0063] S2, Based on the object detection algorithm of Single Shot MultiBox Detector (SSD), perform face detection on the input frame image; if the number of detected objects is 0, then re - execute S2; if the number of objects is greater than 0, obtain the initial region information curRect of the face detection box, including the center coordinates and width and height (in pixels) of the face detection box.
[0064] S3, Determine the isNotFirstFrame of curRect; if isNotFirstFrame is 0, then use curRect as the region information resultRect of the face detection box in the current frame result, and then jump to S4; if isNotFirstFrame is 1, then go to the next frame and jump to S5.
[0065] S4, Update the region parameters curRec of the result detection box to the region parameters preRect of the detection box in the previous frame, that is, isNotFirstFrame is 1, and at the same time save the image data preData of the current frame; then, go to the next frame and execute S5.
[0066] S5, Read the region information preRect of the face detection box in the previous frame, crop and extract the image gray - scale feature vectors curFea and preFea at the same face detection box position of the current frame image data curData and the previous frame image data preData respectively.
[0067] S6, Calculate the mean square error similarity mse between the two groups of image feature vectors curFea and preFea. If mse < thresh, jump to S7, otherwise jump to S8.
[0068] Among them, N is the length of the feature vector.
[0069] S7, Use the face detection box preRect in the previous frame as the face detection box result resultRect in the current frame and jump to S4.
[0070] S8, Perform weighted averaging on the center and width and height parameters of the face detection box preRect in the previous frame and the initial face detection box curRect in the current frame to obtain the face detection box result resultRect in the current frame and jump to S4.
[0071] The calculation formula of weighted average is:
[0072] resultRect.center=alpha×preRect.center+(1-alpha)×curRect.center;
[0073] resultRect.height=alpha×preRect.height+(1-alpha)×curRect.height;
[0074] resultRect.width=alpha×preRect.width+(1-alpha)×curRect.width.
[0075] Based on the above, if the negative correlation between MSE and (1-alpha) is introduced, the calculation formula of weighted average can be:
[0076] resultRect.center=alpha×preRect.center+(1-alpha)×beta×curRect.center;
[0077] resultRect.height=alpha×preRect.height+(1-alpha)×beta×curRect.height;
[0078] resultRect.width=alpha×preRect.width+(1-alpha)×beta×curRect.width.
[0079] Among them, beta = a-b / mse; a and b are user-defined coefficients.
[0080] Business Scenario 2
[0081] This business scenario is a computer vision application related to vehicle detection. The process includes:
[0082] S1, set the system initialization parameters to 0, including the area information preRect of the vehicle detection frame of the previous frame, the image data preData of the previous frame, the first frame flag isNotFirstFrame, the feature matching threshold thresh to 0.95, and the weighting coefficient alpha to 0.5.
[0083] S2, based on the target detection algorithm of Yolov7, performs vehicle detection on the input frame image; if the number of detected vehicle targets is 0, S2 is executed again; if the number of targets is greater than 0, the initial region information curRect of the vehicle detection frame is obtained, including the center coordinates and width and height (in pixels) of the vehicle detection frame.
[0084] S3, determine isNotFirstFrame of curRect; if isNotFirstFrame is 0, use curRect as the area information resultRect of the vehicle detection frame of the current frame, and then jump to S4; if isNotFirstFrame is 1, enter the next frame and jump to S5.
[0085] S4, update the region parameter curRec of the result detection frame to the region parameter preRect of the detection frame of the previous frame, that is, isNotFirstFrame is 1, and save the current frame image data preData; then, enter the next frame to execute S5.
[0086] S5, read the area information preRect of the vehicle detection frame of the previous frame, crop the same detection frame position of the current frame image data curData and the previous frame image data preData respectively, and extract the RGB normalized histogram feature vectors curFea and preFea, the method is as follows:
[0087] Assume that the width and height of the input image are W and H, and the RGB pixel value range is [0-GrayLevel]. Traverse the image and count the R, G, and B component histograms as histR, histG, and histB respectively. The length of each histogram is GrayLevel+1.
[0088] Next, calculate the normalized histogram, histR = histR / (W*H), histG = histG / (W*H), histB = histB / (W*H);
[0089] Afterwards, the normalized histograms are concatenated into a histogram histogram with a length of 3*(GrayLevel+1) as the feature of the cropped image.
[0090] S6, calculate the cosine similarity cos between the two sets of image feature vectors curFea and preFea. If cos>thresh, jump to S7, otherwise jump to S8.
[0091] Among them, the calculation formula of cosine similarity cos is:
[0092] x and y represent curFea and preFea respectively, N=3×(GrayLevel+1)-1.
[0093] S7, use the vehicle detection frame preRect of the previous frame as the vehicle detection frame result resultRect of the current frame and jump to S4.
[0094] S8, perform weighted processing on the center and width and height parameters of the vehicle detection frame preRect of the previous frame and the initial vehicle detection frame curRect of the current frame to obtain the vehicle detection frame result resultRect of the current frame and jump to S4.
[0095] Among them, the calculation formula of weighted average is:
[0096] resultRect.center=alpha×preRect.center+(1-alpha)×curRect.center;
[0097] resultRect.height=alpha×preRect.height+(1-alpha)×curRect.height;
[0098] resultRect.width=alpha×preRect.width+(1-alpha)×curRect.width.
[0099] On the other hand, an embodiment of the present application further provides a detection frame adjustment device for a target detection algorithm. Figure 4 The structure diagram of the detection frame adjustment device is as follows:
[0100] The feature acquisition module 410 is used to obtain the first image feature corresponding to the detection frame of the target detection algorithm in the historical frame and the second image feature corresponding to the current frame when performing target detection based on the target detection algorithm; wherein the number of frames between the historical frame and the current frame is not greater than the preset frame value.
[0101] The feature comparison module 420 is used to determine a comparison result between the first image feature and the second image feature.
[0102] The detection frame adjustment module 430 is used to adjust the detection frame in the second frame selection area corresponding to the current frame based on an adjustment degree that matches the comparison result, with reference to the first frame selection area corresponding to the historical frame.
[0103] When the device of this embodiment performs target detection based on the target detection algorithm, the image features selected by the detection frame in the historical frame and the current frame are compared to evaluate the difference in changes in the detection frame from the historical frame to the current frame. Afterwards, with the first framed area corresponding to the historical frame as a reference, the second framed area corresponding to the detection frame in the current frame is adjusted based on the degree of adjustment that matches the comparison result, so that the second framed area of the current frame transitions more smoothly relative to the first framed area of the historical frame, thereby avoiding excessive changes in the image features of the frame that affect subsequent computer vision applications. Based on the device of this embodiment, when performing target detection in multiple frames of images, the stability and continuity of the detection frame can be improved, providing better support for subsequent computer vision applications.
[0104] Optionally, the detection frame adjustment module 430 takes the first framed area corresponding to the historical frame as a reference, and adjusts the detection frame to the second framed area corresponding to the current frame based on the adjustment degree adapted to the comparison result, including: when the comparison result indicates that the similarity between the first image feature and the second image feature reaches a first threshold, directly adjusting the regional parameters corresponding to the second framed area to the regional parameters corresponding to the first framed area.
[0105] Optionally, the detection frame adjustment module 430 takes the first framed area corresponding to the historical frame as a reference, and adjusts the second framed area corresponding to the current frame based on an adjustment degree that matches the comparison result, including: when the comparison result indicates that the similarity between the first image feature and the second image feature does not reach a second threshold, adjusting the regional parameters corresponding to the second framed area to values close to the regional parameters of the first framed area.
[0106] Optionally, the detection frame adjustment module 430 adjusts the area parameters corresponding to the second frame selection area to be close to the area parameters of the first frame selection area, including: performing weighted averaging on the area parameters corresponding to the first frame selection area and the second frame selection area to obtain the weighted average area parameters; and adjusting the area parameters corresponding to the second frame selection area to the weighted average area parameters.
[0107] Optionally, the similarity between the first image feature and the second image feature is negatively correlated with the weight of the area parameter corresponding to the second framed area when performing the weighted averaging.
[0108] Optionally, determining the comparison result between the first image feature and the second image feature includes: vectorizing and encoding the first image feature and the second image feature to obtain a first feature vector corresponding to the first image feature and a second feature vector corresponding to the second image feature; and performing similarity calculation on the first feature vector and the second feature vector to obtain the comparison result between the first image feature and the second image feature.
[0109] Optionally, the area parameters include: the center coordinates of the detection frame in the detection image, and the width and height of the detection frame.
[0110] Optionally, the image feature includes: at least one of a texture feature, a color feature, a deep learning feature and a grayscale feature.
[0111] It should be understood that Figure 4 The detection frame adjustment device shown can be used as Figure 1 The execution body of the method shown in Figure 1 The steps and corresponding functions shown in the figure are the same and will not be described in detail in this article.
[0112] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 5 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0113] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0114] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0115] Optionally, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming the above-mentioned Figure 4 Correspondingly, the processor executes the program stored in the memory and is specifically used to perform the following operations:
[0116] When performing target detection based on a target detection algorithm, a first image feature of a detection frame of the target detection algorithm corresponding to a historical frame and a second image feature corresponding to a current frame are obtained; wherein the number of frames between the historical frame and the current frame is not greater than a preset frame value.
[0117] A comparison result between the first image feature and the second image feature is determined.
[0118] With reference to the first framed area corresponding to the historical frame, and based on an adjustment degree that matches the comparison result, the detection frame is adjusted in the second framed area corresponding to the current frame.
[0119] When the electronic device of this embodiment performs target detection based on the target detection algorithm, the image features selected by the detection frame in the historical frame and the current frame are compared to evaluate the difference in changes in the detection frame from the historical frame to the current frame. Afterwards, with the first framed area corresponding to the historical frame as a reference, the second framed area corresponding to the detection frame in the current frame is adjusted based on the degree of adjustment that matches the comparison result, so that the second framed area of the current frame transitions more smoothly relative to the first framed area of the historical frame, thereby avoiding excessive changes in the image features of the frame that affect subsequent computer vision applications. Based on the electronic device of this embodiment, when performing target detection in multiple frames of images, it is possible to improve the stability and continuity of the detection frame frames, thereby providing better support for subsequent computer vision applications.
[0120] The detection frame adjustment method disclosed in the above-mentioned embodiment as shown in this specification can be applied to a processor and implemented by a processor. The processor 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 or an instruction in the form of software. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0121] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0122] In addition, an embodiment of the present application also proposes a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions.
[0123] When the above instructions are executed by a portable electronic device including a plurality of application programs, the portable electronic device can execute Figure 1 The steps of the method shown include:
[0124] When performing target detection based on a target detection algorithm, a first image feature of a detection frame of the target detection algorithm corresponding to a historical frame and a second image feature corresponding to a current frame are obtained; wherein the number of frames between the historical frame and the current frame is not greater than a preset frame value.
[0125] A comparison result between the first image feature and the second image feature is determined.
[0126] With reference to the first framed area corresponding to the historical frame, and based on an adjustment degree that matches the comparison result, the detection frame is adjusted in the second framed area corresponding to the current frame.
[0127] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0128] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0129] The above are only embodiments of this specification and are not intended to limit this specification. For those skilled in the art, this specification may be subject to various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims of this specification. In addition, all other embodiments obtained by ordinary technicians in this field without creative work shall fall within the scope of protection of this document.
Claims
1. A detection frame adjustment method for a target detection algorithm, characterized in that: include: When performing target detection based on a target detection algorithm, obtaining a first image feature corresponding to a detection frame of the target detection algorithm in a historical frame and a second image feature corresponding to a current frame; wherein the number of frames between the historical frame and the current frame is not greater than a preset frame value; determining a comparison result between the first image feature and the second image feature; With reference to the first framed area corresponding to the historical frame, and based on an adjustment degree that matches the comparison result, the detection frame is adjusted in the second framed area corresponding to the current frame.
2. The method according to claim 1, characterized in that The adjusting the detection frame in the second frame selection area corresponding to the current frame based on the adjustment degree adapted to the comparison result with the first frame selection area corresponding to the historical frame as a reference includes: When the comparison result indicates that the similarity between the first image feature and the second image feature reaches a first threshold, the region parameters corresponding to the second framed region are directly adjusted to the region parameters corresponding to the first framed region.
3. The method according to claim 1, characterized in that The adjusting the detection frame in the second frame selection area corresponding to the current frame based on the adjustment degree adapted to the comparison result with the first frame selection area corresponding to the historical frame as a reference includes: When the comparison result indicates that the similarity between the first image feature and the second image feature does not reach a second threshold, the region parameters corresponding to the second framed region are adjusted to values close to the region parameters of the first framed region.
4. The method according to claim 3, characterized in that: The adjusting the area parameters corresponding to the second frame selection area to be close to the area parameters of the first frame selection area includes: Performing weighted averaging on the area parameters corresponding to the first framed area and the second framed area to obtain weighted average area parameters; The region parameters corresponding to the second framed region are adjusted to the region parameters after the weighted average.
5. The method according to claim 4, characterized in that The similarity between the first image feature and the second image feature is negatively correlated with the weight of the area parameter corresponding to the second framed area when performing the weighted averaging.
6. The method according to any one of claims 1 to 5, characterized in that: The determining a comparison result between the first image feature and the second image feature includes: Performing vectorized encoding on the first image feature and the second image feature to obtain a first feature vector corresponding to the first image feature and a second feature vector corresponding to the second image feature; A similarity calculation is performed on the first feature vector and the second feature vector to obtain a comparison result between the first image feature and the second image feature.
7. The method according to any one of claims 1 to 5, characterized in that: The area parameters include: the center coordinates of the detection frame in the detection image, and the width and height of the detection frame.
8. The method according to any one of claims 1 to 5, characterized in that: The image features include: at least one of texture features, color features, deep learning features and grayscale features.
9. An electronic device, comprising a processor; and a memory configured to store computer executable instructions, wherein when the computer executable instructions are executed, the processor executes the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, wherein the computer-readable storage medium is used to store computer-executable instructions, wherein the computer-executable instructions implement the method according to any one of claims 1 to 8 when executed by a processor.
Citation Information
Cited By
Bounding box adjustment method for object detection algorithm, device, and storage medium
EP4693213A1