Method, device, readable medium and electronic device for tracking designated area in video

Through preset recognition and tracking algorithms, the designated area locations in video frames are quickly and accurately identified and tracked, solving the problem of low position recognition efficiency in video processing and achieving efficient video element replacement.

CN112258556BActive Publication Date: 2024-11-08BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011140043.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-22
Publication Date
2024-11-08
Estimated Expiration
2040-11-08

AI Technical Summary

Technical Problem

In video processing, prior art is difficult to quickly and accurately identify and track the location of designated areas in video, resulting in inefficiency in replacing video elements, especially when multiple video frames are required to be processed.

Method used

The preset recognition algorithm determines the location of the specified area in the video frame, and uses the tracking algorithm to perform position checksum updates on adjacent frames. This process is repeated until all frame positions are determined to achieve fast and accurate tracking of the specified area.

Benefits of technology

It improves the efficiency of identifying and replacing designated areas in videos, reduces the amount of calculation, enhances processing speed and accuracy, and is suitable for the video processing needs of individual users and enterprise users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112258556B_ABST
    Figure CN112258556B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device, readable medium and electronic device for tracking a specified area in a video, and to the field of image processing technology. The method comprises: determining the position of a specified area in a first image frame according to a preset recognition algorithm, the first image frame being any image frame in a target video, tracking the specified area in a second image frame according to the position of the specified area in the first image frame to obtain a tracking position, verifying the tracking position according to the position of the specified area in the first image frame and the tracking position, and determining the position of the specified area in the second image frame according to the verification result of the tracking position, updating the first image frame to the second image frame, and repeatedly performing the steps of tracking the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, and updating the first image frame to the second image frame, until the position of the specified area in each image frame in the target video is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular, to a method, device, readable medium and electronic device for tracking a specified area in a video. Background Art

[0002] In the field of image processing technology, as smart terminals become more and more popular in daily life, users can shoot videos and share them. For individual users, when they see a video of interest, they may want to imitate it and change certain elements in the video to shoot the same video. For corporate users, they often design the same advertisement for a series of products, and then only need to shoot the advertisement once and replace the products in the advertisement with other products in the same series to obtain advertisements for a series of products. Therefore, it is necessary to identify the position of the specified area in each image frame in the video to achieve replacement. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, the present disclosure provides a method for tracking a specified area in a video, the method comprising:

[0005] Determine the position of the designated area in a first image frame according to a preset recognition algorithm, where the first image frame is any image frame in the target video;

[0006] According to the position of the designated area in the first image frame, the designated area in the second image frame is tracked to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame;

[0007] Verifying the tracking position according to the position of the designated area in the first image frame and the tracking position, and determining the position of the designated area in the second image frame according to the verification result of the tracking position;

[0008] Updating the first image frame to the second image frame;

[0009] Repeat the step of tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position, and then update the first image frame to the second image frame until the position of the designated area in each image frame in the target video is obtained.

[0010] In a second aspect, the present disclosure provides a device for tracking a specified area in a video, the device comprising:

[0011] A recognition module, used to determine the position of a specified area in a first image frame according to a preset recognition algorithm, wherein the first image frame is any image frame in a target video;

[0012] A tracking module, configured to track a designated area in a second image frame according to a position of the designated area in the first image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame;

[0013] a verification module, configured to verify the tracking position according to the position of the designated area in the first image frame and the tracking position, and determine the position of the designated area in the second image frame according to the verification result of the tracking position;

[0014] An updating module, used for updating the first image frame to the second image frame;

[0015] Repeat the step of tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position, and then update the first image frame to the second image frame until the position of the designated area in each image frame in the target video is obtained.

[0016] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect of the present disclosure.

[0017] In a fourth aspect, the present disclosure provides an electronic device, including:

[0018] a storage device having a computer program stored thereon;

[0019] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.

[0020] Through the above technical scheme, the present disclosure first identifies the position of the specified area in the first image frame according to a preset recognition algorithm, and then tracks the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, and then verifies the tracking position, and determines the position of the specified area in the second image frame according to the verification result of the tracking position, and then uses the second image frame as the first image frame, and repeats the above steps until the position of the specified area in each image frame in the target video is obtained. The present disclosure first identifies the position of the specified area in any image frame in the target video through a recognition algorithm, and then tracks other video frames in the target video according to the position to obtain the position of the specified area in other video frames, and can quickly and accurately identify the position of the specified area in each image frame in the target video.

[0021] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0023] Figure 1 is a flow chart of a method for tracking a specified area in a video according to an exemplary embodiment;

[0024] Figure 2 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment;

[0025] Figure 3 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment;

[0026] Figure 4 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment;

[0027] Figure 5 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment;

[0028] Figure 6 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment;

[0029] Figure 7 is a schematic diagram of a target video according to an exemplary embodiment;

[0030] Figure 8 is a block diagram of a device for tracking a specified area in a video according to an exemplary embodiment;

[0031] Fig. 9 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment;

[0032] Fig.10 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment;

[0033] Fig.11 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment;

[0034] Fig.12 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0035] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0036] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0037] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0038] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0039] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0040] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0041] Figure 1 is a flow chart of a method for tracking a specified area in a video according to an exemplary embodiment. Figure 1 As shown, the method may include the following steps:

[0042] Step 101: determine the position of a designated area in a first image frame according to a preset recognition algorithm, where the first image frame is any image frame in a target video.

[0043] For example, the execution subject of the embodiments in the present disclosure may be a terminal device or a server, and the present disclosure does not specifically limit this. First, the target video is determined. The target video may be a video shot by a user, or a video selected by a user by browsing a multimedia resource library (the multimedia resource library may be stored in a terminal device or in a server). Afterwards, any image frame in the target video may be used as a first image frame to identify the position of a specified area in the first image frame. The first image frame may be the first image frame in the target video in chronological order, or the last image frame, or any image frame in the middle.

