def json2fp(json, size, ratio): scene = objs.Scene() utils.loadLabelByJson(json, scene) scene.normalize(cameraH=1.6) floorMap_down = utils.genLayoutFloorMap(scene, size, ratio) scene = objs.Scene() utils.loadLabelByJson(json, scene) scene.normalize_ceiling(ccH=1.6) floorMap_up = utils.genLayoutFloorMap(scene, size, ratio) return floorMap_down, floorMap_up
def json2fp(json, size, ratio): scene = objs.Scene() utils.loadLabelByJson(json, scene) floorMap = utils.genLayoutFloorMap(scene, size, ratio) return floorMap
def lnet2scene(data_path): with open(data_path) as f: content = f.readlines() data = [x.strip().split() for x in content] scene = objs.Scene() scene.cameraHeight = 1.6 scene.layoutHeight = float(data[0][0]) if math.isnan(scene.layoutHeight): return None for i in range(1, 5): if math.isnan(float(data[i][0])) or math.isnan(float(data[i][1])): return None xyz = (float(data[i][0]), 0, -float(data[i][1])) scene.layoutPoints.append(objs.GeoPoint(scene, None, xyz)) scene.layoutPoints.reverse() scene.genLayoutWallsByPoints(scene.layoutPoints) scene.updateLayoutGeometry() return scene
def data2scene(fp_points, height): # cam-ceiling / cam-floor scale = (height - 1.6) / 1.6 #layout_fp, fp_points = fit_layout(fp, scale=None, max_cor=12) size = 512 ratio = 20/size fp_points = fp_points.astype(float) fp_points[0] -= size/2 fp_points[1] -= size/2 fp_points *= scale fp_points[0] += size/2 fp_points[1] += size/2 fp_points = fp_points.astype(int) scene = objs.Scene() scene.cameraHeight = 1.6 scene.layoutHeight = float(height) scene.layoutPoints = [] for i in range(fp_points.shape[1]): fp_xy = (fp_points[:,i] - size/2) * ratio xyz = (fp_xy[1], 0, fp_xy[0]) scene.layoutPoints.append(objs.GeoPoint(scene, None, xyz)) scene.genLayoutWallsByPoints(scene.layoutPoints) scene.updateLayoutGeometry() return scene
def json2scene(json): scene = objs.Scene() utils.loadLabelByJson(json, scene) #scene.normalize(cameraH=1.6) scene.normalize_ceiling(ccH=1.6) return scene
def pts2scene(fp_pts, height): camera_h = cf.camera_h scale = (height - camera_h) / camera_h fp_pts = fp_pts.astype(float) fp_pts -= cf.fp_size / 2 fp_pts *= scale fp_pts = fp_pts.astype(int) scene = objs.Scene() scene.cameraHeight = camera_h scene.layoutHeight = float(height) scene.layoutPoints = [] for i in range(fp_pts.shape[1]): fp_xy = fp_pts[:,i] * (cf.fp_meter / cf.fp_size) xyz = (fp_xy[1], 0, fp_xy[0]) scene.layoutPoints.append(objs.GeoPoint(xyz)) scene.genLayoutWallsByPoints(scene.layoutPoints) scene.updateLayoutGeometry() return scene
for i in range(1, 5): xyz = (float(data[i][0]), 0, -float(data[i][1])) print(xyz) scene.layoutPoints.append(objs.GeoPoint(scene, None, xyz)) scene.genLayoutWallsByPoints(scene.layoutPoints) scene.updateLayoutGeometry() return scene if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--i', required=True) parser.add_argument('--gt', required=True) args = parser.parse_args() data_path = args.i scene_pred = lnet2scene(data_path) fp_pred = utils.genLayoutFloorMap(scene_pred, (512, 512), 20 / 512) gt_path = args.gt scene_gt = objs.Scene() utils.loadLabelByJson(gt_path, scene_gt) scene_gt.normalize(cameraH=1.6) fp_gt = utils.genLayoutFloorMap(scene_gt, (512, 512), 20 / 512) utils.showImage([fp_pred, fp_gt])
def json2scene(json): scene = objs.Scene() utils.loadLabelByJson(json, scene) return scene
import os import argparse import objs import utils if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--i', required=True) args = parser.parse_args() labelPath = args.i outputPath = os.path.dirname(args.i) scene = objs.Scene() utils.loadLabelByJson(labelPath, scene) scene.normalize() mapSize = [512, 1024, 3] #edgeMap = utils.genLayoutEdgeMap(scene, mapSize) #utils.saveImage(edgeMap, os.path.join(outputPath, 'edge.png')) #normalMap = utils.genLayoutNormalMap(scene, mapSize) #utils.saveImage(normalMap, os.path.join(outputPath, 'normal.png')) #depthMap = utils.genLayoutDepthMap(scene, mapSize) #utils.saveDepth(depthMap, os.path.join(outputPath, 'depth.png')) #obj2dMap = utils.genLayoutObj2dMap(scene, mapSize)