|
|
|
@ -7,6 +7,7 @@ import { Annotation } from "./annotation.js";
|
|
|
|
import { EgoPose } from "./ego_pose.js";
|
|
|
|
import { EgoPose } from "./ego_pose.js";
|
|
|
|
import { logger } from "./log.js";
|
|
|
|
import { logger } from "./log.js";
|
|
|
|
import request from "./request.js";
|
|
|
|
import request from "./request.js";
|
|
|
|
|
|
|
|
import fileHttp from "./fileHttp.js";
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
euler_angle_to_rotate_matrix,
|
|
|
|
euler_angle_to_rotate_matrix,
|
|
|
|
euler_angle_to_rotate_matrix_3by3,
|
|
|
|
euler_angle_to_rotate_matrix_3by3,
|
|
|
|
@ -21,12 +22,14 @@ function FrameInfo(data, sceneMeta, sceneName, frame) {
|
|
|
|
this.dir = "";
|
|
|
|
this.dir = "";
|
|
|
|
this.scene = sceneName;
|
|
|
|
this.scene = sceneName;
|
|
|
|
this.frame = frame;
|
|
|
|
this.frame = frame;
|
|
|
|
|
|
|
|
this.annotationData = null;
|
|
|
|
this.pcd_ext = "";
|
|
|
|
this.pcd_ext = "";
|
|
|
|
|
|
|
|
this.loadCallback = null;
|
|
|
|
(this.frame_index = this.sceneMeta.frames.findIndex(function (x) {
|
|
|
|
(this.frame_index = this.sceneMeta.frames.findIndex(function (x) {
|
|
|
|
return x == frame;
|
|
|
|
return x == frame;
|
|
|
|
})),
|
|
|
|
})),
|
|
|
|
(this.transform_matrix = this.sceneMeta.point_transform_matrix),
|
|
|
|
(this.transform_matrix = this.sceneMeta.point_transform_matrix),
|
|
|
|
(this.annotation_format = this.sceneMeta.boxtype), //xyz(24 number), csr(center, scale, rotation, 9 number)
|
|
|
|
(this.annotation_format = this.sceneMeta.boxType), //xyz(24 number), csr(center, scale, rotation, 9 number)
|
|
|
|
// this.set = function(scene, frame_index, frame, transform_matrix, annotation_format){
|
|
|
|
// this.set = function(scene, frame_index, frame, transform_matrix, annotation_format){
|
|
|
|
// this.scene = scene;
|
|
|
|
// this.scene = scene;
|
|
|
|
// this.frame = frame;
|
|
|
|
// this.frame = frame;
|
|
|
|
@ -36,15 +39,18 @@ function FrameInfo(data, sceneMeta, sceneName, frame) {
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
(this.get_pcd_path = function () {
|
|
|
|
(this.get_pcd_path = function () {
|
|
|
|
|
|
|
|
if (this.annotationData) {
|
|
|
|
|
|
|
|
return fileHttp + this.annotationData.lidarPcdPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
request + "/data/" + this.scene + "/lidar/" + this.frame + this.sceneMeta.lidar_ext
|
|
|
|
request + "/data/" + this.scene + "/lidar/" + this.frame + this.sceneMeta.lidarExt
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.get_radar_path = function (name) {
|
|
|
|
this.get_radar_path = function (name) {
|
|
|
|
return `${request}/data/${this.scene}/radar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
|
|
|
|
return `${request}/data/${this.scene}/radar/${name}/${this.frame}${this.sceneMeta.radarExt}`;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.get_aux_lidar_path = function (name) {
|
|
|
|
this.get_aux_lidar_path = function (name) {
|
|
|
|
return `${request}/data/${this.scene}/aux_lidar/${name}/${this.frame}${this.sceneMeta.radar_ext}`;
|
|
|
|
return `${request}/data/${this.scene}/aux_lidar/${name}/${this.frame}${this.sceneMeta.radarExt}`;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.get_anno_path = function () {
|
|
|
|
this.get_anno_path = function () {
|
|
|
|
@ -55,6 +61,17 @@ function FrameInfo(data, sceneMeta, sceneName, frame) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置注释数据并触发回调
|
|
|
|
|
|
|
|
this.setAnnotationData = function(data) {
|
|
|
|
|
|
|
|
this.annotationData = data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果已经有加载回调但尚未执行,则执行它
|
|
|
|
|
|
|
|
if (this.loadCallback && !this.loadCallback.executed) {
|
|
|
|
|
|
|
|
this.loadCallback.executed = true;
|
|
|
|
|
|
|
|
this.loadCallback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.anno_to_boxes = function (text) {
|
|
|
|
this.anno_to_boxes = function (text) {
|
|
|
|
var _self = this;
|
|
|
|
var _self = this;
|
|
|
|
if (this.annotation_format == "psr") {
|
|
|
|
if (this.annotation_format == "psr") {
|
|
|
|
@ -166,6 +183,11 @@ function FrameInfo(data, sceneMeta, sceneName, frame) {
|
|
|
|
|
|
|
|
|
|
|
|
function Images(sceneMeta, sceneName, frame) {
|
|
|
|
function Images(sceneMeta, sceneName, frame) {
|
|
|
|
this.loaded = function () {
|
|
|
|
this.loaded = function () {
|
|
|
|
|
|
|
|
// 如果没有相机名称,则认为已加载完成
|
|
|
|
|
|
|
|
if (!this.names || this.names.length === 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (var n in this.names) {
|
|
|
|
for (var n in this.names) {
|
|
|
|
if (!this.loaded_flag[this.names[n]]) return false;
|
|
|
|
if (!this.loaded_flag[this.names[n]]) return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -175,61 +197,94 @@ function Images(sceneMeta, sceneName, frame) {
|
|
|
|
|
|
|
|
|
|
|
|
this.names = sceneMeta.camera; //["image","left","right"],
|
|
|
|
this.names = sceneMeta.camera; //["image","left","right"],
|
|
|
|
this.loaded_flag = {};
|
|
|
|
this.loaded_flag = {};
|
|
|
|
// this.active_name = "";
|
|
|
|
this.content = {};
|
|
|
|
// this.active_image = function(){
|
|
|
|
this.on_all_loaded = null;
|
|
|
|
// return this.content[this.active_name];
|
|
|
|
this.annotationData = null;
|
|
|
|
// };
|
|
|
|
this.sceneName = sceneName;
|
|
|
|
|
|
|
|
this.frame = frame;
|
|
|
|
|
|
|
|
this.sceneMeta = sceneMeta;
|
|
|
|
|
|
|
|
this.loadCallback = null;
|
|
|
|
|
|
|
|
this.active_name = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.getImageByName = function (name) {
|
|
|
|
this.getImageByName = function (name) {
|
|
|
|
return this.content[name];
|
|
|
|
return this.content[name];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// this.activate = function(name){
|
|
|
|
// 设置注释数据并触发图像加载
|
|
|
|
// this.active_name = name;
|
|
|
|
this.setAnnotationData = function(data) {
|
|
|
|
// };
|
|
|
|
this.annotationData = data;
|
|
|
|
|
|
|
|
|
|
|
|
this.content = {};
|
|
|
|
// 如果已经有加载回调但尚未执行,则执行它
|
|
|
|
this.on_all_loaded = null;
|
|
|
|
if (this.loadCallback && !this.loadCallback.executed) {
|
|
|
|
|
|
|
|
this.loadCallback.executed = true;
|
|
|
|
|
|
|
|
this.loadCallback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
(this.load = function (on_all_loaded, active_name) {
|
|
|
|
this.load = function (on_all_loaded, active_name) {
|
|
|
|
this.on_all_loaded = on_all_loaded;
|
|
|
|
this.on_all_loaded = on_all_loaded;
|
|
|
|
|
|
|
|
this.active_name = active_name;
|
|
|
|
// if global camera not set, use first camera as default.
|
|
|
|
|
|
|
|
// if (active_name.length > 0)
|
|
|
|
|
|
|
|
// this.active_name = active_name;
|
|
|
|
|
|
|
|
// else if (this.names && this.names.length>0)
|
|
|
|
|
|
|
|
// this.active_name = this.names[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _self = this;
|
|
|
|
var _self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义实际的图像加载函数
|
|
|
|
|
|
|
|
const doImageLoad = function() {
|
|
|
|
|
|
|
|
// 如果 global camera 未设置,使用第一个相机作为默认
|
|
|
|
|
|
|
|
// if (active_name.length > 0)
|
|
|
|
|
|
|
|
// this.active_name = active_name;
|
|
|
|
|
|
|
|
// else if (this.names && this.names.length>0)
|
|
|
|
|
|
|
|
// this.active_name = this.names[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_self.names) {
|
|
|
|
|
|
|
|
_self.names.forEach(function (cam) {
|
|
|
|
|
|
|
|
_self.content[cam] = new Image();
|
|
|
|
|
|
|
|
_self.content[cam].onload = function () {
|
|
|
|
|
|
|
|
_self.loaded_flag[cam] = true;
|
|
|
|
|
|
|
|
_self.on_image_loaded();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
_self.content[cam].onerror = function () {
|
|
|
|
|
|
|
|
_self.loaded_flag[cam] = true;
|
|
|
|
|
|
|
|
_self.on_image_loaded();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用注释数据构造图像路径(如果可用)
|
|
|
|
|
|
|
|
if (_self.annotationData) {
|
|
|
|
|
|
|
|
_self.content[cam].src = fileHttp + _self.annotationData[`${cam}ImgPath`]
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 回退到原来的路径
|
|
|
|
|
|
|
|
_self.content[cam].src =
|
|
|
|
|
|
|
|
"data/example/camera/" +
|
|
|
|
|
|
|
|
cam +
|
|
|
|
|
|
|
|
"/000965" +
|
|
|
|
|
|
|
|
_self.sceneMeta.cameraExt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("image set", _self.content[cam].src);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 没有相机名称,直接调用完成回调
|
|
|
|
|
|
|
|
if (_self.on_all_loaded) {
|
|
|
|
|
|
|
|
_self.on_all_loaded();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (this.names) {
|
|
|
|
// 如果已经有注释数据,立即加载图像
|
|
|
|
this.names.forEach(function (cam) {
|
|
|
|
if (this.annotationData) {
|
|
|
|
_self.content[cam] = new Image();
|
|
|
|
doImageLoad();
|
|
|
|
_self.content[cam].onload = function () {
|
|
|
|
} else {
|
|
|
|
_self.loaded_flag[cam] = true;
|
|
|
|
// 否则保存回调,等待注释数据到达后再执行
|
|
|
|
_self.on_image_loaded();
|
|
|
|
this.loadCallback = doImageLoad;
|
|
|
|
};
|
|
|
|
|
|
|
|
_self.content[cam].onerror = function () {
|
|
|
|
|
|
|
|
_self.loaded_flag[cam] = true;
|
|
|
|
|
|
|
|
_self.on_image_loaded();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_self.content[cam].src =
|
|
|
|
|
|
|
|
"data/" +
|
|
|
|
|
|
|
|
sceneName +
|
|
|
|
|
|
|
|
"/camera/" +
|
|
|
|
|
|
|
|
cam +
|
|
|
|
|
|
|
|
"/" +
|
|
|
|
|
|
|
|
frame +
|
|
|
|
|
|
|
|
sceneMeta.camera_ext;
|
|
|
|
|
|
|
|
console.log("image set");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
(this.on_image_loaded = function () {
|
|
|
|
|
|
|
|
if (this.loaded()) {
|
|
|
|
this.on_image_loaded = function () {
|
|
|
|
|
|
|
|
if (this.loaded()) {
|
|
|
|
|
|
|
|
if (this.on_all_loaded) {
|
|
|
|
this.on_all_loaded();
|
|
|
|
this.on_all_loaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function World(data, sceneName, frame, coordinatesOffset, on_preload_finished) {
|
|
|
|
function World(data, sceneName, frame, coordinatesOffset, on_preload_finished) {
|
|
|
|
|