[0044] Specifically, the designated area may be an area where the designated object in the target video is located. For example, when the target video is shot in advance, the designated object (e.g., screen of an electronic device, billboard, window, door, etc.) may be set to a designated color (e.g., green, blue, etc.), so that the designated object in the shot target video presents the designated color, so that the user can replace the designated object in the target video. For another example, when the target video is shot in advance, a designated object of a designated shape (e.g., a rectangle, etc.) may be shot, so that the designated object in the shot target video presents the designated shape, so that the user can replace the designated object in the target video. Therefore, the target video may be understood as a template video. According to a preset recognition algorithm, the position of the designated area in the first image frame may be determined, wherein the position of the designated area in the first image frame may be the coordinate range of the designated area on the first image frame, for example: abscissa range: 15-217, ordinate range: 60-190. The position of the specified area in the first image frame may also be the vertex coordinates of the specified area on the first image frame, for example, the coordinates of the four vertices are (15, 60), (15, 190), (217, 60), and (217, 90).

[0045] For example, the recognition algorithm may first perform contour detection on the first frame image, and then perform polygon fitting on the detected contour to obtain the position of the specified area in the first image frame. For another example, the recognition algorithm may first filter the color of each pixel in the first frame image, filter out the pixels of the specified color as the initial area, and then perform edge extraction and polygon fitting on the initial area to obtain the position of the specified area in the first image frame. The recognition algorithm may also first filter and dilate the first image frame, and then perform edge extraction to obtain the position of the specified area in the first image frame. The present disclosure does not limit the specific implementation method of the recognition algorithm.

[0046] Step 102, according to the position of the designated area in the first image frame, track the designated area in the second image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame.

[0047] For example, after obtaining the position of the specified area in the first image frame, the position of the specified area in the first image frame can be used as a reference to track the specified area in the second image frame to obtain the tracking position, which can be understood as a prediction of the position of the specified area in the second image frame. For example, the position of the specified area in the first image frame can be used as the input of the optical flow tracking algorithm to obtain the tracking position output by the optical flow tracking algorithm. The position of the specified area in the first image frame can also be used as the input of the feature point tracking algorithm to obtain the tracking position output by the feature point tracking algorithm. The position of the specified area in the first image frame can also be used as a pre-trained feature point tracking model to obtain the tracking position output by the feature point tracking model. The feature point tracking model can be a neural network such as RNN (English: Recurrent Neural Network, Chinese: Recurrent Neural Network), CNN (English: Convolutional Neural Networks, Chinese: Convolutional Neural Network), LSTM (English: Long Short-Term Memory, Chinese: Long Short-Term Memory Network), etc., and the present disclosure does not specifically limit this.

[0048] Among them, the second image frame is an image frame adjacent to the first image frame in the target video, that is, the second image frame is temporally continuous with the first image frame. If the first image frame is the first image frame in the target video in time sequence, then the second image frame may be the second image frame in the target video. If the first image frame is the last image frame in the target video in time sequence, then the second image frame may be the second to last image frame in the target video. If the first image frame is the middle image frame in time sequence in the target video, then the second image frame may be the previous image frame of the first image frame, or the next image frame, or the previous image frame and the next image frame (that is, the second image frame may be two).

[0049] Step 103: verify the tracking position according to the position of the designated area in the first image frame and the tracking position, and determine the position of the designated area in the second image frame according to the verification result of the tracking position.

[0050] Step 104: Update the first image frame to a second image frame.

[0051] Steps 102 to 104 are repeatedly performed until the position of the designated area in each image frame in the target video is obtained.

[0052] For example, the tracking position may be checked first to determine the accuracy of the tracking position. If the check result indicates that the accuracy of the tracking position is high, the tracking position may be directly used as the position of the designated area in the second image frame. If the check result indicates that the accuracy of the tracking position is low, the tracking position may be corrected and the corrected tracking position may be used as the position of the designated area in the second image frame, or the position of the designated area in the second image frame may be identified according to the recognition algorithm in step 101. The tracking position may be checked by comparing the position of the designated area in the first image frame with the distance between the tracking position. Since the time difference between two adjacent image frames is very short, if the distance between the position of the designated area in the first image frame and the tracking position is too large, it may be determined that the accuracy of the tracking position is low. It may also be compared by comparing the area of ​​the designated area in the first image frame with the area of ​​the designated area indicated by the tracking position. If the area of ​​the designated area in the first image frame differs too much from the area of ​​the designated area indicated by the tracking position, it may be determined that the accuracy of the tracking position is low. It is also possible to compare the color distribution of the specified area in the first image frame with the color distribution of the specified area indicated by the tracking position. If the color distribution of the specified area in the first image frame is too different from the color distribution of the specified area indicated by the tracking position, it can be determined that the accuracy of the tracking position is low.

[0053] After step 101 to step 103, the position of the designated area in the first image frame and the position of the designated area in the second image frame are obtained. Afterwards, the first image frame can be updated to the second image frame, and then steps 102 to 104 are repeated until the position of the designated area in each image frame in the target video is obtained. If the first image frame is the first image frame in the target video in chronological order, then steps 102 to 104 are repeated, which can be understood as taking the position of the designated area in the first image frame as a reference, and tracking the position of the designated area in each subsequent image frame in chronological order, that is, backward tracking. If the first image frame is the last image frame in the target video in chronological order, then steps 102 to 104 are repeated, which can be understood as taking the position of the designated area in the last image frame as a reference, and tracking the position of the designated area in each previous image frame in chronological order, that is, forward tracking. If the first image frame is the middle image frame in the target video, then steps 102 to 104 are repeated. This can be understood as taking the position of the specified area in the middle image frame as a reference and tracking the position of the specified area in each of the previous and subsequent image frames in chronological order, that is, tracking in two directions.

[0054] A specific description is given by taking an example in which a target video includes 10 image frames arranged in time sequence: image frame 1, image frame 2, ..., image frame 10.

