|
|
|
|
|
#include "ImageObject.h"
|
|
|
|
|
|
#include "CoreCtrl.h"
|
|
|
|
|
|
#include "zfunctions.h"
|
|
|
|
|
|
|
|
|
|
|
|
CImageObject::CImageObject(class CCoreCtrl* pCoreCtrl)
|
|
|
|
|
|
: m_pCoreCtrl(pCoreCtrl)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pCamImg = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CImageObject::~CImageObject()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CImageObject::SetCameraImage(CZkCameraImage* pCamImage)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pCamImg = pCamImage;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emTpColorFormat CImageObject::IColorFormat()
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return TP_COLOR_NONE;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->ColorFormat();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BYTE* CImageObject::IImageData(int& nOutW, int& nOutH, int& nOutBitsPerPixel, int& nBytesPerLine)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->ImageData(nOutW, nOutH, nOutBitsPerPixel, nBytesPerLine);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CImageObject::IGetId()
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->GetId();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CImageObject::IGetAlgorithm()
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->Algorithm();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CImageObject::IGetFrameNum()
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->FrameNumber();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CImageObject::IGetTriggerCount()
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL == m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->TriggerCount();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::ISetCameroProperty(TP_CAMERA_PROPERTY& property)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( NULL != m_pCamImg )
|
|
|
|
|
|
{
|
|
|
|
|
|
glpCameralPool->ISetCameraProperty(m_pCamImg->Serial(), property);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::ISendDataToUI(void* pData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL != m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
// gGuiCallback_FuncCall(ISendDataToUI, TP_UI_DATA_FROM_ALGORITHM, m_pCamImg->Serial(), pData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::ISafeDataToUI(void* pData, int nDataLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
QByteArray data((char*)pData, nDataLen);
|
|
|
|
|
|
if (NULL != m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
//gGuiCallback_FuncCall(ISafeDataToUI, TP_UI_DATA_FROM_ALGORITHM, m_pCamImg->Serial(), data);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//gGuiCallback_FuncCall(ISafeDataToUI, TP_UI_DATA_FROM_ALGORITHM, NULL, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::ISafeDataToUI(WORD type, void* pData, int nDataLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
QByteArray data((char*)pData, nDataLen);
|
|
|
|
|
|
emTpUiDataType emType = (emTpUiDataType)(TP_UI_DATA_FROM_ALGORITHM | type);
|
|
|
|
|
|
if (NULL != m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
// gGuiCallback_FuncCall(ISafeDataToUI, emType, m_pCamImg->Serial(), data);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// gGuiCallback_FuncCall(ISafeDataToUI, emType, NULL, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::IDrawDefect(const char* szWinName, emTpDefectType defectType, BYTE* pData, int nDataLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
QByteArray data((char*)pData, nDataLen);
|
|
|
|
|
|
// gGuiCallback_FuncCall(IDrawDefectToScene, szWinName, defectType, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
void CImageObject::IDrawDefectOrg(emTpDefectType defectType, BYTE* pData, int nDataLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
// if (NULL != m_pCoreCtrl && NULL != m_pCamImg)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// m_pCoreCtrl->DrawDefectOrg(defectType, pData, nDataLen, m_pCamImg);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT64 CImageObject::IMeterCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL == m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
return m_pCamImg->MeterCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
const char* CImageObject::IGetImageUtf8String()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL == m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
return m_pCamImg->FileName().data();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::IDrawImage(QImage& image/* = QImage()*/, const char* szWinName/* = NULL*/)
|
|
|
|
|
|
{
|
|
|
|
|
|
// if (NULL != m_pCoreCtrl && NULL != m_pCamImg)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (image.isNull())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// image = m_pCamImg->ToQImage();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// m_pCoreCtrl->DrawImageOrg(image, m_pCamImg);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QImage CImageObject::IImage()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL == m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return QImage();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->ToQImage();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ZStringA& CImageObject::IDllSuffix()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->DllSuffix();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::ISetResult(const QString& key, QVariant& val)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL != m_pCoreCtrl)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pCoreCtrl->ISetResult(key, val);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::IAccumulateResult(const QString& key, QVariant& val)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL != m_pCoreCtrl)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pCoreCtrl->AccumulateResult(key, val);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::IMoveToFolder(const QString& szFolder)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (QFile::exists(QString::fromUtf8(IGetImageUtf8String())))
|
|
|
|
|
|
{
|
|
|
|
|
|
ZKF::qtCopyFile(IGetImageUtf8String(), szFolder.toUtf8().data());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (NULL == m_pCamImg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IAlgorithmShared* CImageObject::IGetShared()
|
|
|
|
|
|
{
|
|
|
|
|
|
// if (NULL == m_pCoreCtrl)
|
|
|
|
|
|
// {
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return &m_pCoreCtrl->m_algShared;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CImageObject::IVariantMapToUI(const QVariantMap& vMap)
|
|
|
|
|
|
{
|
|
|
|
|
|
glpGuiCallback->IVariantMapToUI(TP_UI_DATA_FROM_ALGORITHM, m_pCamImg->Serial(), vMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ZStringA& CImageObject::ICameraSerial()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->Serial();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const QVariant& CImageObject::IVarFromUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pCamImg->VarFromUI();
|
|
|
|
|
|
}
|