@@ -140,15 +140,13 @@ def findPupil(eyePhoto):
140140 cv2 .drawContours (dilate ,contours ,- 1 ,(255 ,255 ,255 ),- 1 )
141141 if DEBUG :
142142 cv .ShowImage ("Contours" , cv .fromarray (dilate ))
143- cv .WaitKey (0 )
144- cv .DestroyWindow ("Contours" )
145143
146144 print "type of dilate: " + str (type (dilate ))
147145 print "size of dilate: " + str (dilate .size )
148146
149147 cv2 .imwrite ("dilate.jpg" , dilate )
150148 big = bigContinWC (dilate )
151- print big [ 0 ]
149+ print "Big is " + str ( big )
152150
153151
154152 eye = cv .fromarray (eyePhoto )
@@ -159,6 +157,16 @@ def findPupil(eyePhoto):
159157 cv .DestroyWindow ("Biggest" )
160158
161159
160+ def swap_dims (arr ):
161+ '''
162+ swap the dimension of a 2d array
163+ '''
164+ newArr = np .empty ([len (arr [0 ]),len (arr )])
165+ for x in range (len (arr )):
166+ for y in range (len (arr [x ])):
167+ newArr [y ][x ] = arr [x ][y ]
168+
169+ return newArr
162170
163171def bigContinWC (photo ):
164172 '''
@@ -177,22 +185,21 @@ def bigContinWC(photo):
177185 bigY = - 1
178186 lineX = - 1
179187 lineY = - 1
180- for x in range (len (photo )):
188+ print "y goes from 0 to " + str (len (photo ) - 1 )
189+ print "x goes from 0 to " + str (len (photo [0 ]) - 1 )
190+ for y in range (len (photo [0 ])):
181191 lineWC = 0
182- wc = 0
192+ wc = 0
183193 tempCount = 0
184- for y in range (len (photo [ x ] )):
194+ for x in range (len (photo )):
185195 pixel = photo [x ][y ]
186196
187197 if pixel == 255 :
188- print "yes its white\n "
189198 tempCount = tempCount + 1
190- print tempCount
191199 elif tempCount > wc :
192- print "black"
193200 wc = tempCount
194- lineY = y - wc
195201 lineX = x
202+ lineY = y - wc
196203 tempCount = 0
197204 lineWC = wc
198205 if lineWC > bigWC :
0 commit comments