[0055] If the first image frame is image frame 1, by executing step 101, the position of the designated area in image frame 1 is obtained. When steps 102 to 103 are executed for the first time, the second image frame is image frame 2, and the position of the designated area in image frame 2 is obtained. Then, by executing step 104, the first image frame is updated to image frame 2, that is, image frame 2 is used as the first image frame at this time. Steps 102 to 103 are executed again, and the second image frame is image frame 3 at this time, and the position of the designated area in image frame 3 is obtained. Then, by executing step 104, the first image frame is updated to image frame 3. Then, when steps 102 to 103 are executed next time, the second image frame is image frame 4, and so on, until the position of the designated area in each of the 10 image frames is obtained. Similarly, if the first image frame is image frame 10, the position of the designated area in image frame 9, the position of the designated area in image frame 8, etc. are tracked forward in sequence, which will not be repeated here.

[0056] If the first image frame is image frame 5, by executing step 101, the position of the specified area in image frame 5 is obtained. When steps 102 to 103 are executed for the first time, the second image frames are image frames 4 and image frame 6, and the position of the specified area in image frame 4 and the position of the specified area in image frame 6 are obtained. Then, by executing step 104, the first image frame is updated to image frame 4 and image frame 6 (at this time, there are two first image frames). Steps 102 to 103 are executed again. At this time, the second image frame corresponding to image frame 4 is image frame 3, and the second image frame corresponding to image frame 6 is image frame 7. Then, the position of the specified area in image frame 3 and the position of the specified area in image frame 7 can be obtained. Then, by executing step 104, the first image frame is updated to image frame 3 and image frame 7. And so on, until the position of the specified area in each of the 10 image frames is obtained.

[0057] After obtaining the position of the specified area in each image frame in the target video, the specified area in each image frame in the target video (i.e., the area where the specified object is located) can be replaced. In this way, the position in each video frame can be tracked according to the position of the specified area in any image frame in the target video, without having to identify each image frame in the target video, which reduces the amount of calculation and improves the processing speed and accuracy. In addition, by verifying the tracking position, the accuracy of the recognition is further guaranteed, so that the position of the specified area in each image frame in the target video can be quickly and accurately identified. Correspondingly, the specified area in each image frame in the target video can also be quickly and accurately replaced. For individual users, the image to be replaced can be selected to replace the specified object (i.e., the specified area) in each image frame, so as to shoot the same video, which can improve the flexibility of image processing and increase the sense of participation. For corporate users, they can only shoot an advertisement once, and then replace the specified object (i.e., the specified area) in the advertisement with different products, so that a series of product advertisements can be obtained, which can reduce the shooting cost and improve the shooting efficiency.

[0058] In summary, the present disclosure first identifies the position of the specified area in the first image frame according to a preset recognition algorithm, and then tracks the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, and then verifies the tracking position, and determines the position of the specified area in the second image frame according to the verification result of the tracking position, and then uses the second image frame as the first image frame, and repeats the above steps until the position of the specified area in each image frame in the target video is obtained. The present disclosure first identifies the position of the specified area in any image frame in the target video through a recognition algorithm, and then tracks other video frames in the target video according to the position to obtain the position of the specified area in other video frames, and can quickly and accurately identify the position of the specified area in each image frame in the target video.

[0059] In an application scenario, the position of the designated area in the first image frame includes the vertex coordinates of the designated area in the first image frame, and the tracking position includes the vertex coordinates of the designated area in the second image frame. Step 102 may be implemented as follows:

[0060] The first image frame, the second image frame and the vertex coordinates of the designated area in the first image frame are used as inputs of the optical flow tracking algorithm to obtain the vertex coordinates of the designated area in the second image frame output by the optical flow tracking algorithm.

[0061] For example, the position of the designated area in the first image frame is used as a reference to track the designated area in the second image frame. The preset optical flow (English: Optical Flow) tracking algorithm can be used to input the vertex coordinates of the first image frame, the second image frame and the designated area in the first image frame into the optical flow tracking algorithm. The output of the optical flow tracking algorithm is the tracking position, and the tracking position can include the vertex coordinates of the designated area in the second image frame. The optical flow tracking algorithm can be, for example, a KLT tracking algorithm (English: Kanade-Lucas-Tomasi Tracking Method) or an LK tracking algorithm (English: Lucas-Kanade Tracking Method), etc., which is not specifically limited in the present disclosure.

[0062] Figure 2 FIG. 1 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment. Figure 2 As shown, step 103 may include the following steps:

[0063] Step 1031 : Track a designated area in the first image frame according to the tracking position to obtain a verified tracking position.

[0064] Step 1032, if the distance difference between the verified tracking position and the position of the specified area in the first image frame is less than or equal to a preset threshold, the verification result is determined to be passed; if the distance difference between the verified tracking position and the position of the specified area in the first image frame is greater than the preset threshold, the verification result is determined to be failed.

[0065] In an application scenario, the tracking position is verified, and the tracking position can be used to track the designated area in the first image frame to obtain the verified tracking position. It can be understood that the tracking position is used to perform reverse tracking, and the verified tracking position is to predict the position of the designated area in the first image frame based on the tracking position. Ideally, the verified tracking position should be the same as the position of the designated area in the first image frame (it can be understood that the vertex coordinates of the designated area in the first image frame coincide with the vertex coordinates indicated by the verified tracking position). Therefore, the verified tracking position can be compared with the position of the designated area in the first image frame. If the distance difference between the verified tracking position and the position of the designated area in the first image frame is less than or equal to a preset threshold (for example, it can be 5 pixel positions), then it can be determined that the verification result is passed, that is, the accuracy of the tracking position is high. If the distance difference between the verified tracking position and the position of the designated area in the first image frame is greater than the preset threshold, then it can be determined that the verification result is not passed, that is, the accuracy of the tracking position is low.

[0066] Figure 3 FIG. 1 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment. Figure 3 As shown, step 103 may also include the following steps:

[0067] Step 1033: If the verification result is passed, the tracking position is used as the position of the designated area in the second image frame.

[0068] Step 1034: If the verification result is not passed, determine the position of the designated area in the second image frame according to the recognition algorithm.

