1. Install Anaconda
2. run "conda install mingw libpython"
3. run "pip install theano"
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 numpy as np | |
import cv2 | |
from matplotlib import pyplot as plt | |
def show_img(img1, img2, p1, p2, status): | |
h1, w1 = img1.shape[:2] | |
h2, w2 = img2.shape[:2] | |
vis = np.zeros((max(h1, h2), w1+w2), np.uint8) | |
vis[:h1, :w1] = img1 | |
vis[:h2, w1:w1+w2] = img2 |
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 row_contains(data, query): | |
""" | |
Checks row of the matrix for the given condition | |
and returns a list of rows that satisfies the condition | |
""" | |
condition = np.any(query, axis=1) | |
return np.compress(condition, data, axis=0) |
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
#sign to be detected | |
template = cv2.imread('sign.png') | |
#image in which it is to be directed | |
image = cv2.imread('iamge.jpg') | |
template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY) | |
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
res = cv2.matchTemplate(image_gray, template_gray, cv2.TM_CCOEFF_NORMED) | |
threshold = 0.7 |
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 show_contours(contours, img): | |
""" | |
Draw and display contours on the img provided. | |
:contours: - list of contours | |
:img: - on which the contour is suppose to be drawn | |
""" | |
color = np.random.randint(0, 255, (3)).tolist() | |
for cnt in contours: | |
cv2.drawContours(img, [cnt], 0, color, 2) | |
show_img(img) |
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 getprimes(start=2, upto=100): | |
""" | |
Generate primes between a given range defined by | |
:start: and :upto: vars. | |
""" | |
#NOTE: np.arrange is faster then python for loop | |
primes = np.arange(2, upto+1) | |
isprime = np.ones(upto-1, dtype=bool) | |
#find the first prime before starting this loop to optimize | |
for factor in primes[:int(upto**0.5)]: |
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
1. Download Julia.exe | |
2. copy paste the following: | |
run(`git config --global url."https://".insteadOf git://`) | |
this is because the git:// causes an error. |
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 mechanize | |
from urlparse import urlparse, urljoin | |
"""Mechanize will open the link given to it and get the links without breaking much sweat, | |
I am not sure what kind of repository setup you have so i am just going to use a global list named master to store all the succesfully crawled links, I also added a failed_link list that will store the links that the mechanize model was unable to open for further crawling. """ | |
"""I wasn't sure about the links that the program needs to handle or how those links needed to be handled, so this program assumes that the link given to it is a valid link and i tried to make the program such that it doest not fail without warning""" | |
"""to form the repository of sites, the master and failed_links lists needs to be stored. Personally I would prefer storing the data in Mongo in the structure: | |
{'site' : site, |
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
redis-cli -n [DB] keys "pattern" | xargs -d '\n' redis-cli -n [DB] del |
OlderNewer