🚀 update 3d visualization code

This commit is contained in:
shuaiqing 2021-01-25 19:37:23 +08:00
parent ba6e58d56e
commit ceba363dcb
10 changed files with 2596 additions and 18 deletions

View File

@ -2,7 +2,7 @@
* @Date: 2021-01-13 20:32:12 * @Date: 2021-01-13 20:32:12
* @Author: Qing Shuai * @Author: Qing Shuai
* @LastEditors: Qing Shuai * @LastEditors: Qing Shuai
* @LastEditTime: 2021-01-24 22:11:37 * @LastEditTime: 2021-01-25 19:35:14
* @FilePath: /EasyMocapRelease/Readme.md * @FilePath: /EasyMocapRelease/Readme.md
--> -->
# EasyMocap # EasyMocap
@ -74,10 +74,14 @@ out=path/to/output
python3 scripts/preprocess/extract_video.py ${data} python3 scripts/preprocess/extract_video.py ${data}
# 1. example for skeleton reconstruction # 1. example for skeleton reconstruction
python3 code/demo_mv1pmf_skel.py ${data} --out ${out} --vis_det --vis_repro --undis --sub_vis 1 7 13 19 python3 code/demo_mv1pmf_skel.py ${data} --out ${out} --vis_det --vis_repro --undis --sub_vis 1 7 13 19
# 2. example for SMPL reconstruction # 2.1 example for SMPL reconstruction
python3 code/demo_mv1pmf_smpl.py ${data} --out ${out} --end 300 --vis_smpl --undis --sub_vis 1 7 13 19 --gender male python3 code/demo_mv1pmf_smpl.py ${data} --out ${out} --end 300 --vis_smpl --undis --sub_vis 1 7 13 19 --gender male
# 2. example for SMPL-X reconstruction # 2.2 example for SMPL-X reconstruction
python3 code/demo_mv1pmf_smpl.py ${data} --out ${out} --undis --body bodyhandface --sub_vis 1 7 13 19 --start 400 --model smplx --vis_smpl --gender male python3 code/demo_mv1pmf_smpl.py ${data} --out ${out} --undis --body bodyhandface --sub_vis 1 7 13 19 --start 400 --model smplx --vis_smpl --gender male
# 3.1 example for rendering SMPLX to ${out}/smpl
python3 code/vis_render.py ${data} --out ${out} --skel ${out}/smpl --model smplx --gender male --undis --start 400 --sub_vis 1
# 3.2 example for rendering skeleton of SMPL to ${out}/smplskel
python3 code/vis_render.py ${data} --out ${out} --skel ${out}/smpl --model smplx --gender male --undis --start 400 --sub_vis 1 --type smplskel --body bodyhandface
``` ```
## Not Quick Start ## Not Quick Start

View File

@ -2,8 +2,8 @@
@ Date: 2021-01-13 16:53:55 @ Date: 2021-01-13 16:53:55
@ Author: Qing Shuai @ Author: Qing Shuai
@ LastEditors: Qing Shuai @ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-24 22:27:01 @ LastEditTime: 2021-01-25 19:12:34
@ FilePath: /EasyMocapRelease/code/dataset/base.py @ FilePath: /EasyMocap/code/dataset/base.py
''' '''
import os import os
import json import json
@ -351,6 +351,8 @@ class MVBase(Dataset):
self.mode = mode self.mode = mode
self.undis = undis self.undis = undis
self.no_img = no_img self.no_img = no_img
# use when debug
self.ret_crop = False
self.config = config self.config = config
# results path # results path
# the results store keypoints3d # the results store keypoints3d
@ -425,6 +427,18 @@ class MVBase(Dataset):
images.append(img) images.append(img)
# TODO:这里直接取了0 # TODO:这里直接取了0
annot = read_annot(annname, self.mode) annot = read_annot(annname, self.mode)
if self.ret_crop:
for det in annot:
bbox = det['bbox']
l, t, r, b = det['bbox'][:4]
l = max(0, int(l+0.5))
t = max(0, int(t+0.5))
r = min(img.shape[1], int(r+0.5))
b = min(img.shape[0], int(b+0.5))
det['bbox'][:4] = [l, t, r, b]
crop_img = img[t:b, l:r, :]
crop_img = cv2.resize(crop_img, (128, 256))
det['crop'] = crop_img
annots.append(annot) annots.append(annot)
if self.undis: if self.undis:
images = self.undistort(images) images = self.undistort(images)
@ -465,6 +479,29 @@ class MVBase(Dataset):
results.append(result) results.append(result)
self.writer.write_smpl(results, nf) self.writer.write_smpl(results, nf)
def vis_smpl(self, peopleDict, faces, images, nf, sub_vis=[],
mode='smpl', extra_data=[], add_back=True):
# render the smpl to each view
render_data = {}
for pid, data in peopleDict.items():
render_data[pid] = {
'vertices': data.vertices, 'faces': faces,
'vid': pid, 'name': 'human_{}_{}'.format(nf, pid)}
for iid, extra in enumerate(extra_data):
render_data[10000+iid] = {
'vertices': extra['vertices'],
'faces': extra['faces'],
'colors': extra['colors'],
'name': extra['name']
}
cameras = {'K': [], 'R':[], 'T':[]}
if len(sub_vis) == 0:
sub_vis = self.cams
for key in cameras.keys():
cameras[key] = [self.cameras[cam][key] for cam in sub_vis]
images = [images[self.cams.index(cam)] for cam in sub_vis]
self.writer.vis_smpl(render_data, nf, images, cameras, mode, add_back=add_back)
def read_skel(self, nf, mode='none'): def read_skel(self, nf, mode='none'):
if mode == 'a4d': if mode == 'a4d':
outname = join(self.skel_path, '{}.txt'.format(nf)) outname = join(self.skel_path, '{}.txt'.format(nf))

View File

