python - 如何通过在opencv python中单击鼠标按钮在播放视频的顶部绘制形状
问题描述
好吧,首先,我应该承认这是一个很长的问题,我无法通过谷歌搜索找到可能的解决方案
我有一段视频,其中入侵者试图闯入围栏的另一侧。
我可以跟踪入侵者,但是当他在另一边时,我应该能够将入侵持续时间保存到文件中。入侵区域将是这样的
我想了这些步骤:
I. Reading a video file;
II. Getting the very first frame displayed,
1. Pausing the video playback;
2. Manually drawing intrusion area on that frame with a mouse; (making draw and reset buttons as events maybe)
3. Replaying the video again
III. Waiting for the intruder to appear, etc. (III part is not important)
到目前为止,我已经完成了 I 和 II(我知道这很傻),并且应该完成步骤 II 的 1、2、3 个子部分。
import cv2
file = "intrusion.mp4"
capture = cv2.VideoCapture(file)
ret, firstFrame= capture.read()
while True:
cv2.imshow("First Frame", firstFrame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
希望大家多多指教和指点!
PS: 参考任何相关的帖子、博客或链接,我很高兴发现
解决方案
推荐阅读
- python - Tesseract 手写数字失败
- excel - 单个营业月的两个日期之间的差异
- javascript - 无法从嵌套 JSON 获取值到下拉列表
- html - 为什么在页面加载时无法使用 ajax 获取 json 内容
- aws-lambda - 将相同的函数部署到 ASW Lambda 上的不同端点
- powershell - 需要使用 Groovy 在 SoapUI 中调用 PowerShell 文件
- javascript - 重新抛出自定义异常 JavaScript
- virtual-machine - MacOS > Virtualbox > Centos 7.7 如何设置ip/获取IP
- java - 二元运算符 & 的错误操作数类型
- python - 在 Pandas 中计算滚动回归并存储斜率