135 lines
4.2 KiB
C++
Executable File
135 lines
4.2 KiB
C++
Executable File
#include "IniParser.h"
|
|
#include "IniHelper.h"
|
|
#include <iostream>
|
|
|
|
IniHelper* IniHelper::m_instance;
|
|
|
|
#ifdef _WIN32
|
|
static xini_file_t xini_file("./config.ini");
|
|
#else
|
|
static xini_file_t xini_file("./config.ini");
|
|
#endif
|
|
|
|
IniHelper* IniHelper::Get()
|
|
{
|
|
if (IniHelper::m_instance == nullptr) {
|
|
IniHelper::m_instance = new IniHelper();
|
|
|
|
// 2D section
|
|
G(w) = IniHelper::Get()->GetInt("2D", "w");
|
|
G(h) = IniHelper::Get()->GetFloat("2D", "h");
|
|
|
|
G(fx) = IniHelper::Get()->GetFloat("2D", "fx");
|
|
G(fy) = IniHelper::Get()->GetFloat("2D", "fy");
|
|
G(cx) = IniHelper::Get()->GetFloat("2D", "cx");
|
|
G(cy) = IniHelper::Get()->GetFloat("2D", "cy");
|
|
G(k1) = IniHelper::Get()->GetFloat("2D", "k1");
|
|
G(k2) = IniHelper::Get()->GetFloat("2D", "k2");
|
|
G(p1) = IniHelper::Get()->GetFloat("2D", "p1");
|
|
G(p2) = IniHelper::Get()->GetFloat("2D", "p2");
|
|
G(k3) = IniHelper::Get()->GetFloat("2D", "k3");
|
|
|
|
G(yolo_label) = IniHelper::Get()->GetInt("2D", "yolo_label");
|
|
G(yolo_prob) = IniHelper::Get()->GetFloat("2D", "yolo_prob");
|
|
G(yolo_modol_path) = IniHelper::Get()->GetStr("2D", "yolo_modol_path");
|
|
G(save_image) = IniHelper::Get()->GetStr("2D", "save_image");
|
|
G(roi_y_offset) = IniHelper::Get()->GetInt("2D", "roi_y_offset");
|
|
|
|
G(edge_min_line_len) = IniHelper::Get()->GetInt("2D", "edge_min_line_len");
|
|
G(edge_max_line_gap) = IniHelper::Get()->GetInt("2D", "edge_max_line_gap");
|
|
G(edge_min_angle_th) = IniHelper::Get()->GetInt("2D", "edge_min_angle_th");
|
|
|
|
G(kk) = IniHelper::Get()->GetFloat("2D", "kk");
|
|
|
|
|
|
// 3D section
|
|
G(r) = IniHelper::Get()->GetFloat("3D", "r");
|
|
G(p) = IniHelper::Get()->GetFloat("3D", "p");
|
|
G(y) = IniHelper::Get()->GetFloat("3D", "y");
|
|
|
|
G(tx) = IniHelper::Get()->GetFloat("3D", "tx");
|
|
G(ty) = IniHelper::Get()->GetFloat("3D", "ty");
|
|
G(tz) = IniHelper::Get()->GetFloat("3D", "tz");
|
|
|
|
G(dminx) = IniHelper::Get()->GetFloat("3D", "dminx");
|
|
G(dmaxx) = IniHelper::Get()->GetFloat("3D", "dmaxx");
|
|
G(dminy) = IniHelper::Get()->GetFloat("3D", "dminy");
|
|
G(dmaxy) = IniHelper::Get()->GetFloat("3D", "dmaxy");
|
|
G(dminz) = IniHelper::Get()->GetFloat("3D", "dminz");
|
|
G(dmaxz) = IniHelper::Get()->GetFloat("3D", "dmaxz");
|
|
G(cloud_need_points_size) = IniHelper::Get()->GetInt("3D", "cloud_need_points_size");
|
|
G(save_cload) = IniHelper::Get()->GetStr("3D", "save_cload");
|
|
|
|
|
|
G(fake) = IniHelper::Get()->GetStr("sys", "fake");
|
|
G(camera_cap_fake) = IniHelper::Get()->GetStr("sys", "camera_cap_fake");
|
|
G(lidar_cap_fake) = IniHelper::Get()->GetStr("sys", "lidar_cap_fake");
|
|
G(npu_fake) = IniHelper::Get()->GetStr("sys", "npu_fake");
|
|
G(conners_detect_fake) = IniHelper::Get()->GetStr("sys", "conners_detect_fake");
|
|
G(fake_image_fpath) = IniHelper::Get()->GetStr("sys", "fake_image_fpath");
|
|
G(fake_lidar_fpath) = IniHelper::Get()->GetStr("sys", "fake_lidar_fpath");
|
|
G(export_time) = IniHelper::Get()->GetInt("sys", "export_time");
|
|
}
|
|
|
|
return IniHelper::m_instance;
|
|
}
|
|
|
|
static std::string floatToString(float value) {
|
|
std::ostringstream oss;
|
|
oss << value;
|
|
return oss.str();
|
|
}
|
|
|
|
static std::string intToString(int value) {
|
|
std::ostringstream oss;
|
|
oss << value;
|
|
return oss.str();
|
|
}
|
|
|
|
IniHelper::IniHelper()
|
|
{
|
|
|
|
}
|
|
|
|
IniHelper::~IniHelper()
|
|
{
|
|
|
|
}
|
|
|
|
std::string IniHelper::GetStr(std::string section, std::string item)
|
|
{
|
|
std::string val = (const char*)xini_file[section][item];
|
|
//std::cout << item << ": " << val << std::endl;
|
|
this->mRecord += item;
|
|
this->mRecord += ": ";
|
|
this->mRecord += val;
|
|
this->mRecord += "\n";
|
|
return val;
|
|
}
|
|
|
|
float IniHelper::GetFloat(std::string section, std::string item)
|
|
{
|
|
float val = xini_file[section][item];
|
|
//std::cout << item << ": " << val << std::endl;
|
|
this->mRecord += item;
|
|
this->mRecord += ": ";
|
|
this->mRecord += floatToString(val);
|
|
this->mRecord += "\n";
|
|
return val;
|
|
}
|
|
|
|
int IniHelper::GetInt(std::string section, std::string item)
|
|
{
|
|
int val = xini_file[section][item];
|
|
//std::cout << item << ": " << val << std::endl;
|
|
this->mRecord += item;
|
|
this->mRecord += ": ";
|
|
this->mRecord += intToString(val);
|
|
this->mRecord += "\n";
|
|
return val;
|
|
}
|
|
|
|
std::string IniHelper::GetRecord()
|
|
{
|
|
return this->mRecord;
|
|
} |