Ver Fonte

1、添加时间辍;
2、更新子分支

LiuZe há 1 ano atrás
pai
commit
283b68af4f
4 ficheiros alterados com 65 adições e 3 exclusões
  1. 1 1
      etc
  2. 62 0
      include/tool/time.hpp
  3. 1 1
      project/Vzense-Tof-3D
  4. 1 1
      project/yoloseg

+ 1 - 1
etc

@@ -1 +1 @@
-Subproject commit e825970cb9a96d34f8877a63256a2c03887632a8
+Subproject commit 89b0de01a552373097190834f2bb8669cc0a454b

+ 62 - 0
include/tool/time.hpp

@@ -0,0 +1,62 @@
+#pragma once
+
+#include <chrono>
+#include <string>
+#include <iostream>
+#include <iomanip>
+
+class TimeTool {
+public:
+    enum TemporalPrecision {
+        TemporalPrecisionYear = 0,
+        TemporalPrecisionMount = 4,
+        TemporalPrecisionDay = 6,
+        TemporalPrecisionHour = 8,
+        TemporalPrecisionMin = 10,
+        TemporalPrecisionSec = 12,
+        TemporalPrecisionMs = 15,
+    };
+public:
+    static std::string timeDropoutStr(TemporalPrecision begain = TemporalPrecisionMs, TemporalPrecision end = TemporalPrecisionYear) {
+        std::stringstream time;
+        std::string t = getTime();
+        int max = begain;
+        int min = end;
+        if (begain == TemporalPrecisionYear) {
+            max += 3;
+        } else if (begain == TemporalPrecisionMs) {
+            max += 2;
+        } else {
+            max +=1;
+        }
+        for (int i = min; i < max; i++) {
+            time << t[i];
+        }
+        t.clear();
+        time >> t;
+        return t;
+    }
+
+    static unsigned long long timeDropoutLL(TemporalPrecision begain = TemporalPrecisionMs, TemporalPrecision end = TemporalPrecisionYear) {
+        std::string str = timeDropoutStr(begain, end);
+        if (str.empty()) {
+            return 0;
+        }
+        unsigned long long time_dropout = std::stoull(str);
+        return time_dropout;
+    }
+
+private:
+    static std::string getTime() {
+        auto now = std::chrono::system_clock::now();
+        auto timet = std::chrono::system_clock::to_time_t(now);
+        auto localTime = *std::gmtime(&timet);
+        auto ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now).time_since_epoch().count() % 1000;
+        std::stringstream ss;
+        std::string str;
+        ss << std::put_time(&localTime, "%Y%m%d%H%M%S") << std::setfill('0') << std::setw(3) << ms;
+        ss >> str;
+        return str;
+    }
+};
+

+ 1 - 1
project/Vzense-Tof-3D

@@ -1 +1 @@
-Subproject commit 024645279d50953aae6651e59a6916e121e44ec5
+Subproject commit fc5c2b9734f592a3a3c33543d366f5726c566b36

+ 1 - 1
project/yoloseg

@@ -1 +1 @@
-Subproject commit 0eb002a57ceefaa214632a9b067a9f36fde56163
+Subproject commit 05b489a26ea3840db1e0495cb91d1878a361fff9