Преглед изворни кода

add alog.h for log with function line.

yuchuli пре 4 година
родитељ
комит
17444465d2

BIN
doc/架构/ALOG使用说明.docx


+ 134 - 0
include/alog.h

@@ -0,0 +1,134 @@
+#ifndef ALOG_H
+#define ALOG_H
+
+#include <stdarg.h>
+#include <string.h>
+#include <fstream>
+#include <string>
+
+#ifndef __FILENAME__
+
+#ifdef _WIN32
+   #define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
+#else
+   #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#endif
+
+#endif
+
+// Global Logger class
+namespace iv {
+
+class Logger
+{
+private:
+        Logger()
+        {
+            mbFileOpen = false;
+            mbCallBack = false;
+        }
+        ~Logger()
+        {
+
+        }
+public:
+
+        static Logger & Inst()
+        {
+            static iv::Logger instance_;
+            return instance_;
+        }
+        void Log(char const* file, char const* func, int line, char const* format, ...)
+        {
+            static char complete_entry[2048];
+            static char message[1024];
+
+            va_list args;
+            va_start(args, format);
+            vsnprintf(message, 1024, format, args);
+
+    #ifndef DEBUG_NOTRACE
+            snprintf(complete_entry, 2048, "%s |  %s() | %d: %s", file, func,line, message);
+
+    #else
+            strncpy(complete_entry, message, 1024);
+    #endif
+
+            va_end(args);
+            if((!mbFileOpen) &&(!mbCallBack))
+                printf("%s\n", complete_entry);
+            else
+            {
+                if(mbFileOpen)
+                {
+                    file_ << complete_entry << std::endl;
+                    file_.flush();
+                }
+                if(mbCallBack)
+                {
+                    callback_(complete_entry);
+                }
+            }
+        }
+
+        void setlogfile(std::string strfilepath)
+        {
+            if (file_.is_open())
+            {
+                    // Close any open logfile, perhaps user want a new with unique filename
+                    file_.close();
+            }
+
+            file_.open(strfilepath.c_str());
+            if (file_.fail())
+            {
+                mbFileOpen = false;
+                    printf("Cannot open log file: %s \n",
+                            strfilepath.c_str());
+            }
+            else
+            {
+                mbFileOpen = true;
+            }
+        }
+
+        typedef void(*FuncPtr)(const char*);
+
+        void SetCallback(FuncPtr callback)
+        {
+            callback_ = callback;
+            if(callback_ != 0)mbCallBack = true;
+            else mbCallBack = false;
+        }
+        bool IsCallbackSet()
+        {
+            return callback_ != 0;
+        }
+        bool IsFileOpen() { return file_.is_open(); }
+
+private:
+
+        FuncPtr callback_ = 0;
+        std::ofstream file_;
+        bool mbFileOpen;
+        bool mbCallBack;
+
+};
+
+}
+
+
+#ifndef  NOTUSEALOG
+
+#define ALOG(Format_, ...)  iv::Logger::Inst().Log(__FILENAME__, __FUNCTION__, __LINE__, Format_, ##__VA_ARGS__)
+
+#else
+
+#define ALOG(Format_, ...)
+
+#endif
+
+
+
+
+#endif 

+ 2 - 2
src/detection/detection_lidar_cnn_segmentation/detection_lidar_cnn_segmentation.pro

@@ -46,10 +46,10 @@ INCLUDEPATH += /usr/local/cuda-10.2/targets/aarch64-linux/include
 LIBS += -lpcl_io -lpcl_common
 
 
-LIBS += -lboost_system  -lavutil -lglog -lprotobuf
+LIBS += -lboost_system  -lavutil  -lprotobuf -lcudnn
 
 
-unix:!macx: LIBS += -L$$PWD/../../../thirdpartylib/caffe -lcaffe
+unix:!macx: LIBS += -L$$PWD/../../../thirdpartylib/caffe -lcaffe -lcudnn
 
 HEADERS += \
     cluster2d.h \

+ 18 - 0
src/detection/detection_lidar_cnn_segmentation/main.cpp

@@ -16,6 +16,8 @@
 
 #include <thread>
 
+//#include "alog.h"
+
 CNNSegmentation gcnn;
 
 void * gpa;
@@ -401,6 +403,11 @@ void exitfunc()
 
 }
 
