The present invention relates to the field of panoramic camera, and particularly relates to a method for tracking target in panoramic video, and a panoramic camera.
Target tracking is a popular problem in computer vision research, which refers to, tracking and positioning objects by computers, cameras, etc. using a certain algorithm, and adopting corresponding strategies according to the position and movement of the target. In recent years, target tracking has been widely used in various fields such as video surveillance, video coding, and military engineering. The existing panoramic camera can capture 360-degree video around it, and there are also some technical solutions used for tracking target in the panoramic video, for example, the application Pub. No. CN107315992A discloses “a tracking method and device based on an electronic pan-tilt-zoom”. However, this method is based on tracking feature points, and cannot track some scenes where the texture area has single color and the feature points are not abundant.
The object of the present invention is to provide a method for tracking target in panoramic video, a computer readable storage medium and a panoramic camera, which aims to solve the problem that the existing panoramic camera cannot track some scenes where the texture area has single color and the feature points are not abundant.
According to a first aspect, the present invention provides a method for tracking target in panoramic video, comprising steps of:
S201, initializing a position and scale of a tracked target in a spherical coordinate system, calculating an electronic pan-tilt-zoom parameter, and mapping a panoramic image to a current electronic pan-tilt-zoom perspective image;
S202, on the basis of a multi-scale correlation filter, performing target tracking on the current electronic pan-tilt-zoom perspective image, and obtaining a new position and scale of the tracked target;
S203, mapping the new position of the tracked target back to the panoramic spherical coordinate system; and
S204, calculating an electronic pan-tilt-zoom parameter on the basis of the position and scale in the panoramic spherical coordinate system, mapping the same to the current electronic pan-tilt-zoom perspective image, and obtaining a new video frame; then returning to S201 until the panoramic video ends.
According to a second aspect, the present invention provides a computer-readable medium that stores one or more computer programs, one or more processors execute the one or more computer programs to perform the above-mentioned steps of the method for tracking target in panoramic video.
According to a third aspect, the present invention provides a panoramic camera, comprising:
one or more processors;
a memory; and
one or more computer programs; wherein the one or more computer programs are stored in the memory and are configured to be executed by the one or more processors, it is characterized that when the one or more processors execute the one or more computer programs, can perform the above-mentioned steps of the method for tracking target in panoramic video.
In the present invention, the method tracks a target in a panoramic video on the basis of a multi-scale correlation filter, can provide more robust tracking, greater range of application in different tracking scenarios, and faster processing speed; in addition, due to the automatic electronic pan-tilt-zoom technology, the tracking target can always be in the center of the screen.
The foregoing objects, technical solutions and advantages of the invention will be much clearer from the following detail description taken with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
In order to explain the technical solutions of the present invention, the following will be described by specific embodiments.
Referring to
S201, initializing a position and scale of a tracked target in a spherical coordinate system, calculating an electronic pan-tilt-zoom parameter, and mapping a panoramic image to a current electronic pan-tilt-zoom perspective image, that is, the current partial perspective view;
S202, on the basis of a multi-scale correlation filter, performing target tracking on the current electronic pan-tilt-zoom perspective image, and obtaining a new position and scale of the tracked target;
S203, mapping the new position of the tracked target back to the panoramic spherical coordinate system;
S204, calculating an electronic pan-tilt-zoom parameter on the basis of the position and scale in the panoramic spherical coordinate system, mapping the same to the current electronic pan-tilt-zoom perspective image, and obtaining a new video frame; then returning to S201 until the panoramic video ends.
In the first embodiment of the present invention, after the step of obtaining a new video frame, the method may further comprise the following step of:
S205, performing smoothing on a coordinate point at the center of the video frame by means of a Kalman filter, so as to make the output panoramic video more stable.
In the first embodiment of the present invention, S201 can specifically comprise the following steps of:
S2011, initializing a position and scale of the tracking target in a spherical coordinate system.
S2012, rotating a virtual camera to a viewing angle of the tracking target through the electronic pan-tilt-zoom (ePTZ), adjusting the focal length of the virtual camera, and obtaining an initial ePTZ parameter
which makes the virtual camera center aligned with the initialized position of the tracking target, where {tilde over (θ)}0 is used to control a up-down tilt of the virtual camera, {tilde over (φ)}0 is used to control a left and right movement of the virtual camera, and {tilde over (f)}0 is used to control zoom of the virtual camera.
Electronic pan-tilt-zoom technology refers to a technology that controls the view and zoom of the lens inside the camera through program settings. The electronic pan-tilt-zoom technology can simulate a PTZ camera to realize the camera's left and right movement, up and down tilt and zoom. Electronic pan-tilt-zoom technology comprises smoothing and predicting camera movement for tracking position.
S2013, according to the initial ePTZ parameter, remapping and transforming the panoramic image to the current ePTZ perspective image.
In the first embodiment of the present invention, S2013 can specifically comprise:
remapping and transforming the panoramic image to the current ePTZ perspective image by formula (1): Pi,jePTZ=KkgRkgPu,vworld, where Pi,jePTZ is the coordinate position of Pu,vworld mapped to the electronic PTZ perspective image, Pu,vworld is the three-dimensional coordinates on the unit circle transformed from the panoramic image coordinates; Pu,vworld=Rk−1gKk−1gPi,jePTZ as formula (2), where Kk is a perspective matrix of the virtual camera, Rk is the coordinate system from the world coordinate system to the virtual camera:
and the normalized spherical coordinate of the world coordinate system:
where
is the coordinates of Pu,v on the imaging plane of the virtual camera; {tilde over (f)}k is used to control the zoom of the virtual camera; cx, cy are the projection center of the virtual camera; u and v are the two-dimensional coordinates of the panoramic image, respectively normalized to [0, 2π], [0, π]; Pu,v represents a point mapped from two-dimensional coordinates to three-dimensional coordinates; qx, qy and qz are the three components of q; to simplify the formula Rk, substituting
for q, thus the formula can be derived; where θ only represents a parameter, here, θ=∥q∥ which has no specific meaning; substituting
for q in Φ(q) and then obtaining a calculation and derivation method of camera rotation amount Rk.
S2014, in the current ePTZ perspective image, receiving a position of the tracking target manually selected by the user.
In the first embodiment of the present invention, a position of the tracking target can be a rectangular frame
of the tracking target, where
represents the rectangular frame center of the initialized position of the tracking target, and w0, h0 represents a width and height of the rectangular frame of the tracking target, respectively; x0 and y0 are the coordinates of the rectangular frame center of the tracking target.
S2015, calculating the position and scale of the tracking target in the spherical coordinate system according to the position of the tracking target in the current ePTZ perspective image.
In the first embodiment of the present invention, S2015 can specifically comprise:
calculating the position and scale
of the tracking target in the spherical coordinate system by formula
s0 is the scale of the tracking target currently detected, which can be expressed by a width of the tracking target; f0 is the focal length of the virtual camera; h0 is a height of the rectangular frame; {tilde over (θ)}k is used to control the up-down tilt of the virtual camera; {tilde over (φ)}k is used to control the left and right movement of the virtual camera; is used to control the zoom of the virtual camera; {tilde over (θ)}0 and {tilde over (φ)}0 are the initial vertical tilt angle and left and right movement of the virtual camera, respectively; θk and φk are the calculated spherical coordinate of the tracking target; {tilde over (θ)}k and {tilde over (φ)}k are the coordinate position of the viewpoint smoothed by the Kalman filter; θ0 and φ0 are the initialized position, θ0={tilde over (θ)}0, φ0={tilde over (φ)}0, that is, the virtual camera is centered on the tracking target at the initialized position.
In the first embodiment of the present invention, S202 can specifically comprise the following steps of:
S2021, selecting a rectangular frame of the tracking target palming within the area of the tracking target to obtain a predetermined number of training samples to train a position tracking model.
In the first embodiment of the present invention, S2021 specifically comprises the following steps of:
converting the cost function (cost function refers to the function used to measure an error between a predicted value and a true value):
εk=∥Σl=1dhkl⊗fkl−gk∥2+λΣl=1d∥hkl∥2 formula (3)
of the position tracking model to the Fourier domain:
E
k=∥Σl=1dHklFkl−Gk∥2+λΣl=1d∥Hkl∥2 formula (4), and
calculating a solution
of formula (4) using the gradient descent method;
where fk1 and Fk1 respectively represent the Hog (Histogram of Oriented Gradient) feature and the corresponding Fourier domain feature of the first training sample of the tracking target at time k; gk and Gk respectively represent the Gaussian Regression matrix and the corresponding Fourier domain feature; d represents the number of samples; ⊗ represents convolution; hk1 and Hk1 respectively represent a correlation filter coefficient and the corresponding Fourier domain feature at time k; and λ(λ0) represents the regularization coefficient,
S2022, iteratively updating the parameters of the position tracking model according to the solution Hk1 of the position tracking model;
in the first embodiment of the present invention, S2022 specifically comprises the following steps of:
according to the solution
of the position tracking model, updating the parameters of the position tracking model as follows:
A
k
l=(1−η)Ak-1l+η
B
k=(1−η)Bk-1+ηΣl=1d
where A0l=
S2023, predicting a translational position of the tracking target according to the output position and scale of the current ePTZ and the parameters of the position tracking model;
in the first embodiment of the present invention, S2023 specifically comprises the following steps of:
predicting the ePTZ parameters of the next frame using the position of the tracking target at time k−1, and calculating the plane position
and the scale
of the tracking target under the current ePTZ parameters by S2014;
by formula (10):
where λ represents the regularization parameter (generally the value is 0.01); both Bk and Akl represent the model parameters of the tracking model at time k (calculated in S2022); d represents the number of samples; F−1 represents the Inverse Fourier transform; Zkl represents the Fourier transform of the Hog feature of the tracking target area determined by the output position and scale of the ePTZ at time k; responsek represents a response graph of the tracking target at time k, that is, the value of each point in the response graph is equal to the similarity between the sample and the tracking target; finding the position with the largest value in the response graph is to find the position most similar to the tracking target; thereby, a) translational position of the tracking target being: pk=findMax(responsek).
S2024, obtaining training samples of a scale tracking model according to a scale change to increase or decrease the rectangular frame of the tracking target, and repeating S2021 to S2023 to obtain a scale sk of the correlation filtering;
in the first embodiment of the present invention, S2024 specifically comprises the following steps of:
by obtaining fkl in the formula εk=∥Σl=1dhkl⊗fkl−gk∥2+λΣl=1d∥hkl∥2, that is, obtaining training samples of a scale tracking model according to a scale change to increase or decrease the rectangular frame of the tracking target, and repeating S2021 to S2023 to obtain a scale sk of the correlation filtering;
a scale change is that while keeping the translational position pk of the tracking target unchanged, the width and the height of the rectangular frame of the tracking target are multiplied by a coefficient to obtain a new rectangular area as a new sample; calculating a scale change by the following formula:
where, w refers to a width of the rectangular frame of the tracking target, h refers to a height of the rectangular frame of the tracking target, and S represents the number of scales, which is taken as 33 here; α=1.01 represents a scale factor; a maximum similarity can be calculated at each scale, and comparing and finding the scale of the maximum similarity as the scale sk of the current tracking target.
S2025, obtaining a new rectangular frame of the tracking target according to the translational position pk and the scale sk of the tracking target;
the rectangular frame of the new tracking target is denoted as
where wk-1 and hk-1 represent a width and a height of the rectangular frame of the tracking target in the frame k−1.
S2026, calculating the new position and scale of the rectangular frame rectk of the tracking target in the spherical coordinate system.
The second embodiment of the present invention provides a computer-readable storage medium that stores one or more computer programs, when one or more processors execute the one or more computer programs to perform the steps of the method for tracking target in panoramic video provided in the first embodiment.
In the present invention, the method tracks a target in a panoramic video on the basis of a multi-scale correlation filter, can provide more robust tracking, greater range of application in different tracking scenarios, and faster processing speeds; in addition, due to the automatic ePTZ technology, the tracking target can always be in the center of the screen.
A person of ordinary skill in the art may understand that all or part of the steps in the method of the above-mentioned embodiments can be implemented by the one or more programs instructing the relevant hardware. The one or more programs can be stored in a computer-readable storage medium, and the storage medium can include: Read Only Memory (ROM), Random Access Memory (RAM), magnetic disk or optical disk, etc.
The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modification, equivalent replacements and improvement made within the spirit and principle of the present invention shall be included in the protection of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
201810541553.6 | May 2018 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2019/087274 | 5/16/2019 | WO | 00 |