如下所示:
創新互聯于2013年創立,先為高邑等服務建站,高邑等地企業,進行企業商務咨詢服務。為高邑企業網站制作PC+手機+微官網三網同步一站式服務解決您的所有建站問題。def draw_circle(event,x,y,flags,param): global ix,iy,drawing,mode,start_x,start_y if event == cv2.EVENT_LBUTTONDOWN: if drawing == False: start_x, start_y = x,y ix,iy = x,y drawing = True elif drawing == True: cv2.line(img,(ix,iy),(x,y),(0,255,0),3) ix, iy = x, y print(drawing) elif event == cv2.EVENT_MBUTTONDOWN: drawing = False cv2.line(img, (ix, iy), (start_x, start_y), (0, 255, 0), 3) print(drawing) # # elif event == cv2.EVENT_RBUTTONUP: # cv2.line(img,(ix,iy),(x,y),(0,255,0),3) # Next we have to bind this mouse callback function to OpenCV # # window. In the main loop, we should set a keyboard binding for # key ‘m' to toggle between rectangle and circle. img = np.zeros((512,512,3), np.uint8) cv2.namedWindow('image') cv2.setMouseCallback('image',draw_circle) while(1): cv2.imshow('image',img) k = cv2.waitKey(1) & 0xFF if k == ord('m'): # 切換模式 mode = not mode elif k == 27: break cv2.destroyAllWindows()
當前名稱:python_opencv用線段畫封閉矩形的實例-創新互聯
本文URL:http://vcdvsql.cn/article14/cdjege.html
成都網站建設公司_創新互聯,為您提供服務器托管、定制開發、響應式網站、小程序開發、微信公眾號、全網營銷推廣
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