[0069] For example, if the verification result is passed, it means that the accuracy of the tracking position is high, and the tracking position can be directly used as the position of the specified area in the second image frame. If the verification result is not passed, it means that the accuracy of the tracking position is low, and the position of the specified area in the second image frame can be determined according to the above recognition algorithm. For example, the second image frame can be input into the recognition algorithm to obtain the position of the specified area in the second image frame output by the recognition algorithm.

[0070] Figure 4 FIG. 1 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment. Figure 4 As shown, the implementation of step 101 may be:

[0071] Step 1011, obtaining the color coordinates of each pixel of the first image frame in the color space.

[0072] For example, to determine the position of a specified area in the first image frame, the color coordinates of each pixel in the first image frame in the color space can be obtained first. The color space in the embodiment of the present disclosure can be one or more of RGB (Red-Green-Blue) color space, LUV color space, LAB color space, CMY (Cyan-Magenta-Yellow) color space, HSV (Hue-Saturation-Value) color space, and HSI (Hue-Saturation-Intensity) color space, and the present disclosure does not specifically limit this.

[0073] Step 1012, determining an initial region according to the color coordinates of each pixel and a preset color range, the color coordinates of the pixels in the initial region belonging to the color range.

[0074] For example, the color coordinates of each pixel in the first image frame can be judged in turn to determine whether the pixel belongs to a preset color range. The color range can be understood as the color coordinate range corresponding to the specified color in the color space. Taking the specified color as green and the color space as the RGB color space as an example, the color range corresponding to green can be: R (red) channel is less than 120, B (blue) channel is less than 120, and G (green) channel is greater than 150. In this way, the color coordinates of each pixel can be compared with the color range to determine whether the pixel is green. After that, the pixels belonging to the color range can be integrated to obtain an initial area composed of pixels whose color coordinates belong to the color range. In other words, the color coordinates of each pixel included in the initial area belong to the color range. It should be noted that the initial area may include each pixel whose color coordinates belong to the color range in the first image frame, and may also include some pixels whose color coordinates belong to the color range in the first image frame. For example, the pixels belonging to the color range may be marked, and then the marked pixels may be clustered, and the region formed by the pixels contained in the densest cluster obtained by clustering is the initial region. One or more connected regions formed by the marked pixels in the first image frame may also be determined (i.e., the region formed by the marked pixels adjacent to each other in the first image frame), and then the connected region with the largest area may be used as the initial region.

[0075] Step 1013: extract edges of the initial region to obtain at least one initial edge of the initial region.

[0076] Step 1014: polygon fitting is performed on at least one initial edge to obtain a target polygon, and the position of the designated area in the first image frame is determined according to the vertices of the target polygon.

[0077] For example, when the target video is pre-shot, the designated object may be blocked by other objects at certain moments, resulting in the shape of the determined initial area being often irregular, or the shape of the determined initial area being deformed due to different shooting angles. In this way, it may be impossible to accurately locate the position of the designated object in the first image frame, and further to accurately replace the area where the designated object is located in the first image frame (i.e., the designated area). Therefore, after determining the initial area, the initial area may be edge extracted to obtain at least one initial edge of the initial area. For example, the initial area may be used as the input of a preset edge extraction algorithm, and the output of the edge extraction algorithm is at least one initial edge. Among them, the edge extraction algorithm may be a Canny algorithm, a Sobel algorithm, a Laplacian algorithm, etc., and the present disclosure does not specifically limit this. Further, polygon fitting may be performed on at least one initial edge obtained by edge extraction to obtain a target polygon composed of edges with a specified number of edges (e.g., 4, 5, etc.) connected end to end, and finally the target polygon is used as the designated area (the designated area is a closed area), thereby obtaining the position of the designated area in the first image frame, i.e., the vertex of the target polygon. For example, the specified number of sides and at least one initial edge can be used as inputs of a preset polygon fitting algorithm, and the output of the polygon fitting algorithm is a polygon consisting of edges with the specified number of sides connected end to end. The specified number of sides is used to limit the number of sides of the polygon fitted by the polygon fitting algorithm. For example, if the specified number of sides is 4, the polygon fitting algorithm can fit a quadrilateral. Through the above steps, the position of the specified area in the first image frame can be quickly and accurately identified.

[0078] It should be noted that the initial area in the above embodiment may be one or more, and correspondingly, the designated area may also be one or more. For example, when pre-shooting the target video, the shooting scene may include one or more designated objects set to a designated color, and the corresponding first image frame may include one or more designated objects. When the first image frame includes one designated object, the initial area and the designated area are one, and when the first image frame includes N (N is a positive integer greater than 1) designated objects, the initial area and the designated area are N.

[0079] Further, step 1012 can be implemented by the following steps:

[0080] Step 1) taking a pixel whose first color coordinates belong to a preset first color range as a first pixel.

[0081] Step 2) The first pixel point whose second color coordinates belong to the preset second color range is used as the second pixel point.

[0082] Step 3) Determine the initial area based on the second pixel point.

[0083] In an application scenario, in order to more accurately extract the pixel points of the specified color in the first image frame, the color coordinates of each pixel point in the first image frame in multiple color spaces can be obtained, and the initial area can be determined according to the color range corresponding to each color space. Taking two color spaces as an example, the first color coordinates of each pixel point in the first image frame in the first color space and the second color coordinates in the second color space can be obtained. Correspondingly, the preset color range can include the color coordinate ranges corresponding to the specified color in the two color spaces, that is, the first color space corresponds to the first color range, and the second color space corresponds to the second color range. Then, in the first color space, it can be first determined in turn whether the first color coordinate of each pixel point belongs to the first color range, and the pixel points belonging to the first color range are marked as first pixels. Then, in the second color space, it is determined in turn whether the second color coordinate of each first pixel point belongs to the second color range, and the first pixel point belonging to the second color range is marked as a second pixel point. That is to say, the first color coordinate of the second pixel point belongs to the first color range, and the second color coordinate of the second pixel point belongs to the second color range, that is, the set composed of the second pixel points is a subset of the set composed of the first pixel points. Finally, the initial area is determined according to the second pixel point. Taking the specified color as green, the first color space as RGB color space, and the second color space as HSV color space as an example, the first color range can be: R (red) channel is less than 120, B (blue) channel is less than 120, G (green) channel is greater than 150, and the second color range can be: H (hue) channel is greater than 35 and less than 77. Then the second pixel point is a pixel point in the first image frame, whose first color coordinate in the RGB color space belongs to the first color range, and whose second color coordinate in the HSV color space belongs to the second color range.

