Skip to content

Instantly share code, notes, and snippets.

@botforge
botforge / hsv-trackbar.py
Last active July 11, 2021 09:09
Find the HSV Bounds for a colored object in a video stream using a neat trackbar gui using OpenCV
import cv2 as cv
import numpy as np
# optional argument for trackbars
def nothing(x):
pass
# named ites for easy reference
barsWindow = 'Bars'
hl = 'H Low'
@botforge
botforge / opencv-angle-calc.py
Last active May 25, 2023 10:57
Calculate & visualize the angle between two colored objects in a video stream using OpenCV
"""
USES OPENCV 4.10, PROBABLY WILL WORK FOR OPENCV 2.70 and up
REMEMBER TO CALCULATE THE HSV BOUNDS FOR color1 & color2, use the trackbar:
https://gist.github.com/botforge/c6559abd3c48bceb78c2664dcb53cef6
to get these values
"""
import cv2
import numpy as np
import math
@botforge
botforge / gym_to_gif.py
Last active April 29, 2024 10:27
Save OpenAI Gym renders as GIFS
from matplotlib import animation
import matplotlib.pyplot as plt
import gym
"""
Ensure you have imagemagick installed with
sudo apt-get install imagemagick
Open file in CLI with:
xgd-open <filelname>