Compare commits

..

No commits in common. '76fd865537b5e04ee9fa64ba38ee2ba23affdce1' and 'e26959acea1895d0b833cd40244ad95190d911be' have entirely different histories.

@ -66,14 +66,6 @@
"typeinfo": "cpp", "typeinfo": "cpp",
"cassert": "cpp", "cassert": "cpp",
"bitset": "cpp", "bitset": "cpp",
"regex": "cpp", "regex": "cpp"
"filesystem": "cpp",
"codecvt": "cpp",
"optional": "cpp",
"cfenv": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"queue": "cpp",
"locale": "cpp"
} }
} }

@ -27,8 +27,7 @@ typedef struct _DL_INIT_PARAM
int keyPointsNum = 2;//Note:kpt number for pose int keyPointsNum = 2;//Note:kpt number for pose
bool cudaEnable = false; bool cudaEnable = false;
int logSeverityLevel = 3; int logSeverityLevel = 3;
int intraOpNumThreads = 8; int intraOpNumThreads = 1;
int interOpNumThreads = 8;
} DL_INIT_PARAM; } DL_INIT_PARAM;

@ -25,14 +25,14 @@ bool YOLO_V3::CreateSession(std::string model_path, std::string model_name)
modelWeights = model_path + "/" + model_name; modelWeights = model_path + "/" + model_name;
modelConfiguration = model_path + "/jd.cfg"; modelConfiguration = model_path + "/jd.cfg";
classesFile = model_path + "/jd.names"; classesFile = model_path + "/jd.names";
image_path = model_path + "/" + "alg_jd"+ std::string(IMG_SUFFIX); image_path = model_path + "/" + "alg_jd"+ std::string(SUFFIX);
} }
else { else {
modelWeights = ROOTPATH_PREFIX + SLASH + MODELPATH + "jd.weights"; modelWeights = "D:/model/jd.weights";
classesFile = ROOTPATH_PREFIX + SLASH + MODELPATH + "jd.names"; classesFile = "D:/model/jd.names";
// Give the configuration and weight files for the model // Give the configuration and weight files for the model
modelConfiguration = ROOTPATH_PREFIX + SLASH + MODELPATH + "jd.cfg"; modelConfiguration = "D:/model/jd.cfg";
image_path = ROOTPATH_PREFIX + SLASH + MODELPATH + "alg_jd"+ std::string(IMG_SUFFIX); image_path = "D:/model/alg_jd"+ std::string(SUFFIX);
} }
std::ifstream classNamesFile(classesFile.c_str()); std::ifstream classNamesFile(classesFile.c_str());
@ -54,7 +54,14 @@ bool YOLO_V3::CreateSession(std::string model_path, std::string model_name)
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
#endif #endif
//cv::Mat image = cv::imread("alg_jd"+SUFFIX);
cv::Mat image = cv::imread(image_path); cv::Mat image = cv::imread(image_path);
/*if (g_sys_conf.model_jpg_path.length() > 0) {
image = cv::imread(g_sys_conf.model_jpg_path.toStdString());
}
else {
image = cv::imread("D:/Release/alg_jd"+SUFFIX);
}*/
//识别一张图测试模型是否正确并且完成GPU数据加载 //识别一张图测试模型是否正确并且完成GPU数据加载
if (!image.data) return false; //判断测试图片是否正常读取 if (!image.data) return false; //判断测试图片是否正常读取

@ -105,9 +105,7 @@ bool YOLO_V8::InitParam(DL_INIT_PARAM& iParams)
modelType = iParams.modelType; modelType = iParams.modelType;
cudaEnable = iParams.cudaEnable; cudaEnable = iParams.cudaEnable;
intraOpNumThreads = iParams.intraOpNumThreads; intraOpNumThreads = iParams.intraOpNumThreads;
interOpNumThreads = iParams.interOpNumThreads;
logSeverityLevel = iParams.logSeverityLevel; logSeverityLevel = iParams.logSeverityLevel;
classes = { "jd" };
return true; return true;
} }
@ -131,7 +129,6 @@ bool YOLO_V8::CreateSession(std::string model_path, std::string model_name) {
sessionOption.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL); sessionOption.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_ALL);
sessionOption.SetIntraOpNumThreads(intraOpNumThreads); sessionOption.SetIntraOpNumThreads(intraOpNumThreads);
sessionOption.SetInterOpNumThreads(interOpNumThreads);
sessionOption.SetLogSeverityLevel(logSeverityLevel); sessionOption.SetLogSeverityLevel(logSeverityLevel);
#ifdef _WIN32 #ifdef _WIN32
@ -227,7 +224,7 @@ char* YOLO_V8::RunSession(cv::Mat& in, cv::Mat& out, std::vector<std::pair<int,
float confidence = floor(100 * re.confidence) / 100; float confidence = floor(100 * re.confidence) / 100;
std::cout << std::fixed << std::setprecision(2); std::cout << std::fixed << std::setprecision(2);
std::string label = classes[re.classId] + std::string(" ") + std::string label = std::string("jd") + std::string(" ") +
std::to_string(confidence).substr(0, std::to_string(confidence).size() - 4); std::to_string(confidence).substr(0, std::to_string(confidence).size() - 4);
cv::rectangle( cv::rectangle(

@ -56,7 +56,6 @@ private:
//std::vector<const char*> outputNodeNames; //std::vector<const char*> outputNodeNames;
int logSeverityLevel; int logSeverityLevel;
int intraOpNumThreads; int intraOpNumThreads;
int interOpNumThreads;
MODEL_TYPE modelType; MODEL_TYPE modelType;
std::vector<int> imgSize; std::vector<int> imgSize;
float rectConfidenceThreshold; float rectConfidenceThreshold;

@ -37,6 +37,7 @@ void CleanWorkThread::doWork()
qint64 spaceSize; qint64 spaceSize;
qint64 dirSize; qint64 dirSize;
QString dirPath = g_conf_path.save_pics_path; QString dirPath = g_conf_path.save_pics_path;
//QString iDriver = "D:/";
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
char dir_1[_MAX_DIR]; char dir_1[_MAX_DIR];
char fname[_MAX_FNAME]; char fname[_MAX_FNAME];
@ -47,6 +48,7 @@ void CleanWorkThread::doWork()
LPCWSTR strDriver = (LPCWSTR)iDriver.utf16(); LPCWSTR strDriver = (LPCWSTR)iDriver.utf16();
ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace; ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace;
qint64 gb = (1024 * 1024 * 1024); qint64 gb = (1024 * 1024 * 1024);
//QString dir("D:/image");
QString dir(g_conf_path.save_pics_path + "/ALL"); QString dir(g_conf_path.save_pics_path + "/ALL");
if (delSelection == 2) if (delSelection == 2)

@ -2,8 +2,8 @@
#include <QDir> #include <QDir>
#include <QMutex> #include <QMutex>
#include <QDate> #include <QDate>
#include <common.h>
const char PATH_LogPath[] = "D:/log/";
const char Suffix[] = ".txt"; const char Suffix[] = ".txt";
bool CLog::isFileReady = false; bool CLog::isFileReady = false;
bool CLog::isRecord2File = true; bool CLog::isRecord2File = true;
@ -21,7 +21,7 @@ void CLog::setLogType(const CLog::CLOG_TYPE& level)
bool CLog::init(LogConfig& logConfig) bool CLog::init(LogConfig& logConfig)
{ {
isRecord2File = logConfig.isRecord2File; isRecord2File = logConfig.isRecord2File;
QString logDir = QString::fromStdString(ROOTPATH_PREFIX + SLASH + LOGPATH); QString logDir = QString(PATH_LogPath);
if (createDir(logDir)) if (createDir(logDir))
{ {
QString fileName = logDir + QDir::separator() + QDate::currentDate().toString("yyyy-MM-dd") + QString(Suffix); QString fileName = logDir + QDir::separator() + QDate::currentDate().toString("yyyy-MM-dd") + QString(Suffix);

@ -203,11 +203,10 @@ void SyncWorkThread::run()
if (merge_index == work_camera_nums * unit_count) { if (merge_index == work_camera_nums * unit_count) {
file_name = g_conf_path.save_pics_path + "/" file_name = g_conf_path.save_pics_path + "/"
+ now_ts.toString("yyyy-MM-dd") + "/" + now_ts.toString("yyyy-MM-dd") + "/"
+ now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + SUFFIX;
QString::fromStdString(IMG_SUFFIX);
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), merge_image)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), merge_image));
#ifdef __TCPSend #ifdef __TCPSend
QString sendName = now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + SUFIMG_SUFFIXFIX; QString sendName = now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + SUFFIX;
TCPSendInfo.pics_name = sendName.toLocal8Bit().constData(); TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
TCP_Info_queue->put(TCPSendInfo); TCP_Info_queue->put(TCPSendInfo);
#endif #endif
@ -279,11 +278,11 @@ void SyncWorkThread::run()
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
QString remotePath = "/image/ng/" + QString remotePath = "/image/ng/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
m = vec_out[index].clone(); m = vec_out[index].clone();
@ -292,11 +291,11 @@ void SyncWorkThread::run()
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
remotePath = "/image/ng_result/" + remotePath = "/image/ng_result/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
//g_save_queue->put(std::make_pair(file_name.toStdString(), m)); //g_save_queue->put(std::make_pair(file_name.toStdString(), m));
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
} }

@ -184,14 +184,12 @@ void WorkThread::run()
now_ts.toString("yyyy-MM-dd") + "/" now_ts.toString("yyyy-MM-dd") + "/"
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "#" + "_" + QString::number(index + 1) + SUFFIX;
QString::fromStdString(IMG_SUFFIX);
std::string filename = file_name.toLocal8Bit().constData(); std::string filename = file_name.toLocal8Bit().constData();
g_save_queue->put(std::make_pair(filename, m)); g_save_queue->put(std::make_pair(filename, m));
QString sendName = now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + QString sendName = now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "#" + "_" + QString::number(index + 1) + SUFFIX;
QString::fromStdString(IMG_SUFFIX);
#ifdef __TCPSend #ifdef __TCPSend
TCPSendInfo.pics_name = sendName.toLocal8Bit().constData(); TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
TCP_Info_queue->put(TCPSendInfo); TCP_Info_queue->put(TCPSendInfo);
@ -263,11 +261,11 @@ void WorkThread::run()
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
QString remotePath = "/image/ng/" + QString remotePath = "/image/ng/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
m = vec_out[index].clone(); m = vec_out[index].clone();
@ -276,11 +274,11 @@ void WorkThread::run()
+ QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
remotePath = "/image/ng_result/" + remotePath = "/image/ng_result/" +
now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) +
"#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] +
QString::fromStdString(IMG_SUFFIX); SUFFIX;
//g_save_queue->put(std::make_pair(file_name.toStdString(), m)); //g_save_queue->put(std::make_pair(file_name.toStdString(), m));
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
} }

@ -62,9 +62,9 @@ DialogSetup::DialogSetup(QWidget* parent) : QDialog(parent) {
if (!dirinfo->exists()) { if (!dirinfo->exists()) {
// 如果文件夹信息不存在 // 如果文件夹信息不存在
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
g_conf_path.config_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); g_conf_path.config_path = "D:/conf";
} }
dirinfo->setNameFilters(QStringList(CONF_FILE.c_str())); dirinfo->setNameFilters(QStringList("conf.txt"));
QStringList fileList = dirinfo->entryList(QDir::Files); QStringList fileList = dirinfo->entryList(QDir::Files);
fileList.removeOne("."); fileList.removeOne(".");
fileList.removeOne(".."); fileList.removeOne("..");
@ -72,7 +72,7 @@ DialogSetup::DialogSetup(QWidget* parent) : QDialog(parent) {
} }
else { else {
// 如果路径空 // 如果路径空
g_conf_path.config_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); g_conf_path.config_path = "D:/conf";
} }
ui.comboBox_config_path->addItem(g_conf_path.config_path); ui.comboBox_config_path->addItem(g_conf_path.config_path);
// 更换选择文件 // 更换选择文件
@ -354,7 +354,7 @@ void DialogSetup::on_toolButton_choose_config_path_released() {
if (dirName.isEmpty()) { if (dirName.isEmpty()) {
// 点击取消按钮 // 点击取消按钮
if (g_conf_path.config_path.isEmpty()) if (g_conf_path.config_path.isEmpty())
dirName = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); dirName = "D:/conf";
else else
dirName = g_conf_path.config_path; dirName = g_conf_path.config_path;
} }
@ -363,11 +363,11 @@ void DialogSetup::on_toolButton_choose_config_path_released() {
if (!dirinfo->exists()) if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
dirinfo->setNameFilters(QStringList(CONF_FILE.c_str())); dirinfo->setNameFilters(QStringList("conf.txt"));
QStringList fileList = dirinfo->entryList(QDir::Files); QStringList fileList = dirinfo->entryList(QDir::Files);
if (fileList.count() == 0) { if (fileList.count() == 0) {
dirName = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); dirName = "D:/conf";
} }
//fileList.removeOne("."); //fileList.removeOne(".");
@ -395,7 +395,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() {
if (dirName.isEmpty()) { if (dirName.isEmpty()) {
if (g_sys_conf.model_path.isEmpty()) if (g_sys_conf.model_path.isEmpty())
dirName = QString::fromStdString(ROOTPATH_PREFIX + SLASH + MODELPATH); dirName = "D:/model";
else else
dirName = g_sys_conf.model_path; dirName = g_sys_conf.model_path;
@ -409,7 +409,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() {
dirinfo->setNameFilters(QStringList("*.weights")); dirinfo->setNameFilters(QStringList("*.weights"));
QStringList fileList = dirinfo->entryList(QDir::Files); QStringList fileList = dirinfo->entryList(QDir::Files);
if (fileList.count() == 0) { if (fileList.count() == 0) {
g_sys_conf.model_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + MODELPATH); g_sys_conf.model_path = "D:/model";
g_sys_conf.model_name = "jd.weights"; g_sys_conf.model_name = "jd.weights";
} }
else else
@ -472,7 +472,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
void DialogSetup::write_pswd() void DialogSetup::write_pswd()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open((ROOTPATH_PREFIX + SLASH + PSWD_FILE).c_str(), std::ios::out | std::ios::trunc); cfg_file.open("D:/Release/pswd.txt", std::ios::out | std::ios::trunc);
if (cfg_file.good()) if (cfg_file.good())
{ {
char buf[256]; char buf[256];
@ -485,7 +485,7 @@ void DialogSetup::write_pswd()
void DialogSetup::write_pswd_op() void DialogSetup::write_pswd_op()
{ {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open((ROOTPATH_PREFIX + SLASH + PSWD_OP_FILE).c_str(), std::ios::out | std::ios::trunc); cfg_file.open("D:/Release/pswd_op.txt", std::ios::out | std::ios::trunc);
if (cfg_file.good()) if (cfg_file.good())
{ {
char buf[256]; char buf[256];
@ -497,7 +497,7 @@ void DialogSetup::write_pswd_op()
} }
void DialogSetup::write_conf_path() { void DialogSetup::write_conf_path() {
std::fstream cfg_file; std::fstream cfg_file;
cfg_file.open(ROOTPATH_PREFIX + CONFPATH, std::ios::out | std::ios::trunc); cfg_file.open(CONFPATH, std::ios::out | std::ios::trunc);
if (cfg_file.good()) { if (cfg_file.good()) {
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);

@ -50,7 +50,7 @@ void output_statistic::recMsgFromDialogSetup()
QString file_path, file_name; QString file_path, file_name;
QFile file; QFile file;
for (int i = 0; i < NumberOfSupportedCameras; i++) { for (int i = 0; i < NumberOfSupportedCameras; i++) {
file_name = QString::fromStdString(STATISTIC_FILE).arg(i); file_name = QString(STATISTIC_FILE).arg(i);
file_path = g_conf_path.config_path + "/" + file_name; file_path = g_conf_path.config_path + "/" + file_name;
file.setFileName(file_path); file.setFileName(file_path);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) if (file.open(QIODevice::ReadOnly | QIODevice::Text))
@ -60,7 +60,7 @@ void output_statistic::recMsgFromDialogSetup()
textBrowser_mat[i]->setText(in.readAll()); textBrowser_mat[i]->setText(in.readAll());
} }
else { else {
std::cout << "can not open statistic file" << file_path.toShort() << std::endl; std::cout << "can not open statistic file" << std::endl;
} }
file.close(); file.close();
this->show(); this->show();

@ -244,13 +244,13 @@ void PlcSetup::handleTimeout()
void PlcSetup::read_plc_items() void PlcSetup::read_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
QString plc_file = g_conf_path.config_path + "/" + QString::fromStdString(PLC_CONFIG_FILE); QString plc_file = g_conf_path.config_path + "/" + PLC_CONFIG_FILE;
cfg_file.open(plc_file.toLocal8Bit().constData()); cfg_file.open(plc_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open production file " << plc_file.toStdString() << std::endl; std::cout << "Error: Open production file " << PLC_ITEM_FILE << std::endl;
return; return;
} }
while (!cfg_file.eof()) while (!cfg_file.eof())
@ -280,7 +280,7 @@ void PlcSetup::read_plc_items()
void PlcSetup::save_plc_items() void PlcSetup::save_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
QString plc_file = g_conf_path.config_path + "/" + QString::fromStdString(PLC_CONFIG_FILE); QString plc_file = g_conf_path.config_path + "/" + PLC_CONFIG_FILE;
cfg_file.open(plc_file.toLocal8Bit().constData(), std::ios::out | std::ios::trunc); cfg_file.open(plc_file.toLocal8Bit().constData(), std::ios::out | std::ios::trunc);
if (cfg_file.good()) if (cfg_file.good())
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

@ -122,12 +122,12 @@ Cigarette::Cigarette(QWidget* parent)
if (!dirinfo->exists()) { if (!dirinfo->exists()) {
// 如果文件夹信息不存在 // 如果文件夹信息不存在
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
g_conf_path.config_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); g_conf_path.config_path = "D:/conf";
} }
delete dirinfo, dirinfo = nullptr; delete dirinfo, dirinfo = nullptr;
} }
else else
g_conf_path.config_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + CONFPATH); g_conf_path.config_path = "D:/conf";
bool update_rotate = false; bool update_rotate = false;
if (!read_rotate_message()) { if (!read_rotate_message()) {
@ -247,11 +247,11 @@ Cigarette::Cigarette(QWidget* parent)
quantity_stop_count = 0; quantity_stop_count = 0;
g_seconds = 0; g_seconds = 0;
QString config_path = g_conf_path.config_path + QString::fromStdString( SLASH + CONF_FILE); QString config_path = g_conf_path.config_path + "/conf.txt";
read_sys_config(g_sys_conf, config_path); //初始化系统配置 read_sys_config(g_sys_conf, config_path); //初始化系统配置
if (g_sys_conf.model_path.isEmpty()) { if (g_sys_conf.model_path.isEmpty()) {
g_sys_conf.model_path = QString::fromStdString(ROOTPATH_PREFIX + SLASH + MODELPATH); g_sys_conf.model_path = "D:/model";
} }
if (g_sys_conf.model_name.isEmpty()) { if (g_sys_conf.model_name.isEmpty()) {
@ -1061,12 +1061,12 @@ void Cigarette::OnKey(QKeyEvent* event)
std::fstream cfg_file; std::fstream cfg_file;
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE.c_str(), Num, Cnt); sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
QString rects_file = g_conf_path.config_path + "/" + buf; QString rects_file = g_conf_path.config_path + "/" + buf;
cfg_file.open(rects_file.toLocal8Bit().constData(), ios::trunc | ofstream::out); cfg_file.open(rects_file.toLocal8Bit().constData(), ios::trunc | ofstream::out);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open SelectRects file " << rects_file.toStdString() << std::endl; std::cout << "Error: Open config file SelectRects.txt" << std::endl;
return; return;
} }
for (int i = 0; i < g_display_label_conf[Num].RectVet[Cnt].size(); i++) for (int i = 0; i < g_display_label_conf[Num].RectVet[Cnt].size(); i++)
@ -1209,12 +1209,12 @@ void Cigarette::DrawRect_init(int Num_Cnt) {
std::fstream cfg_file; std::fstream cfg_file;
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE.c_str(), Num, Cnt); sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
QString rects_file = g_conf_path.config_path + "/" + buf; QString rects_file = g_conf_path.config_path + "/" + buf;
cfg_file.open(rects_file.toLocal8Bit().constData()); cfg_file.open(rects_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open SelectRects file" << rects_file.toStdString() << std::endl; std::cout << "Error: Open config file SelectRects" << Num << Cnt << ".txt" << std::endl;
return; return;
} }
while (!cfg_file.eof()) while (!cfg_file.eof())
@ -1256,12 +1256,12 @@ void Cigarette::OnTPClickHub(int Num_Cnt)
std::fstream cfg_file; std::fstream cfg_file;
char buf[256]; char buf[256];
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE.c_str(), Num, Cnt); sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
QString rects_file = g_conf_path.config_path + "/" + buf; QString rects_file = g_conf_path.config_path + "/" + buf;
cfg_file.open(rects_file.toLocal8Bit().constData()); cfg_file.open(rects_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open SelectRects file " << rects_file.toStdString() << std::endl; std::cout << "Error: Open config file SelectRects.txt" << std::endl;
return; return;
} }
while (!cfg_file.eof()) while (!cfg_file.eof())
@ -2112,11 +2112,10 @@ void Cigarette::on_pushButton_clear_released()//换班
QString Cigarette::read_pswd() QString Cigarette::read_pswd()
{ {
std::fstream cfg_file; std::fstream cfg_file;
std::string pswd_path = ROOTPATH_PREFIX + SLASH + PSWD_FILE; cfg_file.open("D:/Release/pswd.txt");
cfg_file.open(pswd_path.c_str());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open pswd file" << pswd_path <<std::endl; std::cout << "Error: Open config file pswd.txt" << std::endl;
return "81dc9bdb52d04dc20036dbd8313ed055"; return "81dc9bdb52d04dc20036dbd8313ed055";
} }
if (!cfg_file.eof()) if (!cfg_file.eof())
@ -2145,11 +2144,10 @@ QString Cigarette::read_pswd()
QString Cigarette::read_op_pswd() QString Cigarette::read_op_pswd()
{ {
std::fstream cfg_file; std::fstream cfg_file;
std::string pswd_op_path = ROOTPATH_PREFIX + SLASH + PSWD_OP_FILE; cfg_file.open("D:/Release/pswd_op.txt");
cfg_file.open(pswd_op_path.c_str());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open pswd_op file" <<pswd_op_path<< std::endl; std::cout << "Error: Open config file pswd_op.txt" << std::endl;
return "81dc9bdb52d04dc20036dbd8313ed055"; return "81dc9bdb52d04dc20036dbd8313ed055";
} }
if (!cfg_file.eof()) if (!cfg_file.eof())
@ -2176,10 +2174,9 @@ QString Cigarette::read_op_pswd()
bool Cigarette::read_conf(ConfPath& conf_path) { bool Cigarette::read_conf(ConfPath& conf_path) {
std::fstream conf_file; std::fstream conf_file;
std::string conf_file_path = ROOTPATH_PREFIX + SLASH + CONFPATH + CONFPATH_FILE; conf_file.open(CONFPATH);
conf_file.open(conf_file_path);
if (!conf_file.is_open()) { if (!conf_file.is_open()) {
std::cout << "Error: Open conf_path file " << conf_file_path << std::endl; std::cout << "Error: Open conf path file " << CONFPATH << std::endl;
return false; return false;
} }
while (!conf_file.eof()) { while (!conf_file.eof()) {
@ -2606,11 +2603,11 @@ bool Cigarette::read_modbus_config(ModbusConf& conf)
{ {
QString str_kick; QString str_kick;
std::fstream cfg_file; std::fstream cfg_file;
QString modbus_file = g_conf_path.config_path + "/" + QString::fromStdString(MODBUS_CONFIGURE_FILE); QString modbus_file = g_conf_path.config_path + "/" + MODBUS_CONFIGURE_FILE;
cfg_file.open(modbus_file.toLocal8Bit().constData()); cfg_file.open(modbus_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open modbus file" << modbus_file.toStdString() << std::endl; std::cout << "Error: Open config file " << MODBUS_CONFIGURE_FILE << std::endl;
return false; return false;
} }
while (!cfg_file.eof()) while (!cfg_file.eof())
@ -2665,11 +2662,11 @@ bool Cigarette::read_modbus_config(ModbusConf& conf)
bool Cigarette::read_rotate_message() bool Cigarette::read_rotate_message()
{ {
std::fstream cfg_file; std::fstream cfg_file;
QString rotate_file = g_conf_path.config_path + "/" + QString::fromStdString(ROTATE_FILE); QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
cfg_file.open(rotate_file.toLocal8Bit().constData()); cfg_file.open(rotate_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file rotate.txt" << ROTATE_FILE << std::endl; std::cout << "Error: Open config file rotate.txt" << std::endl;
return false; return false;
} }
if (!cfg_file.eof()) if (!cfg_file.eof())
@ -2702,11 +2699,11 @@ bool Cigarette::read_rotate_message()
bool Cigarette::save_rotate_message() bool Cigarette::save_rotate_message()
{ {
std::fstream cfg_file; std::fstream cfg_file;
QString rotate_file = g_conf_path.config_path + "/" + QString::fromStdString(ROTATE_FILE); QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
cfg_file.open(rotate_file.toLocal8Bit().constData(), ios::trunc | ofstream::out); cfg_file.open(rotate_file.toLocal8Bit().constData(), ios::trunc | ofstream::out);
if (!cfg_file.is_open()) if (!cfg_file.is_open())
{ {
std::cout << "Error: Open config file rotate.txt" << ROTATE_FILE << std::endl; std::cout << "Error: Open config file rotate.txt" << std::endl;
return false; return false;
} }
for (int i = 0; i < NumberOfSupportedCameras; i++) { for (int i = 0; i < NumberOfSupportedCameras; i++) {
@ -2785,7 +2782,7 @@ QImage Cigarette::cvMatToQImage(const cv::Mat& mat)
void Cigarette::read_plc_items() void Cigarette::read_plc_items()
{ {
std::fstream cfg_file; std::fstream cfg_file;
QString plc_file = g_conf_path.config_path + "/" + QString::fromStdString(PLC_CONFIG_FILE); QString plc_file = g_conf_path.config_path + "/" + PLC_CONFIG_FILE;
cfg_file.open(plc_file.toLocal8Bit().constData()); cfg_file.open(plc_file.toLocal8Bit().constData());
if (!cfg_file.is_open()) if (!cfg_file.is_open())
@ -3703,7 +3700,7 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor
{ {
if (SingleCamInfo[i].IsOpen && quantity > 0) { if (SingleCamInfo[i].IsOpen && quantity > 0) {
std::fstream cfg_file; std::fstream cfg_file;
file_name = QString::fromStdString(STATISTIC_FILE).arg(i); file_name = QString(STATISTIC_FILE).arg(i);
file_path = g_conf_path.config_path + "/" + file_name; file_path = g_conf_path.config_path + "/" + file_name;
char buf[256]; char buf[256];

@ -25,7 +25,7 @@
//#define __MQTTSend // MQTT发送 //#define __MQTTSend // MQTT发送
#define BASLER_SUPPORT #define BASLER_SUPPORT
#if defined (BASLER_SUPPORT) #if defined (BASLER_SUPPORT)
#define USB_BASLER_NEW_FW //使用basler定制固件 #define USB_BASLER_NEW_FW //使用basler定制固件
#endif #endif
#define HIK_SUPPORT #define HIK_SUPPORT
#define BALLUFF_SUPPORT #define BALLUFF_SUPPORT
@ -55,32 +55,17 @@
#endif #endif
// 主界面基本参数配置文件 // 主界面基本参数配置文件
#ifdef __DEBUG #define CONFPATH "D:/conf/conf_path.txt"
#define ROOTPATH_PREFIX std::string(".") //#define CONFIGURE_FILE "D:/conf/conf.txt"
#else
#define ROOTPATH_PREFIX std::string("D:")
#endif
#define CONFPATH std::string("conf")
#define MODELPATH std::string("model")
#define LOGPATH std::string("log")
#define IMAGEPATH std::string("image")
#define SLASH std::string("/")
// 相机旋转角度配置文件 // 相机旋转角度配置文件
#define ROTATE_FILE std::string("rotate.txt") #define ROTATE_FILE "rotate.txt"
#define MODBUS_CONFIGURE_FILE std::string("modbus.txt") #define MODBUS_CONFIGURE_FILE "modbus.txt"
#define PLC_CONFIG_FILE std::string("plc.txt") #define PLC_CONFIG_FILE "plc.txt"
#define SELECT_RECTS_FILE std::string("SelectRects%d%d.txt") #define SELECT_RECTS_FILE "SelectRects%d%d.txt"
#define STATISTIC_FILE std::string("camera%1_statistic.txt") #define STATISTIC_FILE "camera%1_statistic.txt"
#define ALARM_RECORD_FILE std::string("alarm.txt") #define ALARM_RECORD_FILE "alarm.txt"
#define CONFPATH_FILE std::string("conf_path.txt")
#define CONF_FILE std::string("conf.txt")
#define PSWD_FILE std::string("pswd.txt")
#define PSWD_OP_FILE std::string("pswd_op.txt")
#define SPLASH_FILE std::string("splash.jpg")
#define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒 #define OUTPUT_HIGH_WIDTH 20000 //输出信号的脉冲宽度,微秒
// 图片格式 #define SUFFIX ".jpg"
#define IMG_SUFFIX std::string(".jpg")
#define OP_TIME 300 //OP权限时长默认300秒 #define OP_TIME 300 //OP权限时长默认300秒
#define ADMIN_TIME 600 //ADMIN权限时长默认300秒 #define ADMIN_TIME 600 //ADMIN权限时长默认300秒

@ -1 +0,0 @@
0,3,0,3,0,3,0,3,

@ -30,7 +30,7 @@ int main(int argc, char* argv[])
} }
#endif #endif
qRegisterMetaType<cv::Mat>("cv::Mat"); qRegisterMetaType<cv::Mat>("cv::Mat");
QPixmap pixmap((ROOTPATH_PREFIX + SLASH + SPLASH_FILE).c_str()); QPixmap pixmap("D:/Release/splash.jpg");
QSplashScreen splash(pixmap); QSplashScreen splash(pixmap);
splash.show(); splash.show();
a.processEvents(); a.processEvents();

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Loading…
Cancel
Save