Ryan Lee commited on
Commit
50cbdd7
·
1 Parent(s): 61f232f

Fix OpenCV version assertions in ViTTrack & RAFT and text offset (#234)

Browse files

* Update OpenCV version assertions for Object Tracking and Optical Flow

* Increased text offset to not overlap with the bounding box.

Files changed (1) hide show
  1. demo.py +2 -2
demo.py CHANGED
@@ -9,7 +9,7 @@ import cv2 as cv
9
  from vittrack import VitTrack
10
 
11
  # Check OpenCV version
12
- assert cv.__version__ > "4.9.0", \
13
  "Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"
14
 
15
  # Valid combinations of backends and targets
@@ -52,7 +52,7 @@ def visualize(image, bbox, score, isLocated, fps=None, box_color=(0, 255, 0),tex
52
  # bbox: Tuple of length 4
53
  x, y, w, h = bbox
54
  cv.rectangle(output, (x, y), (x+w, y+h), box_color, 2)
55
- cv.putText(output, '{:.2f}'.format(score), (x, y+20), cv.FONT_HERSHEY_DUPLEX, fontScale, text_color, fontSize)
56
  else:
57
  text_size, baseline = cv.getTextSize('Target lost!', cv.FONT_HERSHEY_DUPLEX, fontScale, fontSize)
58
  text_x = int((w - text_size[0]) / 2)
 
9
  from vittrack import VitTrack
10
 
11
  # Check OpenCV version
12
+ assert cv.__version__ >= "4.9.0", \
13
  "Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"
14
 
15
  # Valid combinations of backends and targets
 
52
  # bbox: Tuple of length 4
53
  x, y, w, h = bbox
54
  cv.rectangle(output, (x, y), (x+w, y+h), box_color, 2)
55
+ cv.putText(output, '{:.2f}'.format(score), (x, y+25), cv.FONT_HERSHEY_DUPLEX, fontScale, text_color, fontSize)
56
  else:
57
  text_size, baseline = cv.getTextSize('Target lost!', cv.FONT_HERSHEY_DUPLEX, fontScale, fontSize)
58
  text_x = int((w - text_size[0]) / 2)