Skip to content

Commit

Permalink
fix: avoid import loop
Browse files Browse the repository at this point in the history
make `toolbox.py` static
  • Loading branch information
williamfzc committed Sep 26, 2019
1 parent c4a0182 commit 78dc9b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions stagesepx/cutter/cut_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def _handler(obj: object):
# ignore
return "<np.ndarray object>"
return obj.__dict__

return json.dumps(self, sort_keys=True, default=_handler)

def dump(self, json_path: str, **kwargs):
Expand Down
9 changes: 6 additions & 3 deletions stagesepx/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from skimage.measure import compare_nrmse, compare_psnr
from skimage.feature import hog, local_binary_pattern

from stagesepx.video import VideoFrame
# DO NOT IMPORT ANYTHING FROM STAGESEPX HERE
# MAKE TOOLBOX STATIC


@contextlib.contextmanager
Expand All @@ -36,9 +37,11 @@ def compare_ssim(pic1: np.ndarray, pic2: np.ndarray) -> float:


def multi_compare_ssim(
pic1_list: typing.Union[typing.List[VideoFrame], typing.List[np.ndarray]],
pic2_list: typing.Union[typing.List[VideoFrame], typing.List[np.ndarray]],
pic1_list: typing.List, pic2_list: typing.List
) -> typing.List[float]:
# avoid import loop
from stagesepx.video import VideoFrame

if isinstance(pic1_list[0], VideoFrame):
pic1_list = [i.data for i in pic1_list]
if isinstance(pic2_list[0], VideoFrame):
Expand Down
7 changes: 0 additions & 7 deletions stagesepx/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,3 @@ def get_operator(self) -> _BaseFrameOperator:

def __iter__(self):
return self.get_iterator()


if __name__ == "__main__":
v = VideoObject("../demo.mp4")
v.load_frames()
for each in v:
print(each)

0 comments on commit 78dc9b3

Please sign in to comment.