当前位置:网站首页>Opencv mouse and keyboard events
Opencv mouse and keyboard events
2022-07-03 06:23:00 【fksfdh】
1、 Window cycle read
import numpy as np
import cv2
import matplotlib.pyplot as plt
import os
from itertools import cycle
filename = os.listdir("../images")
img_iter = cycle([cv2.imread(os.sep.join(["../images",x]))for x in filename])
key = 0
while key != 27:
cv2.imshow("img",next(img_iter))
key = cv2.waitKey(42)
2、 Get keyboard value
import numpy as np
import cv2
import matplotlib.pyplot as plt
import os
from itertools import cycle
img = cv2.imread("../images/img.jpg")
key = 0
while key != 27:
cv2.imshow("img",img)
key = cv2.waitKey()
msg = "{} if pressed!".format(chr(key) if key < 256 else key)
print(msg)
3、 mouse
import numpy as np
import cv2
import matplotlib.pyplot as plt
import os
from itertools import cycle
def on_mouse(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDOWN:
print(" Press the left mouse button , Location ({},{})".format(x,y))
elif event == cv2.EVENT_LBUTTONUP:
print(" Left mouse button raised , Location ({},{})".format(x,y))
elif event == cv2.EVENT_LBUTTONDBLCLK:
print(" Double click with the left mouse button , Location ({},{})".format(x,y))
elif event == cv2.EVENT_RBUTTONDOWN:
print(" Press the right mouse button , Location ({},{})".format(x,y))
elif event == cv2.EVENT_RBUTTONUP:
print(" Right click to lift up , Location ({},{})".format(x, y))
elif event == cv2.EVENT_RBUTTONDBLCLK:
print(" Double click with the right mouse button , Location ({},{})".format(x, y))
elif event == cv2.EVENT_MBUTTONDOWN:
print(" Press the mouse wheel , Location ({},{})".format(x, y))
elif event == cv2.EVENT_MBUTTONUP:
print(" Lift the mouse wheel , Location ({},{})".format(x, y))
elif event == cv2.EVENT_MBUTTONDBLCLK:
print(" Double click the mouse wheel , Location ({},{})".format(x, y))
elif event == cv2.EVENT_MOUSEMOVE:
print(" Mouse movement , Location ({},{})".format(x, y))
cv2.namedWindow("mouse event")
cv2.setMouseCallback("mouse event",on_mouse)
cv2.waitKey(0)
边栏推荐
- Decision tree of machine learning
- Some thoughts on machine learning
- Cannot get value with @value, null
- scroll-view指定滚动元素的起始位置
- 使用 Abp.Zero 搭建第三方登录模块(一):原理篇
- Characteristics and isolation level of database
- Support vector machine for machine learning
- Request weather interface format, automation
- Kubernetes notes (VIII) kubernetes security
- YOLOV3学习笔记
猜你喜欢

智牛股--03

Simple solution of small up main lottery in station B

从小数据量 MySQL 迁移数据到 TiDB

Scripy learning
![[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)](/img/a4/00aca72b268f77fe4fb24ac06289f5.jpg)
[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)

项目总结--01(接口的增删改查;多线程的使用)

Kubesphere - build Nacos cluster

Phpstudy setting items can be accessed by other computers on the LAN

JMeter performance automation test

Es remote cluster configuration and cross cluster search
随机推荐
项目总结--01(接口的增删改查;多线程的使用)
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
方差迭代公式推导
使用conda创建自己的深度学习环境
Kubernetes notes (II) pod usage notes
Zhiniu stock project -- 04
【5G NR】UE注册流程
PMP笔记记录
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Leetcode solution - 02 Add Two Numbers
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
有意思的鼠标指针交互探究
Oauth2.0 - explanation of simplified mode, password mode and client mode
技术管理进阶——你了解成长的全貌吗?
Cannot get value with @value, null
Redis cluster creation, capacity expansion and capacity reduction
Exportation et importation de tables de bibliothèque avec binaires MySQL
UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
Oracle database synonym creation
Zhiniu stock -- 03