Ryan Lee commited on
Commit
44fe25c
·
1 Parent(s): 2129055

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.

models/object_tracking_vittrack/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)
models/optical_flow_estimation_raft/demo.py CHANGED
@@ -6,7 +6,7 @@ import numpy as np
6
  from raft import Raft
7
 
8
  # Check OpenCV version
9
- assert cv.__version__ > "4.9.0", \
10
  "Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"
11
 
12
  parser = argparse.ArgumentParser(description='RAFT (https://github.com/princeton-vl/RAFT)')
 
6
  from raft import Raft
7
 
8
  # Check OpenCV version
9
+ assert cv.__version__ >= "4.9.0", \
10
  "Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"
11
 
12
  parser = argparse.ArgumentParser(description='RAFT (https://github.com/princeton-vl/RAFT)')