Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 410:91954c76d12c
minor changes to error messages when loading libraries
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 14 Aug 2013 14:23:50 -0400 |
parents | 37c7b46f6e21 |
children | 31604ef1cad4 |
comparison
equal
deleted
inserted
replaced
409:3c271a46b4d4 | 410:91954c76d12c |
---|---|
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 '''Image/Video utilities''' | 2 '''Image/Video utilities''' |
3 | 3 |
4 import Image, ImageDraw # PIL | |
5 try: | 4 try: |
6 import cv2 | 5 import cv2 |
7 opencvAvailable = True | 6 opencvAvailable = True |
8 except ImportError: | 7 except ImportError: |
9 print('OpenCV library could not be loaded') | 8 print('OpenCV library could not be loaded (video replay functions will not be available)') |
10 opencvAvailable = False | 9 opencvAvailable = False |
11 try: | 10 try: |
12 import skimage | 11 import skimage |
13 skimageAvailable = True | 12 skimageAvailable = True |
14 except ImportError: | 13 except ImportError: |
15 print('Scikit-image library could not be loaded') | 14 print('Scikit-image library could not be loaded (HoG-based classification methods will not be available)') |
16 skimageAvailable = False | 15 skimageAvailable = False |
17 | 16 |
18 from sys import stdout | 17 from sys import stdout |
19 | 18 |
20 import utils | 19 import utils |
37 def saveKey(key): | 36 def saveKey(key): |
38 return chr(key&255) == 's' | 37 return chr(key&255) == 's' |
39 | 38 |
40 def drawLines(filename, origins, destinations, w = 1, resultFilename='image.png'): | 39 def drawLines(filename, origins, destinations, w = 1, resultFilename='image.png'): |
41 '''Draws lines over the image ''' | 40 '''Draws lines over the image ''' |
41 import Image, ImageDraw # PIL | |
42 | 42 |
43 img = Image.open(filename) | 43 img = Image.open(filename) |
44 | 44 |
45 draw = ImageDraw.Draw(img) | 45 draw = ImageDraw.Draw(img) |
46 #draw = aggdraw.Draw(img) | 46 #draw = aggdraw.Draw(img) |