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

yipeiwu_com6年前Python基础

需要画框取消注释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的Django框架中加载模版的方法

为了减少模板加载调用过程及模板本身的冗余代码,Django 提供了一种使用方便且功能强大的 API ,用于从磁盘中加载模板, 要使用此模板加载API,首先你必须将模板的保存位置告诉框架。...

Python判断Abundant Number的方法

本文实例讲述了Python判断Abundant Number的方法。分享给大家供大家参考。具体如下: Abundant Number,中文译成:盈数(又称 丰数, 过剩数abundant...

Pycharm之快速定位到某行快捷键的方法

Pycharm之快速定位到某行快捷键的方法

如下所示: 找了好久,今天无意中敲出来了:ctrl+l(小写) 全局查找某个变量:ctrl+h 我用的Eclipse快捷键 以上这篇Pycharm之快速定位到某行快捷键的方法就是小编分...

tensorflow输出权重值和偏差的方法

使用tensorflow 训练模型时,我们可以使用 tensorflow自带的 Save模块 tf.train.Saver()来保存模型,使用方式很简单 就是在训练完模型后,调用save...

django_orm查询性能优化方法

查询操作和性能优化 1.基本操作 增 models.Tb1.objects.create(c1='xx', c2='oo') 增加一条数据,可以接受字典类型数据 **kwargs...