pbar = progressbar.ProgressBar(maxval=conf["num_distraction_images"],
                               widgets=widgets).start()
print("[INFO] describing distraction ROIs...")

# loop over the desired number of distraction images
for i in np.arange(0, conf["num_distraction_images"]):
    # randomly select a distraction images, load it, convert it to grayscale, and
    # then extract random pathces from the image
    print(dstPaths)
    image = cv2.imread(random.choice(dstPaths))
    image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    patches = extract_patches_2d(
        image,
        tuple(conf["window_dim"]),
        max_patches=conf["num_distractions_per_image"])

    # loop over the patches
    for patch in patches:
        # extract features from the patch, then update teh data and label list
        features = hog.describe(patch)
        data.append(features)
        labels.append(-1)

    # update the progress bar
    pbar.update(i)

# dump the dataset to file
pbar.finish()
print("[INFO] dumping features and labels to file...")
dataset.dump_dataset(data, labels, conf["features_path"], "features")
    (boxes, probs) = od.detect(gray,
                               conf["window_dim"],
                               winStep=conf["hn_window_step"],
                               pyramidScale=conf["hn_pyramid_scale"],
                               minProb=conf["hn_min_probability"])

    # loop over the bounding boxes
    for (prob, (startX, startY, endX, endY)) in zip(probs, boxes):
        # extract the ROI from the image, resize it to a known, canonical size, extract
        # HOG features from teh ROI, and finally update the data
        roi = cv2.resize(gray[startY:endY, startX:endX],
                         tuple(conf["window_dim"]),
                         interpolation=cv2.INTER_AREA)
        features = hog.describe(roi)
        data.append(np.hstack([[prob], features]))

    # update the progress bar
    pbar.update(i)

# sort the data points by confidence
pbar.finish()
print("[INFO] sorting by probability...")
data = np.array(data)
data = data[data[:, 0].argsort()[::-1]]

# dump the dataset to file
print("[INFO] dumping hard negatives to file...")
dataset.dump_dataset(data[:, 1:], [-1] * len(data),
                     conf["features_path"],
                     "hard_negatives",
                     writeMethod="a")