Ejemplo n.º 1
0
import argparse
import time
import cv2

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="path to the input image")
ap.add_argument("-w", "--width", type=int, help="width of sliding window")
ap.add_argument("-t", "--height", type=int, help="height of sliding window")
ap.add_argument("-s",
                "--scale",
                type=float,
                default=1.5,
                help="scale factor size")
args = vars(ap.parse_args())

image = cv2.imread(args["image"])
(winW, winH) = (args["width"], args["height"])

for layer in pyramid(image, scale=args["scale"]):
    for (x, y, window) in sliding_window(layer,
                                         stepSize=32,
                                         windowSize=(winW, winH)):
        if window.shape[0] != winH or window.shape[1] != winW:
            continue

        clone = layer.copy()
        cv2.rectangle(clone, (x, y), (x + winW, y + winH), (0, 255, 0), 2)
        cv2.imshow("Window", clone)
        cv2.waitKey(1)
        time.sleep(0.025)
Ejemplo n.º 2
0
from pyimagesearch.object_detection.helpers import pyramid
import argparse
import cv2
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True, help='path to the image')
ap.add_argument('-s',
                '--scale',
                required=True,
                default=1.5,
                help='scale factor size')
args = vars(ap.parse_args())

image = cv2.imread(args['image'])

for (i, layer) in enumerate(pyramid(image, scale=float(args['scale']))):
    cv2.imshow('Layer {}'.format(i + 1), layer)
    cv2.waitKey(0)
Ejemplo n.º 3
0
# USAGE
# python test_pyramid.py --image florida_trip.png --scale 1.5

# import the necessary packages
from pyimagesearch.object_detection.helpers import pyramid
import argparse
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="path to the input image")
ap.add_argument("-s",
                "--scale",
                type=float,
                default=1.5,
                help="scale factor size")
args = vars(ap.parse_args())

# load the input image
image = cv2.imread(args["image"])

# loop over the layers of the image pyramid and display them
for (i, layer) in enumerate(pyramid(image, scale=args["scale"])):
    cv2.imshow("Layer {}".format(i + 1), layer)
    cv2.waitKey(0)
Ejemplo n.º 4
0
                help='width of sliding window')
ap.add_argument('-t',
                '--height',
                required=True,
                type=int,
                help='height of sliding window')
ap.add_argument('-s',
                '--scale',
                type=float,
                default=1.5,
                help='scale factor size')
args = vars(ap.parse_args())

image = cv2.imread(args['image'])
(winW, winH) = (args['width'], args['height'])

for layer in pyramid(image, scale=args['scale']):
    for (x, y, window) in sliding_window(layer,
                                         stepSize=32,
                                         windowSize=(winW, winH)):
        # if the current window does not meet our desired window size, ignore it
        if window.shape[0] != winH or window.shape[1] != winW:
            continue

        clone = layer.copy()
        cv2.rectangle(clone, (x, y), (x + winW, y + winH), (0, 255, 0), 2)
        cv2.imshow('window', clone)

        cv2.waitKey(1)
        time.sleep(0.025)