python对视频画框标记后保存的方法


Posted in Python onDecember 07, 2018

需要画框取消注释rectangle

import cv2
import os,sys,shutil
import numpy as np
 
# Open the input movie file, input the filepath as
input_filepath = sys.argv[1]
input_movie = cv2.VideoCapture(input_filepath)
length = int(input_movie.get(cv2.CAP_PROP_FRAME_COUNT))
 
#设置output
output_movie = cv2.VideoWriter(input_filepath.replace("mp4","avi").replace("input","output"), cv2.VideoWriter_fourcc('D', 'I', 'V', 'X'), 25, (1280, 720))
 
# Initialize some variables
frame_number = 0
 
while True:
 # Grab a single frame of video
 ret, frame = input_movie.read()
 
 frame_number += 1
 
 # Quit when the input video file ends
 if not ret:
  break
 
 # Draw a box around the body: input the top left point(x,y) and bottom right point(x,y)
 #cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
 
 # Write the resulting image to the output video file
 print("Writing frame {} / {}".format(frame_number, length))
 output_movie.write(frame)
 
# All done!
input_movie.release()
cv2.destroyAllWindows()

以上这篇python对视频画框标记后保存的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python进程类subprocess的一些操作方法例子
Nov 22 Python
深入理解Python变量与常量
Jun 02 Python
python 第三方库的安装及pip的使用详解
May 11 Python
Python cookbook(数据结构与算法)实现对不原生支持比较操作的对象排序算法示例
Mar 15 Python
python 定义给定初值或长度的list方法
Jun 23 Python
详解Python函数式编程—高阶函数
Mar 29 Python
在Python中append以及extend返回None的例子
Jul 20 Python
Python3.7 pyodbc完美配置访问access数据库
Oct 03 Python
Python 实现判断图片格式并转换,将转换的图像存到生成的文件夹中
Jan 13 Python
Python爬虫爬取、解析数据操作示例
Mar 27 Python
Django模板标签{% for %}循环,获取制定条数据实例
May 14 Python
在Keras中CNN联合LSTM进行分类实例
Jun 29 Python
python opencv读mp4视频的实例
Dec 07 #Python
python利用requests库模拟post请求时json的使用教程
Dec 07 #Python
Python 加密与解密小结
Dec 06 #Python
Python 带有参数的装饰器实例代码详解
Dec 06 #Python
DES加密解密算法之python实现版(图文并茂)
Dec 06 #Python
python获取时间及时间格式转换问题实例代码详解
Dec 06 #Python
python中ImageTk.PhotoImage()不显示图片却不报错问题解决
Dec 06 #Python
You might like
PHP实现MVC开发得最简单的方法――模型
2007/04/10 PHP
mayfish 数据入库验证代码
2010/04/30 PHP
PHP 5.3.1 安装包 VC9 VC6不同版本的区别是什么
2010/07/04 PHP
与文件上传有关的php配置参数总结
2013/06/14 PHP
如何在HTML 中嵌入 PHP 代码
2015/05/13 PHP
ThinkPHP框架整合微信支付之Native 扫码支付模式一图文详解
2019/04/09 PHP
Jquery跨域获得Json时invalid label错误的解决办法
2011/01/11 Javascript
jQuery中is()方法用法实例
2015/01/06 Javascript
如何利用Promises编写更优雅的JavaScript代码
2016/05/17 Javascript
Vue.js中用webpack合并打包多个组件并实现按需加载
2017/02/17 Javascript
jQuery实现点击关注和取消功能
2017/07/03 jQuery
React根据宽度自适应高度的示例代码
2017/10/11 Javascript
vue .js绑定checkbox并获取、改变选中状态的实例
2018/08/24 Javascript
vue二级菜单导航点击选中事件的方法
2018/09/12 Javascript
ECharts地图绘制和钻取简易接口详解
2019/07/12 Javascript
实例讲解React 组件生命周期
2020/07/08 Javascript
python计算最大优先级队列实例
2013/12/18 Python
python实现每次处理一个字符的三种方法
2014/10/09 Python
python3.6 实现AES加密的示例(pyCryptodome)
2018/01/10 Python
python列表的增删改查实例代码
2018/01/30 Python
Python selenium实现微博自动登录的示例代码
2018/05/16 Python
python 队列基本定义与使用方法【初始化、赋值、判断等】
2019/10/24 Python
Shop Apotheke瑞士:您的健康与美容网上商店
2019/10/09 全球购物
大三自我鉴定范文
2013/10/05 职场文书
优秀安全员事迹材料
2014/05/11 职场文书
卫生系统先进事迹
2014/05/13 职场文书
兽医医药专业求职信
2014/07/27 职场文书
家长高考寄语
2015/02/27 职场文书
催款函范本大全
2015/06/24 职场文书
初中语文教学研修日志
2015/11/13 职场文书
2016党校学习心得体会范文
2016/01/07 职场文书
MySQL系列之二 多实例配置
2021/07/02 MySQL
MySQL七种JOIN类型小结
2021/10/24 MySQL
关于JS中的作用域中的问题思考分享
2022/04/06 Javascript
python实现商品进销存管理系统
2022/05/30 Python
Python中的 enumerate和zip详情
2022/05/30 Python