Skip to content

Instantly share code, notes, and snippets.

Matthew Moore moorage

Block or report user

Report or block moorage

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
moorage /
Last active Oct 4, 2018
For a Greppy Metaverse dataset: rearrange non-contiguous scenes in a dataset, generate camera normals, move to separate folders.
import os, fnmatch, argparse
import numpy as np
import OpenEXR, Imath, json
import shutil, glob
# TODO update to handle stereo camera
# python3 --p /path/to/dataset
moorage /
Created Sep 28, 2018
Convert blender world normals EXR to camera normal
import numpy as np
import OpenEXR, Imath
from scipy.misc import imsave
INPUT_EXR_NORMALS_FILE = '1-world.exr'
OUTPUT_RGB_NORMAL_FILE = '1-world-to-camera.png'
INVERTED_CAMERA_QUARTERNION = np.array([0.8127532005310059, -0.456145316362381, 0.17738527059555054, 0.31606677174568176], dtype=np.float32)
X_CHANNEL_NAME = 'RenderLayer.Normal.X'
Y_CHANNEL_NAME = 'RenderLayer.Normal.Y'
moorage /
Last active Sep 20, 2018
pyrealsense2 implementation for saving numpy arrays for aligned depth
# On macOS, you'll need to build the wrapper and export PYTHONPATH=$PYTHONPATH:/____PATH_TO____/librealsense/build/wrappers/python/Debug
import pyrealsense2 as rs
import numpy as np
# Give time for auto-exposure to kick in
# Create a context object. This object owns the handles to all connected realsense devices
rs_pipeline = rs.pipeline()
moorage /
Last active Sep 17, 2018
Extract BSDF values from Blender in Python
import bpy
import colorsys
import json
def _convert_rgb_to_hsv(red, green, blue):
return colorsys.rgb_to_hsv(*_linear_to_srgb(red, green, blue))
def _linear_to_srgb(r, g, b):
moorage /
Created Jul 9, 2018
Python function that returns the (x,y,z) typle of the center of multiple objects, within blender
cntr = _center_of_object_collection([ D.objects['obj_example1'], D.objects['obj_example2'], ... ])
def _center_of_object_collection(obs):
min_x = max_x = min_y = max_y = min_z = max_z = None
for ob in obs:
local_vertices = ob.bound_box[:]
worldify = lambda p: ob.matrix_world * Vector(p[:])
world_vertices = [worldify(p).to_tuple() for p in local_vertices]
for (x,y,z) in world_vertices:
if min_x is None or x < min_x:
moorage / available-ubuntu-family-os-types-google-cloud.txt
Created Jun 30, 2018
The available Ubuntu OS Types on Google Cloud
View available-ubuntu-family-os-types-google-cloud.txt
moorage / google_cloud_storage_multiple_file_zip.go
Last active Jun 28, 2018
Zip all the google cloud storage files with a prefix, and upload it back into the prefix.
View google_cloud_storage_multiple_file_zip.go
var StorageBucket string // google storage bucket name
var PrefixToZip string // the prefix you want to zip
var ArchiveZipFilename string // the ultimate name of the zipfile, e.g.
var GoogleCloudClientOption option.ClientOption // can load creds from a json file with this, e.g. GoogleCloudClientOption = option.WithCredentialsFile(jsonFile)
var LogContext string // additional logging string
// Download all files & zip (named ArchiveZipFilename) from gcloud prefix (PrefixToZip)
func main() {
moorage /
Last active May 28, 2018
Easy function to call to fetch the primary email address of a user in Rust.
// Example usage:
// let github_email = fetch_github_primary_email(&some_access_token)?;
// Cargo.toml:
// ..
// [dependencies]
// rocket = "0.3.11"
// curl = "0.4"
// serde = "1.0"
// serde_json = "1.0"
moorage /
Created May 27, 2018
Easy function to call GitHub's GraphQL server in Rust.
// Example usage:
// let github_details = github_graphql_query(
// &"some_oauth_access_token",
// &"query { viewer { email name login id location websiteUrl } }",
// )?;
// Cargo.toml:
// ..
// [dependencies]
// rocket = "0.3.11"
moorage / bounding-boxes-darknet.diff
Created Jun 5, 2017
The diff for darknet to output bounding boxes. I'm using the command: `./darknet detect cfg/yolo.cfg yolo.weights ~/Desktop/color_31.jpg`
View bounding-boxes-darknet.diff
diff --git a/examples/detector.c b/examples/detector.c
index 0a31fc2..5764567 100644
--- a/examples/detector.c
+++ b/examples/detector.c
@@ -364,7 +364,7 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
if(fps) fclose(fps[j]);
- fseek(fp, -2, SEEK_CUR);
+ fseek(fp, -2, SEEK_CUR);
You can’t perform that action at this time.