@ -2,7 +2,7 @@
@ Date: 2021-01-12 17:08:25 @ Date: 2021-01-12 17:08:25
@ Author: Qing Shuai @ Author: Qing Shuai
@ LastEditors: Qing Shuai @ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-24 22:26:09 @ LastEditTime: 2021-01-25 19:32:44
@ FilePath: /EasyMocapRelease/code/demo_mv1pmf_smpl.py @ FilePath: /EasyMocapRelease/code/demo_mv1pmf_smpl.py
''' '''
# show skeleton and reprojection # show skeleton and reprojection
@ -23,10 +23,7 @@ def load_weight_shape():
def load_weight_pose(model): def load_weight_pose(model):
if model == 'smpl': if model == 'smpl':
weight = { weight = {
'k3d': 1., 'reg_poses_zero': 1e-2, 'k3d': 1., 'reg_poses_zero': 1e-2, 'smooth_body': 1e-2
'reg_expression': 1e-1,
'smooth_joints': 1e-5
# 'smooth_Rh': 1e-1, 'smooth_Th': 1e-1, 'smooth_poses': 1e-1, 'smooth_hands': 1e-2
} }
elif model == 'smplh': elif model == 'smplh':
weight = { weight = {
@ -38,7 +35,6 @@ def load_weight_pose(model):
'k3d': 1., 'reg_poses_zero': 1e-3, 'k3d': 1., 'reg_poses_zero': 1e-3,
'reg_expression': 1e-2, 'reg_expression': 1e-2,
'smooth_body': 1e-2, 'smooth_hand': 1e-2 'smooth_body': 1e-2, 'smooth_hand': 1e-2
# 'smooth_Rh': 1e-1, 'smooth_Th': 1e-1, 'smooth_poses': 1e-1, 'smooth_hands': 1e-2
} }
else: else:
raise NotImplementedError raise NotImplementedError

View File

@ -2,8 +2,8 @@
* @ Date: 2020-09-14 11:01:52 * @ Date: 2020-09-14 11:01:52
* @ Author: Qing Shuai * @ Author: Qing Shuai
@ LastEditors: Qing Shuai @ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-24 22:28:09 @ LastEditTime: 2021-01-25 16:06:41
@ FilePath: /EasyMocapRelease/code/mytools/reconstruction.py @ FilePath: /EasyMocap/code/mytools/reconstruction.py
''' '''
import numpy as np import numpy as np
@ -72,14 +72,14 @@ def simple_recon_person(keypoints_use, Puse, config=None, ret_repro=False):
# 计算重投影误差 # 计算重投影误差
kpts_repro = projectN3(out, Puse) kpts_repro = projectN3(out, Puse)
square_diff = (keypoints_use[:, :, :2] - kpts_repro[:, :, :2])**2 square_diff = (keypoints_use[:, :, :2] - kpts_repro[:, :, :2])**2
# conf = (out[None, :, -1] > 0.01) * (keypoints_use[:, :, 2] > 0.01)
conf = np.repeat(out[None, :, -1:], len(Puse), 0) conf = np.repeat(out[None, :, -1:], len(Puse), 0)
kpts_repro = np.concatenate((kpts_repro, conf), axis=2) kpts_repro = np.concatenate((kpts_repro, conf), axis=2)
if conf.sum() < 3: # 至少得有3个有效的关节 if conf.sum() < 3: # 至少得有3个有效的关节
repro_error = 1e3 repro_error = 1e3
else: else:
conf2d = conf *(keypoints_use[:, :, -1:] > 0.01)
# (nViews, nJoints): reprojection error for each joint in each view # (nViews, nJoints): reprojection error for each joint in each view
repro_error_joint = np.sqrt(square_diff.sum(axis=2, keepdims=True))*conf repro_error_joint = np.sqrt(square_diff.sum(axis=2, keepdims=True))*conf2d
# remove the not valid joints # remove the not valid joints
# remove the bad views # remove the bad views
repro_error = repro_error_joint.sum()/conf.sum() repro_error = repro_error_joint.sum()/conf.sum()

97
code/vis_render.py Normal file
View File

@ -0,0 +1,97 @@
'''
@ Date: 2021-01-17 21:14:50
@ Author: Qing Shuai
@ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-25 19:34:46
@ FilePath: /EasyMocapRelease/code/vis_render.py
'''
# visualize the results by pyrender
import pyrender # first import the pyrender
from collections import namedtuple
from dataset.base import MVBase
from dataset.config import CONFIG
import numpy as np
from tqdm import tqdm
from visualize.geometry import create_ground
Person = namedtuple('Person', ['vertices', 'keypoints3d'])
def inBound(keypoints3d, bound):
if bound is None:
return True
valid = np.where(keypoints3d[:, -1] > 0.01)[0]
kpts = keypoints3d[valid]
crit = (kpts[:, 0] > bound[0][0]) & (kpts[:, 0] < bound[1][0]) &\
(kpts[:, 1] > bound[0][1]) & (kpts[:, 1] < bound[1][1]) &\
(kpts[:, 2] > bound[0][2]) & (kpts[:, 2] < bound[1][2])
if crit.sum()/crit.shape[0] < 0.8:
return False
else:
return True
def visualize(path, sub, out, mode, rend_type, args):
config = CONFIG[mode]
no_img = False
dataset = MVBase(path, cams=sub, config=config,
undis=args.undis, no_img=no_img, out=out)
dataset.skel_path = args.skel
if rend_type in ['skel']:
from visualize.skelmodel import SkelModel
body_model = SkelModel(config['nJoints'], config['kintree'])
elif rend_type in ['mesh']:
from smplmodel import load_model
body_model = load_model(args.gender, model_type=args.model)
smpl_model = body_model
elif rend_type == 'smplskel':
from smplmodel import load_model
smpl_model = load_model(args.gender, model_type=args.model)
from visualize.skelmodel import SkelModel
body_model = SkelModel(config['nJoints'], config['kintree'])
dataset.writer.save_origin = args.save_origin
start, end = args.start, min(args.end, len(dataset))
bound = None
if args.scene == 'none':
ground = create_ground(step=0.5)
elif args.scene == 'hw':
ground = create_ground(step=1, xrange=14, yrange=10, two_sides=False)
bound = [[0, 0, 0], [14, 10, 2.5]]
else:
ground = create_ground(step=1, xrange=28, yrange=15, two_sides=False)
for nf in tqdm(range(start, end), desc='rendering'):
images, annots = dataset[nf]
if rend_type == 'skel':
infos = dataset.read_skel(nf)
else:
infos = dataset.read_smpl(nf)
# body_model: input: keypoints3d/smpl params, output: vertices, (colors)
# The element of peopleDict must have `id`, `vertices`
peopleDict = {}
for info in infos:
if rend_type == 'skel':
joints = info['keypoints3d']
else:
joints = smpl_model(return_verts=False, return_tensor=False, **info)[0]
if not inBound(joints, bound):
continue
if rend_type == 'smplskel':
joints = smpl_model(return_verts=False, return_tensor=False, **info)[0]
joints = np.hstack([joints, np.ones((joints.shape[0], 1))])
info_new = {'id': info['id'], 'keypoints3d': joints}
vertices = body_model(return_verts=True, return_tensor=False, **info_new)[0]
else:
vertices = body_model(return_verts=True, return_tensor=False, **info)[0]
peopleDict[info['id']] = Person(vertices=vertices, keypoints3d=None)
dataset.vis_smpl(peopleDict, faces=body_model.faces, images=images, nf=nf,
sub_vis=args.sub_vis, mode=rend_type, extra_data=[ground], add_back=args.add_back)
if __name__ == "__main__":
from mytools.cmd_loader import load_parser
parser = load_parser()
parser.add_argument('--type', type=str, default='mesh', choices=['skel', 'mesh', 'smplskel'])
parser.add_argument('--scene', type=str, default='none', choices=['none', 'zjub', 'hw'])
parser.add_argument('--skel', type=str, default=None)
parser.add_argument('--add_back', action='store_true')
parser.add_argument('--save_origin', action='store_true')
args = parser.parse_args()
visualize(args.path, args.sub, args.out, args.body, args.type, args)

