backup code

master
bob.pan 5 years ago
parent 6a06b4a876
commit 7bec299f00

@ -63,12 +63,15 @@ bool CDetectorEngine::detect(cv::Mat srcImg, QString modeName, AlgResultCallBack
map.insert(pOutparam->strName, pOutparam->value);
}
}
map.insert("taskID", pTask->GetID());
map.insert("originImage", EngineBase::convMat2QImage(srcImg));
map.insert("tasktime", pTask->ExecTime());
QVariantMap rltMap;
rltMap.insert("AlgoResult", map);
rltMap.insert("taskName", pTask->GetTaskName());
rltMap.insert("taskID", pTask->GetID());
rltMap.insert("originImage", EngineBase::convMat2QImage(srcImg));
rltMap.insert("tasktime", pTask->ExecTime());
if (func)
{
func(map);
func(rltMap);
}
}
}

@ -50,6 +50,10 @@ PLP_DETECTOR_TASK CDetectorTask::GetTaskInfo()
return &m_tTask;
}
QString CDetectorTask::GetTaskName()
{
return m_tTask.strName;
}
IDetectorROI* CDetectorTask::AddROI(const PLP_DETECTOR_ROI pROI, bool bRet /* = true */)
{
if (NULL == pROI)

@ -27,6 +27,7 @@ public:
virtual bool SetTaskInfo(const PLP_DETECTOR_TASK pTask);
virtual PLP_DETECTOR_TASK GetTaskInfo();
virtual QString GetTaskName();
void SetID(int nID);
virtual int GetID() const;
virtual int GetAlgoBaseID() const;

@ -622,9 +622,6 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
QImage srcImg = vMap.value("srcImage").value<QImage>();
cv::Mat srcMat = QImageToMat(srcImg);
emit(sgShowImgState(tr("显示识别结果")));
Result2Ui *pResult = parseMap(vMap.value("result").toMap());
if (pResult == nullptr)
@ -806,8 +803,15 @@ QVariant lpMainWin::IGetVariantById(int id)
}
void lpMainWin::IEngineResult(QVariantMap vmap)
void lpMainWin::IEngineResult(QVariantMap vMap)
{
QVariantMap algResult = vMap.value("AlgoResult").toMap();
QImage srcImg = vMap.value("originImage").value<QImage>();
double dAngle = algResult.contains("angle") ? algResult.value("angle").toDouble() : 365;
int errorType = algResult.contains("error") ? algResult.value("error").toInt() : 16;
double matchScore = algResult.value("score").toDouble() * 100;
QString str = algResult.value("resultTip").toString();
QString rltmsg = QString("%1 %2 %3").arg(dAngle).arg(errorType).arg(matchScore);
}

@ -53,11 +53,7 @@ bool algEg::Exec(IDetectorTask *lpTask, IDetectorAlgorithm* lpAlgorithm)
qWarning() << "valve detect, gray is empty";
return false;
}
// if (gray.size() != paramInput.roi.img.size())
// {
// qWarning() << "img size not compare";
// return false;
// }
luffy_imageProc::createImage(gray, mask, luffy_imageProc::emCreateColor);
QString strObj = paramInput.strObj = lpTask->GetTaskInfo()->strName;
bool bExist = true;

@ -1175,32 +1175,25 @@ bool imageRotateMatch(Mat & imgSrc, InputParam &paramIn, OutputParam &paramOut,
float m_Index = 0.0;
Mat roi;
roi.setTo(0);
for (int k = 0; k < selectRoi.rows; ++k)
{
for (int k = 0; k < selectRoi.rows; ++k) {
//uchar *ptr = selectRoi.row(k).data;
for (int m = 0; m < selectRoi.cols; ++m)
{
for (int m = 0; m < selectRoi.cols; ++m) {
//qDebug() << "k:" << k << "m :" << m ;
float dis = luffy_math::disofPoints(Point2f(m, k), Point2f(wheelRoi.cols / 2.0, wheelRoi.rows / 2.0));
if (dis > outterRadius || dis < innerRadius)
{
if (dis > outterRadius || dis < innerRadius) {
continue;
}
float nIndex = luffy_math::caculAngle(Point2f(wheelRoi.cols / 2.0, wheelRoi.rows / 2.0), Point2f(m, k));
int flag = false;
for (int y = 0; y < candiateAngleRange.size(); ++y)
{
for (int y = 0; y < candiateAngleRange.size(); ++y) {
if (candiateAngleRange[y][0] > candiateAngleRange[y][1])
{
if ((nIndex >= candiateAngleRange[y][0] && nIndex < 360) || (nIndex >=0 && nIndex <=candiateAngleRange[y][1]))
{
if (candiateAngleRange[y][0] > candiateAngleRange[y][1]) {
if ((nIndex >= candiateAngleRange[y][0] && nIndex < 360) || (nIndex >=0 && nIndex <=candiateAngleRange[y][1])) {
const Mat& templ = templates[nIndex];
int nwidth = templ.cols;
int nheight = templ.rows;
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2))
{
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2)) {
continue;
}
Mat matchRoi = selectRoi(Rect(m, k, nwidth, nheight));
@ -1208,8 +1201,7 @@ bool imageRotateMatch(Mat & imgSrc, InputParam &paramIn, OutputParam &paramOut,
cv::matchTemplate(matchRoi, templ, val, CV_TM_CCOEFF_NORMED);
//float val = norm(matchRoi, templ, NORM_L2);
if (val.at<float>(0, 0) > maxVal)
{
if (val.at<float>(0, 0) > maxVal) {
maxVal = val.at<float>(0, 0);
p = Point(m, k);
m_Index = nIndex;
@ -1217,15 +1209,13 @@ bool imageRotateMatch(Mat & imgSrc, InputParam &paramIn, OutputParam &paramOut,
}
}
}
if (nIndex >= candiateAngleRange[y][0] && nIndex <= candiateAngleRange[y][1])
{
if (nIndex >= candiateAngleRange[y][0] && nIndex <= candiateAngleRange[y][1]) {
//selectRoi.at<uchar>(k, m) = 0;
const Mat& templ = templates[nIndex];
int nwidth = templ.cols;
int nheight = templ.rows;
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2))
{
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2)) {
continue;
}
Mat matchRoi = selectRoi(Rect(m, k, nwidth, nheight));
@ -1233,13 +1223,12 @@ bool imageRotateMatch(Mat & imgSrc, InputParam &paramIn, OutputParam &paramOut,
cv::matchTemplate(matchRoi, templ, val, CV_TM_CCOEFF_NORMED);
//float val = norm(matchRoi, templ, NORM_L2);
if (val.at<float>(0, 0) > maxVal)
{
maxVal = val.at<float>(0, 0);
p = Point(m, k);
m_Index = nIndex;
roi = matchRoi;
}
if (val.at<float>(0, 0) > maxVal) {
maxVal = val.at<float>(0, 0);
p = Point(m, k);
m_Index = nIndex;
roi = matchRoi;
}
}
}

Loading…
Cancel
Save