CreateObjUtil.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. package com.fdkankan.common.util;
  2. import cn.hutool.core.exceptions.ExceptionUtil;
  3. import cn.hutool.core.io.FileTypeUtil;
  4. import com.fdkankan.common.constant.ConstantFileName;
  5. import com.fdkankan.common.constant.ConstantFilePath;
  6. import com.fdkankan.common.proto.BigSceneProto;
  7. import com.fdkankan.common.proto.Common;
  8. import com.fdkankan.common.proto.Visionmodeldata;
  9. import com.fdkankan.common.proto.format.JsonFormat;
  10. import com.google.protobuf.TextFormat;
  11. import java.util.Arrays;
  12. import java.util.Base64;
  13. import java.util.List;
  14. import java.util.concurrent.Callable;
  15. import java.util.concurrent.CountDownLatch;
  16. import java.util.concurrent.ExecutorService;
  17. import java.util.concurrent.Executors;
  18. import java.util.concurrent.Future;
  19. import java.util.concurrent.TimeUnit;
  20. import lombok.extern.slf4j.Slf4j;
  21. import org.slf4j.Logger;
  22. import org.slf4j.LoggerFactory;
  23. import org.springframework.util.StopWatch;
  24. import java.io.*;
  25. import java.util.HashMap;
  26. import java.util.Map;
  27. @Slf4j
  28. public class CreateObjUtil {
  29. // private static Logger log = LoggerFactory.getLogger(CreateObjUtil.class);
  30. public void saveuploadImgs(String folderName) throws IOException, Exception
  31. {
  32. log.info("开始计算");
  33. String command = "bash /home/ubuntu/photoscan-pro/build_model.sh "+folderName;
  34. callshell(command);
  35. boolean flag = false;
  36. String sPath = ConstantFilePath.CREATE_MODEL_PATH+folderName+File.separator+"mesh"+File.separator+"mesh.obj";
  37. while(!flag)
  38. {
  39. flag = isModel(sPath,folderName);
  40. }
  41. log.info("计算完毕");
  42. }
  43. public void saveuploadImgs2(String folderName) throws IOException, Exception
  44. {
  45. log.info("开始计算");
  46. String command = "bash /home/ubuntu/photoscan-pro/build_bigscene.sh "+folderName;
  47. callshell(command);
  48. boolean flag = false;
  49. String sPath = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"mesh"+File.separator+"mesh.obj";
  50. while(!flag)
  51. {
  52. flag = isModel(sPath,folderName);
  53. }
  54. log.info("计算完毕");
  55. log.info("obj和camera转换成大场景要的格式");
  56. convertobjTotxt( folderName);
  57. }
  58. //开始建模
  59. public static void unRar(String rarPath,String dataPath) throws Exception{
  60. log.info("解压rar开始");
  61. String command = "unrar e " + rarPath + " " + dataPath;
  62. callshell(command);
  63. log.info("解压rar完毕:" + command);
  64. }
  65. public static void unZip(String zipPath,String dataPath) throws Exception{
  66. log.info("解压zip开始");
  67. String command = "unzip -O GBK/GB18030CP936 " + zipPath + " -d " + dataPath;
  68. callshell(command);
  69. log.info("解压zip完毕:" + command);
  70. }
  71. //开始建模
  72. public static void build3dModel(String folderName,String isModel) throws Exception{
  73. log.info("开始建模");
  74. String command = ConstantCmd.BUILD_MODEL_COMMAND+folderName;
  75. callshell(command);
  76. log.info("计算完毕:" + command);
  77. }
  78. //开始建模
  79. public static void build3dModel2(String folderName,String isModel) throws Exception{
  80. log.info("开始建模");
  81. String command = ConstantCmd.BUILD_MODEL_COMMAND2+folderName;
  82. callshell(command);
  83. log.info("计算完毕:" + command);
  84. }
  85. //开始建模
  86. public static void build3dModelOld(String folderName,String isModel) throws Exception{
  87. log.info("开始v2建模");
  88. String command = ConstantCmd.BUILD_MODEL_OLD_COMMAND+folderName;
  89. callshell(command);
  90. log.info("计算v2完毕:" + command);
  91. }
  92. //开始建模
  93. public static void translateHoustfloorJSONFile(String filePath,String outputPath) throws Exception{
  94. log.info("开始转换houst_floor.json");
  95. String command = ConstantCmd.TRANSLATE_HOUST_FLOOR + filePath + " " + outputPath;
  96. callshell(command);
  97. log.info("转换houst_floor.json 结束");
  98. }
  99. //激光相机复制资源
  100. public static void cpfile(String filepathOld,String filepathNew) throws Exception{
  101. log.info("开始复制");
  102. String command = ConstantCmd.CP_JG_EXTRA+ " " + filepathOld + " " + filepathNew;
  103. callshell(command);
  104. log.info("复制完毕:" + command);
  105. }
  106. //激光相机复制资源laser下的全部资源
  107. public static void cplaserfile(String filepathOld,String filepathNew) throws Exception{
  108. log.info("开始复制");
  109. String command = ConstantCmd.CP_JG_ALL+ " " + filepathOld + " " + filepathNew;
  110. callshell(command);
  111. log.info("复制完毕:" + command);
  112. }
  113. //开始建模
  114. public void build3dModelSFM(String folderName,String isModel) throws Exception{
  115. log.info("开始建模");
  116. String command = ConstantCmd.BUILD_MODEL_SFM_COMMAND+folderName+" "+isModel;
  117. callshell(command);
  118. log.info("计算完毕");
  119. }
  120. //obj文件转换问txt
  121. public static void objToTxt(String folderName,String isModel) throws Exception{
  122. log.info("obj2txt开始转换");
  123. String command = ConstantCmd.OBJ_TO_TXT+folderName;
  124. callshell(command);
  125. log.info("转换完毕:" + command);
  126. }
  127. public void rebuildModelFllor(String folderName, String isModel) {
  128. try{
  129. log.info("开始建模");
  130. String command = ConstantCmd.REBUILD_MODEL_FLLOR+folderName+" "+isModel;
  131. callshell(command);
  132. log.info("计算完毕");
  133. }
  134. catch(Exception e)
  135. {
  136. e.printStackTrace();
  137. }
  138. }
  139. //切图
  140. public void cutImgs(String[] imgNames ,String folderName)
  141. {
  142. try{
  143. log.info("开始切图");
  144. for(int i=0;i<imgNames.length;++i)
  145. {
  146. String imgName=imgNames[i].replace(".jpg", "");
  147. String command = ConstantCmd.CUT_IMG_COMMAND+folderName+" "+imgName;
  148. callshell(command);
  149. }
  150. log.info("切图完毕");
  151. }
  152. catch(Exception e)
  153. {
  154. e.printStackTrace();
  155. }
  156. }
  157. //调整切图
  158. public void adjustImgs(String folderName)
  159. {
  160. try{
  161. String command = ConstantCmd.ADJUST_IMG_COMMAND + folderName;
  162. log.info("开始调整图片");
  163. callshell(command);
  164. log.info("调整图片完毕");
  165. }
  166. catch(Exception e)
  167. {
  168. e.printStackTrace();
  169. }
  170. }
  171. //obj和camera转换成大场景要的格式
  172. public void convertobjTotxt(String folderName) throws Exception
  173. {
  174. //obj
  175. String command = "/home/ubuntu/photoscan-pro/main/mesh/mesh "+folderName;
  176. callshell(command);
  177. //camera
  178. command = "/home/ubuntu/photoscan-pro/main/read_camera/read_camera "+folderName;
  179. callshell(command);
  180. String prefix = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"data"+File.separator;
  181. String srcpath = prefix +"mesh.txt";
  182. String despath = prefix +"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
  183. convertTxtToDam( srcpath, despath);
  184. //dam转换成lzma
  185. command = "lzma /home/ubuntu/photo_data/bigscene/"+folderName+"/data/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
  186. callshell(command);
  187. srcpath = prefix +"vision.txt";
  188. despath = prefix +"vision.modeldata";
  189. convertTxtToVisionmodeldata( srcpath, despath);
  190. }
  191. public static void convertDamToLzma(String folderName)throws Exception
  192. {
  193. try
  194. {
  195. String command = "lzma "+ folderName+File.separator+ ConstantFileName.modelUUID+"_50k.dam";
  196. log.info("开始转换lzma");
  197. callshell(command);
  198. log.info("转换lzma完毕");
  199. }
  200. catch(Exception e)
  201. {
  202. StringWriter trace=new StringWriter();
  203. e.printStackTrace(new PrintWriter(trace));
  204. log.error(trace.toString());
  205. }
  206. }
  207. public static void convertDamToLzmaByAbsolutePath(String path)throws Exception
  208. {
  209. try
  210. {
  211. String command = "lzma "+ path;
  212. log.info("开始转换lzma");
  213. callshell(command);
  214. log.info("转换lzma完毕");
  215. }
  216. catch(Exception e)
  217. {
  218. StringWriter trace=new StringWriter();
  219. e.printStackTrace(new PrintWriter(trace));
  220. log.error(trace.toString());
  221. }
  222. }
  223. public static void convertDamToLzma2(String folderName)throws Exception
  224. {
  225. try
  226. {
  227. String command = "lzma "+ folderName+File.separator+ ConstantFileName.modelUUID+"_50k2.dam";
  228. log.info("开始转换lzma");
  229. callshell(command);
  230. log.info("转换lzma完毕");
  231. }
  232. catch(Exception e)
  233. {
  234. StringWriter trace=new StringWriter();
  235. e.printStackTrace(new PrintWriter(trace));
  236. log.error(trace.toString());
  237. }
  238. }
  239. public static void convertTxtToDam(String srcpath,String despath)throws Exception
  240. {
  241. BigSceneProto.binary_mesh.Builder builder= BigSceneProto.binary_mesh.newBuilder();
  242. InputStream inputStream = new FileInputStream(srcpath);
  243. InputStreamReader reader = new InputStreamReader(inputStream, "ASCII");
  244. TextFormat.merge(reader, builder);
  245. byte[] buf= builder.build().toByteArray();
  246. //把序列化后的数据写入本地磁盘
  247. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  248. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  249. BufferedInputStream bis = new BufferedInputStream(stream);
  250. int b = -1;
  251. while ((b = bis.read()) != -1) {
  252. bos.write(b);
  253. }
  254. bis.close();
  255. bos.close();
  256. }
  257. public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
  258. {
  259. try
  260. {
  261. File file = new File(srcpath);
  262. FileInputStream fis=new FileInputStream(file);
  263. Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
  264. //PrintStream out = new PrintStream(despath);
  265. String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
  266. ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
  267. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  268. BufferedInputStream bis = new BufferedInputStream(stream);
  269. int b = -1;
  270. while ((b = bis.read()) != -1) {
  271. bos.write(b);
  272. }
  273. //out.close();
  274. bis.close();
  275. bos.close();
  276. }
  277. catch(Exception e)
  278. {
  279. StringWriter trace=new StringWriter();
  280. e.printStackTrace(new PrintWriter(trace));
  281. log.error(trace.toString());
  282. }
  283. }
  284. public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception
  285. {
  286. try{
  287. Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
  288. String jsonFormat = readTxtFileToJson(srcpath);
  289. JsonFormat.merge(jsonFormat, builder);
  290. byte[] buf= builder.build().toByteArray();
  291. //把序列化后的数据写入本地磁盘
  292. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  293. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  294. BufferedInputStream bis = new BufferedInputStream(stream);
  295. int b = -1;
  296. while ((b = bis.read()) != -1) {
  297. bos.write(b);
  298. }
  299. bis.close();
  300. bos.close();
  301. }
  302. catch(Exception e)
  303. {
  304. StringWriter trace=new StringWriter();
  305. e.printStackTrace(new PrintWriter(trace));
  306. log.error(trace.toString());
  307. }
  308. }
  309. public static void convertVisionmodeldataToTxtCommon(String srcpath,String despath)throws Exception
  310. {
  311. try
  312. {
  313. File file = new File(srcpath);
  314. FileInputStream fis=new FileInputStream(file);
  315. Common.NavigationInfo data_NavigationInfo = Common.NavigationInfo.parseFrom(fis);
  316. //PrintStream out = new PrintStream(despath);
  317. String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
  318. ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
  319. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  320. BufferedInputStream bis = new BufferedInputStream(stream);
  321. int b = -1;
  322. while ((b = bis.read()) != -1) {
  323. bos.write(b);
  324. }
  325. //out.close();
  326. bis.close();
  327. bos.close();
  328. }
  329. catch(Exception e)
  330. {
  331. StringWriter trace=new StringWriter();
  332. e.printStackTrace(new PrintWriter(trace));
  333. log.error(trace.toString());
  334. }
  335. }
  336. public static void convertTxtToVisionmodeldataCommon(String srcpath,String despath)throws Exception
  337. {
  338. try
  339. {
  340. Common.NavigationInfo.Builder builder = Common.NavigationInfo.newBuilder();
  341. String jsonFormat = readTxtFileToJson(srcpath);
  342. JsonFormat.merge(jsonFormat, builder);
  343. byte[] buf= builder.build().toByteArray();
  344. //把序列化后的数据写入本地磁盘
  345. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  346. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  347. BufferedInputStream bis = new BufferedInputStream(stream);
  348. int b = -1;
  349. while ((b = bis.read()) != -1) {
  350. bos.write(b);
  351. }
  352. bis.close();
  353. bos.close();
  354. }
  355. catch(Exception e)
  356. {
  357. StringWriter trace=new StringWriter();
  358. e.printStackTrace(new PrintWriter(trace));
  359. log.error(trace.toString());
  360. }
  361. }
  362. public static void callshell(String command)
  363. {
  364. try {
  365. StopWatch stopWatch = new StopWatch();
  366. stopWatch.start();
  367. Process process = Runtime.getRuntime().exec(command);
  368. StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
  369. errorGobbler.start();
  370. StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
  371. outGobbler.start();
  372. process.waitFor();
  373. log.info("脚本{}执行完毕,用时:{}",command,stopWatch.toString());
  374. } catch (Exception e) {
  375. e.printStackTrace();
  376. }
  377. }
  378. public static int doWaitFor(Process process) {
  379. InputStream in = null;
  380. InputStream err = null;
  381. int exitValue = -1; // returned to caller when p is finished
  382. try {
  383. in = process.getInputStream();
  384. err = process.getErrorStream();
  385. boolean finished = false; // Set to true when p is finished
  386. while (!finished) {
  387. try {
  388. while (in.available() > 0) {
  389. // Print the output of our system call
  390. Character c = new Character((char) in.read());
  391. System.out.print(c);
  392. }
  393. while (err.available() > 0) {
  394. // Print the output of our system call
  395. Character c = new Character((char) err.read());
  396. System.out.print(c);
  397. }
  398. // Ask the process for its exitValue. If the process
  399. // is not finished, an IllegalThreadStateException
  400. // is thrown. If it is finished, we fall through and
  401. // the variable finished is set to true.
  402. exitValue = process.exitValue();
  403. finished = true;
  404. } catch (IllegalThreadStateException e) {
  405. // Process is not finished yet;
  406. // Sleep a little to save on CPU cycles
  407. Thread.currentThread().sleep(500);
  408. }
  409. }
  410. } catch (Exception e) {
  411. e.printStackTrace();
  412. } finally {
  413. try {
  414. if (in != null) {
  415. in.close();
  416. }
  417. } catch (IOException e) {
  418. e.printStackTrace();
  419. }
  420. if (err != null) {
  421. try {
  422. err.close();
  423. } catch (IOException e) {
  424. e.printStackTrace();
  425. }
  426. }
  427. }
  428. return exitValue;
  429. }
  430. private boolean isModel(String sPath,String folderName)
  431. {
  432. boolean flag = false;
  433. File file = new File(sPath);
  434. if (file.isFile() && file.exists()) {
  435. flag = true;
  436. }
  437. log.info("等待...");
  438. return flag;
  439. }
  440. public static String readTxtFileToJson(String filePath){
  441. try {
  442. String encoding="UTF-8";
  443. File file=new File(filePath);
  444. if(file.isFile() && file.exists()){
  445. InputStreamReader read = new InputStreamReader(
  446. new FileInputStream(file),encoding);
  447. BufferedReader bufferedReader = new BufferedReader(read);
  448. String lineTxt = null;
  449. String result="";
  450. while((lineTxt = bufferedReader.readLine()) != null){
  451. result+=lineTxt;
  452. //log.info(lineTxt);
  453. }
  454. read.close();
  455. return result;
  456. }else{
  457. return null;
  458. }
  459. } catch (Exception e) {
  460. e.printStackTrace();
  461. return null;
  462. }
  463. }
  464. public Map<String,String> getAllFile(String dPath,String prefix)
  465. {
  466. File dirFile = new File(dPath);
  467. if (!dirFile.isDirectory()) {
  468. }
  469. Map<String,String> map = new HashMap<String,String>();
  470. File[] files = dirFile.listFiles();
  471. for (int i = 0; i < files.length; i++) {
  472. if (files[i].isFile()) {
  473. String path = files[i].getPath();
  474. map.put(path, prefix+path.substring(path.lastIndexOf("/")+1));
  475. }
  476. }
  477. return map;
  478. }
  479. public Map<String,String> getchildFile(String dPath,String prefix,String childname)
  480. {
  481. File dirFile = new File(dPath+File.separator+childname);
  482. if (!dirFile.isDirectory()) {
  483. return null;
  484. }
  485. Map<String,String> map = new HashMap<String,String>();
  486. File[] files = dirFile.listFiles();
  487. for (int i = 0; i < files.length; i++) {
  488. if (files[i].isFile()) {
  489. String path = files[i].getPath();
  490. map.put(path, prefix+childname+path.substring(path.lastIndexOf("/")));
  491. }
  492. }
  493. return map;
  494. }
  495. //转台拼图
  496. public void buildPanoramicImgs(String folderName)throws Exception
  497. {
  498. String command = ConstantCmd.BUILD_PANORAMA + folderName;
  499. log.info("开始拼全景图");
  500. callshell(command);
  501. log.info("全景图拼接完毕");
  502. }
  503. //六目拼图、切图,计算
  504. public void buildForSix(String folderName)throws Exception
  505. {
  506. String command = ConstantCmd.BUILD_FOR_SIX + folderName;
  507. log.info("开始处理数据(六目)");
  508. callshell(command);
  509. log.info("数据处理完毕(六目)");
  510. }
  511. public static void createSoftConnection(String source, String target) {
  512. String command = "ln -s " + source + " " + target;
  513. log.info("开始创建文件夹软连接");
  514. callshell(command);
  515. log.info("数据处理完毕(六目):" + command);
  516. }
  517. //合并音频
  518. public static void mergeVideo(String oldVideo , String newVideo, String targetVideo) throws Exception{
  519. String command = ConstantCmd.MERGE_VIDEO + " " + oldVideo + " " + newVideo + " " + targetVideo + " -y";
  520. log.info("开始合并视频");
  521. callshell(command);
  522. log.info("合并视频完毕:" + command);
  523. }
  524. //生成一段静音音频
  525. public static void createMuteViode(double time , String targetVideo) throws Exception{
  526. String command = ConstantCmd.CREATE_MUTE_VIDEO + " " + time + " " + targetVideo + " -y";
  527. log.info("开始生成一段静音音频");
  528. callshell(command);
  529. log.info("生成一段静音音频完毕:" + command);
  530. }
  531. //mp4文件转换成flv文件
  532. public static void mp4ToFlv(String oldVideo, String newVideo) throws Exception{
  533. String command = ConstantCmd.MP4_TO_FLV + " " + oldVideo + " " + newVideo;
  534. log.info("mp4文件转换成flv文件");
  535. callshell(command);
  536. log.info("mp4文件转换成flv文件完毕:" + command);
  537. }
  538. //删除/mnt/data/下的数据
  539. public static void deleteFile(String filePath) throws Exception{
  540. String command = ConstantCmd.DELETE_FILE + " " + filePath;
  541. log.info("删除/mnt/data/下的数据");
  542. callshell(command);
  543. log.info("删除/mnt/data/下的数据完毕:" + command);
  544. }
  545. public static void ossUtilCp(String fileUrl , String path) throws Exception{
  546. String command = ConstantCmd.OSS_UTIL_CP + " " + fileUrl + " " + path;
  547. Long start = System.currentTimeMillis();
  548. log.info("开始oss下载文件:" + command);
  549. callshell(command);
  550. log.info("oss下载文件完成,时间为:" + (System.currentTimeMillis() - start));
  551. }
  552. public static void ossFileCp(String fileUrl , String path) throws Exception{
  553. String command = ConstantCmd.OSS_FILE_CP + " " + fileUrl + " " + path;
  554. Long start = System.currentTimeMillis();
  555. log.info("开始s3文件下载文件:" + command);
  556. callshell(command);
  557. log.info("s3文件下载文件完成,时间为:" + (System.currentTimeMillis() - start));
  558. }
  559. /**
  560. * matterpro场景获取阿里云的切图数据
  561. * @param path
  562. * @throws Exception
  563. */
  564. public static void matterproCutImg(String num , String path) throws Exception{
  565. String command = ConstantCmd.MATTERPRO_CUT_IMG + " -s " + num + " -d " + path;
  566. Long start = System.currentTimeMillis();
  567. log.info("开始matterpro获取阿里云图片方法:" + command);
  568. callshell(command);
  569. log.info("matterpro获取阿里云图片方法完成,时间为:" + (System.currentTimeMillis() - start));
  570. }
  571. public static void main(String[] args) throws Exception{
  572. CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-HXMNTDYs1E_3.txt", "F:\\visiontest\\vision.modeldata");
  573. // String type = FileTypeUtil.getType(new File("F:\\visiontest\\KJ-HXMNTDYs1E_3.txt"));
  574. // System.out.println(type);
  575. // CreateObjUtil.convertTxtToDam("F:\\visiontest\\modeldata.txt", "F:\\visiontest\\dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
  576. // String text = "web:web";
  577. // byte[] data = text.getBytes("UTF-8");
  578. // String s = Base64.getEncoder().encodeToString(data);
  579. // System.out.println(s);
  580. // org.apache.commons.lang3.time.StopWatch stopWatch = new org.apache.commons.lang3.time.StopWatch();
  581. // stopWatch.start();
  582. // Thread.sleep(2000);
  583. // stopWatch.stop();
  584. // System.out.println(stopWatch.getTime(TimeUnit.SECONDS));
  585. // ExecutorService executorService = Executors.newFixedThreadPool(1);
  586. // Future<String> future = executorService.submit(()->{
  587. // return CreateObjUtil.test();
  588. // });
  589. //
  590. // try {
  591. // String s = future.get();
  592. // }catch (Exception e){
  593. //
  594. // System.out.println(ExceptionUtil.stacktraceToString(e));
  595. // }
  596. }
  597. private static String test() throws Exception{
  598. try {
  599. String test = null;
  600. test.equals("123");
  601. }catch (Exception e){
  602. throw e;
  603. }finally {
  604. }
  605. return "123";
  606. }
  607. }