Skip to content

Commit

Permalink
Merge pull request #6 from tryolabs/improve_vide_input_checking
Browse files Browse the repository at this point in the history
Improve input checking to Video class
  • Loading branch information
joaqo committed Sep 11, 2020
2 parents 4c97632 + de66e8f commit 6ea4254
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions norfair/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def __init__(

# Read Input Video
if self.input_path is not None:
if "~" in self.input_path:
self.input_path = os.path.expanduser(self.input_path)
if not os.path.isfile(self.input_path):
self._fail(f"[bold red]Error:[/bold red] File '{self.input_path}' does not exist.")
self.video_capture = cv2.VideoCapture(self.input_path)
total_frames = int(self.video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
if total_frames == 0:
fail_msg = "[bold red]Error reading input video file:[/bold red] Make sure file exists and is a video file."
if "~" in self.input_path:
fail_msg += "\n[yellow]Using ~ as abbreviation for your home folder is not supported.[/yellow]"
self._fail(fail_msg)
self._fail(f"[bold red]Error:[/bold red] '{self.input_path}' does not seem to be a video file supported by OpenCV. If the video file is not the problem, please check that your OpenCV installation is working correctly.")
description = os.path.basename(self.input_path)
else:
self.video_capture = cv2.VideoCapture(self.camera)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "norfair"
version = "0.1.6"
version = "0.1.7"
description = "Lightweight Python library for real-time 2D object tracking."
license = "BSD-3-Clause"
authors = ["Tryolabs <[email protected]>"]
Expand Down

0 comments on commit 6ea4254

Please sign in to comment.