View File

@ -0,0 +1,82 @@
'''
@ Date: 2021-01-17 22:44:34
@ Author: Qing Shuai
@ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-25 19:14:20
@ FilePath: /EasyMocapRelease/code/visualize/geometry.py
'''
import numpy as np
import cv2
import numpy as np
def create_ground(
center=[0, 0, 0], xdir=[1, 0, 0], ydir=[0, 1, 0], # 位置
step=1, xrange=10, yrange=10, # 尺寸
white=[1., 1., 1.], black=[0.,0.,0.], # 颜色
two_sides=True
):
if isinstance(center, list):
center = np.array(center)
xdir = np.array(xdir)
ydir = np.array(ydir)
xdir = xdir * step
ydir = ydir * step
vertls, trils, colls = [],[],[]
cnt = 0
min_x = -xrange if two_sides else 0
min_y = -yrange if two_sides else 0
for i in range(min_x, xrange+1):
for j in range(min_y, yrange+1):
point0 = center + i*xdir + j*ydir
point1 = center + (i+1)*xdir + j*ydir
point2 = center + (i+1)*xdir + (j+1)*ydir
point3 = center + (i)*xdir + (j+1)*ydir
if (i%2==0 and j%2==0) or (i%2==1 and j%2==1):
col = white
else:
col = black
vert = np.stack([point0, point1, point2, point3])
col = np.stack([col for _ in range(vert.shape[0])])
tri = np.array([[2, 3, 0], [0, 1, 2]]) + vert.shape[0] * cnt
cnt += 1
vertls.append(vert)
trils.append(tri)
colls.append(col)
vertls = np.vstack(vertls)
trils = np.vstack(trils)
colls = np.vstack(colls)
return {'vertices': vertls, 'faces': trils, 'colors': colls, 'name': 'ground'}
def get_rotation_from_two_directions(direc0, direc1):
direc0 = direc0/np.linalg.norm(direc0)
direc1 = direc1/np.linalg.norm(direc1)
rotdir = np.cross(direc0, direc1)
if np.linalg.norm(rotdir) < 1e-2:
return np.eye(3)
rotdir = rotdir/np.linalg.norm(rotdir)
rotdir = rotdir * np.arccos(np.dot(direc0, direc1))
rotmat, _ = cv2.Rodrigues(rotdir)
return rotmat
def create_plane(normal, point, width=1, height=1, depth=0.005):
mesh_box = TriangleMesh.create_box(width=2*width, height=2*height, depth=2*depth)
mesh_box.paint_uniform_color([0.8, 0.8, 0.8])
# 根据normal计算旋转
rotmat = get_rotation_from_two_directions(np.array([0, 0, 1]), normal[0])
transform0 = np.eye(4)
transform0[0, 3] = -width
transform0[1, 3] = -height
transform0[2, 3] = -depth
transform = np.eye(4)
transform[:3, :3] = rotmat
transform[0, 3] = point[0, 0]
transform[1, 3] = point[0, 1]
transform[2, 3] = point[0, 2]
mesh_box.transform(transform @ transform0)
return {'vertices': np.asarray(mesh_box.vertices), 'faces': np.asarray(mesh_box.triangles), 'colors': np.asarray(mesh_box.vertex_colors), 'name': 'ground'}
faces = np.loadtxt('./code/visualize/sphere_faces_20.txt', dtype=np.int)
vertices = np.loadtxt('./code/visualize/sphere_vertices_20.txt')
colors = np.ones((vertices.shape[0], 3))
return {'vertices': vertices, 'faces': faces, 'colors': colors, 'name': 'ground'}

View File

