Target tracking method, apparatus, device and medium
View Patent ↗The present disclosure relates to a target tracking method, apparatus, device and a medium. The target tracking method includes: acquiring a target video, where the target video includes a first image frame and a first subsequent image frame sequence after and adjacent to the first image frame; performing polygon detection on the first image frame to obtain each vertex of a target polygon; and tracking each vertex of the target polygon in the first subsequent image frame sequence according to a first vertex position of each vertex of the target polygon in the first image frame. According to embodiments of the present disclosure, real-time performance and accuracy of tracking the target polygon can be improved.
1 . A target tracking method, applied to a target tracking apparatus, comprising:
acquiring a target video, wherein the target video comprises a first image frame and a first subsequent image frame sequence after and adjacent to the first image frame;
performing polygon detection on the first image frame to obtain each vertex of a target polygon;
tracking each vertex of the target polygon in the first subsequent image frame sequence according to a first vertex position of each vertex of the target polygon in the first image frame, to determine a position of a tracking target corresponding to the target polygon in the first subsequent image frame sequence; and
in a case of determining that the target polygon has an untracked vertex in a second image frame of the first subsequent image frame sequence, relocating the untracked vertex according to a second vertex position of a tracked vertex of the target polygon in the second image frame in the second image frame and a third vertex position of each vertex of the target polygon in a previous image frame of the second image frame to obtain a relocated vertex position of the untracked vertex in the second image frame.
2 . The method according to claim 1 , wherein the determining that the target polygon has the untracked vertex in the second image frame of the first subsequent image frame sequence comprises:
in a case that the target polygon has a vertex that is failed to be tracked in the second image frame or the target polygon has a vertex that has been moved out of the second image frame in the second image frame, determining that the target polygon has the untracked vertex in the second image frame.
3 . The method according to claim 1 , wherein the determining that the target polygon has the untracked vertex in the second image frame of the first subsequent image frame sequence comprises:
upon detecting that a number of the tracked vertex is less than the total number of vertices of the target polygon, determining that the target polygon has the untracked vertex in the second image frame.
4 . The method according to claim 1 , wherein the relocating the untracked vertex according to the second vertex position of the tracked vertex of the target polygon in the second image frame in the second image frame and the third vertex position of each vertex of the target polygon in the previous image frame of the second image frame to obtain the relocated vertex position of the untracked vertex in the second image frame comprises:
calculating a target homography matrix according to the second vertex position and the third vertex position; and
performing homography transformation on a vertex position of the untracked vertex in the previous image frame of the second image frame by using the target homography matrix, to obtain the relocated vertex position.
5 . The method according to claim 4 , further comprising:
performing feature point detection on the target polygon to obtain each feature point of the target polygon; and
tracking each feature point of the target polygon in the first subsequent image frame sequence according to a first feature point position of each feature point of the target polygon in the first image frame;
wherein the calculating the target homography matrix according to the second vertex position and the third vertex position comprises:
in a case that the number of the tracked vertex is greater than or equal to a preset number threshold, calculating the target homography matrix according to the second vertex position and the third vertex position; and
in a case that the number of the tracked vertex is less than the preset number threshold, calculating the target homography matrix according to the second vertex position, the third vertex position, a second feature point position of a tracked feature point of the target polygon in the second image frame in the second image frame and a third feature point position of each feature point of the target polygon in the previous image frame of the second image frame.
6 . The method according to claim 1 , further comprising:
in a case of determining that the target polygon is not tracked in a third image frame of the first subsequent image frame sequence, performing target detection for the target polygon on a second subsequent image frame sequence after and adjacent to the third image frame to determine a fourth image frame in which the target polygon first appears; and
acquiring a fourth vertex position of each vertex of the target polygon in the fourth image frame.
7 . The method according to claim 6 , wherein the determining that the target polygon is not tracked in the third image frame of the first subsequent image frame sequence comprises:
upon detecting that each vertex of the target polygon is not tracked in the third image frame, determining that the target polygon is not tracked in the third image frame.
8 . The method according to claim 6 , wherein the performing the target detection for the target polygon on the second subsequent image frame sequence after and adjacent to the third image frame to determine the fourth image frame in which the target polygon first appears comprises:
performing polygon detection in the second subsequent image frame sequence to determine a fifth image frame in which a polygon to be matched first appears, wherein a shape of the polygon to be matched and a shape of the target polygon are identical;
calculating a similarity between the polygon to be matched and the target polygon; and
in a case that the similarity is greater than or equal to a preset threshold, determining the fifth image frame as the fourth image frame.
9 . The method according to claim 8 , wherein after the performing the polygon detection on the first image frame to obtain each vertex of the target polygon, the method further comprises:
acquiring an initial image of the target polygon in the first image frame;
wherein the calculating the similarity between the polygon to be matched and the target polygon comprises:
acquiring an image to be matched of the polygon to be matched in the fifth image frame; and
performing similarity calculation on the initial image and the image to be matched to obtain the similarity.
10 . The method according to claim 8 , wherein the acquiring the fourth vertex position of each vertex of the target polygon in the fourth image comprises:
in a case that there are at least two polygons to be matched in the fourth image frame whose similarity with the target polygon is greater than or equal to the preset threshold, determining a position of each vertex of a polygon to be matched with the largest size in the at least two polygons to be matched in the fourth image frame as the fourth vertex position.
11 . The method according to claim 1 , wherein the first image frame comprises an image frame in which the target polygon first appears in the target video.
12 . The method according to claim 1 , wherein the tracking each vertex of the target polygon in the first subsequent image frame sequence according to the first vertex position of each vertex of the target polygon in the first image comprises:
tracking each vertex of the target polygon in the first subsequent image frame sequence according to the first vertex position based on an optical flow algorithm.
13 . The method according to claim 12 , further comprising:
performing feature point detection on the target polygon to obtain each feature point of the target polygon; and
tracking each feature point of the target polygon in the first subsequent image frame sequence according to a first feature point position of each feature point of the target polygon in the first image frame based on the optical flow algorithm.
14 . A target tracking apparatus, comprising:
a processor; and
memory, configured to store executable instructions;
wherein the processor is configured to read the executable instructions from the memory and execute the executable instructions to:
acquire a target video, wherein the target video comprises a first image frame and a first subsequent image frame sequence after and adjacent to the first image frame;
perform polygon detection on the first image frame to obtain each vertex of a target polygon;
track each vertex of the target polygon in the first subsequent image frame sequence according to a first vertex position of each vertex of the target polygon in the first image frame, to determine a position of a tracking target corresponding to the target polygon in the first subsequent image frame sequence; and
in a case of determining that the target polygon has an untracked vertex in a second image frame of the first subsequent image frame sequence, relocate the untracked vertex according to a second vertex position of a tracked vertex of the target polygon in the second image frame in the second image frame and a third vertex position of each vertex of the target polygon in a previous image frame of the second image frame to obtain a relocated vertex position of the untracked vertex in the second image frame.
15 . A non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when a processor executes the computer program, the processor is caused to:
acquire a target video, wherein the target video comprises a first image frame and a first subsequent image frame sequence after and adjacent to the first image frame;
perform polygon detection on the first image frame to obtain each vertex of a target polygon;
track each vertex of the target polygon in the first subsequent image frame sequence according to a first vertex position of each vertex of the target polygon in the first image frame, to determine a position of a tracking target corresponding to the target polygon in the first subsequent image frame sequence; and
in a case of determining that the target polygon has an untracked vertex in a second image frame of the first subsequent image frame sequence, relocate the untracked vertex according to a second vertex position of a tracked vertex of the target polygon in the second image frame in the second image frame and a third vertex position of each vertex of the target polygon in a previous image frame of the second image frame to obtain a relocated vertex position of the untracked vertex in the second image frame.
16 . The target tracking apparatus according to claim 14 , wherein the processor is further configured to:
in a case that the target polygon has a vertex that is failed to be tracked in the second image frame or the target polygon has a vertex that has been moved out of the second image frame in the second image frame, determine that the target polygon has the untracked vertex in the second image frame.
17 . The target tracking apparatus according to claim 14 , wherein the processor is further configured to:
upon detecting that a number of the tracked vertex is less than the total number of vertices of the target polygon, determine that the target polygon has the untracked vertex in the second image frame.
18 . The target tracking apparatus according to claim 14 , wherein the processor is further configured to:
calculate a target homography matrix according to the second vertex position and the third vertex position; and
perform homography transformation on a vertex position of the untracked vertex in the previous image frame of the second image frame by using the target homography matrix, to obtain the relocated vertex position.