[0084] Furthermore, in step 1034, the position of the designated area in the second image frame is determined according to the recognition algorithm, which is the same as the processing method for determining the position of the designated area in the first image frame, and will not be repeated here.

[0085] Figure 5 FIG. 1 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment. Figure 5 As shown, the method may also include:

[0086] Step 105 , obtaining an adjustment instruction for the third image frame in the target video, where the adjustment instruction includes the position of a designated area in the third image frame indicated by the user.

[0087] In an application scenario, after obtaining the position of a specified area in each image frame in the target video, or in the process of determining the position of a specified area in each image frame, the user can adjust any image frame in the target video. Taking the image frame that the user needs to adjust as the third image frame as an example, the user can browse the target video on the terminal device, select the third image frame by dragging the scroll bar used to display the playback progress of the target video, and then manually mark the position of the specified area in the third image frame (for example, the vertex coordinates of the specified area can be marked, or the edge of the specified area can be marked, etc.) to trigger an adjustment instruction, which includes the position of the specified area in the third image frame marked by the user. Among them, the third image frame can be one image frame or multiple image frames.

[0088] Step 106, tracking the designated area in the fourth image frame according to the position of the designated area in the third image frame to update the position of the designated area in the fourth image frame, the fourth image frame being an image frame in the target video adjacent to the third image frame.

[0089] Step 107: Update the third image frame to a fourth image frame.

[0090] Steps 106 to 107 are repeatedly performed until the position of the designated area in each image frame in the target video is updated.

[0091] Afterwards, the position of the designated area in the third image frame is used as a reference to track the designated area in the fourth image frame, thereby updating the position of the designated area in the fourth image frame, that is, the result of the tracking can be used as the position of the designated area in the fourth image frame. For example, the position of the designated area in the third image frame can be used as the input of the optical flow tracking algorithm, and the result output by the optical flow tracking algorithm can be used as the position of the designated area in the fourth image frame. The position of the designated area in the third image frame can also be used as the input of the feature point tracking algorithm, and the result output by the feature point tracking algorithm can be used as the position of the designated area in the fourth image frame. The position of the designated area in the third image frame can also be used as a pre-trained feature point tracking model, and the result output by the feature point tracking model can be used as the position of the designated area in the fourth image frame. The feature point tracking model can be a neural network such as RNN, CNN, LSTM, etc., and the present disclosure does not make specific limitations on this. Among them, the fourth image frame is an image frame in the target video that is adjacent to the third image frame, that is, the fourth image frame and the third image frame are continuous in time. Taking the third image frame as an example, the fourth image frame can be the previous image frame of the third image frame, or the next image frame of the third image frame, or the previous image frame and the next image frame of the third image frame (in this case, there are two fourth image frames).

[0092] Further, the third image frame is updated to the fourth image frame, and steps 106 to 107 are repeated until the position of the designated area in each image frame in the target video is updated. In other words, the position of the designated area in each image frame in the target video is updated according to the position of the designated area in the third image frame indicated by the user.

[0093] Figure 6 FIG. 1 is a flowchart of another method for tracking a specified area in a video according to an exemplary embodiment. Figure 6 As shown, there are multiple third image frames. Before step 106, the method may further include:

[0094] Step 108 : determining an adjustment frame range and an adjustment direction corresponding to each third image frame according to the sequence of the plurality of third image frames in the target video.

[0095] For example, after obtaining the adjustment instruction, if it is determined that there are multiple third image frames, then the adjustment frame range and adjustment direction corresponding to each third image frame can be determined according to the order of the multiple third image frames in the target video. Adjusting the frame range can be understood as updating the positions of the specified areas in the image frames in the target video according to the positions of the specified areas in the third image frame. The adjustment direction can be understood as being the same as the time sequence in the target video, or being opposite to the time sequence in the target video.

[0096] Take the case where the target video includes N image frames arranged in chronological order: Image Frame 1, Image Frame 2, …, Image Frame m, …, Image Frame n, …, Image Frame N as an example for specific illustration (m < n). Among them, the third image frame is Image Frame m and Image Frame n. Then, the adjustment frame range corresponding to Image Frame m is: from Image Frame 1 to Image Frame (m + n) / 2, and the adjustment direction is from Image Frame m to Image Frame 1 (opposite to the chronological order), and from Image Frame m to Image Frame (m + n) / 2 (the same as the chronological order). The adjustment frame range corresponding to Image Frame n is: from Image Frame [1 + (m + n) / 2] to Image Frame N, and the adjustment direction is from Image Frame n to Image Frame [1 + (m + n) / 2] (opposite to the chronological order), and from Image Frame n to Image Frame N (the same as the chronological order). The adjustment frame ranges and adjustment directions of Image Frame m and Image Frame n are as Figure 7 shown.

[0097] Correspondingly, step 106 may include:

[0098] Step 1061, determine the fourth image frame corresponding to the third image frame according to the adjustment frame range and adjustment direction. The fourth image frame corresponding to the third image frame belongs to the adjustment frame range and is adjacent to the third image frame in the adjustment direction.

[0099] Step 1062, track the specified area in the fourth image frame corresponding to the third image frame according to the position of the specified area in the third image frame, so as to obtain the position of the specified area in the fourth image frame corresponding to the third image frame.

[0100] Exemplarily, after determining the adjustment frame range and adjustment direction corresponding to each third image frame, the fourth image frame corresponding to the third image frame may be determined according to the adjustment frame range and adjustment direction corresponding to the third image frame. Among them, the fourth image frame belongs to the adjustment frame range corresponding to the third image frame, and the fourth image frame is adjacent to the third image frame in the adjustment direction corresponding to the third image frame. Taking the Image Frame m shown in Figure 7 as an example, then the fourth image frames are Image Frame m - 1 and Image Frame m + 1. Then, track the specified area in the fourth image frame corresponding to the third image frame according to the position of the specified area in the third image frame, so as to obtain the position of the specified area in the fourth image frame corresponding to the third image frame.