@ -0,0 +1,74 @@
'''
@ Date: 2021-01-17 21:38:19
@ Author: Qing Shuai
@ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-22 23:08:18
@ FilePath: /EasyMocap/code/visualize/skelmodel.py
'''
import numpy as np
import cv2
def calTransformation(v_i, v_j, r, adaptr=False, ratio=10):
""" from to vertices to T
Arguments:
v_i {} -- [description]
v_j {[type]} -- [description]
"""
xaxis = np.array([1, 0, 0])
v = (v_i + v_j)/2
direc = (v_i - v_j)
length = np.linalg.norm(direc)
direc = direc/length
rotdir = np.cross(xaxis, direc)
rotdir = rotdir/np.linalg.norm(rotdir)
rotdir = rotdir * np.arccos(np.dot(direc, xaxis))
rotmat, _ = cv2.Rodrigues(rotdir)
# set the minimal radius for the finger and face
shrink = max(length/ratio, 0.005)
eigval = np.array([[length/2/r, 0, 0], [0, shrink, 0], [0, 0, shrink]])
T = np.eye(4)
T[:3,:3] = rotmat @ eigval @ rotmat.T
T[:3, 3] = v
return T, r, length
class SkelModel:
def __init__(self, nJoints, kintree) -> None:
self.nJoints = nJoints
self.kintree = kintree
faces = np.loadtxt('./code/visualize/sphere_faces_20.txt', dtype=np.int)
self.vertices = np.loadtxt('./code/visualize/sphere_vertices_20.txt')
# compose faces
faces_all = []
for nj in range(nJoints):
faces_all.append(faces + nj*self.vertices.shape[0])
for nk in range(len(kintree)):
faces_all.append(faces + nJoints*self.vertices.shape[0] + nk*self.vertices.shape[0])
self.faces = np.vstack(faces_all)
def __call__(self, keypoints3d, id=0, return_verts=True, return_tensor=False):
vertices_all = []
r = 0.02
# joints
for nj in range(self.nJoints):
if nj > 25:
r_ = r * 0.4
else:
r_ = r
if keypoints3d[nj, -1] < 0.01:
vertices_all.append(self.vertices*0.001)
continue
vertices_all.append(self.vertices*r_ + keypoints3d[nj:nj+1, :3])
# limb
for nk, (i, j) in enumerate(self.kintree):
if keypoints3d[i][-1] < 0.1 or keypoints3d[j][-1] < 0.1:
vertices_all.append(self.vertices*0.001)
continue
T, _, length = calTransformation(keypoints3d[i, :3], keypoints3d[j, :3], r=1)
if length > 2: # 超过两米的
vertices_all.append(self.vertices*0.001)
continue
vertices = self.vertices @ T[:3, :3].T + T[:3, 3:].T
vertices_all.append(vertices)
vertices = np.vstack(vertices_all)
return vertices[None, :, :]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,762 @@
0.000 0.000 1.000
0.000 0.000 -1.000
0.156 0.000 0.988
0.155 0.024 0.988
0.149 0.048 0.988
0.139 0.071 0.988
0.127 0.092 0.988
0.111 0.111 0.988
0.092 0.127 0.988
0.071 0.139 0.988
0.048 0.149 0.988
0.024 0.155 0.988
0.000 0.156 0.988
-0.024 0.155 0.988
-0.048 0.149 0.988
-0.071 0.139 0.988
-0.092 0.127 0.988
-0.111 0.111 0.988
-0.127 0.092 0.988
-0.139 0.071 0.988
-0.149 0.048 0.988
-0.155 0.024 0.988
-0.156 0.000 0.988
-0.155 -0.024 0.988
-0.149 -0.048 0.988
-0.139 -0.071 0.988
-0.127 -0.092 0.988
-0.111 -0.111 0.988
-0.092 -0.127 0.988
-0.071 -0.139 0.988
-0.048 -0.149 0.988
-0.024 -0.155 0.988
-0.000 -0.156 0.988
0.024 -0.155 0.988
0.048 -0.149 0.988
0.071 -0.139 0.988
0.092 -0.127 0.988
0.111 -0.111 0.988
0.127 -0.092 0.988
0.139 -0.071 0.988
0.149 -0.048 0.988
0.155 -0.024 0.988
0.309 0.000 0.951
0.305 0.048 0.951
0.294 0.095 0.951
0.275 0.140 0.951
0.250 0.182 0.951
0.219 0.219 0.951
0.182 0.250 0.951
0.140 0.275 0.951
0.095 0.294 0.951
0.048 0.305 0.951
0.000 0.309 0.951
-0.048 0.305 0.951
-0.095 0.294 0.951
-0.140 0.275 0.951
-0.182 0.250 0.951
-0.219 0.219 0.951
-0.250 0.182 0.951
-0.275 0.140 0.951
-0.294 0.095 0.951
-0.305 0.048 0.951
-0.309 0.000 0.951
-0.305 -0.048 0.951
-0.294 -0.095 0.951
-0.275 -0.140 0.951
-0.250 -0.182 0.951
-0.219 -0.219 0.951
-0.182 -0.250 0.951
-0.140 -0.275 0.951
-0.095 -0.294 0.951
-0.048 -0.305 0.951
-0.000 -0.309 0.951
0.048 -0.305 0.951
0.095 -0.294 0.951
0.140 -0.275 0.951
0.182 -0.250 0.951
0.219 -0.219 0.951
0.250 -0.182 0.951
0.275 -0.140 0.951
0.294 -0.095 0.951
0.305 -0.048 0.951
0.454 0.000 0.891
0.448 0.071 0.891
0.432 0.140 0.891
0.405 0.206 0.891
0.367 0.267 0.891
0.321 0.321 0.891
0.267 0.367 0.891
0.206 0.405 0.891
0.140 0.432 0.891
0.071 0.448 0.891
0.000 0.454 0.891
-0.071 0.448 0.891
-0.140 0.432 0.891
-0.206 0.405 0.891
-0.267 0.367 0.891
-0.321 0.321 0.891
-0.367 0.267 0.891
-0.405 0.206 0.891
-0.432 0.140 0.891
-0.448 0.071 0.891
-0.454 0.000 0.891
-0.448 -0.071 0.891
-0.432 -0.140 0.891
-0.405 -0.206 0.891
-0.367 -0.267 0.891
-0.321 -0.321 0.891
-0.267 -0.367 0.891
-0.206 -0.405 0.891
-0.140 -0.432 0.891
-0.071 -0.448 0.891
-0.000 -0.454 0.891
0.071 -0.448 0.891
0.140 -0.432 0.891
0.206 -0.405 0.891
0.267 -0.367 0.891
0.321 -0.321 0.891
0.367 -0.267 0.891
0.405 -0.206 0.891
0.432 -0.140 0.891
0.448 -0.071 0.891
0.588 0.000 0.809
0.581 0.092 0.809
0.559 0.182 0.809
0.524 0.267 0.809
0.476 0.345 0.809
0.416 0.416 0.809
0.345 0.476 0.809
0.267 0.524 0.809
0.182 0.559 0.809
0.092 0.581 0.809
0.000 0.588 0.809
-0.092 0.581 0.809
-0.182 0.559 0.809
-0.267 0.524 0.809
-0.345 0.476 0.809
-0.416 0.416 0.809
-0.476 0.345 0.809
-0.524 0.267 0.809
-0.559 0.182 0.809
-0.581 0.092 0.809
-0.588 0.000 0.809
-0.581 -0.092 0.809
-0.559 -0.182 0.809
-0.524 -0.267 0.809
-0.476 -0.345 0.809
-0.416 -0.416 0.809
-0.345 -0.476 0.809
-0.267 -0.524 0.809
-0.182 -0.559 0.809
-0.092 -0.581 0.809
-0.000 -0.588 0.809
0.092 -0.581 0.809
0.182 -0.559 0.809
0.267 -0.524 0.809
0.345 -0.476 0.809
0.416 -0.416 0.809
0.476 -0.345 0.809
0.524 -0.267 0.809
0.559 -0.182 0.809
0.581 -0.092 0.809
0.707 0.000 0.707
0.698 0.111 0.707
0.672 0.219 0.707
0.630 0.321 0.707
0.572 0.416 0.707
0.500 0.500 0.707
0.416 0.572 0.707
0.321 0.630 0.707
0.219 0.672 0.707
0.111 0.698 0.707
0.000 0.707 0.707
-0.111 0.698 0.707
-0.219 0.672 0.707
-0.321 0.630 0.707
-0.416 0.572 0.707
-0.500 0.500 0.707
-0.572 0.416 0.707
-0.630 0.321 0.707
-0.672 0.219 0.707
-0.698 0.111 0.707
-0.707 0.000 0.707
-0.698 -0.111 0.707
-0.672 -0.219 0.707
-0.630 -0.321 0.707
-0.572 -0.416 0.707
-0.500 -0.500 0.707
-0.416 -0.572 0.707
-0.321 -0.630 0.707
-0.219 -0.672 0.707
-0.111 -0.698 0.707
-0.000 -0.707 0.707
0.111 -0.698 0.707
0.219 -0.672 0.707
0.321 -0.630 0.707
0.416 -0.572 0.707
0.500 -0.500 0.707
0.572 -0.416 0.707
0.630 -0.321 0.707
0.672 -0.219 0.707
0.698 -0.111 0.707
0.809 0.000 0.588
0.799 0.127 0.588
0.769 0.250 0.588
0.721 0.367 0.588
0.655 0.476 0.588
0.572 0.572 0.588
0.476 0.655 0.588
0.367 0.721 0.588
0.250 0.769 0.588
0.127 0.799 0.588
0.000 0.809 0.588
-0.127 0.799 0.588
-0.250 0.769 0.588
-0.367 0.721 0.588
-0.476 0.655 0.588
-0.572 0.572 0.588
-0.655 0.476 0.588
-0.721 0.367 0.588
-0.769 0.250 0.588
-0.799 0.127 0.588
-0.809 0.000 0.588
-0.799 -0.127 0.588
-0.769 -0.250 0.588
-0.721 -0.367 0.588
-0.655 -0.476 0.588
-0.572 -0.572 0.588
-0.476 -0.655 0.588
-0.367 -0.721 0.588
-0.250 -0.769 0.588
-0.127 -0.799 0.588
-0.000 -0.809 0.588
0.127 -0.799 0.588
0.250 -0.769 0.588
0.367 -0.721 0.588
0.476 -0.655 0.588
0.572 -0.572 0.588
0.655 -0.476 0.588
0.721 -0.367 0.588
0.769 -0.250 0.588
0.799 -0.127 0.588
0.891 0.000 0.454
0.880 0.139 0.454
0.847 0.275 0.454
0.794 0.405 0.454
0.721 0.524 0.454
0.630 0.630 0.454
0.524 0.721 0.454
0.405 0.794 0.454
0.275 0.847 0.454
0.139 0.880 0.454
0.000 0.891 0.454
-0.139 0.880 0.454
-0.275 0.847 0.454
-0.405 0.794 0.454
-0.524 0.721 0.454
-0.630 0.630 0.454
-0.721 0.524 0.454
-0.794 0.405 0.454
-0.847 0.275 0.454
-0.880 0.139 0.454
-0.891 0.000 0.454
-0.880 -0.139 0.454
-0.847 -0.275 0.454
-0.794 -0.405 0.454
-0.721 -0.524 0.454
-0.630 -0.630 0.454
-0.524 -0.721 0.454
-0.405 -0.794 0.454
-0.275 -0.847 0.454
-0.139 -0.880 0.454
-0.000 -0.891 0.454
0.139 -0.880 0.454
0.275 -0.847 0.454
0.405 -0.794 0.454
0.524 -0.721 0.454
0.630 -0.630 0.454
0.721 -0.524 0.454
0.794 -0.405 0.454
0.847 -0.275 0.454
0.880 -0.139 0.454
0.951 0.000 0.309
0.939 0.149 0.309
0.905 0.294 0.309
0.847 0.432 0.309
0.769 0.559 0.309
0.672 0.672 0.309
0.559 0.769 0.309
0.432 0.847 0.309
0.294 0.905 0.309
0.149 0.939 0.309
0.000 0.951 0.309
-0.149 0.939 0.309
-0.294 0.905 0.309
-0.432 0.847 0.309
-0.559 0.769 0.309
-0.672 0.672 0.309
-0.769 0.559 0.309
-0.847 0.432 0.309
-0.905 0.294 0.309
-0.939 0.149 0.309
-0.951 0.000 0.309
-0.939 -0.149 0.309
-0.905 -0.294 0.309
-0.847 -0.432 0.309
-0.769 -0.559 0.309
-0.672 -0.672 0.309
-0.559 -0.769 0.309
-0.432 -0.847 0.309
-0.294 -0.905 0.309
-0.149 -0.939 0.309
-0.000 -0.951 0.309
0.149 -0.939 0.309
0.294 -0.905 0.309
0.432 -0.847 0.309
0.559 -0.769 0.309
0.672 -0.672 0.309
0.769 -0.559 0.309
0.847 -0.432 0.309
0.905 -0.294 0.309
0.939 -0.149 0.309
0.988 0.000 0.156
0.976 0.155 0.156
0.939 0.305 0.156
0.880 0.448 0.156
0.799 0.581 0.156
0.698 0.698 0.156
0.581 0.799 0.156
0.448 0.880 0.156
0.305 0.939 0.156
0.155 0.976 0.156
0.000 0.988 0.156
-0.155 0.976 0.156
-0.305 0.939 0.156
-0.448 0.880 0.156
-0.581 0.799 0.156
-0.698 0.698 0.156
-0.799 0.581 0.156
-0.880 0.448 0.156
-0.939 0.305 0.156
-0.976 0.155 0.156
-0.988 0.000 0.156
-0.976 -0.155 0.156
-0.939 -0.305 0.156
-0.880 -0.448 0.156
-0.799 -0.581 0.156
-0.698 -0.698 0.156
-0.581 -0.799 0.156
-0.448 -0.880 0.156
-0.305 -0.939 0.156
-0.155 -0.976 0.156
-0.000 -0.988 0.156
0.155 -0.976 0.156
0.305 -0.939 0.156
0.448 -0.880 0.156
0.581 -0.799 0.156
0.698 -0.698 0.156
0.799 -0.581 0.156
0.880 -0.448 0.156
0.939 -0.305 0.156
0.976 -0.155 0.156
1.000 0.000 0.000
0.988 0.156 0.000
0.951 0.309 0.000
0.891 0.454 0.000
0.809 0.588 0.000
0.707 0.707 0.000
0.588 0.809 0.000
0.454 0.891 0.000
0.309 0.951 0.000
0.156 0.988 0.000
0.000 1.000 0.000
-0.156 0.988 0.000
-0.309 0.951 0.000
-0.454 0.891 0.000
-0.588 0.809 0.000
-0.707 0.707 0.000
-0.809 0.588 0.000
-0.891 0.454 0.000
-0.951 0.309 0.000
-0.988 0.156 0.000
-1.000 0.000 0.000
-0.988 -0.156 0.000
-0.951 -0.309 0.000
-0.891 -0.454 0.000
-0.809 -0.588 0.000
-0.707 -0.707 0.000
-0.588 -0.809 0.000
-0.454 -0.891 0.000
-0.309 -0.951 0.000
-0.156 -0.988 0.000
-0.000 -1.000 0.000
0.156 -0.988 0.000
0.309 -0.951 0.000
0.454 -0.891 0.000
0.588 -0.809 0.000
0.707 -0.707 0.000
0.809 -0.588 0.000
0.891 -0.454 0.000
0.951 -0.309 0.000
0.988 -0.156 0.000
0.988 0.000 -0.156
0.976 0.155 -0.156
0.939 0.305 -0.156
0.880 0.448 -0.156
0.799 0.581 -0.156
0.698 0.698 -0.156
0.581 0.799 -0.156
0.448 0.880 -0.156
0.305 0.939 -0.156
0.155 0.976 -0.156
0.000 0.988 -0.156
-0.155 0.976 -0.156
-0.305 0.939 -0.156
-0.448 0.880 -0.156
-0.581 0.799 -0.156
-0.698 0.698 -0.156
-0.799 0.581 -0.156
-0.880 0.448 -0.156
-0.939 0.305 -0.156
-0.976 0.155 -0.156
-0.988 0.000 -0.156
-0.976 -0.155 -0.156
-0.939 -0.305 -0.156
-0.880 -0.448 -0.156
-0.799 -0.581 -0.156
-0.698 -0.698 -0.156
-0.581 -0.799 -0.156
-0.448 -0.880 -0.156
-0.305 -0.939 -0.156
-0.155 -0.976 -0.156
-0.000 -0.988 -0.156
0.155 -0.976 -0.156
0.305 -0.939 -0.156
0.448 -0.880 -0.156
0.581 -0.799 -0.156
0.698 -0.698 -0.156
0.799 -0.581 -0.156
0.880 -0.448 -0.156
0.939 -0.305 -0.156
0.976 -0.155 -0.156
0.951 0.000 -0.309
0.939 0.149 -0.309
0.905 0.294 -0.309
0.847 0.432 -0.309
0.769 0.559 -0.309
0.672 0.672 -0.309
0.559 0.769 -0.309
0.432 0.847 -0.309
0.294 0.905 -0.309
0.149 0.939 -0.309
0.000 0.951 -0.309
-0.149 0.939 -0.309
-0.294 0.905 -0.309
-0.432 0.847 -0.309
-0.559 0.769 -0.309
-0.672 0.672 -0.309
-0.769 0.559 -0.309
-0.847 0.432 -0.309
-0.905 0.294 -0.309
-0.939 0.149 -0.309
-0.951 0.000 -0.309
-0.939 -0.149 -0.309
-0.905 -0.294 -0.309
-0.847 -0.432 -0.309
-0.769 -0.559 -0.309
-0.672 -0.672 -0.309
-0.559 -0.769 -0.309
-0.432 -0.847 -0.309
-0.294 -0.905 -0.309
-0.149 -0.939 -0.309
-0.000 -0.951 -0.309
0.149 -0.939 -0.309
0.294 -0.905 -0.309
0.432 -0.847 -0.309
0.559 -0.769 -0.309
0.672 -0.672 -0.309
0.769 -0.559 -0.309
0.847 -0.432 -0.309
0.905 -0.294 -0.309
0.939 -0.149 -0.309
0.891 0.000 -0.454
0.880 0.139 -0.454
0.847 0.275 -0.454
0.794 0.405 -0.454
0.721 0.524 -0.454
0.630 0.630 -0.454
0.524 0.721 -0.454
0.405 0.794 -0.454
0.275 0.847 -0.454
0.139 0.880 -0.454
0.000 0.891 -0.454
-0.139 0.880 -0.454
-0.275 0.847 -0.454
-0.405 0.794 -0.454
-0.524 0.721 -0.454
-0.630 0.630 -0.454
-0.721 0.524 -0.454
-0.794 0.405 -0.454
-0.847 0.275 -0.454
-0.880 0.139 -0.454
-0.891 0.000 -0.454
-0.880 -0.139 -0.454
-0.847 -0.275 -0.454
-0.794 -0.405 -0.454
-0.721 -0.524 -0.454
-0.630 -0.630 -0.454
-0.524 -0.721 -0.454
-0.405 -0.794 -0.454
-0.275 -0.847 -0.454
-0.139 -0.880 -0.454
-0.000 -0.891 -0.454
0.139 -0.880 -0.454
0.275 -0.847 -0.454
0.405 -0.794 -0.454
0.524 -0.721 -0.454
0.630 -0.630 -0.454
0.721 -0.524 -0.454
0.794 -0.405 -0.454
0.847 -0.275 -0.454
0.880 -0.139 -0.454
0.809 0.000 -0.588
0.799 0.127 -0.588
0.769 0.250 -0.588
0.721 0.367 -0.588
0.655 0.476 -0.588
0.572 0.572 -0.588
0.476 0.655 -0.588
0.367 0.721 -0.588
0.250 0.769 -0.588
0.127 0.799 -0.588
0.000 0.809 -0.588
-0.127 0.799 -0.588
-0.250 0.769 -0.588
-0.367 0.721 -0.588
-0.476 0.655 -0.588
-0.572 0.572 -0.588
-0.655 0.476 -0.588
-0.721 0.367 -0.588
-0.769 0.250 -0.588
-0.799 0.127 -0.588
-0.809 0.000 -0.588
-0.799 -0.127 -0.588
-0.769 -0.250 -0.588
-0.721 -0.367 -0.588
-0.655 -0.476 -0.588
-0.572 -0.572 -0.588
-0.476 -0.655 -0.588
-0.367 -0.721 -0.588
-0.250 -0.769 -0.588
-0.127 -0.799 -0.588
-0.000 -0.809 -0.588
0.127 -0.799 -0.588
0.250 -0.769 -0.588
0.367 -0.721 -0.588
0.476 -0.655 -0.588
0.572 -0.572 -0.588
0.655 -0.476 -0.588
0.721 -0.367 -0.588
0.769 -0.250 -0.588
0.799 -0.127 -0.588
0.707 0.000 -0.707
0.698 0.111 -0.707
0.672 0.219 -0.707
0.630 0.321 -0.707
0.572 0.416 -0.707
0.500 0.500 -0.707
0.416 0.572 -0.707
0.321 0.630 -0.707
0.219 0.672 -0.707
0.111 0.698 -0.707
0.000 0.707 -0.707
-0.111 0.698 -0.707
-0.219 0.672 -0.707
-0.321 0.630 -0.707
-0.416 0.572 -0.707
-0.500 0.500 -0.707
-0.572 0.416 -0.707
-0.630 0.321 -0.707
-0.672 0.219 -0.707
-0.698 0.111 -0.707
-0.707 0.000 -0.707
-0.698 -0.111 -0.707
-0.672 -0.219 -0.707
-0.630 -0.321 -0.707
-0.572 -0.416 -0.707
-0.500 -0.500 -0.707
-0.416 -0.572 -0.707
-0.321 -0.630 -0.707
-0.219 -0.672 -0.707
-0.111 -0.698 -0.707
-0.000 -0.707 -0.707
0.111 -0.698 -0.707
0.219 -0.672 -0.707
0.321 -0.630 -0.707
0.416 -0.572 -0.707
0.500 -0.500 -0.707
0.572 -0.416 -0.707
0.630 -0.321 -0.707
0.672 -0.219 -0.707
0.698 -0.111 -0.707
0.588 0.000 -0.809
0.581 0.092 -0.809
0.559 0.182 -0.809
0.524 0.267 -0.809
0.476 0.345 -0.809
0.416 0.416 -0.809
0.345 0.476 -0.809
0.267 0.524 -0.809
0.182 0.559 -0.809
0.092 0.581 -0.809
0.000 0.588 -0.809
-0.092 0.581 -0.809
-0.182 0.559 -0.809
-0.267 0.524 -0.809
-0.345 0.476 -0.809
-0.416 0.416 -0.809
-0.476 0.345 -0.809
-0.524 0.267 -0.809
-0.559 0.182 -0.809
-0.581 0.092 -0.809
-0.588 0.000 -0.809
-0.581 -0.092 -0.809
-0.559 -0.182 -0.809
-0.524 -0.267 -0.809
-0.476 -0.345 -0.809
-0.416 -0.416 -0.809
-0.345 -0.476 -0.809
-0.267 -0.524 -0.809
-0.182 -0.559 -0.809
-0.092 -0.581 -0.809
-0.000 -0.588 -0.809
0.092 -0.581 -0.809
0.182 -0.559 -0.809
0.267 -0.524 -0.809
0.345 -0.476 -0.809
0.416 -0.416 -0.809
0.476 -0.345 -0.809
0.524 -0.267 -0.809
0.559 -0.182 -0.809
0.581 -0.092 -0.809
0.454 0.000 -0.891
0.448 0.071 -0.891
0.432 0.140 -0.891
0.405 0.206 -0.891
0.367 0.267 -0.891
0.321 0.321 -0.891
0.267 0.367 -0.891
0.206 0.405 -0.891
0.140 0.432 -0.891
0.071 0.448 -0.891
0.000 0.454 -0.891
-0.071 0.448 -0.891
-0.140 0.432 -0.891
-0.206 0.405 -0.891
-0.267 0.367 -0.891
-0.321 0.321 -0.891
-0.367 0.267 -0.891
-0.405 0.206 -0.891
-0.432 0.140 -0.891
-0.448 0.071 -0.891
-0.454 0.000 -0.891
-0.448 -0.071 -0.891
-0.432 -0.140 -0.891
-0.405 -0.206 -0.891
-0.367 -0.267 -0.891
-0.321 -0.321 -0.891
-0.267 -0.367 -0.891
-0.206 -0.405 -0.891
-0.140 -0.432 -0.891
-0.071 -0.448 -0.891
-0.000 -0.454 -0.891
0.071 -0.448 -0.891
0.140 -0.432 -0.891
0.206 -0.405 -0.891
0.267 -0.367 -0.891
0.321 -0.321 -0.891
0.367 -0.267 -0.891
0.405 -0.206 -0.891
0.432 -0.140 -0.891
0.448 -0.071 -0.891
0.309 0.000 -0.951
0.305 0.048 -0.951
0.294 0.095 -0.951
0.275 0.140 -0.951
0.250 0.182 -0.951
0.219 0.219 -0.951
0.182 0.250 -0.951
0.140 0.275 -0.951
0.095 0.294 -0.951
0.048 0.305 -0.951
0.000 0.309 -0.951
-0.048 0.305 -0.951
-0.095 0.294 -0.951
-0.140 0.275 -0.951
-0.182 0.250 -0.951
-0.219 0.219 -0.951
-0.250 0.182 -0.951
-0.275 0.140 -0.951
-0.294 0.095 -0.951
-0.305 0.048 -0.951
-0.309 0.000 -0.951
-0.305 -0.048 -0.951
-0.294 -0.095 -0.951
-0.275 -0.140 -0.951
-0.250 -0.182 -0.951
-0.219 -0.219 -0.951
-0.182 -0.250 -0.951
-0.140 -0.275 -0.951
-0.095 -0.294 -0.951
-0.048 -0.305 -0.951
-0.000 -0.309 -0.951
0.048 -0.305 -0.951
0.095 -0.294 -0.951
0.140 -0.275 -0.951
0.182 -0.250 -0.951
0.219 -0.219 -0.951
0.250 -0.182 -0.951
0.275 -0.140 -0.951
0.294 -0.095 -0.951
0.305 -0.048 -0.951
0.156 0.000 -0.988
0.155 0.024 -0.988
0.149 0.048 -0.988
0.139 0.071 -0.988
0.127 0.092 -0.988
0.111 0.111 -0.988
0.092 0.127 -0.988
0.071 0.139 -0.988
0.048 0.149 -0.988
0.024 0.155 -0.988
0.000 0.156 -0.988
-0.024 0.155 -0.988
-0.048 0.149 -0.988
-0.071 0.139 -0.988
-0.092 0.127 -0.988
-0.111 0.111 -0.988
-0.127 0.092 -0.988
-0.139 0.071 -0.988
-0.149 0.048 -0.988
-0.155 0.024 -0.988
-0.156 0.000 -0.988
-0.155 -0.024 -0.988
-0.149 -0.048 -0.988
-0.139 -0.071 -0.988
-0.127 -0.092 -0.988
-0.111 -0.111 -0.988
-0.092 -0.127 -0.988
-0.071 -0.139 -0.988
-0.048 -0.149 -0.988
-0.024 -0.155 -0.988
-0.000 -0.156 -0.988
0.024 -0.155 -0.988
0.048 -0.149 -0.988
0.071 -0.139 -0.988
0.092 -0.127 -0.988
0.111 -0.111 -0.988
0.127 -0.092 -0.988
0.139 -0.071 -0.988
0.149 -0.048 -0.988
0.155 -0.024 -0.988

