Skip to content
Permalink
Browse files

fix(video preprocessor): modify inaccurate names

  • Loading branch information...
raccoonliukai committed Aug 22, 2019
1 parent dfb54b6 commit 16aaa77765f65a43d34edab83a3f2f73f292c27c
@@ -267,14 +267,14 @@ def hsv_histogram(image: 'np.ndarray') -> 'np.ndarray':
return hist


def edge_detect(image: 'np.ndarray', **kwargs) -> 'np.ndarray':
def canny_edge(image: 'np.ndarray', **kwargs) -> 'np.ndarray':
arg_dict = {
'compute_threshold': True,
'low_threshold': 0,
'high_threshold': 200,
'sigma': 0.5,
'gauss_kernel': (9, 9),
'L2': True
'l2_gradient': True
}
for k, v in kwargs.items():
if k in arg_dict.keys():
@@ -307,7 +307,7 @@ def compute_descriptor(image: 'np.ndarray',
funcs = {
'bgr_histogram': bgr_histogram,
'hsv_histogram': hsv_histogram,
'edge_detect': lambda image: edge_detect(image, **kwargs),
'canny_edge': lambda image: canny_edge(image, **kwargs),
'block_bgr_histogram': lambda image: block_descriptor(image, bgr_histogram, kwargs.get('num_blocks', 3)),
'block_hsv_histogram': lambda image: block_descriptor(image, hsv_histogram, kwargs.get('num_blocks', 3)),
'pyramid_bgr_histogram': lambda image: pyramid_descriptor(image, bgr_histogram, kwargs.get('max_level', 2)),
@@ -429,9 +429,9 @@ def motion_algo(distances: List[float], **kwargs) -> List[int]:
return shots


def detect_video_shot(distances: List[float],
method: str = 'kmeans',
**kwargs) -> List[int]:
def detect_peak_boundary(distances: List[float],
method: str = 'kmeans',
**kwargs) -> List[int]:
detect_method = {
'kmeans': kmeans_algo,
'threshold': thre_algo,
@@ -18,7 +18,7 @@
from typing import List

from ..base import BaseVideoPreprocessor
from ..helper import get_video_frames, compute_descriptor, compare_descriptor, detect_video_shot, compare_ecr
from ..helper import get_video_frames, compute_descriptor, compare_descriptor, detect_peak_boundary, compare_ecr
from ...proto import gnes_pb2, array2blob


@@ -55,15 +55,15 @@ def detect_from_bytes(self, raw_bytes: bytes) -> (List[List['np.ndarray']], int)
descriptors.append(descriptor)

# compute distances between frames
if self.distance_metric == 'edgechangeration':
if self.distance_metric == 'edge_change_ration':
dists = compare_ecr(descriptors)
else:
dists = [
compare_descriptor(pair[0], pair[1], self.distance_metric)
for pair in zip(descriptors[:-1], descriptors[1:])
]

shots = detect_video_shot(dists, self.detect_method)
shots = detect_peak_boundary(dists, self.detect_method)

shot_frames = []
for ci in range(0, len(shots) - 1):
@@ -1,7 +1,7 @@
!ShotDetectPreprocessor
parameters:
descriptor: "edge_detect"
distance_metric: "edgechangeration"
descriptor: "canny_edge"
distance_metric: "edge_change_ration"
frame_size: "192*168"
frame_rate: "30"
gnes_config:

0 comments on commit 16aaa77

Please sign in to comment.
You can’t perform that action at this time.