Skip to content

Commit

Permalink
Fix OpenCV version assertions in ViTTrack & RAFT and text offset (#234)
Browse files Browse the repository at this point in the history
* Update OpenCV version assertions for Object Tracking and Optical Flow

* Increased text offset to not overlap with the bounding box.
  • Loading branch information
ryan1288 authored Feb 27, 2024
1 parent bdd60c2 commit b1322ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions models/object_tracking_vittrack/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vittrack import VitTrack

# Check OpenCV version
assert cv.__version__ > "4.9.0", \
assert cv.__version__ >= "4.9.0", \
"Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"

# Valid combinations of backends and targets
Expand Down Expand Up @@ -52,7 +52,7 @@ def visualize(image, bbox, score, isLocated, fps=None, box_color=(0, 255, 0),tex
# bbox: Tuple of length 4
x, y, w, h = bbox
cv.rectangle(output, (x, y), (x+w, y+h), box_color, 2)
cv.putText(output, '{:.2f}'.format(score), (x, y+20), cv.FONT_HERSHEY_DUPLEX, fontScale, text_color, fontSize)
cv.putText(output, '{:.2f}'.format(score), (x, y+25), cv.FONT_HERSHEY_DUPLEX, fontScale, text_color, fontSize)
else:
text_size, baseline = cv.getTextSize('Target lost!', cv.FONT_HERSHEY_DUPLEX, fontScale, fontSize)
text_x = int((w - text_size[0]) / 2)
Expand Down
2 changes: 1 addition & 1 deletion models/optical_flow_estimation_raft/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from raft import Raft

# Check OpenCV version
assert cv.__version__ > "4.9.0", \
assert cv.__version__ >= "4.9.0", \
"Please install latest opencv-python to try this demo: python3 -m pip install --upgrade opencv-python"

parser = argparse.ArgumentParser(description='RAFT (https://github.com/princeton-vl/RAFT)')
Expand Down

0 comments on commit b1322ea

Please sign in to comment.