You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.3 KiB
C++
98 lines
2.3 KiB
C++
#pragma once
|
|
#include "common.h"
|
|
#ifdef __UDPSend
|
|
#include <QThread>
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/imgproc/types_c.h>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include "SyncQueue.h"
|
|
|
|
#include <QUdpSocket>
|
|
|
|
#define image_width 160
|
|
#define image_heigh 120
|
|
|
|
#define info_frame 1
|
|
#define speed_frame 2
|
|
#define kick_frame 3
|
|
#define ok_frame 4
|
|
#define ng_frame 5
|
|
#define image_frame 6
|
|
#define total_frame 7
|
|
|
|
class _UDPSendInfo
|
|
{
|
|
public:
|
|
int FrameID;
|
|
int index;
|
|
cv::Mat image;
|
|
int cnt;
|
|
long Total;
|
|
QString JD;
|
|
QString timecost;
|
|
int ok[NumberOfSupportedCameras];
|
|
int ng[NumberOfSupportedCameras];
|
|
QString speed;
|
|
int Kick[NumberOfSupportedCameras];
|
|
|
|
_UDPSendInfo()
|
|
{
|
|
FrameID = 0;
|
|
index = 0;
|
|
image = cv::Mat(image_width, image_heigh, CV_8UC3, cv::Scalar(0, 0, 0));
|
|
Total = 0;
|
|
JD = QString("0,0,0");
|
|
timecost = QString("0ms");;
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)ok[i] = 0;
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)ng[i] = 0;
|
|
speed = QString(" ");
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)Kick[i] = 0;
|
|
}
|
|
};
|
|
|
|
class threadSend : public QThread
|
|
{
|
|
public:
|
|
QString ip;
|
|
int dataport;
|
|
int imageport;
|
|
threadSend(QObject* o = nullptr) :QThread(o)
|
|
{
|
|
isLoop = true;
|
|
}
|
|
|
|
~threadSend()
|
|
{
|
|
stop();
|
|
_UDPSendInfo UDPSendInfo;
|
|
Local_UDP_Info_queue->put(UDPSendInfo);
|
|
quit();
|
|
wait();
|
|
}
|
|
void stop();
|
|
|
|
protected:
|
|
void run();
|
|
|
|
public:
|
|
void init(SyncQueue<_UDPSendInfo>* p_UDP_Info_queue, std::string IP, int port);
|
|
void start_work();
|
|
|
|
void sendData(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendData(QString data, int port);
|
|
void sendImage(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendSpeed(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendKick(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendOK(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendNG(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendTotal(_UDPSendInfo* UDPSendInfo, int port);
|
|
void sendFile(QString FilePath, int port);
|
|
public:
|
|
SyncQueue<_UDPSendInfo>* Local_UDP_Info_queue;
|
|
std::atomic_bool isLoop = { 0 };
|
|
QUdpSocket mSocket;
|
|
};
|
|
#endif |