Skip to content

Instantly share code, notes, and snippets.

View kushalvyas's full-sized avatar
😄
Focusing

Kushal Vyas kushalvyas

😄
Focusing
View GitHub Profile
/*
Author : Kushal Vyas
Code for template matching as implemented by opencv.
*/
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/opencv.hpp"
#include "iostream"
#include "cmath"
"""
Template matching using opencv
Run : python file.py <templateImage> <actualImage>
"""
import sys, cv2
import numpy as np
"""
Using SKLearns API for performing Kmeans clustering.
Using sklearn.datasets.make_blobs for generating randomized gaussians
for clustering.
"""
import numpy as np
from matplotlib import pyplot as plt
from sklearn.cluster import KMeans
n_samples = 1000
n_features = 5;
n_clusters = 3;
# aint this sweet
X, y = make_blobs(n_samples, n_features)
# X => array of shape [nsamples,nfeatures] ;;; y => array of shape[nsamples]
# X : generated samples, y : integer labels for cluster membership of each sample
import cv2
import numpy as np
from glob import glob
import argparse
from helpers import *
class BOV:
def __init__(self, no_clusters):
self.no_clusters = no_clusters
self.train_path = None
import cv2
import numpy as np
from glob import glob
from sklearn.cluster import KMeans
from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
from matplotlib import pyplot as plt
class ImageHelpers:
def __init__(self):
def developVocabulary(self,n_images, descriptor_list, kmeans_ret = None):
"""
Each cluster denotes a particular visual word
Every image can be represeted as a combination of multiple
visual words. The best method is to generate a sparse histogram
that contains the frequency of occurence of each visual word
Thus the vocabulary comprises of a set of histograms of encompassing
all descriptions for all images
@kushalvyas
kushalvyas / example_population.py
Created September 8, 2016 18:43
Example population and chromosome generation for http://bitsmakemecrazy.com/gen_8Q.html#gen_8Q
def generateChromosome():
# randomly generates a sequence of board states.
global nQueens
init_distribution = np.arange(nQueens)
np.random.shuffle(init_distribution)
return init_distribution
def generatePopulation(population_size = 100):
global POPULATION
@kushalvyas
kushalvyas / 8queens.py
Created September 8, 2016 19:44
8 queens problem
"""
check out http://kushalvyas.github.io/gen_8Q.html#gen_8Q
@file : queens.py
Illustration of 8 queens using GA - evolution
"""
import numpy as np
@kushalvyas
kushalvyas / train_model.prototxt
Created January 20, 2017 17:35
Architecture of AlexNET
name: "CaltechNET"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {