forked from vipstone/faceai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#coding=utf-8 | ||
#鼠标绘图 | ||
|
||
import cv2 | ||
import numpy as np | ||
|
||
|
||
def draw_circle(event, x, y, flags, param): | ||
# print(event) | ||
# print("cv2.EVENT_FLAG_ALTKEY:" + str(cv2.EVENT_FLAG_ALTKEY)) | ||
if event == cv2.EVENT_MBUTTONDOWN: | ||
cv2.circle(img, (x, y), 20, (255, 0, 0), -1) | ||
|
||
|
||
img = np.zeros((512, 512, 3), np.uint8) | ||
cv2.namedWindow('image') | ||
cv2.setMouseCallback('image', draw_circle) | ||
|
||
while (1): | ||
cv2.imshow('image', img) | ||
if cv2.waitKey(1) & 0xFF == ord('q'): | ||
break | ||
|
||
# for i in dir(cv2): | ||
# if 'EVENT' in i: | ||
# print(i) | ||
''' | ||
EVENT_FLAG_ALTKEY #按住alt键 | ||
EVENT_FLAG_CTRLKEY #按住ctrl键 | ||
EVENT_FLAG_LBUTTON #按住鼠标左键 | ||
EVENT_FLAG_MBUTTON #按住右键点击左键 | ||
EVENT_FLAG_RBUTTON #按住鼠标右键 | ||
EVENT_FLAG_SHIFTKEY #按住shift键 | ||
EVENT_LBUTTONDBLCLK #左键双击 | ||
EVENT_LBUTTONDOWN #左键按下 | ||
EVENT_LBUTTONUP #左键抬起 | ||
EVENT_MBUTTONDBLCLK #滚轮双击 | ||
EVENT_MBUTTONDOWN #滚轮按下 | ||
EVENT_MBUTTONUP #滚轮抬起 | ||
EVENT_MOUSEMOVE #鼠标移动 | ||
EVENT_MOUSEWHEEL #鼠标滚轮滚动 | ||
EVENT_RBUTTONDBLCLK #右键双击 | ||
EVENT_RBUTTONDOWN #右键按下 | ||
EVENT_RBUTTONUP #右键抬起 | ||
''' | ||
|
||
# cv2.waitKey(0) | ||
|
||
cv2.destroyAllWindows() |