Skip to content

Instantly share code, notes, and snippets.

@TimSC
TimSC / affinedemo.py
Created September 3, 2012 12:29
Test code for scikits-image piecewise affine warp
import skimage.transform
from PIL import Image
from skimage import data
import numpy as np
if __name__ == "__main__":
#Load source image
srcIm = data.lena()
#Define control points for warp
@TimSC
TimSC / vlcsms.c
Created November 20, 2012 22:59
Using libvlc to extract raw frames and audio from media via smem
//To compile:
//cc vlcsms.c -o vlcsms -lvlc
//This source is by Tim Sheerman-Chase and it is released as public domain.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <vlc/vlc.h>
@TimSC
TimSC / gist:5198211
Last active December 15, 2015 03:59
Convert from PIL Image and Numpy array to PyPNG format By Tim Sheerman-Chase, 2013 This code is released as CC0 and public domain code. Do what you will!
#Convert from PIL Image and Numpy array to PyPNG format
#By Tim Sheerman-Chase, 2013
#This code is released as CC0 and public domain code. Do what you will!
import png
from PIL import Image
import numpy as np
class NumpyArrayToPyPngAdapter:
def __init__(self, img):
@TimSC
TimSC / gist:5251670
Last active November 21, 2024 03:25
Generate an RSA key pair, sign a message and verify it using crypto++ 5.6.1 or later. By Tim Sheerman-Chase, 2013. This code is in the public domain and CC0.
//Generate an RSA key pair, sign a message and verify it using crypto++ 5.6.1 or later.
//By Tim Sheerman-Chase, 2013
//This code is in the public domain and CC0
//To compile: g++ gen.cpp -lcrypto++ -o gen
#include <string>
using namespace std;
#include <crypto++/rsa.h>
#include <crypto++/osrng.h>
#include <crypto++/base64.h>
@TimSC
TimSC / qt4-webcam.py
Created May 29, 2013 13:01
QT4 Webcam demo in python. Copyright (c) 2013, Tim Sheerman-Chase.. May be used under BSD or CC0 license. Requires python bindings to opencv.
'''
QT4 Webcam demo in python
Copyright (c) 2013, Tim Sheerman-Chase
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@TimSC
TimSC / fetch-photo-db.py
Last active December 18, 2015 04:29
Get Photos from server
import urllib2, json, StringIO
from PIL import Image
if __name__=="__main__":
urlHandle = urllib2.urlopen("http://192.168.1.9/photodb/getsamples.php")
sampleJson = urlHandle.read()
sampleList = json.loads(sampleJson)
for sample in sampleList:
print sample
@TimSC
TimSC / fast_hog.pyx
Created June 19, 2013 00:12
A cython optimised version of the hog feature descriptor.
# cython: profile=True
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
import cmath, math
cimport numpy as np
import numpy as np
'''
Based on _hog.py from https://github.com/scikit-image/scikit-image
@TimSC
TimSC / splitprow.py
Created July 2, 2013 19:04
Filter KML by way type by Tim Sheerman-Chase, 2013 This file may be used under CC0, http://creativecommons.org/publicdomain/zero/1.0/
#Filter KML by way type
#by Tim Sheerman-Chase, 2013
#This file may be used under CC0, http://creativecommons.org/publicdomain/zero/1.0/
import xml.etree.ElementTree as ET
import sys
def GetMetaData(place):
out = {}
@TimSC
TimSC / tut3extended.py
Created August 3, 2013 21:52
PyODE tutorial 3 with a partial OOP design and spheres
# pyODE example 3: Collision detection
# Originally by Matthias Baas.
# Updated by Pierre Gay to work without pygame or cgkit.
import sys, os, random, time
from math import *
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
@TimSC
TimSC / gltexture.py
Last active December 22, 2015 03:38
Demo to display opengl texture that is read from a file. This code is public domain/CC0.
SCREEN_SIZE = (800, 600)
import math
from OpenGL.GL import *
from OpenGL.GLU import *
import pygame
from pygame.locals import *