[0101] In summary, the present disclosure first identifies the position of the specified area in the first image frame according to a preset recognition algorithm, and then tracks the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, and then verifies the tracking position, and determines the position of the specified area in the second image frame according to the verification result of the tracking position, and then uses the second image frame as the first image frame, and repeats the above steps until the position of the specified area in each image frame in the target video is obtained. The present disclosure first identifies the position of the specified area in any image frame in the target video through a recognition algorithm, and then tracks other video frames in the target video according to the position to obtain the position of the specified area in other video frames, and can quickly and accurately identify the position of the specified area in each image frame in the target video.

[0102] Figure 8 is a block diagram of a device for tracking a specified area in a video according to an exemplary embodiment. Figure 8 As shown, the device 200 includes:

[0103] The recognition module 201 is used to determine the position of a specified area in a first image frame according to a preset recognition algorithm, where the first image frame is any image frame in a target video.

[0104] The tracking module 202 is used to track the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position. The second image frame is an image frame in the target video adjacent to the first image frame.

[0105] The verification module 203 is used to verify the tracking position according to the position of the designated area in the first image frame and the tracking position, and determine the position of the designated area in the second image frame according to the verification result of the tracking position.

[0106] The updating module 204 is configured to update the first image frame to a second image frame.

[0107] Repeat the steps of tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position, and updating the first image frame to the second image frame, until the position of the designated area in each image frame in the target video is obtained.

[0108] In an application scenario, the position of the designated area in the first image frame includes the vertex coordinates of the designated area in the first image frame, and the tracking position includes the vertex coordinates of the designated area in the second image frame. The tracking module 202 can be used to: use the first image frame, the second image frame, and the vertex coordinates of the designated area in the first image frame as inputs of the optical flow tracking algorithm to obtain the vertex coordinates of the designated area in the second image frame output by the optical flow tracking algorithm.

[0109] Fig. 9 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment. Fig. 9 As shown, the verification module 203 may include:

[0110] The tracking submodule 2031 is used to track a designated area in the first image frame according to the tracking position to obtain a verified tracking position.

[0111] The verification submodule 2032 is used to determine that the verification result is passed if the distance difference between the verification tracking position and the position of the specified area in the first image frame is less than or equal to a preset threshold, and to determine that the verification result is failed if the distance difference between the verification tracking position and the position of the specified area in the first image frame is greater than the preset threshold.

[0112] In one application scenario, the verification module 203 may also be used to:

[0113] If the verification result is passed, the tracking position is used as the position of the designated area in the second image frame. If the verification result is not passed, the position of the designated area in the second image frame is determined according to the recognition algorithm.

[0114] Fig.10 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment. Fig.10 As shown, the identification module 201 may include:

[0115] The acquisition submodule 2011 is used to acquire the color coordinates of each pixel point of the first image frame in the color space.

[0116] The determination submodule 2012 is used to determine the initial area according to the color coordinates of each pixel and the preset color range, and the color coordinates of the pixels in the initial area belong to the color range.

[0117] The extraction submodule 2013 is used to extract the edge of the initial area to obtain at least one initial edge of the initial area.

[0118] The fitting submodule 2014 is used to perform polygon fitting on at least one initial edge to obtain a target polygon, and determine the position of the designated area in the first image frame according to the vertices of the target polygon.

[0119] Fig.11 is a block diagram of another device for tracking a designated area in a video according to an exemplary embodiment. Fig.11 As shown, the device 200 may also include:

[0120] The acquisition module 205 is used to acquire an adjustment instruction for the third image frame in the target video, where the adjustment instruction includes the position of a designated area in the third image frame indicated by the user.

[0121] The tracking module 202 is also used to track the specified area in the fourth image frame according to the position of the specified area in the third image frame to update the position of the specified area in the fourth image frame. The fourth image frame is an image frame in the target video that is adjacent to the third image frame.

[0122] The updating module 204 is further configured to update the third image frame to a fourth image frame.

[0123] Repeat the step of tracking the designated area in the fourth image frame according to the position of the designated area in the third image frame to update the position of the designated area in the fourth image frame, until the step of updating the third image frame to the fourth image frame is repeated, until the position of the designated area in each image frame in the target video is updated.

[0124] In an application scenario, there are multiple third image frames, and the acquisition module 205 is further used to:

[0125] According to the order of the plurality of third image frames in the target video, an adjustment frame range and an adjustment direction corresponding to each third image frame are determined.

[0126] Accordingly, the tracking module 202 can be used to:

[0127] The fourth image frame corresponding to the third image frame is determined according to the adjustment frame range and the adjustment direction. The fourth image frame corresponding to the third image frame belongs to the adjustment frame range and is adjacent to the third image frame in the adjustment direction.

[0128] According to the position of the designated area in the third image frame, the designated area in the fourth image frame corresponding to the third image frame is tracked to obtain the position of the designated area in the fourth image frame corresponding to the third image frame.

[0129] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0130] In summary, the present disclosure first identifies the position of the specified area in the first image frame according to a preset recognition algorithm, and then tracks the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, and then verifies the tracking position, and determines the position of the specified area in the second image frame according to the verification result of the tracking position, and then uses the second image frame as the first image frame, and repeats the above steps until the position of the specified area in each image frame in the target video is obtained. The present disclosure first identifies the position of the specified area in any image frame in the target video through a recognition algorithm, and then tracks other video frames in the target video according to the position to obtain the position of the specified area in other video frames, and can quickly and accurately identify the position of the specified area in each image frame in the target video.

