Skip to content

Instantly share code, notes, and snippets.

(opencv-latest) $ python -V
Python 3.8.13
(opencv-latest) $ python -c 'import cv2; print(cv2.getBuildInformation())'
General configuration for OpenCV 4.6.0 =====================================
Version control: 4.6.0
Platform:
Timestamp: 2022-06-07T10:22:17Z
Host: Darwin 20.2.0 arm64
@rvalue
rvalue / trackbar.py
Created July 7, 2022 14:35
OpenCV Trackbar
import numpy as np
import cv2
def update(image, args):
print("Scale: " + str(args))
fontFace = cv2.FONT_HERSHEY_SIMPLEX
pixelHeight = int(image.shape[0] * args / 100)
thickness = 1
org = (0, pixelHeight)
@rvalue
rvalue / worddle_solver.py
Created February 1, 2022 19:03
Worddle Solver
def worddle(length: int, word_list: list[str], skip_characters:str='', present_characters:str='', fixed_characters: dict[int, str]={}, returns=False):
"""Summary
Parameters
----------
length : int
Length of the word in the problem
word_list : list[str]
List of dictionary words
skip_characters : str
@rvalue
rvalue / opencv-gphoto2-example.cpp
Created October 31, 2021 21:03
opencv-cpp-logs
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using namespace cv;
using namespace std;
void drawText(Mat & image);
@rvalue
rvalue / ghoto2-opencv.py
Created October 26, 2021 10:46
Using gphoto2 with opencv
import cv2, ctypes, csv, io
capture = cv2.VideoCapture(0, cv2.CAP_GPHOTO2)
print(capture.isOpened())
camera_data = ctypes.c_char_p(int(capture.get(cv2.CAP_PROP_GPHOTO2_WIDGET_ENUMERATE))).value.decode('utf-8')
headers = ['id', 'label', 'name', 'info', 'readonly', 'type', 'value']
canon_info = [{k:v for k, v in dictionary.items() if k in headers} for dictionary in csv.DictReader(io.StringIO(camera_data))]