This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author : Kushal Vyas | |
Code for template matching as implemented by opencv. | |
*/ | |
#include "opencv2/imgproc/imgproc.hpp" | |
#include "opencv2/opencv.hpp" | |
#include "iostream" | |
#include "cmath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Template matching using opencv | |
Run : python file.py <templateImage> <actualImage> | |
""" | |
import sys, cv2 | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CaltechNET" | |
layer { | |
name: "data" | |
type: "Data" | |
top: "data" | |
top: "label" | |
include { | |
phase: TRAIN | |
} | |
transform_param { |
OlderNewer