From c5fc0ac516d8bec87ab45cf764db145c5d0fe99f Mon Sep 17 00:00:00 2001 From: "Joab Leite S. Neto" Date: Sat, 16 Jul 2022 08:36:47 -0300 Subject: [PATCH] V2.2.0 (#3) * improves: video improves * improves: video improves * improves: video improves --- calango/__init__.py | 2 +- calango/media.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/calango/__init__.py b/calango/__init__.py index 43ff74b..0aec17e 100644 --- a/calango/__init__.py +++ b/calango/__init__.py @@ -26,5 +26,5 @@ from .devices import Mouse from .media import Image, VideoWriter, Video -VERSION = "2.1.9.final.0" +VERSION = "2.2.0.final.0" __version__ = get_version_pep440_compliant(VERSION) diff --git a/calango/media.py b/calango/media.py index 86199f8..5b30325 100644 --- a/calango/media.py +++ b/calango/media.py @@ -880,6 +880,11 @@ def next_frame(self): def is_opened(self): return self._cap.is_opened + @property + def current_time(self): + """returns timesec for""" + return round((1 / self._cap.fps) * self.current_number_frame, 2) + def set_start_on_time(self, _time='00:00:00'): h, m, s = time.strptime(_time, '%H:%M:%S')[-6:-3] h *= 3600 @@ -889,6 +894,8 @@ def set_start_on_time(self, _time='00:00:00'): self._cap.set(cv2.CAP_PROP_POS_MSEC, seconds * 1000) self._current_number_frame = int(round(seconds * self.fps)) self._count_frames = self._current_number_frame + self._fps_time = 0 + self._t0 = None def get_batch_frames(self, kernel_size, strides=1, take_number_frame=False): batch_frames = [] @@ -1054,6 +1061,15 @@ def set_speed(self, speed=1): def stop(self): self._cap.stop() + def __getitem__(self, item): + if isinstance(item, int): + start, end, step = item, item+1, 1 + elif isinstance(item, slice): + start, end, step = item.start, item.stop, item.step or 1 + else: + raise IndexError("Value is not valid") + return self.cut(start, end, step) + class VideoMagnification: def __init__(self, *args, batch_size=20, levels=3, low=2.33, high=2.67, amplification=30, frame_preprocess=None,