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.
79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
#include "algEg.h"
|
|
#include "caliCenter.h"
|
|
#include "qtcvutils.h"
|
|
|
|
using namespace luffy_base;
|
|
algEg::algEg()
|
|
{
|
|
}
|
|
|
|
algEg::~algEg()
|
|
{
|
|
|
|
}
|
|
|
|
bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
|
|
{
|
|
qDebug() << "start cali center";
|
|
//<! detect
|
|
CaliCenter m_objDetect;
|
|
InputParam paramInput;
|
|
OutputParam paramOutput;
|
|
paramInput.roi = lpAlgorithm->GetParamValue("ROI", LP_ROI).value<LP_DETECTOR_ROI_DATA>();
|
|
int nID = lpTask->GetTaskInfo()->nCameraID;
|
|
|
|
Mat gray;
|
|
if (!lpTask->GetTaskInfo()->detectImg.empty()) {
|
|
luffy_imageProc::createImage(lpTask->GetTaskInfo()->detectImg, gray, luffy_imageProc::emCreateGray);
|
|
}
|
|
|
|
if (gray.empty()) {
|
|
qWarning() << "cali center, gray is empty";
|
|
return false;
|
|
}
|
|
if (gray.size() != paramInput.roi.img.size())
|
|
{
|
|
qWarning() << "img size not compare";
|
|
return false;
|
|
}
|
|
Mat mask;
|
|
luffy_imageProc::createImage(gray, mask, luffy_imageProc::emCreateColor);
|
|
m_objDetect.detect(gray, paramInput, paramOutput, mask);
|
|
QPointF pt(paramOutput.ptCenter.x, paramOutput.ptCenter.y);
|
|
lpAlgorithm->SetOutParamValue("center", pt);
|
|
lpAlgorithm->SetOutParamValue("image", EngineBase::convMat2QImage(mask));
|
|
QVariant getCenterRoi;
|
|
getCenterRoi.setValue(paramOutput.centerRoi);
|
|
lpAlgorithm->SetOutParamValue("centerRoi", getCenterRoi);
|
|
qDebug() << "finish cali center";
|
|
return true;
|
|
}
|
|
|
|
bool algEg::Init(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
|
|
{
|
|
LP_ALGORITHM_PARAM param1("ROI", LP_ROI, QVariant(), QObject::tr("圆心模板"));
|
|
lpAlgorithm->AddParam(¶m1, 1);
|
|
|
|
LP_ALGORITHM_PARAM param2("center", LP_POINTF);
|
|
lpAlgorithm->AddOutParam(¶m2, 1);
|
|
|
|
LP_ALGORITHM_PARAM param3("image", LP_IMAGE);
|
|
lpAlgorithm->AddOutParam(¶m3, 1);
|
|
|
|
LP_ALGORITHM_PARAM param4("centerRoi", LP_MAT);
|
|
lpAlgorithm->AddOutParam(¶m4, 1);
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void LpAlgoNewInstance(IAlgo** lppAlgo)
|
|
{
|
|
*lppAlgo = (IAlgo*)new algEg();
|
|
}
|
|
|
|
bool LpAlgoDeleteInstance()
|
|
{
|
|
return true;
|
|
} |