예제 #1
0
import cv2
import numpy as np
from car_detector.detector import car_detector, bow_features
from car_detector.non_maximum import non_max_suppression_fast as nms
from car_detector.pyramid import pyramid
from car_detector.sliding_window import sliding_window


def in_range(number, test, thresh=0.2):
    return abs(number - test) < thresh


test_image = "../images/cars.jpg"

svm, extractor = car_detector()
detect = cv2.xfeatures2d.SIFT_create()

w, h = 100, 40
img = cv2.imread(test_image)

rectangles = []
counter = 1
scaleFactor = 1.25
scale = 1
font = cv2.FONT_HERSHEY_PLAIN

for resized in pyramid(img, scaleFactor):
    scale = float(img.shape[1]) / float(resized.shape[1])
    for (x, y, roi) in sliding_window(resized, 20, (100, 40)):

        if roi.shape[1] != w or roi.shape[0] != h:
예제 #2
0
import cv2
import numpy as np
from car_detector.detector import car_detector, bow_features
from car_detector.pyramid import pyramid
from car_detector.non_maximum import non_max_suppression_fast as nms
from car_detector.sliding_window import sliding_window
import urllib

def in_range(number, test, thresh=0.2):
  return abs(number - test) < thresh

test_image = "/home/dvaliu/Downloads/CarData/TestImages/test-10.pgm"
img_path = "/home/dvaliu/Downloads/CarData/TestImages/test-10.pgm"

svm, extractor = car_detector()
detect = cv2.xfeatures2d.SIFT_create()

w, h = 100, 40
img = cv2.imread(img_path)
#img = cv2.imread(test_image)

rectangles = []
counter = 1
scaleFactor = 1.25
scale = 1
font = cv2.FONT_HERSHEY_PLAIN

for resized in pyramid(img, scaleFactor):
  scale = float(img.shape[1]) / float(resized.shape[1])
  for (x, y, roi) in sliding_window(resized, 20, (100, 40)):
    if roi.shape[1] != w or roi.shape[0] != h: