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