comparison python/cvutils.py @ 894:0c1fed9e8862

updated requirements.txt, removed minor PIL dependency
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 01 Jun 2017 10:33:07 -0400
parents ff92801e5c54
children 739acd338cc0
comparison
equal deleted inserted replaced
893:ff92801e5c54 894:0c1fed9e8862
57 def int2FOURCC(x): 57 def int2FOURCC(x):
58 fourcc = '' 58 fourcc = ''
59 for i in xrange(4): 59 for i in xrange(4):
60 fourcc += unichr((x >> 8*i)&255) 60 fourcc += unichr((x >> 8*i)&255)
61 return fourcc 61 return fourcc
62
63 def plotLines(filename, origins, destinations, w = 1, resultFilename='image.png'):
64 '''Draws lines over the image '''
65 import Image, ImageDraw # PIL
66
67 img = Image.open(filename)
68
69 draw = ImageDraw.Draw(img)
70 #draw = aggdraw.Draw(img)
71 #pen = aggdraw.Pen("red", width)
72 for p1, p2 in zip(origins, destinations):
73 draw.line([p1.x, p1.y, p2.x, p2.y], width = w, fill = (256,0,0))
74 #draw.line([p1.x, p1.y, p2.x, p2.y], pen)
75 del draw
76
77 #out = utils.openCheck(resultFilename)
78 img.save(resultFilename)
79 62
80 def rgb2gray(rgb): 63 def rgb2gray(rgb):
81 return dot(rgb[...,:3], [0.299, 0.587, 0.144]) 64 return dot(rgb[...,:3], [0.299, 0.587, 0.144])
82 65
83 def matlab2PointCorrespondences(filename): 66 def matlab2PointCorrespondences(filename):