[0131] Reference below Fig.12 , which shows a schematic diagram of the structure of an electronic device (i.e., the execution subject of the tracking method of the specified area in the above video) 300 suitable for implementing the embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may be a server, which may be, for example, a local server or a cloud server. The electronic device may also be a terminal device, which may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.12 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0132] like Fig.12 As shown, the electronic device 300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0133] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication devices 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.12 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0134] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0135] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0136] In some embodiments, the terminal devices and servers may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0137] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0138] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: determines the position of a specified area in a first image frame according to a preset recognition algorithm, wherein the first image frame is any image frame in a target video; tracks a specified area in a second image frame according to the position of the specified area in the first image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video that is adjacent to the first image frame; verifies the tracking position according to the position of the specified area in the first image frame and the tracking position, and determines the position of the specified area in the second image frame according to the verification result of the tracking position; updates the first image frame to the second image frame; and repeatedly performs the step of tracking the specified area in the second image frame according to the position of the specified area in the first image frame to obtain a tracking position, until the step of updating the first image frame to the second image frame is performed, until the position of the specified area in each image frame in the target video is obtained.

[0139] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0140] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0141] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the recognition module may also be described as a "module for identifying the position of a specified area in a first image frame".

[0142] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0143] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0144] According to one or more embodiments of the present disclosure, Example 1 provides a method for tracking a specified area in a video, comprising: determining the position of a specified area in a first image frame according to a preset recognition algorithm, wherein the first image frame is any image frame in a target video; tracking the specified area in a second image frame according to the position of the specified area in the first image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video that is adjacent to the first image frame; verifying the tracking position according to the position of the specified area in the first image frame and the tracking position, and determining the position of the specified area in the second image frame according to the verification result of the tracking position; updating the first image frame to the second image frame; repeatedly performing the step of tracking the specified area in the second image frame according to the position of the specified area in the first image frame to obtain a tracking position, until the step of updating the first image frame to the second image frame, until the position of the specified area in each image frame in the target video is obtained.

[0145] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the position of the specified area in the first image frame includes the vertex coordinates of the specified area in the first image frame, and the tracking position includes the vertex coordinates of the specified area in the second image frame; tracking the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position includes: using the first image frame, the second image frame and the vertex coordinates of the specified area in the first image frame as input to an optical flow tracking algorithm to obtain the vertex coordinates of the specified area in the second image frame output by the optical flow tracking algorithm.

[0146] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 1, which verifies the tracking position based on the position of the specified area in the first image frame and the tracking position, including: tracking the specified area in the first image frame based on the tracking position to obtain the verified tracking position; if the distance difference between the verified tracking position and the position of the specified area in the first image frame is less than or equal to a preset threshold, determining that the verification result is passed; if the distance difference between the verified tracking position and the position of the specified area in the first image frame is greater than the preset threshold, determining that the verification result is failed.

[0147] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, which determines the position of the specified area in the second image frame based on the verification result of the tracking position, including: if the verification result is passed, using the tracking position as the position of the specified area in the second image frame; if the verification result is failed, determining the position of the specified area in the second image frame according to the recognition algorithm.

[0148] According to one or more embodiments of the present disclosure, Example 5 provides the method of Examples 1 to 4, which determines the position of a specified area in a first image frame according to a preset recognition algorithm, including: obtaining the color coordinates of each pixel of the first image frame in a color space; determining an initial area based on the color coordinates of each pixel and a preset color range, wherein the color coordinates of the pixel within the initial area belong to the color range; performing edge extraction on the initial area to obtain at least one initial edge of the initial area; performing polygon fitting on the at least one initial edge to obtain a target polygon, and determining the position of the specified area in the first image frame based on the vertices of the target polygon.

[0149] According to one or more embodiments of the present disclosure, Example 6 provides the method of Examples 1 to 4, which further includes: obtaining an adjustment instruction for a third image frame in the target video, the adjustment instruction including a position of a specified area in the third image frame indicated by a user; tracking a specified area in a fourth image frame according to the position of the specified area in the third image frame to update the position of the specified area in the fourth image frame, the fourth image frame being an image frame in the target video adjacent to the third image frame; updating the third image frame to the fourth image frame; repeating the step of tracking a specified area in the fourth image frame according to the position of the specified area in the third image frame to update the position of the specified area in the fourth image frame, to the step of updating the third image frame to the fourth image frame, until the position of the specified area in each image frame in the target video is updated.

[0150] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein there are multiple third image frames, and before tracking the specified area in the fourth image frame according to the position of the specified area in the third image frame to update the position of the specified area in the fourth image frame, the method also includes: determining the adjustment frame range and adjustment direction corresponding to each of the third image frames according to the order of the multiple third image frames in the target video; tracking the specified area in the fourth image frame according to the position of the specified area in the third image frame to obtain the position of the specified area in the fourth image frame, including: determining the fourth image frame corresponding to the third image frame according to the adjustment frame range and the adjustment direction, the fourth image frame corresponding to the third image frame belongs to the adjustment frame range and is adjacent to the third image frame in the adjustment direction; tracking the specified area in the fourth image frame corresponding to the third image frame according to the position of the specified area in the third image frame to obtain the position of the specified area in the fourth image frame corresponding to the third image frame.

[0151] According to one or more embodiments of the present disclosure, Example 8 provides a tracking device for a specified area in a video, comprising: an identification module, used to determine the position of a specified area in a first image frame according to a preset identification algorithm, wherein the first image frame is any image frame in a target video; a tracking module, used to track a specified area in a second image frame according to the position of the specified area in the first image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame; a verification module, used to verify the tracking position according to the position of the specified area in the first image frame and the tracking position, and determine the position of the specified area in the second image frame according to the verification result of the tracking position; an updating module, used to update the first image frame to the second image frame; repeatedly performing the step of tracking the specified area in the second image frame according to the position of the specified area in the first image frame to obtain the tracking position, until the step of updating the first image frame to the second image frame, until the position of the specified area in each image frame in the target video is obtained.

[0152] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of the methods described in Examples 1 to 7 when executed by a processing device.

[0153] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of the method described in Examples 1 to 7.

