Mercurial Hosting > traffic-intelligence
comparison scripts/extract-appearance-images.py @ 906:a57e6fbcd8e3
minor
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 23 Jun 2017 00:03:17 -0400 |
parents | 0e017178f7ab |
children | cd038493f8c6 |
comparison
equal
deleted
inserted
replaced
905:0e017178f7ab | 906:a57e6fbcd8e3 |
---|---|
53 | 53 |
54 if undistort: # setup undistortion | 54 if undistort: # setup undistortion |
55 [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) | 55 [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) |
56 height, width = map1.shape | 56 height, width = map1.shape |
57 | 57 |
58 print(timeInterval) | |
59 if capture.isOpened(): | 58 if capture.isOpened(): |
60 ret = True | 59 ret = True |
61 frameNum = timeInterval.first | 60 frameNum = timeInterval.first |
62 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, frameNum) | 61 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, frameNum) |
63 lastFrameNum = timeInterval.last | 62 lastFrameNum = timeInterval.last |
68 print('frame number: {}'.format(frameNum)) | 67 print('frame number: {}'.format(frameNum)) |
69 if undistort: # undistort only if necessary | 68 if undistort: # undistort only if necessary |
70 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) | 69 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) |
71 for obj in objects: | 70 for obj in objects: |
72 if obj.existsAtInstant(frameNum): | 71 if obj.existsAtInstant(frameNum): |
73 if (10+frameNum-obj.getFirstInstant())%args.nFramesStep == 0: # todo find next non zero image if none | 72 if (10+frameNum-obj.getFirstInstant())%args.nFramesStep == 0: |
73 # todo find next non zero image if none | |
74 # todo get several images if different features (measure of similarity) | |
74 croppedImg = cvutils.imageBox(img, obj, frameNum, invHomography, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels) | 75 croppedImg = cvutils.imageBox(img, obj, frameNum, invHomography, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels) |
75 if croppedImg is not None: | 76 if croppedImg is not None: |
76 imsave(args.directoryName+os.sep+moving.userTypeNames[obj.getUserType()]+os.sep+args.imagePrefix+'-{}-{}.png'.format(obj.getNum(), frameNum), croppedImg) | 77 imsave(args.directoryName+os.sep+moving.userTypeNames[obj.getUserType()]+os.sep+args.imagePrefix+'-{}-{}.png'.format(obj.getNum(), frameNum), croppedImg) |
77 elif obj.getLastInstant() == frameNum: | 78 elif obj.getLastInstant() == frameNum: |
78 objects.remove(obj) | 79 objects.remove(obj) |