Skip to Content
OpenCV 4 with Python Blueprints - Second Edition
book

OpenCV 4 with Python Blueprints - Second Edition

by Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler
March 2020
Intermediate to advanced
366 pages
9h 8m
English
Packt Publishing
Content preview from OpenCV 4 with Python Blueprints - Second Edition

Converting boundary boxes to observations

In order to pass the boundary boxes to the Kalman filter, we will have to define a transformation function from each boundary box to the observation model, and, in order to use the predicted boundary boxes for object tracking, we need to define a function from a state to a boundary box.

Let's start with a transformation function from a boundary box to an observation:

  1. First, we calculate the center coordinates of the boundary box:
def bbox_to_observation(bbox):    x, y = (bbox[0:2] + bbox[2:4]) / 2
  1. Next, we calculate the width and height of the box, which we will use to calculate the size (that is, the area) and the scale:
    w, h = bbox[2:4] - bbox[0:2]
  1. Then, we calculate the size of bbox, that is, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

OpenCV with Python Blueprints

OpenCV with Python Blueprints

Michael Beyeler, Michael Beyeler (USD)
OpenCV 3 Computer Vision with Python Cookbook

OpenCV 3 Computer Vision with Python Cookbook

Aleksei Spizhevoi, Aleksandr Rybnikov
Mastering OpenCV 4 with Python

Mastering OpenCV 4 with Python

Alberto Fernández Villán

Publisher Resources

ISBN: 9781789801811Supplemental Content