diff --git a/3part/libzkq/include/DllLoader.h b/3part/libzkq/include/DllLoader.h index 550cb7b..df0c29b 100644 --- a/3part/libzkq/include/DllLoader.h +++ b/3part/libzkq/include/DllLoader.h @@ -83,10 +83,10 @@ public: { m_lib.setFileName(ZString(szPath) + szLibName); } - tpDebugOut("single paths: %s, name:%s", szPath, szLibName); + //tpDebugOut("single paths: %s, name:%s", szPath, szLibName); m_fpInit = (Func_Lib_Init)m_lib.resolve(szFuncInit); m_fpFree = (Func_Lib_Free)m_lib.resolve(szFuncFree); - tpDebugOut("init function, Name: %s, Address:%d", szFuncInit, (int)m_fpInit); + //tpDebugOut("init function, Name: %s, Address:%d", szFuncInit, (int)m_fpInit); } CDllLoaderM(const char *szLibName, const char *szFuncInit, const char *szFuncFree, const ZStringList& dllPaths) { ZString szName(szLibName); @@ -100,13 +100,13 @@ public: break; } } - tpDebugOut("Multi paths: %s, name:%s", szPath.toLocal8Bit().data(), szName.toLocal8Bit().data()); + //tpDebugOut("Multi paths: %s, name:%s", szPath.toLocal8Bit().data(), szName.toLocal8Bit().data()); // m_lib.setFileName(szPath + szName); if (m_lib.load()) { m_fpInit = (Func_Lib_Init)m_lib.resolve(szFuncInit); m_fpFree = (Func_Lib_Free)m_lib.resolve(szFuncFree); - tpDebugOut("init function, Name: %s, Address:%d", szFuncInit, (int)m_fpInit); + //tpDebugOut("init function, Name: %s, Address:%d", szFuncInit, (int)m_fpInit); } else { m_fpInit = NULL; diff --git a/3part/tadpole/include/tpBase/iCoreCtrl.h b/3part/tadpole/include/tpBase/iCoreCtrl.h index 7d11c63..cff1676 100644 --- a/3part/tadpole/include/tpBase/iCoreCtrl.h +++ b/3part/tadpole/include/tpBase/iCoreCtrl.h @@ -16,6 +16,7 @@ public: typedef std::function FuncCallBack_VarInt; typedef std::function FuncCallBack_VarMap; typedef std::function FuncCallBack_StrMap; +typedef std::function FuncCallBack_StrImg; //interface for gui class ICoreCtrl @@ -47,6 +48,7 @@ public: virtual bool IStopCamera(const QString& strSerial) = 0; virtual bool IDeleteCamera(const QString& strSerial) = 0; virtual bool IAddCamera(const QString& strName, const TP_CAMERA_OPTION& camOpt, bool bNew, bool bAutoRun = false) = 0; + virtual bool IRunAlg(const QString& strSerial, bool bRun) = 0; //更新json配置文件 virtual bool updateCamJson(const QString& sJsonPath) = 0; @@ -54,7 +56,7 @@ public: virtual bool ICamsPausePush() = 0; virtual bool IRegisterGetVariant(FuncCallBack_VarInt callback) = 0; //向算法传递检测参数回调接口 - virtual bool IRegisterImageCallBack(FuncCallBack_VarMap callback) = 0; //获取相机图像回调接口 + virtual bool IRegisterImageCallBack(FuncCallBack_StrImg callback) = 0; //获取相机图像回调接口 virtual bool IRegisterResultCallBack(FuncCallBack_StrMap callback) = 0; //获取算法结果回调接口 public://private: //use private when the old main is discarded; diff --git a/3part/tadpole/include/tpBase/icamera.h b/3part/tadpole/include/tpBase/icamera.h index 8ff7a54..ede9ad7 100644 --- a/3part/tadpole/include/tpBase/icamera.h +++ b/3part/tadpole/include/tpBase/icamera.h @@ -4,11 +4,6 @@ #include "baseInclude.h" #include "lpCameraImage.h" -// typedef struct tagCAMERA_IN_PARAM { -// class ICameraCallback* pCallback; -// }CAMERA_IN_PARAM; - - class ICameraPool { public: @@ -38,7 +33,7 @@ public: virtual int IOpenDevices(bool bReopenAll = true) = 0; virtual int IOpenDevicesEx(bool bReopenAll = true) = 0; //如果camera.json里面配置了auto_open 值为false,则调用该函数不会打开对应相机 virtual void ICloseDevices() = 0; - + virtual bool IRunAlg(const QString& strSerial, bool bRun) = 0; virtual void IStartDevices() = 0; virtual void IStopDevices(const QString& sDef = NULL) = 0; virtual void ISetTriggerMode(emTpDeviceTriggerMode mode, emTpTriggerDirection nDirection = TRIGGER_DIRECT_FOREWARD, long nFrameRate = 0) = 0; @@ -51,28 +46,12 @@ public: //@camera: NULL means setting every camera virtual void ISetCameraProperty(const QString& camera, emTpCameraProperty property, long nValue) = 0; virtual void ISetCameraProperty(const QString& camera, TP_CAMERA_PROPERTY& property) = 0; -// virtual QList ICameraWins() = 0; virtual QMap IGetCamShowNames() = 0; virtual void ISetCameraEncode(INT64 code, INT64 rate) = 0; virtual void ISetVirtualImages(const QString& camera, const QStringList& szImages) = 0; - //operate camera window -// virtual QList ICamWinKeys() = 0; -// virtual bool ICamWinOptionByKey(const QString& strKey, TP_CAMERA_WIN& camwinOpt) = 0; -// virtual bool IAddCamWin(const QString& strKey, const TP_CAMERA_WIN& camwinOpt, bool bNew) = 0; -// virtual bool IDelCamWin(const QString& strKey) = 0; - virtual bool ICamsStartPush() = 0; virtual bool ICamsPausePush() = 0; }; -// class ICameraCallback -// { -// public: -// ICameraCallback() {} -// virtual ~ICameraCallback() {} -// virtual QVariant IGetVariantById(int nId) = 0; -// virtual void INewCameraImage(const QVariantMap& vmap) = 0; -// }; - #endif \ No newline at end of file diff --git a/src/lpCoreCtrl/CoreCtrl.cpp b/src/lpCoreCtrl/CoreCtrl.cpp index 8cb6d4f..8ff22ce 100644 --- a/src/lpCoreCtrl/CoreCtrl.cpp +++ b/src/lpCoreCtrl/CoreCtrl.cpp @@ -193,6 +193,11 @@ void CCoreCtrl::ISetCameraProperty(const QString& camera, TP_CAMERA_PROPERTY& pr return m_gpCameraPool->ISetCameraProperty(camera, property); } +bool CCoreCtrl::IRunAlg(const QString& strSerial, bool bRun) +{ + return m_gpCameraPool->IRunAlg(strSerial, bRun); +} + bool CCoreCtrl::updateCamJson(const QString& sJsonPath) { int nError; @@ -271,7 +276,7 @@ bool CCoreCtrl::IRegisterGetVariant(FuncCallBack_VarInt func) return false; } -bool CCoreCtrl::IRegisterImageCallBack(FuncCallBack_VarMap callback) +bool CCoreCtrl::IRegisterImageCallBack(FuncCallBack_StrImg callback) { if (callback) { @@ -307,20 +312,7 @@ bool CCoreCtrl::onTaskFunc() if (NULL != pCamImage) { - { - // send image to UI - timespan.restart(); - //TODO show Image -// m_pCoreCtrl->ShowCameraImage(pCamImage->Serial() -// , pCamImage->FrameNumber() -// , pCamImage->ToQImage() -// , pCamImage->Stamp() -// , 0 -// , QString::fromUtf8(pCamImage->FileName()));//(pCamImage); -// -// qDebug() << "Show camera image to UI cost " << timespan.elapsed() << " MSecs" -// << " - " __FUNCTION__; - } + CImageObject m_objImage(this); { // Algorithm process image diff --git a/src/lpCoreCtrl/CoreCtrl.h b/src/lpCoreCtrl/CoreCtrl.h index 37d236b..104c378 100644 --- a/src/lpCoreCtrl/CoreCtrl.h +++ b/src/lpCoreCtrl/CoreCtrl.h @@ -43,6 +43,7 @@ private: virtual bool IStopCamera(const QString& strSerial) { return m_gpCameraPool->IStopCamera(strSerial); } virtual bool IDeleteCamera(const QString& strSerial) { return m_gpCameraPool->IDeleteCamera(strSerial); } virtual bool IAddCamera(const QString& strName, const TP_CAMERA_OPTION& camOpt, bool bNew, bool bAutoRun = false) { return m_gpCameraPool->IAddCamera(strName, camOpt, bNew, bAutoRun); } + virtual bool IRunAlg(const QString& strSerial, bool bRun); //更新json配置文件 virtual bool updateCamJson(const QString& sJsonPath); @@ -51,13 +52,13 @@ private: virtual bool ICamsStartPush() { return m_gpCameraPool->ICamsStartPush(); } virtual bool ICamsPausePush() { return m_gpCameraPool->ICamsPausePush(); } - virtual bool IRegisterGetVariant(FuncCallBack_VarInt func); - virtual bool IRegisterImageCallBack(FuncCallBack_VarMap callback); //获取相机图像回调接口 + virtual bool IRegisterGetVariant(FuncCallBack_VarInt func); + virtual bool IRegisterImageCallBack(FuncCallBack_StrImg callback); //获取相机图像回调接口 virtual bool IRegisterResultCallBack(FuncCallBack_StrMap callback); //获取算法结果回调接口 bool onTaskFunc(); private: QList m_imgThdPool; - int m_nCoreCount; + int m_nCoreCount; friend class CImageObject; friend class QTpThreadImage; diff --git a/src/lpCoreCtrl/callbackFunc.h b/src/lpCoreCtrl/callbackFunc.h index 83d6250..26e3db3 100644 --- a/src/lpCoreCtrl/callbackFunc.h +++ b/src/lpCoreCtrl/callbackFunc.h @@ -14,7 +14,7 @@ public: public: FuncCallBack_VarInt m_GetVariantCallBackFunc;//㷨亯 FuncCallBack_StrMap m_ResultCallBackFunc;//ص - FuncCallBack_VarMap m_ImageCallBackFunc;//ͼȡص + FuncCallBack_StrImg m_ImageCallBackFunc;//ͼȡص }; #endif diff --git a/src/lpCoreCtrl/lpCameraImage.cpp b/src/lpCoreCtrl/lpCameraImage.cpp index 54b8112..2bed047 100644 --- a/src/lpCoreCtrl/lpCameraImage.cpp +++ b/src/lpCoreCtrl/lpCameraImage.cpp @@ -22,16 +22,10 @@ lpCameraImage::~lpCameraImage() int lpCameraImage::CopyCameraObject(ICameraObject* pCamObj) { - // SetColorFormat(pCamObj->ColorFormat()); if (NULL == pCamObj || NULL == pCamObj->m_pCamOpt) { return -1; } - // TP_CAMERA_OPTION* pOpt = pCamObj->CameraOption(); - //if (NULL == pOpt) - //{ - // return -1; - //} if (NULL == m_pImage) { int nW = pCamObj->m_nImageWidth; @@ -47,12 +41,6 @@ int lpCameraImage::CopyCameraObject(ICameraObject* pCamObj) } m_nCopiedLines = 0; copyOption(pCamObj); - //SetFrameNum(pCamObj->FrameNumber()); - //SetTriggerCount(pCamObj->StartCount()); - //SetSerial(pOpt->uniqueName.toUtf8().data()); - //SetId(pOpt->id); - //SetAlgorithm(pOpt->algorithm); - //SetDllSuffix(pOpt->dllsuffix.toUtf8()); } int nLines = m_pImage->height() - m_nCopiedLines; if (nLines > pCamObj->m_nImageHeight) @@ -62,7 +50,6 @@ int lpCameraImage::CopyCameraObject(ICameraObject* pCamObj) int nSizes = nLines * pCamObj->m_nImageWidth*((pCamObj->m_nBitsPerPixel + 7) / 8); memcpy(m_pImage->scanLine(m_nCopiedLines), pCamObj->m_pCameraData, nSizes); m_nCopiedLines += nLines; - //SetFileName(pCamObj->Utf8FileName()); if (m_nCopiedLines == m_pImage->height()) { return 1; diff --git a/src/lpCoreCtrl/lpCameraImage.h b/src/lpCoreCtrl/lpCameraImage.h index 45ed38a..53e8d87 100644 --- a/src/lpCoreCtrl/lpCameraImage.h +++ b/src/lpCoreCtrl/lpCameraImage.h @@ -30,7 +30,9 @@ public: emTpColorFormat ColorFormat() { return m_colorFormat; } - + bool pushAlg() { + return bAutoPush; + } long TriggerCount() { return m_nTriggerCount; } @@ -114,6 +116,7 @@ private: INT64 m_nTimeStamp; ZStringA m_dllSuffix; QVariant m_varFromUI; + bool bAutoPush; }; #endif // ZKCAMERAIMAGE_H diff --git a/src/lpCoreCtrl/tpCamera/CameraPool.cpp b/src/lpCoreCtrl/tpCamera/CameraPool.cpp index 7fb7a45..6e08914 100644 --- a/src/lpCoreCtrl/tpCamera/CameraPool.cpp +++ b/src/lpCoreCtrl/tpCamera/CameraPool.cpp @@ -155,18 +155,21 @@ bool CCameraPool::IAddCamera(const QString& strName, const TP_CAMERA_OPTION& cam return bret; } +bool CCameraPool::IRunAlg(const QString& strSerial, bool bRun) +{ + ICameraObject* pCamera = m_cameraes.value(strSerial); + if (!pCamera) + return false; + pCamera->m_pCamOpt->bAutoPush = bRun; + return true; +} + bool CCameraPool::IStartCamera(const QString& strSerial) { ICameraObject* pCamera = m_cameraes.value(strSerial); if (!pCamera) return false; - //if (pCamera->m_pCamOpt->status != TP_CAMERA_STATUS_OPENED && - // pCamera->m_pCamOpt->status != TP_CAMERA_STATUS_STOPPED ) - //{ - // return false; - //} - int nret = pCamera->IStartCamera(); if (nret == 1){ pCamera->m_pCamOpt->status = TP_CAMERA_STATUS_STARTED; @@ -641,7 +644,7 @@ void CCameraPool::cameraCalRelyOnEx(class ICameraObject*& pCam, void* pData) } } } - +//在主线程中运行? int CCameraPool::IPushCameraData(ICameraObject* pCamObj) { if (m_imagesList.size() >= 32) @@ -667,7 +670,7 @@ int CCameraPool::IPushCameraData(ICameraObject* pCamObj) return 0; } // - pCamObj->SaveToFile(); + //pCamObj->SaveToFile();//保存图像 lpCameraImage *pImage = m_imagesMerging.value(pCamObj->m_pCamOpt->uniqueName, NULL); if (NULL == pImage) @@ -678,42 +681,6 @@ int CCameraPool::IPushCameraData(ICameraObject* pCamObj) if (NULL != pImage) { // -// if (!gpGlobalCamCallback){ -// delete pImage; -// return 0; -// } - try{ - - if (lpCallBackFunc::instance()->m_GetVariantCallBackFunc) - { - QVariant val = lpCallBackFunc::instance()->m_GetVariantCallBackFunc(pCamObj->m_pCamOpt->id); - pImage->SetVarFromUI(val); - } -// else -// pImage->SetVarFromUI(gpGlobalCamCallback->IGetVariantById(pCamObj->m_pCamOpt->id)); - - //QVariantMap map; - //map.clear(); - //map.insert("width", pCamObj->m_nImageWidth); - //map.insert("height", pCamObj->m_nImageHeight); - //map.insert("size", pCamObj->m_nImageSize); - //map.insert("frame", pCamObj->m_nFrameNum); - //qint64 nSizes = pCamObj->m_nImageHeight*pCamObj->m_nImageWidth*((pCamObj->m_nBitsPerPixel + 7) / 8); - ////QByteArray baimgdat = QByteArray::fromRawData((const char*)(pCamObj->m_pCameraData), nSizes); - //QByteArray baimgdat = QByteArray((const char*)(pCamObj->m_pCameraData)); - //map.insert("imgdata", baimgdat); - - //std::string imgb64 = base64_encode(pCamObj->m_pCameraData, nSizes); - //int b64len = imgb64.length(); - //QString qsimgb64(imgb64.c_str()); - //map.insert("imgb64", qsimgb64); - //gpGlobalCamCallback->INewCameraImage(map); - } - catch (...){ - qCritical() << "Critical error." << __FUNCTION__; - return 0; - } - // int nRet = pImage->CopyCameraObject(pCamObj); if (-1 == nRet) { @@ -722,9 +689,36 @@ int CCameraPool::IPushCameraData(ICameraObject* pCamObj) } else if (1 == nRet) { - pImage->SetMeterCode(m_nCameraEncode); - m_imagesList.append(pImage); - pImage = NULL; + + if (pCamObj->m_pCamOpt->bAutoPush == false) + { + if (lpCallBackFunc::instance()->m_ImageCallBackFunc) + { + lpCallBackFunc::instance()->m_ImageCallBackFunc(pImage->Serial(), pImage->ToQImage()); + } + delete pImage; + pImage = NULL; + } + else + { + try { + //获取算法参数 绑定到图像 + if (lpCallBackFunc::instance()->m_GetVariantCallBackFunc) + { + QVariant val = lpCallBackFunc::instance()->m_GetVariantCallBackFunc(pCamObj->m_pCamOpt->id); + pImage->SetVarFromUI(val); + } + } + catch (...) { + qCritical() << "Critical error." << __FUNCTION__; + return 0; + } + + pImage->SetMeterCode(m_nCameraEncode); + m_imagesList.append(pImage); + pImage = NULL; + } + } m_imagesMerging.insert(pCamObj->m_pCamOpt->uniqueName, pImage); nRet = 1; diff --git a/src/lpCoreCtrl/tpCamera/CameraPool.h b/src/lpCoreCtrl/tpCamera/CameraPool.h index e51bd8c..a0fde6d 100644 --- a/src/lpCoreCtrl/tpCamera/CameraPool.h +++ b/src/lpCoreCtrl/tpCamera/CameraPool.h @@ -49,7 +49,7 @@ private: virtual bool IStopCamera(const QString& strSerial); virtual bool IDeleteCamera(const QString& strSerial); virtual bool IAddCamera(const QString& strName, const TP_CAMERA_OPTION& camOpt, bool bNew, bool bAutoRun = false); - + virtual bool IRunAlg(const QString& strSerial, bool bRun); // virtual int IOpenDevices(bool bReopenAll); virtual int IOpenDevicesEx(bool bReopenAll); diff --git a/src/lpMain/Station.cpp b/src/lpMain/Station.cpp index 6598e37..c057458 100644 --- a/src/lpMain/Station.cpp +++ b/src/lpMain/Station.cpp @@ -274,22 +274,24 @@ bool Station::trigImage() bool b = m_pCoreCtrl->IStartCamera(szCamKey); } } + if (optCam.bAutoPush == true) + { + //filter + if (!m_pTrigDetector->filterTrig()) { + return false; + } + // check + if (!m_pTrigDetector->isWaitForTrig()) { + return false; + } - //filter - if (!m_pTrigDetector->filterTrig()) { - return false; - } - // check - if (!m_pTrigDetector->isWaitForTrig()) { - return false; + QString str = genTimerInfo(); + //m_pTrigDetector->addTrigCount(); + emit(sgaddTrigCount(1)); + str += "trig succussful: " + QString::number(m_pTrigDetector->getTrigCount()); + emit sgPrint2Window(str); } - QString str = genTimerInfo(); - //m_pTrigDetector->addTrigCount(); - emit(sgaddTrigCount(1)); - str += "trig succussful: " + QString::number(m_pTrigDetector->getTrigCount()); - emit sgPrint2Window(str); - qDebug() << str; QStringList strList = m_pCoreCtrl->ICameraKeys(); if (strList.contains(szCamKey)) { diff --git a/tpvs17/Report/qcheckdatadlg.h b/tpvs17/Report/qcheckdatadlg.h index 9fdaf8a..260eb54 100644 --- a/tpvs17/Report/qcheckdatadlg.h +++ b/tpvs17/Report/qcheckdatadlg.h @@ -39,20 +39,20 @@ private: private: Ui::QCheckDataDlg ui; - QLabel *pShowName_label; - QLabel *check_showImg_label; - QTextBrowser *textBrowser; - StationDB *m_db; - QStandardItemModel *m_tableModel; - QTableView *tableView; - QDateTimeEdit *pStartTimeEdit; - QDateTimeEdit *pEndTimeEdit; + QLabel *pShowName_label{ nullptr }; + QLabel *check_showImg_label{ nullptr }; + QTextBrowser *textBrowser{ nullptr }; + StationDB *m_db{ nullptr }; + QStandardItemModel *m_tableModel{ nullptr }; + QTableView *tableView{ nullptr }; + QDateTimeEdit *pStartTimeEdit{ nullptr }; + QDateTimeEdit *pEndTimeEdit{ nullptr }; QMap m_strMap; int nPrevNum; int nTotlaNumber; - QTpGraphView *m_ViewImg; + QTpGraphView *m_ViewImg{ nullptr }; }; #endif // QCHECKDATADLG_H diff --git a/tpvs17/lpMain/CMainWin.cpp b/tpvs17/lpMain/CMainWin.cpp index 711cbb0..41c4f38 100644 --- a/tpvs17/lpMain/CMainWin.cpp +++ b/tpvs17/lpMain/CMainWin.cpp @@ -10,6 +10,7 @@ #include "Serialport_global.h" #include #include "lpSysConfig.h" +#include #define LEAPER_LOGO ":/leaper/Resource/app.png" #define DELETE_POINTER(p) if (p) {delete p; p = NULL;} @@ -122,6 +123,13 @@ CMainWin::CMainWin(QWidget *parent) pDoc->setMaximumBlockCount(200); pDoc = ui.wf_text_edit_result_2->document(); pDoc->setMaximumBlockCount(200); + + + ui.wf_lb_image_show_1->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui.wf_lb_image_show_1, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onPopMenu(const QPoint&))); + + connect(this, SIGNAL(sgShowSrcImg(QString, QImage)), &m_camSetWid, SLOT(onShowImage(QString, QImage))); + } CMainWin::~CMainWin() @@ -164,6 +172,11 @@ CMainWin::~CMainWin() rmTranslator(); lpSysLog::uninstance(); } +//ԭͼջص չʾͼ +void CMainWin::INewCameraImage(const QString& camKey, QImage img) +{ + emit sgShowSrcImg(camKey, img); +} void CMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap) { @@ -724,6 +737,9 @@ bool CMainWin::onInitCoreCtrl() FuncCallBack_StrMap strMapfunc = std::bind(&CMainWin::IVariantMapToUI, this, std::placeholders::_1,std::placeholders::_2); m_pCoreCtrl->IRegisterResultCallBack(strMapfunc); + FuncCallBack_StrImg strImgfunc = std::bind(&CMainWin::INewCameraImage, this, std::placeholders::_1, std::placeholders::_2); + m_pCoreCtrl->IRegisterImageCallBack(strImgfunc); + } m_pDllDetectorEngine->Initialize(m_pCoreCtrl); @@ -1000,4 +1016,47 @@ Q_SLOT void CMainWin::onShowLog(int nID, QString strMsg) else if (nID == 2) { ui.wf_text_edit_result_2->append(strMsg); } +} + +Q_SLOT void CMainWin::onPopMenu(const QPoint& pt) +{ + if (!m_pWfCtrl) + return; + /*UIжĸλҪ*/ + int nStationID = 1; + QString strObj = sender()->objectName(); + if ("wf_lb_image_show_1" == strObj) + nStationID = 1; + else if ("wf_lb_image_show_2" == strObj) + nStationID = 2; + + IStation *pStation = m_pWfCtrl->IGetStationById(nStationID); + if (!pStation) { + //ûãҪ + return; + } + QString strCamKey = pStation->stationKey(); + QMenu menu; + QAction *pSetAction = menu.addAction(tr("")); + pSetAction->setObjectName("setAction"); + + QAction *pSelect = menu.exec(QCursor::pos()); + if (!pSelect) + { + menu.clear(); + return; + } + QString strObjAction = pSelect->objectName(); + if (strObjAction == "setAction") { + + m_camSetWid.setParent(this); + m_camSetWid.setWindowIcon(QIcon(LEAPER_LOGO)); + m_camSetWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + m_camSetWid.setWindowModality(Qt::ApplicationModal); + m_camSetWid.setAttribute(Qt::WA_ShowModal, true); + + m_camSetWid.setCamParam(m_pCoreCtrl, strCamKey); + m_camSetWid.show(); + } + menu.clear(); } \ No newline at end of file diff --git a/tpvs17/lpMain/CMainWin.h b/tpvs17/lpMain/CMainWin.h index f6e926c..961cc2e 100644 --- a/tpvs17/lpMain/CMainWin.h +++ b/tpvs17/lpMain/CMainWin.h @@ -19,6 +19,7 @@ #include "QModelMangerUI.h" #include "QAboutUI.h" #include "QDeviceMgrUI.h" +#include "QCamSetDlg.h" struct StationInfo { @@ -26,7 +27,7 @@ struct StationInfo bool m_bRunEnable{ false }; QString strModelName; }; -class CMainWin : public QMainWindow//, public IGuiCallback +class CMainWin : public QMainWindow { Q_OBJECT @@ -34,14 +35,18 @@ public: CMainWin(QWidget *parent = Q_NULLPTR); ~CMainWin(); - virtual void INewCameraImage(const QVariantMap& vMap) {}; - virtual void IVariantMapToUI(const QString& camKey, const QVariantMap& vMap); - virtual QVariant IGetVariantById(int id); + //ͼص + void INewCameraImage(const QString& camKey, QImage img); + //㷨ص + void IVariantMapToUI(const QString& camKey, const QVariantMap& vMap); + //㷨ص + QVariant IGetVariantById(int id); public: Q_SLOT void onAppanalysis(SComFrame frame); void onHeartComm(SComFrame &frame); Q_SLOT void onHeardBit(); Q_SLOT void onShowLog(int nID, QString strMsg); + Q_SLOT void onPopMenu(const QPoint& pt); Q_SLOT void onActionClicked(); QString genSavePath(QString modelName, QImage &img); QString genSaveSrcImgPath(QString modelName, QImage &img); @@ -59,6 +64,7 @@ signals: void sgSendChangeUI(QString, QString); void sgShowLog(int, QString); void sgShowImg(int, QImage); + void sgShowSrcImg(QString strkey, QImage); private://Ӣ void SearchQmFile(const QString & strDir); void SetTranslator(const QString strPath); @@ -119,6 +125,7 @@ private: QModelMangerUI m_mangeWid; QAboutUI m_aboutWid; QDeviceMgrUI m_devMgrWid; + QCamSetDlg m_camSetWid; QString m_strUserName; QString m_strComName; diff --git a/tpvs17/lpMain/QCamSetDlg.cpp b/tpvs17/lpMain/QCamSetDlg.cpp new file mode 100644 index 0000000..d87f55e --- /dev/null +++ b/tpvs17/lpMain/QCamSetDlg.cpp @@ -0,0 +1,83 @@ +#include "QCamSetDlg.h" + +QCamSetDlg::QCamSetDlg(QWidget *parent) + : QWidget(parent) +{ + ui.setupUi(this); + m_ViewImg = new QTpGraphView; + QGridLayout *pGrid = new QGridLayout(this); + pGrid->addWidget(m_ViewImg); + ui.m_ImageLabel->setLayout(pGrid); + + connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(onButtonClicked())); +} + +QCamSetDlg::~QCamSetDlg() +{ + if (m_ViewImg) { + delete m_ViewImg; + m_ViewImg = nullptr; + } +} + +void QCamSetDlg::setCamParam(ICoreCtrl* ptr, QString strCamkey) +{ + m_curCamKey = strCamkey; + m_pCorl = ptr; + TP_CAMERA_OPTION camOpt; + bool b = m_pCorl->ICameraOptionByKey(strCamkey,camOpt); + if (b == true) + { + ui.m_camSnlineEdit->setText(m_curCamKey); + ui.comboBox_2->setCurrentIndex(camOpt.deviceType); + ui.comboBox->setCurrentIndex(camOpt.format); + ui.lineEdit_2->setText(QString("%1").arg(camOpt.exposure)); + ui.lineEdit_3->setText(QString("%1").arg(camOpt.gain)); + + } +} + +void QCamSetDlg::onShowImage(QString strKey, QImage img) +{ + if (this->isHidden()) + return; + if (strKey != m_curCamKey) + return; + + if (m_ViewImg) + { + m_ViewImg->setImg(QPixmap::fromImage(img)); + } +} + +Q_SLOT void QCamSetDlg::onButtonClicked() +{ + QString strObj = sender()->objectName(); + if ("pushButton" == strObj)// + { + + } + else if ("pushButton_2" == strObj)// + { +// m_pCorl->IOpenCamera(m_curCamKey); +// m_pCorl->IStartCamera(m_curCamKey); + m_pCorl->IRunAlg(m_curCamKey, false); +// m_pCorl->ISnapImage(QStringList()<text().toInt(); + int gain = ui.lineEdit_3->text().toInt(); + } +} + +void QCamSetDlg::closeEvent(QCloseEvent *event) +{ + if (m_pCorl) + { + m_pCorl->IRunAlg(m_curCamKey, true); + } +} diff --git a/tpvs17/lpMain/QCamSetDlg.h b/tpvs17/lpMain/QCamSetDlg.h new file mode 100644 index 0000000..c7a9891 --- /dev/null +++ b/tpvs17/lpMain/QCamSetDlg.h @@ -0,0 +1,33 @@ +#ifndef _H_QCAMSETDLG_H_ +#define _H_QCAMSETDLG_H_ + +#include +#include "ui_QCamSetDlg.h" +#include "iCoreCtrl.h" +#include "cunstomgraphview.h" +#include +class QCamSetDlg : public QWidget +{ + Q_OBJECT + +public: + QCamSetDlg(QWidget *parent = Q_NULLPTR); + ~QCamSetDlg(); + + void setCamParam(ICoreCtrl* ptr, QString strCam); + + Q_SLOT void onShowImage(QString strKey, QImage img); + Q_SLOT void onButtonClicked(); +protected: + virtual void closeEvent(QCloseEvent *event); +private: + Ui::QCamSetDlg ui; + QTpGraphView *m_ViewImg{ nullptr }; + + QString m_curCamKey; + + ICoreCtrl* m_pCorl{ nullptr }; + +}; + +#endif diff --git a/tpvs17/lpMain/QCamSetDlg.ui b/tpvs17/lpMain/QCamSetDlg.ui new file mode 100644 index 0000000..c5868df --- /dev/null +++ b/tpvs17/lpMain/QCamSetDlg.ui @@ -0,0 +1,221 @@ + + + QCamSetDlg + + + + 0 + 0 + 841 + 484 + + + + 相机设置 + + + + + + + 5 + 0 + + + + background-color: rgb(191, 191, 191); + + + + + + + + + + + 9 + + + + + + + + + + + 11 + + + + + + + + 增益值: + + + + + + + + 11 + + + + + GRAY8 + + + + + + + + + 11 + + + + + Virtual(100) + + + + + Gige(120) + + + + + HIK(140) + + + + + Baumer(160) + + + + + + + + 曝光值: + + + + + + + + 11 + + + + + + + + + 11 + + + + + + + + + 11 + + + + 图像格式: + + + + + + + + 11 + + + + 相机类型: + + + + + + + + 11 + + + + 打开 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 11 + + + + 相机ID: + + + + + + + + 11 + + + + 应用参数 + + + + + + + + + + + 11 + + + + 保存 + + + + + + + + + diff --git a/tpvs17/lpMain/lpMain.vcxproj b/tpvs17/lpMain/lpMain.vcxproj index af3954a..317de38 100644 --- a/tpvs17/lpMain/lpMain.vcxproj +++ b/tpvs17/lpMain/lpMain.vcxproj @@ -139,6 +139,7 @@ + @@ -155,12 +156,17 @@ + + + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSerialBus;$(QTDIR)\include\QtSerialPort;$(QTDIR)\include\QtSql;.\..\..\3part\SerialPortTool\include;.\..\..\src\lpMain;.\..\..\src\lpMain\algela;.\..\..\src\lpMain\QDiskCleanThread;.\..\..\src\lpMain\sqliteDB;.\..\..\src\lpMain\UI;.\..\..\3part\opencv3.4.1\include;.\..\..\3part\opencv3.4.1\include\opencv;.\..\..\3part\opencv3.4.1\include\opencv2;.\..\..\3part\libzkq\include;.\..\..\3part\lpSyslog\inc;.\..\..\3part\customgui\include;.\..\..\src\userCtrl;.\..\..\src\lpMain\CoreCtrl;.\..\..\3part\tadpole\include\tpBase + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSerialBus;$(QTDIR)\include\QtSerialPort;$(QTDIR)\include\QtSql;.\..\..\3part\SerialPortTool\include;.\..\..\src\lpMain;.\..\..\src\lpMain\algela;.\..\..\src\lpMain\QDiskCleanThread;.\..\..\src\lpMain\sqliteDB;.\..\..\src\lpMain\UI;.\..\..\3part\opencv3.4.1\include;.\..\..\3part\opencv3.4.1\include\opencv;.\..\..\3part\opencv3.4.1\include\opencv2;.\..\..\3part\libzkq\include;.\..\..\3part\lpSyslog\inc;.\..\..\3part\customgui\include;.\..\..\src\userCtrl;.\..\..\src\lpMain\CoreCtrl;.\..\..\src\lpBase + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSerialBus;$(QTDIR)\include\QtSerialPort;$(QTDIR)\include\QtSql;.\..\..\3part\SerialPortTool\include;.\..\..\src\lpMain;.\..\..\src\lpMain\algela;.\..\..\src\lpMain\QDiskCleanThread;.\..\..\src\lpMain\sqliteDB;.\..\..\src\lpMain\UI;.\..\..\3part\opencv3.4.1\include;.\..\..\3part\opencv3.4.1\include\opencv;.\..\..\3part\opencv3.4.1\include\opencv2;.\..\..\3part\libzkq\include;.\..\..\3part\lpSyslog\inc;.\..\..\3part\customgui\include;.\..\..\src\userCtrl;.\..\..\src\lpMain\CoreCtrl;.\..\..\src\lpBase .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSerialBus;$(QTDIR)\include\QtSerialPort;$(QTDIR)\include\QtSql;.\..\..\3part\SerialPortTool\include;.\..\..\src\lpMain;.\..\..\src\lpMain\algela;.\..\..\src\lpMain\QDiskCleanThread;.\..\..\src\lpMain\sqliteDB;.\..\..\src\lpMain\UI;.\..\..\3part\opencv3.4.1\include;.\..\..\3part\opencv3.4.1\include\opencv;.\..\..\3part\opencv3.4.1\include\opencv2;.\..\..\3part\libzkq\include;.\..\..\3part\lpSyslog\inc;.\..\..\3part\customgui\include;.\..\..\src\userCtrl;.\..\..\src\lpMain\CoreCtrl;.\..\..\src\lpBase diff --git a/tpvs17/lpMain/lpMain.vcxproj.filters b/tpvs17/lpMain/lpMain.vcxproj.filters index 471fd4b..19d4a84 100644 --- a/tpvs17/lpMain/lpMain.vcxproj.filters +++ b/tpvs17/lpMain/lpMain.vcxproj.filters @@ -133,6 +133,9 @@ Source Files + + Source Files + @@ -216,6 +219,9 @@ Header Files + + Header Files + @@ -239,6 +245,9 @@ Form Files + + Form Files +