This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) OpenMMLab. All rights reserved. | |
import os | |
import warnings | |
from argparse import ArgumentParser | |
import cv2 | |
from mmpose.apis import (get_track_id, inference_top_down_pose_model, | |
init_pose_model, process_mmdet_results, | |
vis_pose_tracking_result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def center_cumsum(a:np.ndarray, pivot:tuple) -> np.ndarray: | |
""" | |
Compute the cumsum but pivoting a specified index | |
""" | |
assert isinstance(a, np.ndarray) | |
assert a.ndim == 2 | |
a_cum = np.zeros_like(a, dtype=a.dtype) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from skimage.feature import peak_local_max | |
from scipy.cluster.vq import kmeans | |
def get_centroids(array2d, maximum_gap=0.2, peak_theshold = 0.5): | |
maximum_distortion = array2d.shape[0] * maximum_gap | |
for _k in [1, 2, 3, 4]: | |
peaks = peak_local_max(array2d, threshold_rel=peak_theshold).astype(np.float32) | |
k_peaks, distortion = kmeans(peaks.astype(float), _k) |