|
|
|
@ -35,19 +35,22 @@ 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;
|
|
|
|
@ -531,18 +534,24 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
if (pBaslerCaptureThread[i])
|
|
|
|
|
while (!pBaslerCaptureThread[i]->Ready)Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
if (pHIKCaptureThread[i])
|
|
|
|
|
while (!pHIKCaptureThread[i]->Ready)Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -579,6 +588,7 @@ 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])
|
|
|
|
|
{
|
|
|
|
@ -588,7 +598,9 @@ void Cigarette::start_work()
|
|
|
|
|
pCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID) {
|
|
|
|
|
if (pBaslerCaptureThread[i])
|
|
|
|
|
{
|
|
|
|
|
pBaslerCaptureThread[i]->p_result_queue->clear();
|
|
|
|
@ -597,7 +609,9 @@ void Cigarette::start_work()
|
|
|
|
|
pBaslerCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID) {
|
|
|
|
|
if (pHIKCaptureThread[i])
|
|
|
|
|
{
|
|
|
|
|
pHIKCaptureThread[i]->p_result_queue->clear();
|
|
|
|
@ -606,6 +620,7 @@ void Cigarette::start_work()
|
|
|
|
|
pHIKCaptureThread[i]->p_shooted_queue->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -742,9 +757,9 @@ void Cigarette::Exit()
|
|
|
|
|
}
|
|
|
|
|
qApp->quit();
|
|
|
|
|
this->close();
|
|
|
|
|
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
Pylon::PylonTerminate();
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//停止工作按钮
|
|
|
|
@ -2926,6 +2941,7 @@ 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";
|
|
|
|
@ -3021,7 +3037,9 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for basler";
|
|
|
|
|
try
|
|
|
|
@ -3142,7 +3160,9 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for hik";
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
@ -3262,9 +3282,11 @@ 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";
|
|
|
|
@ -3294,7 +3316,9 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for basler";
|
|
|
|
|
disconnect(pThread[Num], SIGNAL(started()), pBaslerCaptureThread[Num], SLOT(process()));
|
|
|
|
@ -3322,7 +3346,9 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for hik";
|
|
|
|
|
void* camhandle;
|
|
|
|
@ -3351,6 +3377,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
SingleCamInfo[Num].IsOpen = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -3361,12 +3388,15 @@ 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");
|
|
|
|
@ -3390,11 +3420,13 @@ 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++)
|
|
|
|
|
{
|
|
|
|
@ -3456,8 +3488,10 @@ 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++)
|
|
|
|
|
{
|
|
|
|
@ -3484,7 +3518,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;
|
|
|
|
@ -3520,6 +3554,7 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].IsOpen && SingleCamInfo[i].Detect)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
//设置帧率=10fps
|
|
|
|
@ -3528,7 +3563,9 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
//关闭外触发
|
|
|
|
|
pAC[i]->triggerMode.writeS("Off");
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
|
MV_CC_SetFrameRate(HIKCamHandle[i], 10.0);
|
|
|
|
@ -3538,7 +3575,9 @@ 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; }
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
bool nRet = false;
|
|
|
|
|
nRet = BaslerCamHandle[i]->AcquisitionFrameRate.TrySetValue(10);
|
|
|
|
@ -3556,6 +3595,7 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
if (!nRet) { std::cout << "can not set Basler's TriggerMode_Off" << std::endl; }
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_debug_mode = true;
|
|
|
|
@ -3567,6 +3607,7 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].IsOpen && SingleCamInfo[i].Detect)
|
|
|
|
|
{
|
|
|
|
|
#if defined (BALLUFF_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
//设置帧率
|
|
|
|
@ -3575,7 +3616,9 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
pAC[i]->triggerSource.writeS("Line4");
|
|
|
|
|
pAC[i]->triggerActivation.writeS("RisingEdge");
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (HIK_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
|
nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerMode", MV_TRIGGER_MODE_ON);
|
|
|
|
@ -3592,7 +3635,9 @@ void Cigarette::DisableDebugMode()
|
|
|
|
|
nRet = MV_CC_SetBoolValue(HIKCamHandle[i], "AcquisitionFrameRateEnable", false);
|
|
|
|
|
if (nRet) { std::cout << "can not set Hik's AcquisitionFrameRateEnable" << std::endl; }
|
|
|
|
|
}
|
|
|
|
|
else if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (BASLER_SUPPORT)
|
|
|
|
|
if (SingleCamInfo[i].CamClass == BaslerClassID)
|
|
|
|
|
{
|
|
|
|
|
bool nRet = false;
|
|
|
|
|
#ifndef USB_BASLER_NEW_FW
|
|
|
|
@ -3608,6 +3653,7 @@ 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;
|
|
|
|
@ -3687,11 +3733,13 @@ 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)
|
|
|
|
|