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
# https://www.johnpapa.net/node-and-npm-without-sudo/ | |
VERSION=v18.18.0 | |
DISTRO=linux-x64 | |
wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DISTRO.tar.xz | |
tar -xvf node-$VERSION-$DISTRO.tar.xz | |
rm node-$VERSION-$DISTRO.tar.xz | |
mkdir ~/.nodejs | |
mv node-$VERSION-$DISTRO ~/.nodejs |
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 cv2 | |
import ffmpeg | |
def get_fps_fast(video_path): | |
# using only opencv-python package, fast but can be inaccurate | |
cap = cv2.VideoCapture(video_path) | |
if not cap.isOpened(): | |
raise Exception(f"Cannot open {video_path}") | |
fps = cap.get(cv2.CAP_PROP_FPS) |
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
### Basic configs | |
# source file | |
unbind r | |
bind r source-file ~/.tmux.conf | |
# new prefix | |
# unbind C-b | |
# set -g prefix C-a | |
# act like vim |
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 warp_affine(img, M, fill_value=127): | |
new_img = np.full_like(img, fill_value, dtype=img.dtype) | |
h, w = img.shape[:2] | |
y, x = np.indices((h, w)) | |
x = x.flatten() | |
y = y.flatten() | |
ones = np.ones((h * w, 1)) |
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 | |
import cv2 | |
def img_horizontal_concat(img1, img2, img_size=(240, 480)): | |
img1_resized = cv2.resize(img1, img_size) | |
img2_resized = cv2.resize(img2, img_size) | |
return np.concatenate((img1_resized, img2_resized), axis=1) | |
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
def iou_calc(boxes1, boxes2): | |
boxes1_area = (boxes1[2] - boxes1[0]) * (boxes1[3] - boxes1[1]) | |
boxes2_area = (boxes2[2] - boxes2[0]) * (boxes2[3] - boxes2[1]) | |
left_up = np.maximum(boxes1[:2], boxes2[:2]) | |
right_down = np.minimum(boxes1[2:-2], boxes2[2:-2]) | |
inter_section = np.maximum(right_down - left_up, 0.0) | |
inter_area = inter_section[0] * inter_section[1] |
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 cv2 | |
def bbox_percentage_to_pixel(bbox, h, w): | |
x1, y1, x2, y2 = bbox | |
return x1 * w, y1 * h, x2 * w, y2 * h | |
def draw_bboxes_on_image(img, bboxes, show=True, percentage=True): | |
h, w = img.shape[:2] |
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 cv2 | |
import numpy as np | |
def horizontal_concat(img1, img2, img_size): | |
img1_resized = cv2.resize(img1, img_size) | |
img2_resized = cv2.resize(img2, img_size) | |
return np.concatenate((img1_resized, img2_resized), axis=1) |
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 | |
class PerfMonitorMixin: | |
PERF_MONITOR = {} | |
def update_perf(self, name, latency, ignore_classwise=False): | |
if not ignore_classwise: | |
name = self.__class__.__name__ + "_" + name | |
if name not in PerfMonitorMixin.PERF_MONITOR: |