|
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@@ -34,7 +35,7 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
log.info("计算完毕");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void saveuploadImgs2(String folderName) throws IOException, Exception
|
|
|
{
|
|
|
log.info("开始计算");
|
|
@@ -49,7 +50,7 @@ public class CreateObjUtil {
|
|
|
log.info("计算完毕");
|
|
|
log.info("obj和camera转换成大场景要的格式");
|
|
|
convertobjTotxt( folderName);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//开始建模
|
|
@@ -129,7 +130,7 @@ public class CreateObjUtil {
|
|
|
callshell(command);
|
|
|
log.info("复制完毕:" + command);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//开始建模
|
|
|
public void build3dModelSFM(String folderName,String isModel) throws Exception{
|
|
|
log.info("开始建模");
|
|
@@ -177,7 +178,7 @@ public class CreateObjUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//调整切图
|
|
|
public void adjustImgs(String folderName)
|
|
|
{
|
|
@@ -192,7 +193,7 @@ public class CreateObjUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//obj和camera转换成大场景要的格式
|
|
|
public void convertobjTotxt(String folderName) throws Exception
|
|
|
{
|
|
@@ -202,16 +203,16 @@ public class CreateObjUtil {
|
|
|
//camera
|
|
|
command = "/home/ubuntu/photoscan-pro/main/read_camera/read_camera "+folderName;
|
|
|
callshell(command);
|
|
|
-
|
|
|
+
|
|
|
String prefix = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"data"+File.separator;
|
|
|
String srcpath = prefix +"mesh.txt";
|
|
|
String despath = prefix +"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
|
|
|
-
|
|
|
+
|
|
|
convertTxtToDam( srcpath, despath);
|
|
|
//dam转换成lzma
|
|
|
command = "lzma /home/ubuntu/photo_data/bigscene/"+folderName+"/data/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
|
|
|
callshell(command);
|
|
|
-
|
|
|
+
|
|
|
srcpath = prefix +"vision.txt";
|
|
|
despath = prefix +"vision.modeldata";
|
|
|
convertTxtToVisionmodeldata( srcpath, despath);
|
|
@@ -270,7 +271,7 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void convertTxtToDam(String srcpath,String despath)throws Exception{
|
|
|
InputStream inputStream = null;
|
|
|
InputStreamReader reader = null;
|
|
@@ -314,28 +315,28 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- File file = new File(srcpath);
|
|
|
+ File file = new File(srcpath);
|
|
|
FileInputStream fis=new FileInputStream(file);
|
|
|
|
|
|
Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
|
|
|
-
|
|
|
- //PrintStream out = new PrintStream(despath);
|
|
|
+
|
|
|
+ //PrintStream out = new PrintStream(despath);
|
|
|
String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
|
|
|
- ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
|
|
|
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
- BufferedInputStream bis = new BufferedInputStream(stream);
|
|
|
- int b = -1;
|
|
|
- while ((b = bis.read()) != -1) {
|
|
|
- bos.write(b);
|
|
|
- }
|
|
|
+ ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
|
|
|
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
+ BufferedInputStream bis = new BufferedInputStream(stream);
|
|
|
+ int b = -1;
|
|
|
+ while ((b = bis.read()) != -1) {
|
|
|
+ bos.write(b);
|
|
|
+ }
|
|
|
//out.close();
|
|
|
- bis.close();
|
|
|
- bos.close();
|
|
|
+ bis.close();
|
|
|
+ bos.close();
|
|
|
}
|
|
|
catch(Exception e)
|
|
|
{
|
|
@@ -344,7 +345,7 @@ public class CreateObjUtil {
|
|
|
log.error(trace.toString());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception
|
|
|
{
|
|
|
try{
|
|
@@ -352,17 +353,17 @@ public class CreateObjUtil {
|
|
|
String jsonFormat = readTxtFileToJson(srcpath);
|
|
|
JsonFormat.merge(jsonFormat, builder);
|
|
|
byte[] buf= builder.build().toByteArray();
|
|
|
-
|
|
|
+
|
|
|
//把序列化后的数据写入本地磁盘
|
|
|
- ByteArrayInputStream stream = new ByteArrayInputStream(buf);
|
|
|
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
- BufferedInputStream bis = new BufferedInputStream(stream);
|
|
|
- int b = -1;
|
|
|
- while ((b = bis.read()) != -1) {
|
|
|
- bos.write(b);
|
|
|
- }
|
|
|
- bis.close();
|
|
|
- bos.close();
|
|
|
+ ByteArrayInputStream stream = new ByteArrayInputStream(buf);
|
|
|
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
|
|
|
+ BufferedInputStream bis = new BufferedInputStream(stream);
|
|
|
+ int b = -1;
|
|
|
+ while ((b = bis.read()) != -1) {
|
|
|
+ bos.write(b);
|
|
|
+ }
|
|
|
+ bis.close();
|
|
|
+ bos.close();
|
|
|
}
|
|
|
catch(Exception e)
|
|
|
{
|
|
@@ -429,22 +430,22 @@ public class CreateObjUtil {
|
|
|
log.error(trace.toString());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void callshell(String command){
|
|
|
try {
|
|
|
Long start = System.currentTimeMillis();
|
|
|
Process process = Runtime.getRuntime().exec(command);
|
|
|
StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
|
|
|
- errorGobbler.start();
|
|
|
- StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
|
|
|
- outGobbler.start();
|
|
|
+ errorGobbler.start();
|
|
|
+ StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
|
|
|
+ outGobbler.start();
|
|
|
process.waitFor();
|
|
|
log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static int doWaitFor(Process process) {
|
|
|
InputStream in = null;
|
|
|
InputStream err = null;
|
|
@@ -498,44 +499,44 @@ public class CreateObjUtil {
|
|
|
return exitValue;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
private boolean isModel(String sPath,String folderName)
|
|
|
{
|
|
|
- boolean flag = false;
|
|
|
- File file = new File(sPath);
|
|
|
- if (file.isFile() && file.exists()) {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
+ boolean flag = false;
|
|
|
+ File file = new File(sPath);
|
|
|
+ if (file.isFile() && file.exists()) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
log.info("等待...");
|
|
|
- return flag;
|
|
|
+ return flag;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static String readTxtFileToJson(String filePath){
|
|
|
- try {
|
|
|
- String encoding="UTF-8";
|
|
|
- File file=new File(filePath);
|
|
|
- if(file.isFile() && file.exists()){
|
|
|
- InputStreamReader read = new InputStreamReader(
|
|
|
+ try {
|
|
|
+ String encoding="UTF-8";
|
|
|
+ File file=new File(filePath);
|
|
|
+ if(file.isFile() && file.exists()){
|
|
|
+ InputStreamReader read = new InputStreamReader(
|
|
|
new FileInputStream(file),encoding);
|
|
|
- BufferedReader bufferedReader = new BufferedReader(read);
|
|
|
- String lineTxt = null;
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(read);
|
|
|
+ String lineTxt = null;
|
|
|
String result="";
|
|
|
- while((lineTxt = bufferedReader.readLine()) != null){
|
|
|
+ while((lineTxt = bufferedReader.readLine()) != null){
|
|
|
result+=lineTxt;
|
|
|
- //log.info(lineTxt);
|
|
|
- }
|
|
|
- read.close();
|
|
|
+ //log.info(lineTxt);
|
|
|
+ }
|
|
|
+ read.close();
|
|
|
return result;
|
|
|
- }else{
|
|
|
+ }else{
|
|
|
return null;
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
return null;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Map<String,String> getAllFile(String dPath,String prefix)
|
|
|
{
|
|
|
File dirFile = new File(dPath);
|
|
@@ -551,7 +552,7 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Map<String,String> getchildFile(String dPath,String prefix,String childname)
|
|
|
{
|
|
|
File dirFile = new File(dPath+File.separator+childname);
|
|
@@ -568,7 +569,7 @@ public class CreateObjUtil {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//转台拼图
|
|
|
public void buildPanoramicImgs(String folderName)throws Exception
|
|
|
{
|
|
@@ -577,7 +578,7 @@ public class CreateObjUtil {
|
|
|
callshell(command);
|
|
|
log.info("全景图拼接完毕");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//六目拼图、切图,计算
|
|
|
public void buildForSix(String folderName)throws Exception
|
|
|
{
|
|
@@ -698,24 +699,19 @@ public class CreateObjUtil {
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
|
- List<File> zipList = new ArrayList<>();
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240112"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240113"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240115"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240116"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240117"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240118"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240119"));
|
|
|
- zipList.addAll(FileUtil.loopFiles("E:\\20240130"));
|
|
|
- Set<String> numList = new HashSet<>();
|
|
|
- zipList.stream().forEach(file -> {
|
|
|
- String str = file.getName();
|
|
|
- numList.add(str.substring(0, str.lastIndexOf(".")));
|
|
|
- });
|
|
|
- for (String num : numList) {
|
|
|
- FileUtil.appendUtf8String(num + "\n", "E:\\num.txt");
|
|
|
- }
|
|
|
+ String downloadedPath = "C:\\Users\\dsx\\Desktop\\孙\\已下载场景.txt";
|
|
|
+ String allPath = "C:\\Users\\dsx\\Desktop\\孙\\1.txt";
|
|
|
+ String nowMeshPath = "C:\\Users\\dsx\\Desktop\\孙\\now-mesh.txt";
|
|
|
+ String nowLaserPath = "C:\\Users\\dsx\\Desktop\\孙\\now-laser.txt";
|
|
|
+
|
|
|
+ List<String> downloadedNums = FileUtil.readUtf8Lines(downloadedPath);
|
|
|
+ List<String> allNums = FileUtil.readUtf8Lines(allPath);
|
|
|
+ Set<String> nowMeshNums = allNums.stream().filter(v -> !downloadedNums.contains(v) && !v.startsWith("SS-") && !v.startsWith("SG-")).collect(Collectors.toSet());
|
|
|
+ Set<String> nowLaserNums = allNums.stream().filter(v -> !downloadedNums.contains(v) && (v.startsWith("SS-") || v.startsWith("SG-"))).collect(Collectors.toSet());
|
|
|
+ FileUtil.writeUtf8Lines(nowMeshNums, nowMeshPath);
|
|
|
+ FileUtil.writeUtf8Lines(nowLaserNums, nowLaserPath);
|
|
|
|
|
|
+// CreateObjUtil.convertVisionmodeldataToTxt("D:\\test\\vision.modeldata", "D:\\test\\vision.txt");
|
|
|
|
|
|
|
|
|
}
|