|
@@ -1,5 +1,6 @@
|
|
|
package com.css.simulation.resource.video.service;
|
|
|
|
|
|
+import api.common.pojo.common.ResponseBodyVO;
|
|
|
import api.common.pojo.po.scene.VehicleTypePO;
|
|
|
import api.common.pojo.vo.model.VehicleVO;
|
|
|
import api.common.util.FileUtil;
|
|
@@ -45,7 +46,8 @@ public class VideoService {
|
|
|
public static final String oldXoscName = "simulation_my0.xosc";
|
|
|
public static final String newXoscName = "simulation_my05.xosc";
|
|
|
public static final String oldXoscRelativePath = "xosc/simulation_my0.xosc";
|
|
|
- public static final String[] csvNameArray = {"Ego.csv", "evaluation.csv"};
|
|
|
+ public static final String csv1Name = "Ego.csv";
|
|
|
+ public static final String csv2Name = "evaluation.csv";
|
|
|
|
|
|
//* -------------------------------- Comment --------------------------------
|
|
|
@Value("${scheduler.linux-path.temp}")
|
|
@@ -60,26 +62,35 @@ public class VideoService {
|
|
|
* 生成视频
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public void generateVideo(String projectId, String projectType, String taskId) {
|
|
|
+ public ResponseBodyVO<String> generateVideo(String projectId, String projectType, String taskId) {
|
|
|
//1 获取两个 csv 的目录,和 xodr 和 osgb 三个路径
|
|
|
- String csvDirectoryPath = linuxTempPath + "video/" + projectId + "/" + taskId + "/";
|
|
|
- String xodrPath = FileUtil.listAbsolutePathByFiletype(csvDirectoryPath, ".xodr").get(0); // xodr 文件在创建项目时已经下载好了
|
|
|
- String osgbPath = FileUtil.listAbsolutePathByFiletype(csvDirectoryPath, ".osgb").get(0); // osgb 文件在创建项目时已经下载好了
|
|
|
- //2 下载 csv 文件
|
|
|
- for (String csvName : csvNameArray) {
|
|
|
- MinioUtil.downloadToFile(minioClient, bucketName, projectResultPathOfMinio + projectId + "/" + taskId + "/" + csvName, csvDirectoryPath + "/" + csvName);
|
|
|
- }
|
|
|
+ String rootDirectoryPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/";
|
|
|
+ String xodrPathOfMinio = rootDirectoryPathOfMinio + taskId + ".xodr";
|
|
|
+ String osgbPathOfMinio = rootDirectoryPathOfMinio + taskId + ".osgb";
|
|
|
+ String csv1PathOfMinio = rootDirectoryPathOfMinio + csv1Name;
|
|
|
+ String csv2PathOfMinio = rootDirectoryPathOfMinio + csv2Name;
|
|
|
+ String rootDirectoryPathOfLinux = linuxTempPath + "video/" + projectId + "/" + taskId + "/";
|
|
|
+ String xodrPathOfLinux = rootDirectoryPathOfLinux + taskId + ".xodr";
|
|
|
+ String osgbPathOfLinux = rootDirectoryPathOfLinux + taskId + ".osgb";
|
|
|
+ String csv1PathOfLinux = rootDirectoryPathOfLinux + csv1Name;
|
|
|
+ String csv2PathOfLinux = rootDirectoryPathOfLinux + csv2Name;
|
|
|
+ //2 下载 csv、xodr、osgb
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, xodrPathOfMinio, xodrPathOfLinux);
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, osgbPathOfMinio, osgbPathOfLinux);
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, csv1PathOfMinio, csv1PathOfLinux);
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, csv2PathOfMinio, csv2PathOfLinux);
|
|
|
+
|
|
|
//3 生成 xosc 文件
|
|
|
- String xoscPath = generateXosc(csvDirectoryPath, xodrPath, osgbPath, projectId, projectType);
|
|
|
+ String xoscPath = generateXosc(rootDirectoryPathOfLinux, xodrPathOfLinux, osgbPathOfLinux, projectId, projectType);
|
|
|
//4 生成图片
|
|
|
- String pictureDirectoryPath = csvDirectoryPath + "picture";
|
|
|
+ String pictureDirectoryPath = rootDirectoryPathOfLinux + "picture";
|
|
|
FileUtil.createDirectory(pictureDirectoryPath);
|
|
|
- String esminiCommand = "/root/disk1/simulation-cloud/esmini/build/EnvironmentSimulator/code-examples/image-capture/image-capture "
|
|
|
+ String esminiCommand = "/root/disk1/simulation-cloud/esmini/build/EnvironmentSimulator/code-examples/image-capture/image-capture "
|
|
|
+ xoscPath + " " + pictureDirectoryPath + "/screenshot";
|
|
|
String esminiResult = LinuxUtil.execute(esminiCommand);
|
|
|
//5 生成视频
|
|
|
String videoName = "simulation_output.mp4";
|
|
|
- String videoTargetPathOfLinux = csvDirectoryPath + "video";
|
|
|
+ String videoTargetPathOfLinux = rootDirectoryPathOfLinux + "video";
|
|
|
FileUtil.createDirectory(videoTargetPathOfLinux);
|
|
|
String videoTargetPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/" + videoName;
|
|
|
|
|
@@ -91,6 +102,7 @@ public class VideoService {
|
|
|
);
|
|
|
//6 将视频上传到 minio
|
|
|
MinioUtil.uploadFromFile(minioClient, videoTargetPathOfLinux + videoName, bucketName, videoTargetPathOfMinio);
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -142,7 +154,7 @@ public class VideoService {
|
|
|
name.setText("Audi_A3_2009_red");
|
|
|
Attribute vehicleCategory = node3.attribute("vehicleCategory");
|
|
|
vehicleCategory.setText(po.getVehicleCategory());
|
|
|
- node3.addAttribute("model3d",po.getModel3d());//自车渲染
|
|
|
+ node3.addAttribute("model3d", po.getModel3d());//自车渲染
|
|
|
Iterator<Element> iterator4 = node3.elementIterator();
|
|
|
while (iterator4.hasNext()) {
|
|
|
Element node4 = iterator4.next();
|