修复图片旋转问题

CigaretteSH
CJ980606 8 months ago
parent 7a2fe26b88
commit f0e12c5d1d

@ -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"

@ -68,27 +68,17 @@ void SyncWorkThread::run()
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
std::vector<std::pair<int, cv::Mat>> 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<int, cv::Mat> 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,7 +121,7 @@ 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<cv::Mat> vec_in;
@ -154,7 +138,6 @@ void SyncWorkThread::run()
}
vec_in.push_back(temp_image.clone());
}
std::vector<cv::Mat> vec_out;
std::vector<std::vector<std::pair<int, cv::Rect>>> 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,7 +328,6 @@ 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)
@ -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

Loading…
Cancel
Save