|
|
|
@ -1,35 +1,76 @@
|
|
|
|
/******************************************************************************
|
|
|
|
#include "CoreCtrl.h"
|
|
|
|
Copyright(C):2015~2018 hzleaper
|
|
|
|
|
|
|
|
FileName:CoreCtrl.cpp
|
|
|
|
|
|
|
|
Author:zhikun wu
|
|
|
|
|
|
|
|
Email:zk.wu@hzleaper.com
|
|
|
|
|
|
|
|
Tools:vs2010 pc on company
|
|
|
|
|
|
|
|
Created:2015/03/24
|
|
|
|
|
|
|
|
History:24:3:2015 17:22
|
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include "CoreCtrl.h"
|
|
|
|
|
|
|
|
#include "globalCoreCtrl.h"
|
|
|
|
#include "globalCoreCtrl.h"
|
|
|
|
#include "baseFunction.h"
|
|
|
|
#include "baseFunction.h"
|
|
|
|
#include "QZkJsonParser.h"
|
|
|
|
#include "QZkJsonParser.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QThreadPool>
|
|
|
|
#include <QThreadPool>
|
|
|
|
|
|
|
|
#include "callbackFunc.h"
|
|
|
|
|
|
|
|
#include "CameraPool.h"
|
|
|
|
|
|
|
|
#include "globalCamera.h"
|
|
|
|
|
|
|
|
|
|
|
|
CCoreCtrl::CCoreCtrl(void)
|
|
|
|
CCoreCtrl::CCoreCtrl(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CCoreCtrl::CCoreCtrl(void* inParam)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CORE_CTRL_IN_PARAM* pCciParam = (CORE_CTRL_IN_PARAM*)inParam;
|
|
|
|
|
|
|
|
m_gpData = new CGlobalCoreCtrl(pCciParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CAMERA_IN_PARAM camInParam;
|
|
|
|
|
|
|
|
camInParam.pCallback = m_gpData;
|
|
|
|
|
|
|
|
camInParam.pGlobalData = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_gpGlobalCameraZZZ = new CGlobalCamera(&camInParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_gpCameraPool = new CCameraPool();
|
|
|
|
|
|
|
|
((CCameraPool*)m_gpCameraPool)->InitPool();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMGPROC_IN_PARAM imgprocInParam;
|
|
|
|
|
|
|
|
imgprocInParam.pGlobalData = m_gpGlobalCameraZZZ->m_pGlobalData;
|
|
|
|
|
|
|
|
m_gpImgProc = new CImgProc(&imgprocInParam);
|
|
|
|
|
|
|
|
((CImgProc*)m_gpImgProc)->InitProc();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCoreCtrl::~CCoreCtrl(void)
|
|
|
|
CCoreCtrl::~CCoreCtrl(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_gpImgProc)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
((CImgProc*)m_gpImgProc)->FreeProc();
|
|
|
|
|
|
|
|
delete m_gpImgProc;
|
|
|
|
|
|
|
|
m_gpImgProc = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_gpCameraPool)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
((CCameraPool*)m_gpCameraPool)->FreePool();
|
|
|
|
|
|
|
|
delete m_gpCameraPool;
|
|
|
|
|
|
|
|
m_gpCameraPool = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_gpData)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
delete m_gpData;
|
|
|
|
|
|
|
|
m_gpData = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_gpGlobalCameraZZZ)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
delete m_gpGlobalCameraZZZ;
|
|
|
|
|
|
|
|
m_gpGlobalCameraZZZ = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFreeCore();
|
|
|
|
IFreeCore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CCoreCtrl::IInitCore(class IDetectorEngine* pDE /*= NULL*/)
|
|
|
|
int CCoreCtrl::IInitCore(class IDetectorEngine* pDE /*= NULL*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int nRet = 0;
|
|
|
|
int nRet = 0;
|
|
|
|
//nRet = createShowWindows();//根据camera.json中的"windows"创建显示窗口内存,
|
|
|
|
|
|
|
|
//create threads
|
|
|
|
//create threads
|
|
|
|
int nCount = gCoreSetting.threadsCount;
|
|
|
|
int nCount = 4;// gCoreSetting.threadsCount;
|
|
|
|
if (nCount <= 0)
|
|
|
|
if (nCount <= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nCount = SYS_F::GetCpus();//获取系统cpu线程数量
|
|
|
|
nCount = SYS_F::GetCpus();//获取系统cpu线程数量
|
|
|
|
@ -42,9 +83,6 @@ int CCoreCtrl::IInitCore(class IDetectorEngine* pDE /*= NULL*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// pThd->StartThread();
|
|
|
|
|
|
|
|
// pThd->setPriority(QThread::TimeCriticalPriority);
|
|
|
|
|
|
|
|
m_imgThdPool.append(pThd);
|
|
|
|
m_imgThdPool.append(pThd);
|
|
|
|
++nRet;
|
|
|
|
++nRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -52,18 +90,18 @@ int CCoreCtrl::IInitCore(class IDetectorEngine* pDE /*= NULL*/)
|
|
|
|
//
|
|
|
|
//
|
|
|
|
IStartImageProcess();
|
|
|
|
IStartImageProcess();
|
|
|
|
//create cameraes...
|
|
|
|
//create cameraes...
|
|
|
|
glpCameralPool->ICreateCameraes();//更加camera.json 创建相机对象
|
|
|
|
m_gpCameraPool->ICreateCameraes();//更加camera.json 创建相机对象
|
|
|
|
glpCameralPool->IOpenDevicesEx();//打开相机
|
|
|
|
m_gpCameraPool->IOpenDevicesEx();//打开相机
|
|
|
|
glpCameralPool->ISetTriggerMode(DEV_TRIGGER_MODE_OUT);//设置默认的触发模式
|
|
|
|
m_gpCameraPool->ISetTriggerMode(DEV_TRIGGER_MODE_OUT);//设置默认的触发模式
|
|
|
|
glpCameralPool->IStartDevices();//设置相机开始工作
|
|
|
|
m_gpCameraPool->IStartDevices();//设置相机开始工作
|
|
|
|
return nRet;
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::IFreeCore()
|
|
|
|
void CCoreCtrl::IFreeCore()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glpCameralPool->IStopDevices();//设置相机停止工作
|
|
|
|
m_gpCameraPool->IStopDevices();//设置相机停止工作
|
|
|
|
glpCameralPool->ICloseDevices();//关闭相机
|
|
|
|
m_gpCameraPool->ICloseDevices();//关闭相机
|
|
|
|
glpCameralPool->IDeleteDameraes();//删除相机
|
|
|
|
m_gpCameraPool->IDeleteDameraes();//删除相机
|
|
|
|
//删除图片处理线程
|
|
|
|
//删除图片处理线程
|
|
|
|
while( !m_imgThdPool.isEmpty() )
|
|
|
|
while( !m_imgThdPool.isEmpty() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -71,13 +109,10 @@ void CCoreCtrl::IFreeCore()
|
|
|
|
pThd->EndThread();
|
|
|
|
pThd->EndThread();
|
|
|
|
delete pThd;
|
|
|
|
delete pThd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//m_showImages.clear(releaseShowImage);
|
|
|
|
|
|
|
|
// m_showWindows.clear(releaseShowWindow);//删除用用图像显示窗口内存
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 这里等待所有线程完成工作,虽然用clear也可以,
|
|
|
|
// 这里等待所有线程完成工作,虽然用clear也可以,
|
|
|
|
// 但是程序在退出的时候会跳出来错误。不够友好
|
|
|
|
// 但是程序在退出的时候会跳出来错误。不够友好
|
|
|
|
QThreadPool::globalInstance()->waitForDone();
|
|
|
|
QThreadPool::globalInstance()->waitForDone();
|
|
|
|
//QThreadPool::globalInstance()->clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::IStartImageProcess()
|
|
|
|
void CCoreCtrl::IStartImageProcess()
|
|
|
|
@ -97,58 +132,6 @@ void CCoreCtrl::IEndImageProcess()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//void CCoreCtrl::releaseShowImage(const QString& k, QZkShowImage*& v, void* pData)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// delete v;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool CCoreCtrl::ShowCameraImage(const ZStringA& serial, UINT nFrameNum, QImage& image, INT64 nStamp, int nIndex/* = 0*/, const QString& szExtend /*= NULL*/)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// QVariantMap map;
|
|
|
|
|
|
|
|
// map.clear();
|
|
|
|
|
|
|
|
// map.insert("camera", serial);
|
|
|
|
|
|
|
|
// map.insert("frame", nFrameNum);
|
|
|
|
|
|
|
|
// QVariant vimg;
|
|
|
|
|
|
|
|
// vimg.setValue(image);
|
|
|
|
|
|
|
|
// map.insert("image", vimg);
|
|
|
|
|
|
|
|
// glpGuiCallback->INewCameraImage(map);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// QString sWinId = serial + "_" + QString::number(nIndex);
|
|
|
|
|
|
|
|
// CShowWindow* pWin = m_showWindows.value(sWinId, NULL);
|
|
|
|
|
|
|
|
// if (NULL != pWin && pWin->AddCameraImage(image, nFrameNum, nStamp, szExtend)/*pWin->SetCameraImage(pCamImage)*/)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// glpGuiCallback->IUpdateShow(pWin->CameraWin().key);
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::DrawDefectOrg(IImageObject::emTpDefectType defectType, BYTE* pData, int nDataLen, CZkCameraImage* pCamImage)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// QString sWinId = QString::fromUtf8(pCamImage->Serial()) + "_" + QString::number(0);
|
|
|
|
|
|
|
|
// CShowWindow* pWin = m_showWindows.value(sWinId, NULL);
|
|
|
|
|
|
|
|
// if (NULL != pWin && pWin->DrawDefect(defectType, pData, nDataLen, pCamImage))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// glpGuiCallback->IUpdateShow(pWin->CameraWin().key);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::DrawImageOrg(QImage& srcImg, CZkCameraImage* pCamImage)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (!ShowCameraImage(pCamImage->Serial(), pCamImage->FrameNumber(), srcImg, pCamImage->Stamp(), 1, QString::fromUtf8(pCamImage->FileName())))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// QString sWinId = QString::fromUtf8(pCamImage->Serial()) + "_" + QString::number(0);
|
|
|
|
|
|
|
|
// CShowWindow* pWin = m_showWindows.value(sWinId, NULL);
|
|
|
|
|
|
|
|
// if (NULL != pWin && pWin->DrawImage(srcImg, pCamImage->FrameNumber(), QString::fromUtf8(pCamImage->FileName())))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// glpGuiCallback->IUpdateShow(pWin->CameraWin().key);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::ISetResult(const QString& key, QVariant& val)
|
|
|
|
void CCoreCtrl::ISetResult(const QString& key, QVariant& val)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_algResult.SetResult(key, val);
|
|
|
|
m_algResult.SetResult(key, val);
|
|
|
|
@ -164,228 +147,71 @@ void CCoreCtrl::AccumulateResult(const QString& key, QVariant& val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
void CCoreCtrl::setShowWindow(CShowWindow*& pWin, void* pData)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void CCoreCtrl::setShowImage(const QString& k, QZkShowImage*& v, void* pData)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// v->SetShowImage((CZkCameraImage*)pData);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QString> CCoreCtrl::ICameraKeys()
|
|
|
|
QList<QString> CCoreCtrl::ICameraKeys()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ICameraKeys();
|
|
|
|
return m_gpCameraPool->ICameraKeys();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList<QString> CCoreCtrl::ICameraKeysOrderByIds()
|
|
|
|
QList<QString> CCoreCtrl::ICameraKeysOrderByIds()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ICameraKeysOrderByIds();
|
|
|
|
return m_gpCameraPool->ICameraKeysOrderByIds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::ICameraOption(const QString& strSerial, TP_CAMERA_OPTION& camOpt)
|
|
|
|
bool CCoreCtrl::ICameraOption(const QString& strSerial, TP_CAMERA_OPTION& camOpt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ICameraOption(strSerial, camOpt);
|
|
|
|
return m_gpCameraPool->ICameraOption(strSerial, camOpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::ICameraOptionByKey(const QString& strSerial, TP_CAMERA_OPTION& camOpt)
|
|
|
|
bool CCoreCtrl::ICameraOptionByKey(const QString& strSerial, TP_CAMERA_OPTION& camOpt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ICameraOptionByKey(strSerial, camOpt);
|
|
|
|
return m_gpCameraPool->ICameraOptionByKey(strSerial, camOpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList<QString> CCoreCtrl::IEnumAvailableCameras(emTpDeviceType camType)
|
|
|
|
QList<QString> CCoreCtrl::IEnumAvailableCameras(emTpDeviceType camType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->IEnumAvailableCameras(camType);
|
|
|
|
return m_gpCameraPool->IEnumAvailableCameras(camType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::ISetTriggerMode(emTpDeviceTriggerMode triggerMode, long nFrameRate)
|
|
|
|
void CCoreCtrl::ISetTriggerMode(emTpDeviceTriggerMode triggerMode, long nFrameRate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glpCameralPool->ISetTriggerMode(triggerMode, TRIGGER_DIRECT_FOREWARD, nFrameRate);
|
|
|
|
m_gpCameraPool->ISetTriggerMode(triggerMode, TRIGGER_DIRECT_FOREWARD, nFrameRate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::IManualTrigger(emTpTriggerDirection direct)
|
|
|
|
void CCoreCtrl::IManualTrigger(emTpTriggerDirection direct)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glpCameralPool->IManualTrigger(direct);
|
|
|
|
m_gpCameraPool->IManualTrigger(direct);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::ISnapImage(const QStringList& camKeys)
|
|
|
|
void CCoreCtrl::ISnapImage(const QStringList& camKeys)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glpCameralPool->ISnapImage(camKeys);
|
|
|
|
m_gpCameraPool->ISnapImage(camKeys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::ISendSoftTrigger(const QStringList& camKeys)
|
|
|
|
void CCoreCtrl::ISendSoftTrigger(const QStringList& camKeys)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glpCameralPool->ISendSoftTrigger(camKeys);
|
|
|
|
m_gpCameraPool->ISendSoftTrigger(camKeys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::IDrawImage(const QString& sKey, QPainter& painter, QRect& rt)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// /*
|
|
|
|
|
|
|
|
// tagDrawShowImageParam param;
|
|
|
|
|
|
|
|
// param.painter = &painter;
|
|
|
|
|
|
|
|
// param.rt = &rt;
|
|
|
|
|
|
|
|
// m_showImages.valueCall(sKey, drawShowImage, ¶m);*/
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void CCoreCtrl::drawShowImage(const QString& key, QZkShowImage*& v, void* pData)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// tagDrawShowImageParam* param = (tagDrawShowImageParam*)pData;
|
|
|
|
|
|
|
|
// v->DrawToPainter(param->painter, param->rt);
|
|
|
|
|
|
|
|
//// param->painter->drawPixmap()
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int CCoreCtrl::createShowWindows()
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int nCount = 0;
|
|
|
|
|
|
|
|
// // QList<TP_CAMERA_WIN*> camWins = glpCameralPool->ICameraWins();
|
|
|
|
|
|
|
|
// // for (int i = 0; i < camWins.size(); ++i)
|
|
|
|
|
|
|
|
// // {
|
|
|
|
|
|
|
|
// // CShowWindow* pShow = new CShowWindow(camWins[i]);
|
|
|
|
|
|
|
|
// // if (NULL == pShow)
|
|
|
|
|
|
|
|
// // {
|
|
|
|
|
|
|
|
// // continue;
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // if (m_showWindows.contains(pShow->WindowId()))
|
|
|
|
|
|
|
|
// // {
|
|
|
|
|
|
|
|
// // delete pShow;
|
|
|
|
|
|
|
|
// // continue;
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // m_showWindows.insert(pShow->WindowId(), pShow);
|
|
|
|
|
|
|
|
// // gGuiCallback_FuncCall(IAddWindows, camWins[i]->key, pShow->WindowId());
|
|
|
|
|
|
|
|
// // ++nCount;
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// return nCount;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::releaseShowWindow(CShowWindow*& pWin, void* pData)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// delete pWin;
|
|
|
|
|
|
|
|
// pWin = NULL;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool CCoreCtrl::IAddCamWin(const QString& strKey, const TP_CAMERA_WIN& camwinOpt, bool bNew)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (glpCameralPool->IAddCamWin(strKey, camwinOpt, bNew))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (bNew){
|
|
|
|
|
|
|
|
// QList<TP_CAMERA_WIN*> camWins = glpCameralPool->ICameraWins();
|
|
|
|
|
|
|
|
// for (int i = 0; i < camWins.size(); ++i)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (camWins[i]->key.compare(strKey, Qt::CaseInsensitive) == 0){
|
|
|
|
|
|
|
|
// CShowWindow* pShow = new CShowWindow(camWins[i]);
|
|
|
|
|
|
|
|
// if (!pShow) return false;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // if (m_showWindows.contains(pShow->WindowId()))
|
|
|
|
|
|
|
|
// // {
|
|
|
|
|
|
|
|
// // delete pShow;
|
|
|
|
|
|
|
|
// // return false;
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // m_showWindows.insert(pShow->WindowId(), pShow);
|
|
|
|
|
|
|
|
// gGuiCallback_FuncCall(IAddWindows, camWins[i]->key, pShow->WindowId());
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool CCoreCtrl::IDelCamWin(const QString& strKey)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// TP_CAMERA_WIN optCamWin;
|
|
|
|
|
|
|
|
// if (ICamWinOptionByKey(strKey, optCamWin)){
|
|
|
|
|
|
|
|
// QString strWinId = QString(optCamWin.device) + "_" + QString::number(optCamWin.index);
|
|
|
|
|
|
|
|
// CShowWindow* pShow = m_showWindows.value(strWinId);
|
|
|
|
|
|
|
|
// if (pShow){
|
|
|
|
|
|
|
|
// m_showWindows.remove(strWinId);
|
|
|
|
|
|
|
|
// delete pShow;
|
|
|
|
|
|
|
|
// pShow = NULL;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return glpCameralPool->IDelCamWin(strKey);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QImage CCoreCtrl::IShowImage(const QString& sShowId, int& nFrameNum, QString& szExShow)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// CShowWindow* pWin = m_showWindows.value(sShowId, NULL);
|
|
|
|
|
|
|
|
// if (NULL == pWin)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// nFrameNum = -1;
|
|
|
|
|
|
|
|
// return QImage();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// nFrameNum = pWin->FrameNum();
|
|
|
|
|
|
|
|
// szExShow = pWin->ExtendString();
|
|
|
|
|
|
|
|
// return pWin->ShowImage();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString, QString> CCoreCtrl::IGetCamShowNames()
|
|
|
|
QMap<QString, QString> CCoreCtrl::IGetCamShowNames()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->IGetCamShowNames();
|
|
|
|
return m_gpCameraPool->IGetCamShowNames();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IAlgorithmOption* CCoreCtrl::IGetAlgorithmOption(int nAlgorithm)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return glpImgProc->IGetAlgorithmOption(nAlgorithm);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::ISetCameraOption(const QString& strSerial, const TP_CAMERA_OPTION& camOpt)
|
|
|
|
bool CCoreCtrl::ISetCameraOption(const QString& strSerial, const TP_CAMERA_OPTION& camOpt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ISetCameraOption(strSerial, camOpt);
|
|
|
|
return m_gpCameraPool->ISetCameraOption(strSerial, camOpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::IReopenCameraes()
|
|
|
|
bool CCoreCtrl::IReopenCameraes()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->IOpenDevices();
|
|
|
|
return m_gpCameraPool->IOpenDevices();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::ISetVirtualImages(const QString& camera, const QStringList& szImages)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// glpCameralPool->ISetVirtualImages(camera, szImages);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QImage CCoreCtrl::IOriginImage(const QString& sShowId)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// CShowWindow* pWin = m_showWindows.value(sShowId, NULL);
|
|
|
|
|
|
|
|
// if (NULL == pWin)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return QImage();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return pWin->OriginImage();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CCoreCtrl::ISetCameraProperty(const QString& camera, TP_CAMERA_PROPERTY& property)
|
|
|
|
void CCoreCtrl::ISetCameraProperty(const QString& camera, TP_CAMERA_PROPERTY& property)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return glpCameralPool->ISetCameraProperty(camera, property);
|
|
|
|
return m_gpCameraPool->ISetCameraProperty(camera, property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::ISetAlgorithmShared(const QString& key, const QVariant& value)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// // m_algShared.SetValue(key, value);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void CCoreCtrl::IWriteIo(const TP_IO_OUT_CONTROL& state)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool CCoreCtrl::updateCommJson(const QString& sJsonPath)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::updateCamJson(const QString& sJsonPath)
|
|
|
|
bool CCoreCtrl::updateCamJson(const QString& sJsonPath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int nError;
|
|
|
|
int nError;
|
|
|
|
@ -435,32 +261,6 @@ bool CCoreCtrl::updateCamJson(const QString& sJsonPath)
|
|
|
|
cameraRoot["devices"] = cameraDevs;
|
|
|
|
cameraRoot["devices"] = cameraDevs;
|
|
|
|
cameraRoot["pool"] = originObjJson["pool"].toObject();
|
|
|
|
cameraRoot["pool"] = originObjJson["pool"].toObject();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonObject cameraWins;
|
|
|
|
|
|
|
|
QList<QString> camwinlist = ICamWinKeys();
|
|
|
|
|
|
|
|
foreach(const QString& strCamWinName, camwinlist)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TP_CAMERA_WIN camwinOpt;
|
|
|
|
|
|
|
|
if (ICamWinOptionByKey(strCamWinName, camwinOpt))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QJsonObject camwinObj;
|
|
|
|
|
|
|
|
camwinObj["bitsperpixel"] = camwinOpt.bitsPerPixel;
|
|
|
|
|
|
|
|
camwinObj["buffer_h"] = camwinOpt.bufferH;
|
|
|
|
|
|
|
|
camwinObj["buffer_w"] = camwinOpt.bufferW;
|
|
|
|
|
|
|
|
camwinObj["buffers"] = camwinOpt.buffers;
|
|
|
|
|
|
|
|
camwinObj["cache_origin"] = camwinOpt.bCacheOriginImage;
|
|
|
|
|
|
|
|
camwinObj["device"] = camwinOpt.device;
|
|
|
|
|
|
|
|
camwinObj["images"] = camwinOpt.images;
|
|
|
|
|
|
|
|
camwinObj["index"] = camwinOpt.index;
|
|
|
|
|
|
|
|
camwinObj["mirror"] = camwinOpt.mirror;
|
|
|
|
|
|
|
|
camwinObj["rgb_swapped"] = camwinOpt.bNeedRgbSwapped;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cameraWins[camwinOpt.key] = camwinObj;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cameraRoot["windows"] = cameraWins;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return saveJsonToFile(cameraRoot, sJsonPath);
|
|
|
|
return saveJsonToFile(cameraRoot, sJsonPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -478,3 +278,36 @@ bool CCoreCtrl::saveJsonToFile(const QJsonObject& json, const QString& fileFullN
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::IRegisterGetVariant(FuncCallBack_VarInt func)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (func)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lpCallBackFunc::instance()->m_GetVariantCallBackFunc = func;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::IRegisterImageCallBack(FuncCallBack_VarMap callback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lpCallBackFunc::instance()->m_ImageCallBackFunc = callback;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CCoreCtrl::IRegisterResultCallBack(FuncCallBack_StrMap callback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lpCallBackFunc::instance()->m_ResultCallBackFunc = callback;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|