Skip to content

Instantly share code, notes, and snippets.

View creotiv's full-sized avatar

Andrey Nikishaev creotiv

View GitHub Profile
@creotiv
creotiv / MusicLights.ino
Created January 24, 2016 11:06
Arduin MusicLights example
#define OCTAVE 1 // // Group buckets into octaves
#define OCT_NORM 0 // Don't normalise octave intensities by number of bins
#define FHT_N 256 // set to 256 point fht
#include <FHT.h> // include the library
int noise[] = {90, 125, 147, 143, 128, 123, 104, 89}; //just test output without in silence, and use values from ocatve bins
//int noise[] = {90, 85, 147, 143, 128, 123, 104, 89}; //just test output without in silence, and use values from ocatve bins
// leds
@creotiv
creotiv / gist:f440cd524596d78787ae
Created February 8, 2016 15:48
Circle packing problem
http://www.codeproject.com/Articles/42067/2D-Circle-Packing-algorithm-ported-to-C
http://stackoverflow.com/questions/3851668/position-n-circles-of-different-radii-inside-a-larger-circle-without-overlapping
@creotiv
creotiv / MainActivity.java
Created September 25, 2016 17:09
ReactNative permission model fix for Android
package com.example.app;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
@creotiv
creotiv / vehicle_counter.py
Last active August 29, 2018 13:30
Class that used in car counting during CV traffic analysis
import logging
import math
import numpy as np
from scipy import spatial
import cv2
# ============================================================================
CAR_COLOURS = [ (0,0,255), (0,106,255), (0,216,255), (0,255,182), (0,255,76)
, (144,255,0), (255,255,0), (255,148,0), (255,0,178), (220,0,255) ]
import sys
sys.path.append("../libs")
import tfutils
import numpy as np
import tensorflow as tf
import tensorflow.contrib.graph_editor as ge
##########################################################################
VGG_MEAN = [103.939, 116.779, 123.68]
# old
conv1 = _conv_layer(image, 32, 9, 1)
conv2 = _conv_layer(conv1, 64, 3, 2)
conv3 = _conv_layer(conv2, 128, 3, 2)
resid1 = _residual_block(conv3, 3)
resid2 = _residual_block(resid1, 3)
resid3 = _residual_block(resid2, 3)
resid4 = _residual_block(resid3, 3)
resid5 = _residual_block(resid4, 3)
conv_t1 = _conv_tranpose_layer(resid5, 64, 3, 2)
@creotiv
creotiv / yolo.py
Last active September 4, 2017 11:28
from ctypes import *
import os
import random
import numpy as np
import skvideo.io
with open('names.txt') as fp:
NAMES = {i: name.strip() for i, name in enumerate(fp)}
import os
import logging
import logging.handlers
import random
import numpy as np
import skvideo.io
import cv2
import matplotlib.pyplot as plt
def filter_mask(img):
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2, 2))
# Fill any small holes
closing = cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel)
# Remove noise
opening = cv2.morphologyEx(closing, cv2.MORPH_OPEN, kernel)
# Dilate to merge adjacent blobs
def get_centroid(x, y, w, h):
x1 = int(w / 2)
y1 = int(h / 2)
cx = x + x1
cy = y + y1
return (cx, cy)
def detect_vehicles(fg_mask, min_contour_width=35, min_contour_height=35):