当前位置:网站首页>Videos are stored in a folder every 100 frames, and pictures are transferred to videos after processing
Videos are stored in a folder every 100 frames, and pictures are transferred to videos after processing
2022-06-30 12:24:00 【cv-daily】
video Turn picture
import cv2
from PIL import Image
import numpy as np
import os
# cap = cv2.VideoCapture("/home/zhanglu/tao/contain/tlt_infer_testing/deepstm_result/result.mp4") # Get the video object
cap = cv2.VideoCapture("/media/zhanglu/ff11386b-3ffe-4e34-a2f7-35bd45cb2e72/data/realbsvsr/0629.mov") # Get the video object
isOpened = cap.isOpened # Decide whether to open
# Video information acquisition
fps = cap.get(cv2.CAP_PROP_FPS)
imageNum = -1
sum=0
while (isOpened):
sum+=1
(frameState, frame) = cap.read() # Record each frame and acquisition status
# if frameState == True and (sum % timef==0):
if frameState == True:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = Image.fromarray(np.uint8(frame))
frame = np.array(frame)
# RGBtoBGR Satisfy opencv Display format
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
imageNum = imageNum + 1
name = str(imageNum).zfill(8)
fileName = 'data/part/part1/' + str(name) + '.png' # Storage path
cv2.imwrite(fileName, frame, [cv2.IMWRITE_JPEG_QUALITY, 100])
print(fileName + " successfully write in") # Output storage status
elif frameState == False:
break
print('finish!')
cap.release()
Pictures per folder 00000000.png~00000099.png Deposit
import os,cv2
path='imgs/all/'
new_path='imgs/partaa/'
dir=os.listdir(path)
count=0
for name in dir:
a=cv2.imread(path+name)
name_i=int(name.strip('.png'))
res=int(name_i/100)
for i in range(99):
if i==0:
continue
if res>=i and res<i+1:
new_path_1=new_path+'part'+str(res+1)
if not os.path.exists(new_path_1):
os.mkdir(new_path_1)
new_name_i=name_i-100*res
name_last = str(new_name_i).zfill(8)+'.png'
os.rename(os.path.join(path,name),os.path.join(new_path_1,name_last))
After processing, save these folders as video
import os,cv2
video = cv2.VideoWriter('/media/zhanglu/0bb0d537-0b35-45bf-94ec-9def4a6dd599/zhanglu/RealBasic/BasicVSR_PlusPlus-master/ss.mp4', cv2.VideoWriter_fourcc(*"mp4v"), 30, (1408,792)) # Create a video stream object - Format 1
path='/media/zhanglu/0bb0d537-0b35-45bf-94ec-9def4a6dd599/zhanglu/RealBasic/BasicVSR_PlusPlus-master/results/'
for i in range(1,35):
path_new = path+ 'demo_'+str(i)
dir=os.listdir(path_new)
for j in range(100):
for name in dir:
if j==int(name.strip('.png')):
img=cv2.imread(os.path.join(path_new,name))
video.write(img) # Write a frame to the video file -- Only images , No sound
video.release()
cv2.waitKey()
边栏推荐
- AGCO AI frontier promotion (6.30)
- grep匹配查找
- A review of quantum neural networks 2022 for generating learning tasks
- Getting started with the go language is simple: go handles XML files
- Set set
- DMA controller 8237a
- 海思3559万能平台搭建:获取数据帧修改后编码
- 串行通信接口8250
- 网络营销之四大误解
- Getting started with the go language is simple: go handles XML files
猜你喜欢

Building of Hisilicon 3559 universal platform: obtaining the modified code of data frame

用于生成学习任务的量子神经网络2022最新综述

STM32 porting the fish component of RT thread Standard Edition

Swagger2自动生成APi文档

How to detect 3D line spectral confocal sensors in semiconductors

治数如治水,数据治理和数据创新难在哪?

Yolov5 export the pit encountered by onnx

浏览器播放rtsp视频,基于nodeJs

Lichuang EDA learning notes 10 common connector component identification and passive buzzer driving circuit

How difficult is data governance and data innovation?
随机推荐
Lichuang EDA learning notes 10 common connector component identification and passive buzzer driving circuit
Hannaiping of Qilin software: the construction of Digital China needs its own open source root community
SuperMap iClient3D 11i for Cesium三维场景中图例使用说明
Some commonly used hardware information of the server (constantly updated)
网络营销之四大误解
Multiparty cardinality testing for threshold private set-2021: Interpretation
ES6新特性介绍
Pinda general permission system (day 7~day 8)
90.(cesium篇)cesium高度监听事件
8253 counter introduction
Openmldb meetup No.4 meeting minutes
海思3559 sample解析:venc
R language ggplot2 visualization: gganimate package is based on Transition_ The time function creates a dynamic scatter graph animation (GIF), and uses the labs function to add a dynamic time title to
Introduction to new features of ES6
Yolov5 export the pit encountered by onnx
并行接口8255A
Go 语言入门很简单:Go 处理 XML 文件
会议预告 | 华为 2012 实验室全球软件技术峰会-欧洲分会场
不同类型的变量与零究竟是如何比较
杂文:自家的智能家居方案研究