Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / clahe.py
Created August 31, 2023 10:12
equalize brightness with CLAHE +2 step background learning
import cv2
import numpy as np
from Tracker import Tracker
from TouchEvents import TouchEvents
from pythonosc import udp_client as osc
from scipy.signal import convolve2d
w,h=640,480
mouseX, mouseY = 0,0
exposure=-8
@companje
companje / tps-remap.py
Last active August 28, 2023 16:30
Fast mapping with Thin Plate Spline Shape Transformer and remap
import cv2
import numpy as np
w,h = 640,480
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_EXPOSURE,-6)
cv2.namedWindow("src")
cv2.namedWindow("dst", cv2.WINDOW_NORMAL)
cv2.moveWindow("dst",w,0)
@companje
companje / Draw Quads.py
Last active August 28, 2023 09:31
Textured Quads in Py5 (Processing / Python)
import py5
class Quad:
def __init__(self, s):
self.p = list(map(int, s.split(" ")))
def load_quads(filename):
return [Quad(s) for s in py5.load_strings(filename)]
def draw_quads(xy_quads, uv_quads, tex):
@companje
companje / Quads.pde
Last active August 28, 2023 08:41
Quads
PImage cam, screen;
ArrayList<Quad> cam_quads, screen_quads;
void setup() {
size(1280, 480, P3D);
cam = loadImage("vis_200.png");
cam_quads = load_quads("cam_quads.txt");
screen_quads = load_quads("screen_quads.txt");
}
@companje
companje / 0-texture-mapping-in-opencv.py
Last active August 27, 2023 10:55
Unwarp with multiple getPerspectiveTransform / warpPerspective calls. UPDATE: using ThinPlateSplineShapeTransformer now
# By Rick Companje, 2023-08-26
# Enjoy!
# inspired by: https://stackoverflow.com/questions/10196198/how-to-remove-convexity-defects-in-a-sudoku-square/11366549#11366549
# Please let me know if you know an easier/better way to achieve this simple 2D mapping in OpenCV.
# Something like OpenGL vertex / texcoords approach but then in OpenCV...
import cv2,csv
import numpy as np
@companje
companje / 001.py
Last active August 9, 2023 06:50
stretch and colorize cam channels
#https://becominghuman.ai/real-time-finger-detection-1e18fea0d1d4
def bgSubMasking(self, frame):
"""Create a foreground (hand) mask
@param frame: The video frame
@return: A masked frame
"""
fgmask = bgSubtractor.apply(frame, learningRate=0)
kernel = np.ones((4, 4), np.uint8)
@companje
companje / ocr mac.py
Created April 25, 2023 11:59
ocr mac
#!/Applications/Xcode.app/Contents/Developer/usr/bin/python3
import config,json,os,subprocess,ocr2json
from tqdm import tqdm
from joblib import Parallel, delayed
import Quartz,Vision
from Cocoa import NSURL
from Foundation import NSDictionary
from wurlitzer import pipes # needed to capture system-level stderr
@companje
companje / load-link-filter.js
Created October 26, 2022 07:27
load, link and filter data in javascript from triplestore
@companje
companje / Understanding-City-in-a-bottle.pde
Last active October 2, 2022 19:27
Understanding 'City in a bottle' in Processing
//Original by Frank Force (KilledByAPixel) - https://twitter.com/KilledByAPixel/status/1517294627996545024.
//Observable by Daniel Darabos - https://observablehq.com/@darabos/decoding-a-city-in-a-bottle
//Processing version by Rick Companje as intermediate step to 8086 assembly language.
//this version currently lacks textures on the buildings. To be continued.
int w=72;
int h=50;
int t=0;
void setup() {
@companje
companje / data.ttl
Created August 16, 2022 11:28
geof:sfWithin (filter results with a boundingbox) with SPARQL
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
@prefix def: <https://hetutrechtsarchief.nl/def/> .
@prefix hua: <https://hetutrechtsarchief.nl/id/> .
hua:D8884A3B2E6CA8F6E0538F04000A374B
a def:Adresvermelding ;
geo:asWKT "POINT (9.1825624999999995 45.4652869999999965)"^^geo:wktLiteral .