Computer Vision News - July 2019
algorithm is to build a correlation filter (i.e. kernel) such that a convolution with the input image gives the desired response. This desired response usually has a Gaussian shape centered around the object and decreasing with the distance. To calculate the optimal filter, the algorithm uses translated instances of the object from the previous frames. The maximal filter response is taken to be the object location. In order to explain how the kernel trick works (like in SVM), we first start with linear correlation filter. The optimal linear filter w is found by solving the following least squares problem of the form: Here, X is a circulant matrix containing all the possible cyclic image shifts, λ is a regularization coefficient term and y is the response that we expect to receive. The advantage of this formulation is that, given such circulant matrix X, we can find the optimal weights in the Fourier domain w* using a closed form solution. Like in SVM, the kernel trick allows us to perform a non-linear regression by mapping the input using a non-linear mapping. In this way, the weights have the form of = ∑ ϕ(x i ሻ and the minimization problem is of the form: Here the matrix K is the kernel matrix with entries , thus we can solve in a closed form in the Fourier domain as well. In this method, usually an RBF Gaussian kernel is used. Implementation Before we begin to dive into the code, note that some of the tracker described above are not available in old versions of OpenCV so make sure that you pip- installed the latest version of OpenCV. Moreover, make sure you have opencv- contib-python on your environment, we need it to create the tracking object. We begin with importing the cv and sys libraries: 1 import cv2 2 import sys Next, we define the tracker object. As mention above, we have eight possible trackers to use and we used the KCF. For other trackers, you can take a look on the OpenCV documentation. Defining the KCF tracker is simple as: 39 Focus on Computer Vision News Object Tracking in Python Using OpenCV ൠ min{ − 2 + | | min α − 2 + ൯ = (
Made with FlippingBook
RkJQdWJsaXNoZXIy NTc3NzU=