Пример #1
0
import progressbar
import argparse
import pickle
import random
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-c",
                "--conf",
                required=True,
                help="path to the configuration file")
args = vars(ap.parse_args())

# load the configuration file and initialize the data list
conf = conf.Conf(args["conf"])
data = []

# load the classifier, then initialize the Histogram of Oriented Gradients descriptor
# and the object detector
model = pickle.loads(open(conf["classifier_path"], "rb").read())
hog = hog.HOG(orientations=conf["orientations"],
              pixelsPerCell=tuple(conf["pixels_per_cell"]),
              cellsPerBlock=tuple(conf["cells_per_block"]),
              normalise=conf["normalize"])
od = objectdetector.ObjectDetector(model, hog)

# grab the set of distraction paths and randomly sample them
dstPaths = list(paths.list_images(conf["image_distractions"]))
dstPaths = random.sample(dstPaths, 50)
Пример #2
0
from skimage import feature
from pyimagesearch.utils import dataset
from pyimagesearch.utils import conf
from imutils import paths
from scipy import io
import numpy as np
import progressbar
import argparse
import random
import cv2

ap = argparse.ArgumentParser()
ap.add_argument('-c', '--conf', required=True, help='path to config file')
args = ap.parse_args()

conf = conf.Conf(args.conf)

# hog = HOG
data = []
labels = []

# feature.hog(image, orientations=conf["orientations"], pixels_per_cell=tuple(conf["pixels_per_cell"]),
#             cells_per_block=tuple(conf["cells_per_block"]), transform_sqrt=conf["normalize"])

# select ground-truth images and select a percentage of them for training
trnPaths = list(paths.list_images(conf["image_dataset"]))
trnPaths = random.sample(trnPaths, int(len(trnPaths) * conf["percent_gt_images"]))
print("[INFO] describing training ROIs...")

# set up the progress bar
widgets = ["Extracting: ", progressbar.Percentage(), " ", progressbar.Bar(), " ", progressbar.ETA()]