Improve TCP send compress file of images

CigaretteSH
Flamingo 5 months ago
parent cf70338b7d
commit 5b215b8e0c

@ -278,8 +278,10 @@ Cigarette::Cigarette(QWidget* parent)
//保存图片线程 //保存图片线程
saveThread.init();//初始化 saveThread.init();//初始化
#ifdef __TCPSend
#ifdef __ExportData #ifdef __ExportData
connect(&saveThread, &SaveThread::sendDataToExport, &exportDataThread, &ExportDataThread::GetDataFromSaveThread); connect(&sync_work_thread, &SyncWorkThread::sendDataToCompress, &exportDataThread, &ExportDataThread::GetDataFromSaveThread);
#endif
#endif #endif
saveThread.start_work(); saveThread.start_work();
#ifdef __UDPSend #ifdef __UDPSend

@ -328,7 +328,7 @@ void ExportDataThread::run()
} }
if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) { if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) {
listToZip += tmpListToZip; listToZip.unite(tmpListToZip);
tmpListToZip.clear(); tmpListToZip.clear();
zipTimeStamp.append(lastTimeStamp[0]); zipTimeStamp.append(lastTimeStamp[0]);
lastTimeStamp.clear(); lastTimeStamp.clear();
@ -377,17 +377,16 @@ void ExportDataThread::run()
argsOk.append("a"); argsOk.append("a");
argsOk.append(zipFilePaths[1]); argsOk.append(zipFilePaths[1]);
// create zip file // create zip file
for (int i = 0; i < listToZip.size(); i++) { QMapIterator<QString, bool> iterator(listToZip);
QStringList strList = listToZip[i].split("_"); while (iterator.hasNext()) {
strList = strList[strList.size() - 1].split("."); iterator.next();
int index = listToZip[i].lastIndexOf("/\\", 0); if (iterator.value()) {
if (strList[0] == okStr) { ngStream << iterator.key() << endl;
okStream << listToZip[i] << endl;
} }
else { else {
okStream << iterator.key() << endl;
ngStream << listToZip[i] << endl;
} }
} }
argsNg.append("-i@" + fileList[0]); argsNg.append("-i@" + fileList[0]);
@ -515,7 +514,7 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) {
} }
} }
void ExportDataThread::GetDataFromSaveThread(QString filePath) { void ExportDataThread::GetDataFromSaveThread(QString filePath, bool Ng) {
QString remotePath; QString remotePath;
QStringList currentTimeStamp; QStringList currentTimeStamp;
QRegExp rx("((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))_([0-1]?[0-9]|2[0-3])-([0-5][0-9])"); QRegExp rx("((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))_([0-1]?[0-9]|2[0-3])-([0-5][0-9])");
@ -534,7 +533,7 @@ void ExportDataThread::GetDataFromSaveThread(QString filePath) {
if (lastTimeStamp.isEmpty() || (currentTimeStamp[0] != lastTimeStamp[0])) { if (lastTimeStamp.isEmpty() || (currentTimeStamp[0] != lastTimeStamp[0])) {
if (!tmpListToZip.isEmpty()) { if (!tmpListToZip.isEmpty()) {
listToZip = tmpListToZip; listToZip.unite(tmpListToZip);
tmpListToZip.clear(); tmpListToZip.clear();
} }
if (!listToZip.isEmpty()) { if (!listToZip.isEmpty()) {
@ -546,7 +545,7 @@ void ExportDataThread::GetDataFromSaveThread(QString filePath) {
timer->stop(); timer->stop();
timer->start(1000 * (60 * 1 + 10)); timer->start(1000 * (60 * 1 + 10));
} }
tmpListToZip.append(filePath); tmpListToZip.insert(filePath, Ng);
} }
} }

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include <QList>
#include <QMap>
#include "ui_output_statistic.h" #include "ui_output_statistic.h"
#include <vector> #include <vector>
#include <qdir.h> #include <qdir.h>
@ -11,9 +13,10 @@
#include "common.h" #include "common.h"
#include "cigarette.h" #include "cigarette.h"
#include "qdebug.h" #include "qdebug.h"
#define EXPORTDATA_FILE "camera%1_data_info.xml"
#include <wininet.h> #include <wininet.h>
#define EXPORTDATA_FILE "camera%1_data_info.xml"
using namespace tinyxml2; using namespace tinyxml2;
class _XMLExportDataInfo { class _XMLExportDataInfo {
@ -116,8 +119,9 @@ public:
wait(); wait();
} }
QTimer* timer; QTimer* timer;
QStringList listToZip;
QStringList tmpListToZip; QMap<QString, bool> listToZip;
QMap<QString, bool> tmpListToZip;
BOOLEAN readyToSendZip; BOOLEAN readyToSendZip;
@ -145,7 +149,7 @@ public:
public slots: public slots:
void EDrecMsgFromCigarette(); void EDrecMsgFromCigarette();
void GetDataFromSaveThread(QString filePath); void GetDataFromSaveThread(QString filePath, bool Ng);
private: private:

@ -337,16 +337,6 @@ void SyncWorkThread::run()
roi = cv::Rect(j * m.cols, index * m.rows, m.cols, m.rows); roi = cv::Rect(j * m.cols, index * m.rows, m.cols, m.rows);
m.copyTo(merge_image(roi)); m.copyTo(merge_image(roi));
if (merge_index == work_camera_nums * unit_count) { if (merge_index == work_camera_nums * unit_count) {
if (!IsNG)
{
ngReason = 1;
}
else
{
ngReason = 0;
}
//条盒TJ 小盒BJ //条盒TJ 小盒BJ
file_name = g_conf_path.save_pics_path + "/" file_name = g_conf_path.save_pics_path + "/"
+ now_ts.toString("yyyy-MM-dd") + "/"+"416_BJ_01_" + now_ts.toString("yyyy-MM-dd") + "/"+"416_BJ_01_"
@ -357,6 +347,7 @@ void SyncWorkThread::run()
QString sendName = "416_BJ_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(); TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
TCP_Info_queue->put(TCPSendInfo); TCP_Info_queue->put(TCPSendInfo);
sendDataToCompress(file_name, IsNG);
#endif #endif
} }
} }

@ -22,6 +22,10 @@ signals:
void event_ok(int Num); void event_ok(int Num);
void event_ng(int Num); void event_ng(int Num);
#endif #endif
#ifdef __TCPSend
signals:
void sendDataToCompress(QString filePath, bool Ng);
#endif
public: public:
SyncWorkThread(QObject* parent = 0) : QThread(parent) SyncWorkThread(QObject* parent = 0) : QThread(parent)

Loading…
Cancel
Save