Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 929:be28a3538dc9
work in progress on projection
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 12 Jul 2017 18:00:53 -0400 |
parents | 063d1267585d |
children | 8ac7f61c6e4f |
comparison
equal
deleted
inserted
replaced
928:063d1267585d | 929:be28a3538dc9 |
---|---|
1576 return userType2Num['car'] | 1576 return userType2Num['car'] |
1577 self.appearanceClassifier = CarClassifier() | 1577 self.appearanceClassifier = CarClassifier() |
1578 # project feature positions | 1578 # project feature positions |
1579 if self.hasFeatures(): | 1579 if self.hasFeatures(): |
1580 for f in self.getFeatures(): | 1580 for f in self.getFeatures(): |
1581 f.projectedPositions = cvutils.projectArray(homography, f.getPositions().asArray(), intrinsicCameraMatrix, distortionCoefficients) | 1581 pp = cvutils.projectArray(homography, f.getPositions().asArray(), intrinsicCameraMatrix, array(distortionCoefficients)).tolist() |
1582 f.positions = Trajectory(pp) | |
1582 self.userTypes = {} | 1583 self.userTypes = {} |
1583 | 1584 |
1584 def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm): | 1585 def classifyUserTypeHoGSVMAtInstant(self, img, instant, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm): |
1585 '''Extracts the image box around the object | 1586 '''Extracts the image box around the object |
1586 (of square size max(width, height) of the box around the features, | 1587 (of square size max(width, height) of the box around the features, |
1587 with an added px or py for width and height (around the box)) | 1588 with an added px or py for width and height (around the box)) |
1588 computes HOG on this cropped image (with parameters rescaleSize, orientations, pixelsPerCell, cellsPerBlock) | 1589 computes HOG on this cropped image (with parameters rescaleSize, orientations, pixelsPerCell, cellsPerBlock) |
1589 and applies the SVM model on it''' | 1590 and applies the SVM model on it''' |
1590 croppedImg = cvutils.imageBox(img, self, instant, homography, width, height, px, py, minNPixels) | 1591 croppedImg = cvutils.imageBox(img, self, instant, width, height, px, py, minNPixels) |
1591 if croppedImg is not None and len(croppedImg) > 0: | 1592 if croppedImg is not None and len(croppedImg) > 0: |
1592 hog = cvutils.HOG(croppedImg, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm, visualize=False, normalize=False) | 1593 hog = cvutils.HOG(croppedImg, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, blockNorm, visualize=False, normalize=False) |
1593 self.userTypes[instant] = int(self.appearanceClassifier.predict(hog)) | 1594 self.userTypes[instant] = int(self.appearanceClassifier.predict(hog)) |
1594 else: | 1595 else: |
1595 self.userTypes[instant] = userType2Num['unknown'] | 1596 self.userTypes[instant] = userType2Num['unknown'] |