.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "build/examples_tracking/demo_SiamRPN.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_build_examples_tracking_demo_SiamRPN.py: 01. Single object tracking with pre-trained SiamRPN models ============================================================= Object tracking is a long standing and useful computer vision task. Unlike image object detection, it predicts the position of the object in the next frame according to its position in the current (and sometimes previous) frame. `SiamRPN `_ (Siamese Region Proposal Network) is a widely adopted single object tracking method. It consists of a Siamese subnetwork for feature extraction and a region proposal subnetwork including the classification branch and regression branch for prediction. In the inference phase, the proposed framework is formulated as a local one-shot detection task. We can pre-compute the template branch of the Siamese subnetwork and formulate the correlation layers as trivial convolution layers to perform online tracking. In this tutorial, we will demonstrate how to load a pre-trained SiamRPN model from :ref:`gluoncv-model-zoo` and perform single object tracking on an arbitrary video. .. GENERATED FROM PYTHON SOURCE LINES 24-32 Predict with a SiamRPN model ---------------------------- You need to prepare two things to start a tracking demo, the video and its first frame object coordinates. The coordinates show the region of interest where to track, and in the format of (min_x, min_y, width, height). Here we download a video and set the region of interest in the first frame as [298, 160, 48, 80]. .. GENERATED FROM PYTHON SOURCE LINES 32-38 .. code-block:: default from gluoncv import utils video_path = 'https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/tracking/Coke.mp4' im_video = utils.download(video_path) gt_bbox = [298, 160, 48, 80] .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Downloading Coke.mp4 from https://raw.githubusercontent.com/dmlc/web-data/master/gluoncv/tracking/Coke.mp4... 0%| | 0/9652 [00:00
.. GENERATED FROM PYTHON SOURCE LINES 58-61 Our model is very stable. It can track the object even when it moves at high speed and is partially occluded. Try it on your own video and see the results! .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.305 seconds) .. _sphx_glr_download_build_examples_tracking_demo_SiamRPN.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_SiamRPN.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_SiamRPN.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_