Mercurial Hosting > traffic-intelligence
changeset 905:0e017178f7ab
correct bug in classify-objects script when correcting for distrotion
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 22 Jun 2017 23:40:16 -0400 |
parents | 8f60ecfc2f06 |
children | a57e6fbcd8e3 |
files | scripts/classify-objects.py scripts/extract-appearance-images.py |
diffstat | 2 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/classify-objects.py Thu Jun 22 18:08:46 2017 -0400 +++ b/scripts/classify-objects.py Thu Jun 22 23:40:16 2017 -0400 @@ -73,6 +73,7 @@ if undistort: # setup undistortion [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) + height, width = map1.shape pastObjects = [] currentObjects = []
--- a/scripts/extract-appearance-images.py Thu Jun 22 18:08:46 2017 -0400 +++ b/scripts/extract-appearance-images.py Thu Jun 22 23:40:16 2017 -0400 @@ -3,7 +3,7 @@ import numpy as np, cv2 import argparse, os from pandas import read_csv -from matplotlib.pyplot import imsave +from matplotlib.pyplot import imsave, imshow, figure import cvutils, moving, ml, storage @@ -53,6 +53,7 @@ if undistort: # setup undistortion [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) + height, width = map1.shape print(timeInterval) if capture.isOpened(): @@ -69,10 +70,10 @@ img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) for obj in objects: if obj.existsAtInstant(frameNum): - if (obj.getFirstInstant()-frameNum)%args.nFramesStep == 0: # todo find next non zero image if none + if (10+frameNum-obj.getFirstInstant())%args.nFramesStep == 0: # todo find next non zero image if none croppedImg = cvutils.imageBox(img, obj, frameNum, invHomography, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels) if croppedImg is not None: - imsave(args.directoryName+os.sep+moving.userTypeNames[obj.getUserType()]+args.imagePrefix+'-{}-{}.png'.format(obj.getNum(), frameNum), croppedImg) + imsave(args.directoryName+os.sep+moving.userTypeNames[obj.getUserType()]+os.sep+args.imagePrefix+'-{}-{}.png'.format(obj.getNum(), frameNum), croppedImg) elif obj.getLastInstant() == frameNum: objects.remove(obj) frameNum += 1