@@ -173,10 +173,10 @@ def getthresholdedimg(im):
173
173
174
174
return imgthreshold
175
175
#---------------------------------------------------------
176
- #img is an image (passed in by reference I'm pretty sure )
176
+ #img is an image (passed in by reference)
177
177
#sideName is for output printing purposes
178
178
#this returns an x and y coordinate of the blimp (x = col, y = row)
179
- def procImg (img ,sideName ):
179
+ def procImg (img ,sideName , dispFlag ):
180
180
181
181
#creates empty images of the same size
182
182
imdraw = cv .CreateImage (cv .GetSize (img ), 8 , 3 )
@@ -188,7 +188,7 @@ def procImg(img,sideName):
188
188
imgbluethresh = getthresholdedimg (imgSmooth ) #Get a color thresholed binary image
189
189
cv .Erode (imgbluethresh , imgbluethresh , None , 3 )
190
190
cv .Dilate (imgbluethresh , imgbluethresh , None , 10 )
191
- img2 = cv .CloneImage (imgbluethresh )
191
+ # img2 = cv.CloneImage(imgbluethresh)
192
192
storage = cv .CreateMemStorage (0 )
193
193
contour = cv .FindContours (imgbluethresh , storage , cv .CV_RETR_CCOMP , cv .CV_CHAIN_APPROX_SIMPLE )
194
194
@@ -205,7 +205,11 @@ def procImg(img,sideName):
205
205
206
206
#get the largest contour
207
207
area = bound_rect [2 ]* bound_rect [3 ];
208
- if area > prevArea :
208
+
209
+ if dispFlag :
210
+ print ("Area= " + str (area ))
211
+
212
+ if (area > prevArea and area > 2000 ):
209
213
pt1 = (bound_rect [0 ], bound_rect [1 ])
210
214
pt2 = (bound_rect [0 ] + bound_rect [2 ], bound_rect [1 ] + bound_rect [3 ])
211
215
@@ -224,6 +228,17 @@ def procImg(img,sideName):
224
228
225
229
print ("" )
226
230
231
+ if dispFlag :
232
+ small_thresh = cv .CreateImage ((int (0.25 * cv .GetSize (imgbluethresh )[0 ]), int (0.25 * cv .GetSize (imgbluethresh )[1 ])), 8 , 1 )
233
+ cv .Resize (imgbluethresh , small_thresh )
234
+ cv .ShowImage (sideName + "_threshold" , small_thresh )
235
+ cv .WaitKey (100 )
236
+
237
+ small_hsv = cv .CreateImage ((int (0.25 * cv .GetSize (imghsv )[0 ]), int (0.25 * cv .GetSize (imghsv )[1 ])), 8 , 3 )
238
+ cv .Resize (imghsv , small_hsv )
239
+ cv .ShowImage (sideName + "_hsv" , small_hsv )
240
+ cv .WaitKey (100 )
241
+
227
242
return (centroidx , centroidy )
228
243
229
244
@@ -242,6 +257,15 @@ def procImg(img,sideName):
242
257
cv .NamedWindow ("west" ,cv .CV_WINDOW_AUTOSIZE )
243
258
cv .NamedWindow ("east" ,cv .CV_WINDOW_AUTOSIZE )
244
259
260
+ # extra images to show intermediate tracking results
261
+ dispMore = 0
262
+ if dispMore :
263
+ cv .NamedWindow ("west_threshold" ,cv .CV_WINDOW_AUTOSIZE )
264
+ cv .NamedWindow ("east_threshold" ,cv .CV_WINDOW_AUTOSIZE )
265
+ cv .NamedWindow ("west_hsv" ,cv .CV_WINDOW_AUTOSIZE )
266
+ cv .NamedWindow ("east_hsv" ,cv .CV_WINDOW_AUTOSIZE )
267
+
268
+
245
269
#address of the control server
246
270
ip = "md-red5.discovery.wisc.edu"
247
271
port = 7779
@@ -260,22 +284,19 @@ def procImg(img,sideName):
260
284
frame_west = cv .LoadImageM (fname_west ,cv .CV_LOAD_IMAGE_COLOR );
261
285
frame_east = cv .LoadImageM (fname_east ,cv .CV_LOAD_IMAGE_COLOR );
262
286
263
- #small_west
264
- #small_east =
265
-
266
- #find the blimp with one camera
267
- centroids = procImg (frame_west ,"west" )
287
+ #find the blimp with one camera, frame is passed in by reference
288
+ centroids = procImg (frame_west ,"west" ,dispMore )
268
289
centx_west = centroids [0 ]
269
290
centy_west = centroids [1 ]
270
291
271
- #find the blimp with one camera
272
- centroids = procImg (frame_east ,"east" )
292
+ #find the blimp with one camera, frame is passed in by reference
293
+ centroids = procImg (frame_east ,"east" , dispMore )
273
294
centx_east = centroids [0 ]
274
295
centy_east = centroids [1 ]
275
296
276
297
#decimate the resulting images
277
- small_west = cv .CreateImage ((int (0.5 * cv .GetSize (frame_west )[0 ]), int (0.5 * cv .GetSize (frame_west )[1 ])), 8 , 3 )
278
- small_east = cv .CreateImage ((int (0.5 * cv .GetSize (frame_east )[0 ]), int (0.5 * cv .GetSize (frame_east )[1 ])), 8 , 3 )
298
+ small_west = cv .CreateImage ((int (0.25 * cv .GetSize (frame_west )[0 ]), int (0.25 * cv .GetSize (frame_west )[1 ])), 8 , 3 )
299
+ small_east = cv .CreateImage ((int (0.25 * cv .GetSize (frame_east )[0 ]), int (0.25 * cv .GetSize (frame_east )[1 ])), 8 , 3 )
279
300
cv .Resize (frame_west , small_west )
280
301
cv .Resize (frame_east , small_east )
281
302
0 commit comments