import scipy.io as scio import os import math import cv2 import numpy as np def read_video(video_path): cap = cv2.VideoCapture(video_path) wid = int(cap.get(3)) hei = int(cap.get(4)) framerate = int(cap.get(5)) framenum = int(cap.get(7)) print(framerate) print(framenum) video = np.zeros((framenum, hei, wid, 3), dtype='float16') cnt = 0 while (cap.isOpened()): a, b = cap.read() print(type(b)) if b is not None: b = b.astype('float16') / 255 video[cnt] = b else: break cnt += 1 print(video.shape) def get_file_names(file_dir, extension): file_names = [] for root, dirs, files in os.walk(file_dir): for _file in files: if os.path.splitext(_file)[-1] == extension: file_names.append(_file) return file_names def mpi(indnum): dir_path='/home/passwordis1/Desktop/MOCAP-mpi/' mat_file_names =get_file_names(dir_path,'.mat') print(mat_file_names) mpi_index = [0,1,2,4,5,6,7,8] print (mpi_index) mpi_annot =[] for name in mat_file_names: file_path = dir_path + name data = scio.loadmat(file_path) for i in range(0,8): camera_num = mpi_index[i] anoot_for_camera_num = data['annot3'][camera_num] joint_for_camera_num = anoot_for_camera_num[0] mpi_annot.append(joint_for_camera_num) print(len(mpi_annot)) print(mpi_annot[0].shape) print(mpi_annot[127].shape) number = indnum%8 seqnum = int(math.floor(indnum/8)) print(number,seqnum) prefixion = mat_file_names[seqnum][0:3] print(prefixion) video_name = prefixion +'Video_' + str(mpi_index[number-1])+'.avi' video_path = os.path.join(dir_path,video_name) print(video_path) mpi(10)
mpi
最新推荐文章于 2021-04-29 20:50:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)