View File

@ -2,7 +2,7 @@
@ Date: 2021-01-13 20:38:33 @ Date: 2021-01-13 20:38:33
@ Author: Qing Shuai @ Author: Qing Shuai
@ LastEditors: Qing Shuai @ LastEditors: Qing Shuai
@ LastEditTime: 2021-01-22 20:45:37 @ LastEditTime: 2021-01-25 14:41:56
@ FilePath: /EasyMocap/scripts/preprocess/extract_video.py @ FilePath: /EasyMocap/scripts/preprocess/extract_video.py
''' '''
import os, sys import os, sys
@ -16,7 +16,7 @@ sys.path.append(code_path)
mkdir = lambda x: os.makedirs(x, exist_ok=True) mkdir = lambda x: os.makedirs(x, exist_ok=True)
def extract_video(videoname, path, start=0, end=10000, step=1): def extract_video(videoname, path, start, end, step):
base = os.path.basename(videoname).replace('.mp4', '') base = os.path.basename(videoname).replace('.mp4', '')
if not os.path.exists(videoname): if not os.path.exists(videoname):
return base return base
@ -193,6 +193,12 @@ if __name__ == "__main__":
default='/media/qing/Project/openpose') default='/media/qing/Project/openpose')
parser.add_argument('--render', action='store_true', help='use to render the openpose 2d') parser.add_argument('--render', action='store_true', help='use to render the openpose 2d')
parser.add_argument('--no2d', action='store_true') parser.add_argument('--no2d', action='store_true')
parser.add_argument('--start', type=int, default=0,
help='frame start')
parser.add_argument('--end', type=int, default=10000,
help='frame end')
parser.add_argument('--step', type=int, default=1,
help='frame step')
parser.add_argument('--debug', action='store_true') parser.add_argument('--debug', action='store_true')
args = parser.parse_args() args = parser.parse_args()
mode = args.mode mode = args.mode
@ -201,7 +207,7 @@ if __name__ == "__main__":
videos = sorted(glob(join(args.path, 'videos', '*.mp4'))) videos = sorted(glob(join(args.path, 'videos', '*.mp4')))
subs = [] subs = []
for video in videos: for video in videos:
basename = extract_video(video, args.path) basename = extract_video(video, args.path, start=args.start, end=args.end, step=args.step)
subs.append(basename) subs.append(basename)
print('cameras: ', ' '.join(subs)) print('cameras: ', ' '.join(subs))
if not args.no2d: if not args.no2d: