Latihan 6

You might also like

Download as pdf
Download as pdf
You are on page 1of 2
coency Library ez videotapture(a) Biotoctector_parans() 13 params. FilterByarea 44 params mintrea = 5 35 params maxArea = 250000 a7 # Filter by circularity’ 18 params. filtersyCireularity ~ 19 params mincircularity = 008 21 # Filter by convexity 22 params. Filtersyconvexity ~ 1 23 params minconvexity = 9.2 25 # Filter by Inertia 26 params. filtersyTnertia = True 27 params minTnertiaRatio = 0.02 33. detector ~ cv2.SinpleBlotDetector_create(parans) 35 # define range of selected color in HSV 36 lover_Linit » np.array({2,50,50]) 37 upperclimit = np.array( [26,255,2 D 39 kernel = np.ones((S, 5), ap-uinta) 40 while(True): 43 by frome 4 sim = vid.read() 45 Rév'= evz.cvtcolor(im, cv2.coLOR_scR2H5V) 6 47 Threshold the USV image to get only blue colors 48 mack — cv2-dnmange(nsv, lower. Linit, upper_Linit) 49 mask = ev2.morphologyEx(nask, cv2.NORPH_CLASE, kernel) 51 # Bitwise-AND mask and original tage 52. res = eva.oitwise_and(im,im, mask ask) 33 54 ev2.imshow( Frome’ in) $3 sev2.imshow( “aask' mask) 56 ev2.dmshow("res' res) 37 58 59° wind ~ cv2.bitwise_not(tna) 62 keypoints = detector. detect(cv2.bitwise not(nask)) 6 62 stwcy = cv2.cvtCotor(np.orray( tn) ,cv2. COLOR RGBZBGR) 63 im with keypoints = cv2.dranteypoints(im, keypoints, np.array(C]), 6a 6 Hev2.tmshow("Mask", én3) 66 ev2cdnchow( "Detection", im with _keypotnts) 6 68 the ‘a button is set os the 78 # desired button of your choice 71 AF evd.waitKey(1) & OxFF == ord('a") n ‘reak 74 # After the Loop release the cop object 75 vid.release() 77 ev2.destroyALIWindows() a 3 ver = (ev2,_verston_)-sp11tC.°) 3 ie anctvert 31 aecector» ov iapleBloboetector(parans) Reue ?* Le % (049,255), v2. 0RAM_MATCHES_FLAGS.DRAM_RICH_KEYPOINTS)

You might also like