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.
whellvalue/tpvs17/tpMain/CoreCtrl/CDllDetectorEngine.cpp

79 lines
1.7 KiB
C++

#include "CDllDetectorEngine.h"
#include "iCoreCtrl.h"
CDllDetectorEngine::CDllDetectorEngine()
{
m_pDE = NULL;
#ifdef _DEBUG
m_lib.setFileName("lpbengined.dll");
#else
m_lib.setFileName("lpbengine.dll");
#endif
if (!m_lib.load())
{
qWarning("failed to load lpbengine");
}
FnLpNewEngineInstance pfnLpNewInstance = (FnLpNewEngineInstance)m_lib.resolve("LpNewEngineInstance");
if (pfnLpNewInstance)
pfnLpNewInstance(&m_pDE, NULL);
if (!m_pDE)
{
qWarning("failed to get instance from lpbengine");
}
}
CDllDetectorEngine::~CDllDetectorEngine()
{
Quit();
}
bool CDllDetectorEngine::Initialize(class ICoreCtrl* pCoreCtrl)
{
if (m_pDE && pCoreCtrl)
{
void* p = NULL;
m_pDE->GetDataInterface(DEVICEMGR, &p);
IDetectorDeviceMgr* pDeviceMgr = (IDetectorDeviceMgr*)p;
if (pDeviceMgr)
{
pDeviceMgr->RegisterCoreCtrl(pCoreCtrl);
QList<QString> strCameraKeys = pCoreCtrl->ICameraKeys();
for (int i = 0; i < strCameraKeys.size(); i++)
{
IDetectorCameraDevice* pCamera = (IDetectorCameraDevice*)pDeviceMgr->AddDevice(CAMERA);
if (pCamera)
{
TP_CAMERA_OPTION option;
pCoreCtrl->IGetCameraOption(strCameraKeys.at(i), option);
pCamera->SetName(strCameraKeys.at(i));
pCamera->SetID(option.id);
}
}
}
m_pDE->GetDataInterface(SHAREAPARAM, &p);
IAlgorithmShare* pAlgoShare = (IAlgorithmShare*)p;
if (pAlgoShare)
{
pAlgoShare->RegisterCoreCtrl(pCoreCtrl);
}
return true;
}
return false;
}
void CDllDetectorEngine::Quit()
{
FnLpDeleteEngineInstance pfnLpDeleteInstance = (FnLpDeleteEngineInstance)m_lib.resolve("LpDeleteEngineInstance");
if (pfnLpDeleteInstance)
pfnLpDeleteInstance();
if (m_lib.isLoaded())
m_lib.unload();
}