Commit 6332b534 authored by oscar's avatar oscar

提交写log日志的逻辑。

parent 7914ee49
......@@ -341,8 +341,21 @@ void TrackingRos::Init(ros::NodeHandle& nh)
#endif
// SDK_LOG(SDK_INFO, "trans = [%s]", GetMatrixStr(m_trans, 4, 4).c_str());
SDK_LOG(SDK_INFO, "kitti2origin = [%s]", GetMatrixStr(m_kitti2origin,4,4).c_str());
// ADD_DEF_LOG(1, "tracking.csv");
// SDK_IDX_LOG(1, SDK_INFO, "date,frameNum,time,id,input_radian,input_angle,predict_radian,predict_angle,output_radian,output_angle,input_type,input_x,input_y,input_z,input_l,input_w,input_h,last_type,predict_x,predict_y,predict_z,predict_l,predict_w,preditc_h,output_type,output_x,output_y,output_z,output_l,output_w,output_h,output_rot_y,v_x,v_y,v_z,lat,lon");
int is_save_log = 0;
if(config["is_save_log"])
is_save_log = config["is_save_log"].as<int>();
if(is_save_log == 1)
{
std::string logFile = "./tracking_log.log";
if(config["save_log_file"])
logFile = config["save_log_file"].as<std::string>();
ADD_DEF_LOG(1, logFile.c_str());
SDK_IDX_LOG(1, SDK_INFO, "frame,type,score,h,w,l,x,y,z,rot_y,obj_id,v_x,v_y,v_z,loc_x,loc_y,loc_z,Lat,Long,center_Lat,center_Long,name,license_plate_number,color_name");
// frame,type,score,h,w,l,x,y,z,rot_y,obj_id,v_x,v_y,v_z,loc_x,loc_y,loc_z,Lat,Long,center_Lat,center_Long,name,license_plate_number,color_name
// 时间戳(整型),目标类型(整型),置信度(浮点),高度(浮点),宽度(浮点),长度(浮点),中心点局部x坐标(浮点),中心点局部y坐标(浮点),中心点局部z坐标(浮点),航向角(浮点),跟踪ID(整型),速度x(浮点),速度y(浮点),速度z(浮点),定位点x(浮点),定位点y(浮点),定位点z(浮点),定位点纬度(双精度浮点),定位点经度(双精度浮点),中心点纬度(双精度浮点),中心点经度(双精度浮点),名称(字符串,可选),车牌号(字符串,可选),颜色(字符串,可选)
}
//m_coordinate.Init(value[0][0], value[0][1], value[0][2], value[0][3], value[1][0], value[1][1]);
std::string fusion_topic = "/fusion_res";
......@@ -720,6 +733,11 @@ void TrackingRos::ThreadTrackingProcess()
// last_type,predict[0], predict[1], predict[2], predict[4], predict[5], predict[6],
// obj.type,obj.x, obj.y, obj.z, obj.l, obj.w, obj.h, obj.rot_y, obj.v_x, obj.v_y, obj.v_z, obj.Lat, obj.Long);
}
// frame,type,score,h,w,l,x,y,z,rot_y,obj_id,v_x,v_y,v_z,loc_x,loc_y,loc_z,Lat,Long,center_Lat,center_Long,name,license_plate_number,color_name
// 时间戳(整型),目标类型(整型),置信度(浮点),高度(浮点),宽度(浮点),长度(浮点),中心点局部x坐标(浮点),中心点局部y坐标(浮点),中心点局部z坐标(浮点),航向角(浮点),跟踪ID(整型),速度x(浮点),速度y(浮点),速度z(浮点),定位点x(浮点),定位点y(浮点),定位点z(浮点),定位点纬度(双精度浮点),定位点经度(双精度浮点),中心点纬度(双精度浮点),中心点经度(双精度浮点),名称(字符串,可选),车牌号(字符串,可选),颜色(字符串,可选)
SDK_IDX_LOG(1, SDK_INFO, "%llu,%d,%f,%f,%f,%f,%f,%f,%f,%f,%u,%f,%f,%f,0,0,0,0,0,%.10f,%.10f,%s,%s,%s",
obj.frame,obj.type,obj.score,obj.h,obj.w,obj.l,obj.x,obj.y,obj.z,obj.rot_y,
obj.obj_id,obj.v_x*10,obj.v_y*10,obj.v_z*10,obj.Lat,obj.Long,obj.name.c_str(),obj.license_plate_number.c_str(),obj.color_name.c_str());
jsk_recognition_msgs::BoundingBox box = {};
box.label = obj.obj_id;
......
......@@ -47,25 +47,41 @@ int AddLogFileSys(const char* file, int& fileIdx)
if (name.empty())
return -1;
fileIdx = 1;
std::string path = GetRootDir();
time_t tt = time(NULL);
tm* t = localtime(&tt);
char logName[1024] = {};
sprintf(logName, "%04d%02d%02d-%02d%02d%02d_%s", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, file);
std::string csvFile = std::string(logName);
std::string dir = path + "/" + csvFile;
LOG(INFO) << "AddLogFileSys save file = " << dir;
#ifdef _WIN32
if (fopen_s(&g_file, dir.c_str(), "wt") != 0)
#else
if (nullptr == (g_file = fopen(dir.c_str(), "wt")))
#endif
{
g_file = nullptr;
return -2;
}
if(name == "csv")
{
std::string path = GetRootDir();
time_t tt = time(NULL);
tm* t = localtime(&tt);
char logName[1024] = {};
sprintf(logName, "%04d%02d%02d-%02d%02d%02d_%s", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, file);
std::string csvFile = std::string(logName);
std::string dir = path + "/" + csvFile;
LOG(INFO) << "AddLogFileSys save file = " << dir;
#ifdef _WIN32
if (fopen_s(&g_file, dir.c_str(), "wt") != 0)
#else
if (nullptr == (g_file = fopen(dir.c_str(), "wt")))
#endif
{
g_file = nullptr;
return -2;
}
}
else
{
std::string dir = name;
LOG(INFO) << "AddLogFileSys save file = " << dir;
#ifdef _WIN32
if (fopen_s(&g_file, dir.c_str(), "wt+") != 0)
#else
if (nullptr == (g_file = fopen(dir.c_str(), "wt")))
#endif
{
g_file = nullptr;
return -2;
}
}
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment