From f0e12c5d1dd8bdaefd488d2264e262570422b31a Mon Sep 17 00:00:00 2001 From: CJ980606 <805250096@qq.com> Date: Mon, 20 May 2024 17:21:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/common.h | 12 +++++++----- Cigarette/syncworkthread.cpp | 36 +++++++++++------------------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/Cigarette/common.h b/Cigarette/common.h index 98ea9c8..e76a790 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -21,7 +21,7 @@ #define USB_BASLER_NEW_FW //使用basler定制固件 //#define IMM_PROCESS //拍照后立马处理,不等校验信号 //#define IMM_FEED_BACK //处理完后立马反馈,不等校验信号 -#define ONE_TIME_SHIFT //错开一拍发送反馈(默认错开两次) +//#define ONE_TIME_SHIFT //错开一拍发送反馈(默认错开两次) //CAP_FEED_BACK和DOUBLE_FEED_BACK不要一起开 #if defined (ONE_TIME_SHIFT) //#define CAP_FEED_BACK //拍照时也检测有没有测试结果,有的话就反馈 @@ -29,7 +29,7 @@ #endif #define AI_WARM_UP //AI识别开始前的热身动作 -#define LICENSE_VERIFY //开启license文件校验 +//#define LICENSE_VERIFY //开启license文件校验 //#define identify_Hik_YSXID//识别海康相机YSXID //#define DRAW_RECT // 鼠标画框功能 #define SYNC_CAMERA //相机同步处理图片 @@ -38,7 +38,9 @@ #define Unit_Queue_Size Queue_Size*3 #define StrobeLineTime 10000 -#define EquipmentModel "TH"//设备型号:TH、XH、THXH +#define EquipmentModel "TH"//设备型号 +#define image_w 512 //图片宽度 +#define image_h 512 //图片高度 #ifdef __DEBUG #define DEBUG(format, ...) printf (format, ##__VA_ARGS__) @@ -50,8 +52,8 @@ #define DEFAULT_CONFPATH_PATH "D:/conf" #define DEFAULT_PIC_SAVE_PATH "D:/image" // 主界面基本参数配置文件 -//#define CONFPATH "D:/Release/conf_path2.txt"//XH -#define CONFPATH "D:/Release/conf_path3.txt"//TH +#define CONFPATH "D:/Release/conf_path2.txt"//小盒 +//#define CONFPATH "D:/Release/conf_path3.txt"//条盒 // 相机旋转角度配置文件 #define ROTATE_FILE "rotate.txt" #define MODBUS_CONFIGURE_FILE "modbus.txt" diff --git a/Cigarette/syncworkthread.cpp b/Cigarette/syncworkthread.cpp index 52b3948..1061851 100644 --- a/Cigarette/syncworkthread.cpp +++ b/Cigarette/syncworkthread.cpp @@ -67,28 +67,18 @@ void SyncWorkThread::run() try { uint32_t result_index[NumberOfSupportedCameras] = { 0 }; while (!b_quit) { - QDateTime now_ts = QDateTime::currentDateTime(); -//#ifdef __TCPSend -// _TCPSendInfo TCPSendInfo; -//#ifdef __TCPSend -// QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz"); -// TCPSendInfo.pics_name = sendName.toLocal8Bit().constData(); -// TCP_Info_queue->put(TCPSendInfo); -//#endif -//#endif - + QDateTime now_ts = QDateTime::currentDateTime(); std::vector> element_vec; local_g_image_sync_queue->take(element_vec); bool IsNGForAll = false; int merge_index; - cv::Mat merge_image = cv::Mat::zeros(512 * g_sys_conf.shoot[0], 640 * work_camera_nums, CV_8UC3); + cv::Mat merge_image = cv::Mat::zeros(image_h * g_sys_conf.shoot[0], image_w * work_camera_nums, CV_8UC3);//640*work_camera_nums cv::Rect roi; int j = 0; // 实际工作的相机标识,element_vec中可能有相机没在工作 for (int i = 0; i < element_vec.size(); i++)//每个相机的图轮流遍历 { if (!SingleCamInfo[i].Detect || !SingleCamInfo[i].IsOpen || SingleCamInfo[i].OffLine) continue; - local_camera_number = i; std::pair element; element = element_vec[i]; @@ -123,12 +113,6 @@ void SyncWorkThread::run() #ifdef __TCPSend _TCPSendInfo TCPSendInfo; #endif -//#ifdef __TCPSend -// QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz"); -// TCPSendInfo.pics_name = sendName.toLocal8Bit().constData(); -// TCP_Info_queue->put(TCPSendInfo); - -//#endif if (!image.data) { continue; //图像为空,跳过 @@ -137,11 +121,11 @@ void SyncWorkThread::run() { cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像 } - cv::resize(image, image, cv::Size(640, 512 * unit_count)); + cv::resize(image, image, cv::Size(image_w, image_h * unit_count)); if (local_SysConf.shoot[local_camera_number] == unit_count) { std::vector vec_in; - int w = image.cols; + int w = image.cols ; int h = image.rows / unit_count; for (int index = 0; index < unit_count; index++) { cv::Rect temp_Rect(0, h * index, w, h); @@ -154,7 +138,6 @@ void SyncWorkThread::run() } vec_in.push_back(temp_image.clone()); } - std::vector vec_out; std::vector>> vec_results; QDateTime ts_start = QDateTime::currentDateTime(); @@ -167,7 +150,9 @@ void SyncWorkThread::run() vec_results.push_back(results); } else { + alg_jd[local_camera_number].detect_batch(vec_in, vec_out, vec_results); + } QDateTime ts_jd = QDateTime::currentDateTime(); int time_process = ts_start.msecsTo(ts_jd); @@ -343,9 +328,8 @@ void SyncWorkThread::run() merge_index = j * unit_count + index + 1; roi = cv::Rect(j * m.cols, index * m.rows, m.cols, m.rows); m.copyTo(merge_image(roi)); - if (merge_index == work_camera_nums * unit_count) { - + if (IsNGForAll) { ngReason = 1; @@ -354,13 +338,15 @@ void SyncWorkThread::run() { ngReason = 0; } + //条盒TJ 小盒BJ file_name = g_conf_path.save_pics_path + "/" - + now_ts.toString("yyyy-MM-dd") + "/"+"416_TJ_01_" + + now_ts.toString("yyyy-MM-dd") + "/"+"416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz_") + ng_reason_maps[ngReason] + ".jpg"; g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), merge_image)); + #ifdef __TCPSend - QString sendName = "416_TJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz"); + QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz"); TCPSendInfo.pics_name = sendName.toLocal8Bit().constData(); TCP_Info_queue->put(TCPSendInfo); #endif