Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 893:ff92801e5c54
updated hog to scikit-image 0.13 (needed to add a block_norm attribute in classifier.cfg)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 30 May 2017 16:10:18 -0400 |
parents | e2452abba0e7 |
children | 1fc901d983ed |
comparison
equal
deleted
inserted
replaced
892:f766fe0995f4 | 893:ff92801e5c54 |
---|---|
1575 return userType2Num['car'] | 1575 return userType2Num['car'] |
1576 self.appearanceClassifier = CarClassifier() | 1576 self.appearanceClassifier = CarClassifier() |
1577 | 1577 |
1578 self.userTypes = {} | 1578 self.userTypes = {} |
1579 | 1579 |
1580 def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock): | 1580 def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm): |
1581 '''Extracts the image box around the object | 1581 '''Extracts the image box around the object |
1582 (of square size max(width, height) of the box around the features, | 1582 (of square size max(width, height) of the box around the features, |
1583 with an added px or py for width and height (around the box)) | 1583 with an added px or py for width and height (around the box)) |
1584 computes HOG on this cropped image (with parameters rescaleSize, orientations, pixelsPerCell, cellsPerBlock) | 1584 computes HOG on this cropped image (with parameters rescaleSize, orientations, pixelsPerCell, cellsPerBlock) |
1585 and applies the SVM model on it''' | 1585 and applies the SVM model on it''' |
1586 croppedImg, yCropMin, yCropMax, xCropMin, xCropMax = cvutils.imageBox(img, self, instant, homography, width, height, px, py, minNPixels) | 1586 croppedImg, yCropMin, yCropMax, xCropMin, xCropMax = cvutils.imageBox(img, self, instant, homography, width, height, px, py, minNPixels) |
1587 if croppedImg is not None and len(croppedImg) > 0: | 1587 if croppedImg is not None and len(croppedImg) > 0: |
1588 hog = cvutils.HOG(croppedImg, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, visualize=False, normalize=False) | 1588 hog = cvutils.HOG(croppedImg, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm, visualize=False, normalize=False) |
1589 self.userTypes[instant] = int(self.appearanceClassifier.predict(hog)) | 1589 self.userTypes[instant] = int(self.appearanceClassifier.predict(hog)) |
1590 else: | 1590 else: |
1591 self.userTypes[instant] = userType2Num['unknown'] | 1591 self.userTypes[instant] = userType2Num['unknown'] |
1592 | 1592 |
1593 def classifyUserTypeHoGSVM(self, pedBikeCarSVM = None, width = 0, height = 0, homography = None, images = None, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), minSpeedEquiprobable = -1, speedProbabilities = None, aggregationFunc = median, nInstantsIgnoredAtEnds = 0, px = 0.2, py = 0.2, minNPixels = 800, rescaleSize = (64, 64), orientations = 9, pixelsPerCell = (8,8), cellsPerBlock = (2,2)): | 1593 def classifyUserTypeHoGSVM(self, pedBikeCarSVM = None, width = 0, height = 0, homography = None, images = None, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), minSpeedEquiprobable = -1, speedProbabilities = None, aggregationFunc = median, nInstantsIgnoredAtEnds = 0, px = 0.2, py = 0.2, minNPixels = 800, rescaleSize = (64, 64), orientations = 9, pixelsPerCell = (8,8), cellsPerBlock = (2,2)): |