[0154] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0155] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0156] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A method for tracking a specified area in a video, characterized in that: The method comprises: According to a preset recognition algorithm, determine the position of a specified area in a first image frame, where the first image frame is any image frame in a target video, and the specified area is an area where a specified object is located in the target video; According to the position of the designated area in the first image frame, the designated area in the second image frame is tracked to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame; Verifying the tracking position according to the position of the designated area in the first image frame and the tracking position, and determining the position of the designated area in the second image frame according to the verification result of the tracking position; Updating the first image frame to the second image frame; Repeat the step of tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position, to the step of updating the first image frame to the second image frame, until the position of the designated area in each image frame in the target video is obtained; Determining the position of the designated area in the first image frame according to a preset recognition algorithm includes: Acquire color coordinates of the first image frame in a color space; Determine an initial area according to the color coordinates and a preset color range, wherein the color range is a color coordinate range corresponding to a specified color in a color space; Performing edge extraction on the initial region to obtain at least one initial edge of the initial region; Determine the position of the designated area in the first image frame based on the target polygon obtained from the initial edge; The obtaining of color coordinates of the first image frame in a color space includes: Obtaining a first color coordinate of each pixel in the first image frame in a first color space, and obtaining a second color coordinate of each pixel in a second color space; Determining the initial area according to the color coordinates and a preset color range includes: Taking a pixel point whose first color coordinate belongs to a preset first color range as a first pixel point; The first pixel point whose second color coordinates belong to a preset second color range is used as the second pixel point; Determine the initial area according to the second pixel point; The determining the position of the designated area in the first image frame based on the target polygon obtained from the initial edge includes: Polygon fitting is performed on at least one initial edge to obtain a target polygon, and a position of a designated area in the first image frame is determined according to vertices of the target polygon.

2. The method according to claim 1, characterized in that: The position of the designated area in the first image frame includes the vertex coordinates of the designated area in the first image frame, and the tracking position includes the vertex coordinates of the designated area in the second image frame; Tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position includes: The first image frame, the second image frame and the vertex coordinates of the specified area in the first image frame are used as inputs of an optical flow tracking algorithm to obtain the vertex coordinates of the specified area in the second image frame output by the optical flow tracking algorithm.

3. The method according to claim 1, characterized in that The verifying the tracking position according to the position of the designated area in the first image frame and the tracking position comprises: According to the tracking position, tracking a designated area in the first image frame to obtain a verified tracking position; If the distance difference between the verification tracking position and the position of the specified area in the first image frame is less than or equal to a preset threshold, the verification result is determined to be passed; if the distance difference between the verification tracking position and the position of the specified area in the first image frame is greater than the preset threshold, the verification result is determined to be failed.

4. The method according to claim 3, characterized in that Determining the position of the designated area in the second image frame according to the verification result of the tracking position includes: If the verification result is passed, taking the tracking position as the position of the designated area in the second image frame; If the verification result is failed, the position of the designated area in the second image frame is determined according to the recognition algorithm.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Acquire an adjustment instruction for a third image frame in the target video, wherein the adjustment instruction includes a position of a designated area in the third image frame indicated by a user; Tracking the designated area in a fourth image frame according to the position of the designated area in the third image frame to update the position of the designated area in the fourth image frame, wherein the fourth image frame is an image frame in the target video that is adjacent to the third image frame; Updating the third image frame to the fourth image frame; Repeat the step of tracking the designated area in the fourth image frame according to the position of the designated area in the third image frame to update the position of the designated area in the fourth image frame, until the step of updating the third image frame to the fourth image frame, until the position of the designated area in each image frame in the target video is updated.

6. The method according to claim 5, characterized in that There are multiple third image frames. Before tracking the designated area in the fourth image frame according to the position of the designated area in the third image frame to update the position of the designated area in the fourth image frame, the method further includes: Determining an adjustment frame range and an adjustment direction corresponding to each of the third image frames according to an order of the plurality of third image frames in the target video; Tracking the designated area in the fourth image frame according to the position of the designated area in the third image frame to obtain the position of the designated area in the fourth image frame includes: Determine, according to the adjustment frame range and the adjustment direction, the fourth image frame corresponding to the third image frame, wherein the fourth image frame corresponding to the third image frame belongs to the adjustment frame range and is adjacent to the third image frame in the adjustment direction; According to the position of the designated area in the third image frame, the designated area in the fourth image frame corresponding to the third image frame is tracked to obtain the position of the designated area in the fourth image frame corresponding to the third image frame.

7. A tracking device for a specified area in a video, characterized in that: The device comprises: A recognition module, used to determine the position of a specified area in a first image frame according to a preset recognition algorithm, wherein the first image frame is any image frame in a target video; A tracking module, configured to track a designated area in a second image frame according to a position of the designated area in the first image frame to obtain a tracking position, wherein the second image frame is an image frame in the target video adjacent to the first image frame; a verification module, configured to verify the tracking position according to the position of the designated area in the first image frame and the tracking position, and determine the position of the designated area in the second image frame according to the verification result of the tracking position; An updating module, used for updating the first image frame to the second image frame; Repeat the step of tracking the designated area in the second image frame according to the position of the designated area in the first image frame to obtain the tracking position, to the step of updating the first image frame to the second image frame, until the position of the designated area in each image frame in the target video is obtained; The identification module includes: An acquisition submodule, used to acquire the color coordinates of the first image frame in the color space; A determination submodule, configured to determine an initial area according to the color coordinates and a preset color range, wherein the color range is a color coordinate range corresponding to a specified color in a color space; An extraction submodule, configured to perform edge extraction on the initial region to obtain at least one initial edge of the initial region; A fitting submodule, configured to determine a position of a designated area in the first image frame based on a target polygon obtained from the initial edge; The acquisition submodule is used to acquire the first color coordinates of each pixel in the first image frame in the first color space, and acquire the second color coordinates of each pixel in the second color space; The determination submodule is used to take a pixel point whose first color coordinate belongs to a preset first color range as a first pixel point; take the first pixel point whose second color coordinate belongs to a preset second color range as a second pixel point; and determine the initial area according to the second pixel point; The fitting submodule is used to perform polygon fitting on at least one initial edge to obtain a target polygon, and determine the position of the designated area in the first image frame according to the vertices of the target polygon.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.