Skip to content

Instantly share code, notes, and snippets.

@RH2
RH2 / position of markers
Created May 12, 2022 23:39
sample output
[1, 10, 5]
id:1--------
c0:[Vector((1.0, 1.0, 1.0)), Vector((1.0, 1.0, 1.0)), Vector((2.5952634811401367, 4.673618316650391, 2.528850555419922)), Vector((0.0, 0.0, 0.0)), Vector((-2.174985408782959, 14.062763214111328, 12.237187385559082))]
c1:[Vector((4.53745698928833, 9.417943954467773, 2.810494899749756)), Vector((-2.3082613945007324, 1.2570186853408813, 5.259504795074463)), Vector((-1.3547754287719727, 17.855918884277344, 13.437776565551758))]
c2:[Vector((5.320581436157227, 3.0470848083496094, -3.7964653968811035)), Vector((-4.250454902648926, -3.487306594848633, 4.977860450744629)), Vector((1.1032078266143799, 16.89960289001465, 10.495382308959961))]
c3:[Vector((6.8457183837890625, 8.160924911499023, -2.449009895324707)), Vector((-1.5251367092132568, -5.113840103149414, -1.3474555015563965)), Vector((1.2449270486831665, 13.604747772216797, 8.606368064880371))]
id:10--------
c0:[Vector((1.0, 1.0, 1.0)), Vector((1.0, 1.0, 1.0)), Vector((2.5952634811401367, 4.673618316650391, 2.528850555419922)), Vector((0.
@RH2
RH2 / aprilDirectoryDetect.py
Created May 11, 2022 01:09
aprilDirectoryDetect.py
#pip install opencv-contrib-python --user
import cv2 as cv
import numpy as np
import argparse
import sys
import imutils
import glob
import os
import json
@RH2
RH2 / gist:5197d7000685a1f0686f747a00d20139
Created May 11, 2022 01:08
blenderraycastsample.py
import bpy
from mathutils import Vector, Quaternion
import numpy as np
import bmesh
import glob
import os
os.system('clear')
def lerp( t, a, b):
return a + t * (b - a)
float fovx; //field of view in X -
float fovy; //field of view in Y -
float aperature_x; //aperture in X 41.4214
float aperature_y; //aperture in Y -
float focal; //focal length 50
float resx; //pixel resolution in X 320
float resy; //pixel resolution in Y 243
float pixel_aspect; //pixel aspect (width/height)
#pip install opencv-contrib-python --user
import cv2 as cv
import numpy as np
import argparse
import sys
import imutils
import glob
import os
import json
@RH2
RH2 / gist:c29135dc5de2f5ce1ad656a6b2bc3624
Created May 5, 2022 03:56
houdini import mark detection with camera registration.py
node = hou.pwd()
geo = node.geometry()
import os
import glob
geo.addAttrib(hou.attribType.Point, "id", 0)
geo.addAttrib(hou.attribType.Point, "corner", 0)
geo.addAttrib(hou.attribType.Point, "name", "")
geo.addAttrib(hou.attribType.Point, "dimx", 0)
geo.addAttrib(hou.attribType.Point, "dimy", 0)
useFrame((state,delta)=>{
let pi = Math.PI
const keyframes1_position = [[new THREE.Vector3(0,0,0),0],[new THREE.Vector3(0,0,0),0.5],[new THREE.Vector3(0,0,0),1.0]]
const keyframes1_rotation = [[new THREE.Vector3(),0],[new THREE.Vector3(),0.5],[new THREE.Vector3(),1.0]]
const keyframes2_position = [[new THREE.Vector3(0,0,0),0],[new THREE.Vector3(0,0,0),0.5],[new THREE.Vector3(0,0,0),1.0]]
const keyframes2_rotation = [[new THREE.Vector3(),0],[new THREE.Vector3(),0.5],[new THREE.Vector3(),1.0]]
const offset = (1 - scroll.offset)
const offset2 = scroll.offset -2
@RH2
RH2 / gist:f54f4d7fb6cb7d280b53a03982074b27
Created March 17, 2022 05:18
shader and geometry-node generator
#import bpy
mat_name = "pointcloud2"
materials = bpy.data.materials
if materials.get(mat_name) is None:
print("creating pointcloud material")
mat = materials.new(mat_name)
mat.use_nodes = True
materialtree = mat.node_tree.nodes
materialtree.remove(materialtree.get("Principled BSDF"))
materialtree.remove(materialtree.get("Material Output"))
"csg" :
[
[
{
"type" : "cube"
"mode" : "add"
"rgb" : "153 204 255"
"round%": "0.25"
"r" : "1 0 0 0 1 0 0 0 1"
"t" : "0 0 256"
@RH2
RH2 / gist:956895379daa01a2b69679bb5dc05d21
Last active September 30, 2020 21:37
Vertex color from first material slot with baked cavity pass.
import bpy
import random
#matcol = bpy.data.materials["Material.001"].diffuse_color
#for m in bpy.context.object.material_slots:
for obj in bpy.context.selected_objects:
bpy.ops.object.mode_set(mode='OBJECT')
matname = bpy.context.selected_objects[0].material_slots[0].name
#specialColor = bpy.data.materials[matname].diffuse_color
specialColor = bpy.data.materials[matname].node_tree.nodes['Principled BSDF'].inputs[0].default_value