예제 #1
0
def main():
    charDetector = hog.HOG()
    cap = cv2.VideoCapture(0)
    while True:
        ret, frame = cap.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('s', gray)
        charDetector.describe(gray)

        if cv2.waitKey(1) == ord('q'):
            break
예제 #2
0
def load_data(path):
    X = []
    set_type = path.split('/')[-3]
    class_type = path.split('/')[-2]
    count = 1
    total = len(glob.glob(path))
    for im in glob.glob(path):
        print(str(count) + '/' + str(total) + ' —— ' + str(im))
        hog_vector = hog.HOG(im)
        X.append(hog_vector)
        count += 1
    X = np.array(X)
    return X
예제 #3
0
def load_data(path):
    X = []
    set_type = path.split('/')[-3]
    class_type = path.split('/')[-2]
    for im in glob.glob(path):
        print(im)
        hog_vector = hog.HOG(im)
        print(hog_vector.shape)
        X.append(hog_vector)
    X = np.array(X)
    y = np.ones(
        X.shape[0]) if class_type == 'pos' else -1 * np.ones(X.shape[0])
    return X, y
예제 #4
0
from sklearn.externals import joblib
from sklearn.svm import LinearSVC
import numpy as np
import hog
import cv2
import dataset

model = joblib.load("model/svm.cpickle")
hg = hog.HOG(orientations=18,
             pixelPerCell=(10, 10),
             cellsPerBlock=(1, 1),
             trasforme=True)
cap = cv2.VideoCapture(0)

while True:
    ret, image = cap.read()
    image = cv2.imread("cellphone.png", 1)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    blurred = cv2.GaussianBlur(gray, (5, 5), 0)
    edged = cv2.Canny(blurred, 30, 150)
    (_, cnt, _) = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL,
                                   cv2.CHAIN_APPROX_SIMPLE)
    cnts = sorted([(c, cv2.boundingRect(c)[0]) for c in cnt],
                  key=lambda x: x[1])
    for (c, _) in cnts:
        (x, y, w, h) = cv2.boundingRect(c)
        if w >= 7 and h >= 20:
            rio = gray[y:y + h, x:x + w]
            _, thresh = cv2.threshold(rio.copy(), 0, 255,
                                      cv2.THRESH_BINARY + cv2.THRESH_OTSU)
            thresh = dataset.deskew(thresh, 20)
예제 #5
0
import hog
import cv2 as cv

# Read in the test image
img = cv.imread("../Phantom.jpg")
img = cv.resize(img, (500, 500))

img2 = cv.imread("../Phantom_Melissa.jpg")
img2 = cv.resize(img2, (467, 350))

img3 = cv.imread("../Pixel_melissa.png")

hog = hog.HOG()
hog.run_hog(img)