+//void testcall(const char * str)
+//{
+//    std::cout<<"call msg is "<<str<<std::endl;
+//}
+
 int main(int argc, char *argv[])
 {
     showversion("detection_lidar_cnn_segmentation");
@@ -410,7 +417,18 @@ int main(int argc, char *argv[])
     givlog = new iv::Ivlog("lidar_cnn_segmentation");
 
     gfault->SetFaultState(0,0,"cnn initialize.");
+\
+
+//    ALOG("cnn.");
+//    ALOG("VALUE = %d",1);
+
+//    iv::Logger::Inst().SetCallback(testcall);
+
+//    ALOG("cnn.");
+
+//    iv::Logger::Inst().setlogfile("/home/nvidia/logger.txt");
 
+//    ALOG("CNN");
 
     char * strhome = getenv("HOME");
     std::string protofile = strhome ;//

+ 4 - 3
src/ui/ui_osgviewer/main.cpp

@@ -29,6 +29,7 @@
 #include "viewer.hpp"
 #include "RoadManager.hpp"
 #include "CommonMini.hpp"
+#include "alog.h"
 
 
 #define DEFAULT_SPEED   70  // km/h
@@ -108,7 +109,7 @@ double gfrel_y = 0;
 double gfrel_z = 0;
 double gvehicle_hdg = 0;
 
-double gvehicleheight = 1.6;
+double gvehicleheight = 7.6;//1.6
 double gfspeed = 0;
 
 void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
@@ -492,10 +493,10 @@ int main(int argc, char** argv)
     argv = new char*[3];
     argv[0] = "testodrviewer";
     argv[1] = "--odr";
-    argv[2] = "/home/yuchuli/map/models/y.xodr";
+    argv[2] = "/home/nvidia/map/models/y.xodr";
 
 
-    void * pa = iv::modulecomm::RegisterRecv("hcp2_gpsimu",Listengpsimu);
+    void * pa = iv::modulecomm::RegisterRecv("ins550d_gpsimu",Listengpsimu);
     pa = iv::modulecomm::RegisterRecv("radar",ListenRADAR);
     (void)pa;
 

+ 7 - 7
src/ui/ui_osgviewer/ui_osgviewer.pro

@@ -38,9 +38,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
 !isEmpty(target.path): INSTALLS += target
 
 
-INCLUDEPATH += /home/yuchuli/File/git/OpenSceneGraph/include
+INCLUDEPATH += $$PWD/../../../thirdpartylib/osglib/include
 
-INCLUDEPATH += /home/yuchuli/File/git/OpenSceneGraph/build/include
+INCLUDEPATH += $$PWD/../../../thirdpartylib/osglib/include/build/include
 
 INCLUDEPATH += $$PWD/../../../thirdpartylib/esminilib
 
@@ -58,14 +58,14 @@ INCLUDEPATH += $$PWD/../../../thirdpartylib/esminilib
 }
 
 
-LIBS += -L/home/yuchuli/File/git/OpenSceneGraph/build/lib -losg -losgDB -losgFX \
+LIBS += -L$$PWD/../../../thirdpartylib/osglib/lib -losg -losgDB -losgFX \
         -losgGA -losgViewer -losgSim -losgUtil -losgText
 
 
-LIBS += /home/yuchuli/File/git/OpenSceneGraph/build/lib/osgPlugins-3.7.0/osgdb_serializers_osg.so
-LIBS += /home/yuchuli/File/git/OpenSceneGraph/build/lib/osgPlugins-3.7.0/osgdb_osg.so
-LIBS += /home/yuchuli/File/git/OpenSceneGraph/build/lib/osgPlugins-3.7.0/osgdb_serializers_osgsim.so
-LIBS += /home/yuchuli/File/git/OpenSceneGraph/build/lib/osgPlugins-3.7.0/osgdb_jpeg.so
+LIBS += $$PWD/../../../thirdpartylib/osglib/lib/osgPlugins-3.7.0/osgdb_serializers_osg.so
+LIBS += $$PWD/../../../thirdpartylib/osglib/lib/osgPlugins-3.7.0/osgdb_osg.so
+LIBS += $$PWD/../../../thirdpartylib/osglib/lib/osgPlugins-3.7.0/osgdb_serializers_osgsim.so
+LIBS += $$PWD/../../../thirdpartylib/osglib/lib/osgPlugins-3.7.0/osgdb_jpeg.so