python對視頻畫框標(biāo)記后保存的方法
更新時間:2018年12月07日 09:10:01 作者:別說話寫代碼
今天小編就為大家分享一篇python對視頻畫框標(biāo)記后保存的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
需要畫框取消注釋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))
#設(shè)置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對視頻畫框標(biāo)記后保存的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
pygame實現(xiàn)俄羅斯方塊游戲(基礎(chǔ)篇1)
這篇文章主要為大家介紹了pygame實現(xiàn)俄羅斯方塊游戲基礎(chǔ)的第1篇,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-10-10
jupyter notebook讀取/導(dǎo)出文件/圖片實例
這篇文章主要介紹了jupyter notebook讀取/導(dǎo)出文件/圖片實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
使用PyTorch實現(xiàn)去噪擴(kuò)散模型的完整代碼
在本文中,我們將深入研究DDPM的復(fù)雜性,涵蓋其訓(xùn)練過程,包括正向和逆向過程,并探索如何執(zhí)行采樣,在整個探索過程中,我們將使用PyTorch從頭開始構(gòu)建DDPM,并完成其完整的訓(xùn)練,需要的朋友可以參考下2024-01-01

