Skip to content

Instantly share code, notes, and snippets.

View mtschirs's full-sized avatar

mtschirs mtschirs

View GitHub Profile
#!/usr/bin/python3
import base64
import hmac
import struct
import time
def hotp(key, counter, digits=6, digest='sha1'):
key = base64.b32decode(key.upper() + '=' * ((8 - len(key)) % 8))
counter = struct.pack('>Q', counter)
@mtschirs
mtschirs / convert_features_opencv_traincascade.py
Created February 4, 2015 07:12
Converting the new OpenCV haar cascades into the js-objectdetect format.
import xml.etree.ElementTree
'''
Classifier - array layout:
[width, height, threshold, num_simple_classifiers, tilted, num_features, f1, f2, f3, f4, f_weight, simple_threshold, left_val, right, val, ...]
'''
wrapper = "(function(module) {\n" + \
" \"use strict\";\n" + \
" \n" + \