# USAGE # python train.py --dataset data/digits.csv --model models/svm.cpickle # import the necessary packages from sklearn.externals import joblib from sklearn.svm import LinearSVC from pyimagesearch.hog import HOG from pyimagesearch import dataset import argparse dataset_path = "data/digits.csv" models_path = "models/svm.cpickle_01" # load the dataset and initialize the data matrix (digits, target) = dataset.load_digits(dataset_path) data = [] # initialize the HOG descriptor hog = HOG(orientations=18, pixelsPerCell=(10, 10), cellsPerBlock=(1, 1), normalize=True) # loop over the images for image in digits: # deskew the image, center it image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # describe the image and update the data matrix hist = hog.describe(image) data.append(hist)
import argparse # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-d", "--dataset", required=True, help="path to the dataset file") ap.add_argument("-m", "--model", required=True, help="path to where the model will be stored") args = vars(ap.parse_args()) # load the dataset and initialize the data matrix (digits, target) = dataset.load_digits(args["dataset"]) data = [] # initialize the HOG descriptor hog = HOG(orientations=18, pixelsPerCell=(10, 10), cellsPerBlock=(1, 1), transform=True) # loop over the images for image in digits: # deskew the image, center it image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # describe the image and update the data matrix
from pyimagesearch.hog import HOG from pyimagesearch import dataset import argparse ap = argparse.ArgumentParser() ap.add_argument("-d", "--dataset", required=True, help="path to the dataset file") ap.add_argument("-m", "--model", required=True, help="path to where the model will be stored") args = vars(ap.parse_args()) (digits, target) = dataset.load_digits(args['dataset']) data = [] # 18 orientations for the gradient magnitude histogram, 10 pixels for each # cell, and 1 cell per block. hog = Hog(orientations=18, pixelsPerCell=(10, 10), cellsPerBlock=(1, 1), transform=True) for image in digits: image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # HOG feature vector is computed for the pre-processed image by calling # the describe method hist = hog.describe(image) data.appned(hist)
from sklearn.svm import LinearSVC from pyimagesearch.hog import HOG from pyimagesearch import dataset import argparse import cPickle # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-d", "--dataset", required = True, help = "path to the dataset file") ap.add_argument("-m", "--model", required = True, help = "path to where the model will be stored") args = vars(ap.parse_args()) # load the dataset and initialize the data matrix (digits, target) = dataset.load_digits(args["dataset"]) data = [] # initialize the HOG descriptor hog = HOG(orientations = 18, pixelsPerCell = (10, 10), cellsPerBlock = (1, 1), normalize = True) # loop over the images for image in digits: # deskew the image, center it image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # describe the image and update the data matrix hist = hog.describe(image) data.append(hist)
import cv2 image = cv2.imread('/Users/ryanzotti/Downloads/IMG_0302.JPG') #image = cv2.imread('/Users/ryanzotti/Documents/repos/OpenCvDigits/images/cellphone.png') #print(image.shape[0]) #print(image.shape[1]) # import the necessary packages from sklearn.externals import joblib from sklearn.svm import LinearSVC from pyimagesearch.hog import HOG from pyimagesearch import dataset import argparse # load the dataset and initialize the data matrix (digits, target) = dataset.load_digits( "/Users/ryanzotti/Documents/repos/OpenCvDigits/data/digits.csv") data = [] # initialize the HOG descriptor hog = HOG(orientations=18, pixelsPerCell=(10, 10), cellsPerBlock=(1, 1), normalize=True) image = digits[0] image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # loop over the images for image in digits: # deskew the image, center it
image = cv2.imread('/Users/ryanzotti/Downloads/IMG_0302.JPG') #image = cv2.imread('/Users/ryanzotti/Documents/repos/OpenCvDigits/images/cellphone.png') #print(image.shape[0]) #print(image.shape[1]) # import the necessary packages from sklearn.externals import joblib from sklearn.svm import LinearSVC from pyimagesearch.hog import HOG from pyimagesearch import dataset import argparse # load the dataset and initialize the data matrix (digits, target) = dataset.load_digits("/Users/ryanzotti/Documents/repos/OpenCvDigits/data/digits.csv") data = [] # initialize the HOG descriptor hog = HOG(orientations = 18, pixelsPerCell = (10, 10), cellsPerBlock = (1, 1), normalize = True) image = digits[0] image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20)) # loop over the images for image in digits: # deskew the image, center it image = dataset.deskew(image, 20) image = dataset.center_extent(image, (20, 20))