Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / Kurokesu-C3_4K-resolutions.py
Created February 26, 2025 10:32
Kurokesu C3_4K resolutions
import cv2
def get_framerate(prev_time=[0], fps=[30]):
current_time = cv2.getTickCount()
elapsed = (current_time - prev_time[0]) / cv2.getTickFrequency()
prev_time[0] = current_time
fps[0] = (1.0 / elapsed * 0.1) + (fps[0] * 0.9)
return fps[0]
cam = cv2.VideoCapture(0)
@companje
companje / faiss.py
Created February 24, 2025 12:02
FAISS
import faiss
import numpy as np
import torch
import torchvision.transforms as transforms
from torchvision import models
from PIL import Image
import os
# --- 1. Load Pre-trained Model (ResNet50) ---
class FeatureExtractor:
@companje
companje / 0. StreamSketch.pde
Created February 23, 2025 13:38
Render to screen and stream on a different resolution and framerate to Websocket
Streamer streamer;
void setup() {
size(640, 600, P3D);
frameRate(60);
background(0);
streamer = new Streamer(400, 400, 8080);
}
void draw() {
@companje
companje / 0.ultimate-sphere.pde
Last active February 22, 2025 21:17
Ultimate Sphere rotation code with lat/lon GeoPoints, projections, ortho / dome / lens / cubemap texture, corrections for eye rotation and Weather API
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
PGraphics dome, ortho3D, lens, cubemap[] = new PGraphics[6];
PShape globe;
PShader shader;
PImage tex;
float h=512, d=h, hd2=h/2, r=hd2;
int cubemapSize=512;
Rotation qTo = new Rotation(new Vector3D(0, 0, 1), 0);
@companje
companje / Anchor point z-rotation. Working test.pde
Created February 22, 2025 16:46
Anchor point z-rotation. Working test.
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
class GeoPoint extends Vector3D {
float lat, lon;
GeoPoint(float lat, float lon) {
super(
cos(radians(lat)) * sin(-radians(lon)),
sin(radians(lat)),
@companje
companje / rotation-lat-lon-sphere-unwarp-to-texture-cubemap-lens-projections.pde
Last active February 19, 2025 17:13
Rotation lat/lon Sphere and unwarp to texture, cubemap, lens, projections etc.
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
PGraphics dome, ortho3D, lens, cubemap[] = new PGraphics[6];
PShape globe;
PShader shader;
PImage tex;
float h=512, d=h, hd2=h/2, r=hd2;
int cubemapSize=512;
Rotation qTo = new Rotation(new Vector3D(0, 0, 1), 0);
@companje
companje / lat,lon to Rotation and back.pde
Created February 19, 2025 14:32
lat/lon to Rotation and back
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
GeoPoint nl = new GeoPoint(52.37, 4.91);
GeoPoint ny = new GeoPoint(40.79, -73.96);
GeoPoint jp = new GeoPoint(36.14, 137.86);
GeoPoint north = new GeoPoint(90, 0);
GeoPoint south = new GeoPoint(-90, 0);
GeoPoint west = new GeoPoint(0,-90);
GeoPoint east = new GeoPoint(0,90);
@companje
companje / 3D Sphere to CubeMap to Equirectangular texture.pde
Created February 12, 2025 20:01
3D Sphere to CubeMap to Equirectangular texture
PImage earth;
PShape globe;
PGraphics fbo[] = new PGraphics[6];
int cubemapSize = 1024;
PImage output_texture;
PImage tex;
PGraphics view3D,ortho3D;
float h, hd2;
PVector center[] = {
@companje
companje / CubeMap camera FOV 90 (stretched).pde
Last active February 12, 2025 12:59
CubeMap camera FOV 90 (stretched)
PImage earth;
PShape globe;
PGraphics fbo[] = new PGraphics[6];
int cubemapSize = 512;
PVector eye = new PVector(0, 0, 0);
PVector up[] = {
new PVector(0, -1, 0), // +X
new PVector(0, -1, 0), // -X
@companje
companje / weather.pde
Created February 10, 2025 21:02
Globe Weather API
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
Vector3D focusPoint = latLonToVector3D(0, 0);
Vector3D nl = latLonToVector3D(52.37, 4.91);
Vector3D ny = latLonToVector3D(40.79, -73.96);
Vector3D jp = latLonToVector3D(36.14, 137.86);
Vector3D north = latLonToVector3D(90, 0);