def testImage(self, image, scale=1, subwindow=None): imgProcessor = ImageProcessor(image, scale=scale) imgProcessor.getIntegralChannels(6) if subwindow != None: nsx, nsy, nw, nh = utils.getDetectionWindow( subwindow, imgProcessor.getWidth(), imgProcessor.getHeight(), scale) else: nsx, nsy, nw, nh = 0, 0, imgProcessor.getWidth( ), imgProcessor.getHeight() windows = [] for startx in xrange(nsx, nsx + nw - 64, 16): for starty in xrange(nsy, nsy + nh - 128, 16): windows.append( (startx, starty, imgProcessor.getFeature(startx, starty, self.featureCoords))) probs = self.classifier.predict_proba([w[2] for w in windows]) classes = self.classifier.predict([w[2] for w in windows]) results = [] for i in xrange(0, len(windows)): results.append((windows[i][0], windows[i][1], probs[i])) return results, classes
def getImgFeatures(self, imgPath, noSamples=1, test=False): imgProc = ImageProcessor( path.realpath(path.join(self.dirPath, imgPath))) imgProc.getIntegralChannels(6) features = [] for i in xrange(0, noSamples): if test: startx = random.randrange(3, imgProc.getWidth() - 3 - 64, 16) starty = random.randrange(3, imgProc.getHeight() - 3 - 128, 16) else: startx = random.randrange(3, imgProc.getWidth() - 3 - 64, 16) starty = random.randrange(3, imgProc.getHeight() - 3 - 128, 16) features.append( imgProc.getFeature(startx, starty, self.featureCoords)) return features
def getImgFeature(self, imgPath, test=False): imgProc = ImageProcessor( path.realpath(path.join(self.dirPath, imgPath))) imgProc.getIntegralChannels(6) if test: return imgProc.getFeature(3, 3, self.featureCoords) return imgProc.getFeature(16, 16, self.featureCoords)
def getFeature(self, img): imgProcessor = ImageProcessor(img) imgProcessor.getIntegralChannels(6) # needed for centering the 64x128 image startx = int((imgProcessor.getWidth() - 64) / 2) starty = int((imgProcessor.getHeight() - 128) / 2) feature = imgProcessor.getFeature(startx, starty, self.featureCoords) return feature
def getWindowsAndDescriptors(self, image, scale, subwindow=None): imgProcessor = ImageProcessor(image, scale=scale) imgProcessor.getIntegralChannels(6) if subwindow != None: nsx, nsy, nw, nh = utils.getDetectionWindow( subwindow, imgProcessor.getWidth(), imgProcessor.getHeight(), scale) else: nsx, nsy, nw, nh = 0, 0, imgProcessor.getWidth( ), imgProcessor.getHeight() windows = [] for startx in xrange(nsx, nsx + nw - 64, 16): for starty in xrange(nsy, nsy + nh - 128, 16): feature = imgProcessor.getFeature(startx, starty, self.featureCoords) windows.append([(startx, starty, 64, 128), feature]) return windows
def getWindowsAndDescriptors(self, image, scale, subwindow=None): imgProcessor = ImageProcessor(image, scale=scale) imgProcessor.getIntegralChannels(6) if subwindow != None: nsx, nsy, nw, nh = utils.getDetectionWindow(subwindow, imgProcessor.getWidth(), imgProcessor.getHeight(), scale) else: nsx, nsy, nw, nh = 0, 0, imgProcessor.getWidth(), imgProcessor.getHeight() windows = [] for startx in xrange(nsx, nsx + nw - 64, 16): for starty in xrange(nsy, nsy + nh - 128, 16): feature = imgProcessor.getFeature(startx, starty, self.featureCoords) windows.append([(startx, starty, 64, 128), feature]) return windows
def testImage(self, image, scale=1, subwindow=None): imgProcessor = ImageProcessor(image, scale=scale) imgProcessor.getIntegralChannels(6) if subwindow != None: nsx, nsy, nw, nh = utils.getDetectionWindow(subwindow, imgProcessor.getWidth(), imgProcessor.getHeight(), scale) else: nsx, nsy, nw, nh = 0, 0, imgProcessor.getWidth(), imgProcessor.getHeight() windows = [] for startx in xrange(nsx, nsx + nw - 64, 16): for starty in xrange(nsy, nsy + nh - 128, 16): windows.append((startx, starty, imgProcessor.getFeature(startx, starty, self.featureCoords))) probs = self.classifier.predict_proba([w[2] for w in windows]) classes = self.classifier.predict([w[2] for w in windows]) results = [] for i in xrange(0, len(windows)): results.append((windows[i][0], windows[i][1], probs[i])) return results, classes