|
|
|
@ -35,22 +35,19 @@ AlgJd alg_test;//test AI算法
|
|
|
|
|
QThread* pThread[NumberOfSupportedCameras];
|
|
|
|
|
|
|
|
|
|
int work_camera_nums;
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
//巴鲁夫相机相关
|
|
|
|
|
CaptureThread* pCaptureThread[NumberOfSupportedCameras];
|
|
|
|
|
FunctionInterface* pFI[NumberOfSupportedCameras];
|
|
|
|
|
mvIMPACT::acquire::GenICam::AcquisitionControl* pAC[NumberOfSupportedCameras];
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
|
|
|
|
|
//巴斯勒相机相关
|
|
|
|
|
CaptureThreadBasler* pBaslerCaptureThread[NumberOfSupportedCameras];
|
|
|
|
|
Pylon::CBaslerUniversalInstantCamera* BaslerCamHandle[NumberOfSupportedCameras];
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
|
|
|
|
|
//海康相机相关
|
|
|
|
|
void* HIKCamHandle[NumberOfSupportedCameras];
|
|
|
|
|
CaptureThreadHIK* pHIKCaptureThread[NumberOfSupportedCameras];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
SyncQueue<std::pair<std::string, cv::Mat>>* g_save_queue; //图片保存队列
|
|
|
|
|
#ifdef SYNC_CAMERA
|
|
|
|
|
ImageSyncArr g_image_sync_arr;
|
|
|
|
@ -534,24 +531,18 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen) {
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID) {
|
|
|
|
|
if (pCaptureThread[i])
|
|
|
|
|
while (!pCaptureThread[i]->Ready)Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
if (pBaslerCaptureThread[i])
|
|
|
|
|
while (!pBaslerCaptureThread[i]->Ready)Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
if (pHIKCaptureThread[i])
|
|
|
|
|
while (!pHIKCaptureThread[i]->Ready)Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -588,7 +579,6 @@ void Cigarette::start_work()
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen) {
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID) {
|
|
|
|
|
if (pCaptureThread[i])
|
|
|
|
|
{
|
|
|
|
@ -598,9 +588,7 @@ void Cigarette::start_work()
|
|
|
|
|
pCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
if (pBaslerCaptureThread[i])
|
|
|
|
|
{
|
|
|
|
|
pBaslerCaptureThread[i]->p_result_queue->clear();
|
|
|
|
@ -609,9 +597,7 @@ void Cigarette::start_work()
|
|
|
|
|
pBaslerCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
if (pHIKCaptureThread[i])
|
|
|
|
|
{
|
|
|
|
|
pHIKCaptureThread[i]->p_result_queue->clear();
|
|
|
|
@ -620,7 +606,6 @@ void Cigarette::start_work()
|
|
|
|
|
pHIKCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -757,9 +742,9 @@ void Cigarette::Exit()
|
|
|
|
|
}
|
|
|
|
|
qApp->quit();
|
|
|
|
|
this->close();
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
|
|
|
|
|
Pylon::PylonTerminate();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//停止工作按钮
|
|
|
|
@ -2941,7 +2926,6 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
{
|
|
|
|
|
if (OpenOrClose == OPEN && !SingleCamInfo[Num].IsOpen)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for balluff";
|
|
|
|
@ -3037,9 +3021,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for basler";
|
|
|
|
|
try
|
|
|
|
@ -3160,9 +3142,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for hik";
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
@ -3282,11 +3262,9 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else if (OpenOrClose == CLOSE && SingleCamInfo[Num].IsOpen)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for balluff";
|
|
|
|
@ -3316,9 +3294,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for basler";
|
|
|
|
|
disconnect(pThread[Num], SIGNAL(started()), pBaslerCaptureThread[Num], SLOT(process()));
|
|
|
|
@ -3346,9 +3322,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for hik";
|
|
|
|
|
void* camhandle;
|
|
|
|
@ -3377,7 +3351,6 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -3388,15 +3361,12 @@ void Cigarette::EnumerateCameras(SingleCamInfoStruct* TempSingleCamInfoStruct, b
|
|
|
|
|
//这些厂商相机枚举时候会过滤别的厂商相机,单独枚举
|
|
|
|
|
int basler_cnt = 0;
|
|
|
|
|
int filtered = 0;
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
filtered = BaslerCamera::Enumerate();
|
|
|
|
|
Pylon::CInstantCameraArray cameras(filtered);
|
|
|
|
|
Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < min(filtered, NumberOfSupportedCameras); i++)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
SingleCamInfoStruct CamInfo;
|
|
|
|
|
//cameras[i].Attach(tlFactory.CreateDevice(BaslerCamera::devices[i]));
|
|
|
|
|
//Pylon::String_t selectedAction = ::GenICam::gcstring("Action");
|
|
|
|
@ -3420,13 +3390,11 @@ void Cigarette::EnumerateCameras(SingleCamInfoStruct* TempSingleCamInfoStruct, b
|
|
|
|
|
TempSingleCamInfo.push_back(CamInfo);
|
|
|
|
|
basler_cnt++;
|
|
|
|
|
//}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//这些厂商相机可以互相枚举,但是Enumerate都要执行里面会初始化一些全局信息
|
|
|
|
|
int hik_cnt = 0;
|
|
|
|
|
int unfiltered = 0;
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
unfiltered = HIKCamera::Enumerate();
|
|
|
|
|
for (int i = 0; i < min(unfiltered, NumberOfSupportedCameras); i++)
|
|
|
|
|
{
|
|
|
|
@ -3488,10 +3456,8 @@ void Cigarette::EnumerateCameras(SingleCamInfoStruct* TempSingleCamInfoStruct, b
|
|
|
|
|
hik_cnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int balluff_cnt = 0;
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
unfiltered = BalluffCamera::Enumerate();
|
|
|
|
|
for (int i = 0; i < min(unfiltered, NumberOfSupportedCameras); i++)
|
|
|
|
|
{
|
|
|
|
@ -3518,7 +3484,7 @@ void Cigarette::EnumerateCameras(SingleCamInfoStruct* TempSingleCamInfoStruct, b
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (showinfo) {
|
|
|
|
|
std::cout << "Camera Count:\t" << TempSingleCamInfo.size() << std::endl;
|
|
|
|
|
if (balluff_cnt)std::cout << "Balluff Count:\t" << balluff_cnt << std::endl;
|
|
|
|
@ -3554,7 +3520,6 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].IsOpen && SingleCamInfo[i].Detect)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
//设置帧率=10fps
|
|
|
|
@ -3563,9 +3528,7 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
//关闭外触发
|
|
|
|
|
pAC[i]->triggerMode.writeS("Off");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
|
MV_CC_SetFrameRate(HIKCamHandle[i], 10.0);
|
|
|
|
@ -3575,9 +3538,7 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerMode", MV_TRIGGER_MODE_OFF);
|
|
|
|
|
if (nRet) { std::cout << "can not set Hik's TriggerMode" << std::endl; }
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
bool nRet = false;
|
|
|
|
|
nRet = BaslerCamHandle[i]->AcquisitionFrameRate.TrySetValue(10);
|
|
|
|
@ -3595,7 +3556,6 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
if (!nRet) { std::cout << "can not set Basler's TriggerMode_Off" << std::endl; }
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_debug_mode = true;
|
|
|
|
@ -3607,7 +3567,6 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].IsOpen && SingleCamInfo[i].Detect)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
//设置帧率
|
|
|
|
@ -3616,9 +3575,7 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
pAC[i]->triggerSource.writeS("Line4");
|
|
|
|
|
pAC[i]->triggerActivation.writeS("RisingEdge");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
|
nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerMode", MV_TRIGGER_MODE_ON);
|
|
|
|
@ -3635,9 +3592,7 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
nRet = MV_CC_SetBoolValue(HIKCamHandle[i], "AcquisitionFrameRateEnable", false);
|
|
|
|
|
if (nRet) { std::cout << "can not set Hik's AcquisitionFrameRateEnable" << std::endl; }
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
bool nRet = false;
|
|
|
|
|
#ifndef USB_BASLER_NEW_FW
|
|
|
|
@ -3653,7 +3608,6 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
nRet = BaslerCamHandle[i]->AcquisitionFrameRateEnable.TrySetValue(false);
|
|
|
|
|
if (!nRet) { std::cout << "can not set Basler's AcquisitionFrameRateEnable" << std::endl; }
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_debug_mode = false;
|
|
|
|
@ -3733,13 +3687,11 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor
|
|
|
|
|
last_shift = shift;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __MQTTSend
|
|
|
|
|
void Cigarette::MqttMsgSend()
|
|
|
|
|
{
|
|
|
|
|
_MqttSendInfo MqttSendInfo;
|
|
|
|
|
MQTT_Info_queue->put(MqttSendInfo);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
void Cigarette::recMsgFromUdp(QString data)
|
|
|
|
|