parent
0fbfccf161
commit
04246a9598
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: xiewenji 527774126@qq.com
|
|
||||||
* @Date: 2025-08-04 21:26:32
|
|
||||||
* @LastEditors: xiewenji 527774126@qq.com
|
|
||||||
* @LastEditTime: 2025-08-13 16:05:08
|
|
||||||
* @FilePath: /BOE_ZB_PLATE/AlgorithmModule/include/Pin_QX_Det.h
|
|
||||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* @Author: xiewenji 527774126@qq.com
|
|
||||||
* @Date: 2025-08-04 21:26:32
|
|
||||||
* @LastEditors: xiewenji 527774126@qq.com
|
|
||||||
* @LastEditTime: 2025-08-04 21:29:05
|
|
||||||
* @FilePath: /BOE_ZB_PLATE/AlgorithmModule/include/Pin_QX_Det.h
|
|
||||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
//实现对部分缺陷 需要进行 数量 和距离上分析的
|
|
||||||
*/
|
|
||||||
#ifndef Pin_QX_Det_H_
|
|
||||||
#define Pin_QX_Det_H_
|
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
|
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
#include "CheckUtil.hpp"
|
|
||||||
#include "OtherDetBaseDefine.h"
|
|
||||||
#include "CheckErrorCodeDefine.hpp"
|
|
||||||
#include "ImageDetConfig.h"
|
|
||||||
#include "CheckConfigDefine.h"
|
|
||||||
#include "ImageStorage.h"
|
|
||||||
#include "AI_Factory.h"
|
|
||||||
#include "DetLog.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace cv;
|
|
||||||
|
|
||||||
// Pin脚缺陷检测
|
|
||||||
class Pin_QX_Det
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct QX_Result
|
|
||||||
{
|
|
||||||
cv::Rect roi_src;
|
|
||||||
int area_pixel;
|
|
||||||
QX_Result()
|
|
||||||
{
|
|
||||||
roi_src = cv::Rect(0, 0, 0, 0);
|
|
||||||
area_pixel = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
struct Det_ROI_Config
|
|
||||||
{
|
|
||||||
cv::Rect roi;
|
|
||||||
std::vector<cv::Point> plist;
|
|
||||||
};
|
|
||||||
// 检测参数和结果
|
|
||||||
struct DetConfigResult
|
|
||||||
{
|
|
||||||
|
|
||||||
BaseCheckFunction *pBaseCheckFunction;
|
|
||||||
std::string strChannel;
|
|
||||||
bool bSaveResultImg;
|
|
||||||
DetConfigResult()
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
pBaseCheckFunction = NULL;
|
|
||||||
strChannel = "";
|
|
||||||
bSaveResultImg = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
Pin_QX_Det(std::shared_ptr<DetLog>& log_ref);
|
|
||||||
~Pin_QX_Det();
|
|
||||||
|
|
||||||
int GetPinMask(const cv::Mat &img, DetConfigResult *pDetConfig, Mat &mask);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int InitModel_Pin();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_bInitSucc; // 是否初始化成功
|
|
||||||
|
|
||||||
std::shared_ptr<DetLog>& m_pdetlog;
|
|
||||||
|
|
||||||
bool m_bshowimg;
|
|
||||||
cv::Mat showimg;
|
|
||||||
|
|
||||||
std::shared_ptr<AIFactory> AI_Factory;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/* data */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
#include "Pin_QX_Det.h"
|
|
||||||
#include "CheckUtil.hpp"
|
|
||||||
#include <numeric>
|
|
||||||
#include <random>
|
|
||||||
#include "CheckErrorCodeDefine.hpp"
|
|
||||||
|
|
||||||
Pin_QX_Det::Pin_QX_Det(std::shared_ptr<DetLog> &log_ref)
|
|
||||||
: m_pdetlog(log_ref)
|
|
||||||
{
|
|
||||||
std::string m_strSavePath;
|
|
||||||
AI_Factory = AIFactory::GetInstance();
|
|
||||||
}
|
|
||||||
Pin_QX_Det::~Pin_QX_Det()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Pin_QX_Det::GetPinMask(const cv::Mat &img, DetConfigResult *pDetConfig, Mat &mask)
|
|
||||||
{
|
|
||||||
std::shared_ptr<AIModel_Base> pBackPlate_Pin;
|
|
||||||
pBackPlate_Pin = AI_Factory->Pin_Loc;
|
|
||||||
cv::Size sz;
|
|
||||||
sz.width = pBackPlate_Pin->input_0.width;
|
|
||||||
sz.height = pBackPlate_Pin->input_0.height;
|
|
||||||
cv::Mat detImg;
|
|
||||||
cout<< pDetConfig->strChannel << ": " << "---Pin---";
|
|
||||||
cout << "imgSize: " << img.size() << ", " << "detImgSize: " << detImg.size() << ", " << "szSize: " << sz << endl;
|
|
||||||
|
|
||||||
cv::resize(img, detImg, sz);
|
|
||||||
int re = 0;
|
|
||||||
if (detImg.channels() != 1)
|
|
||||||
{
|
|
||||||
cv::cvtColor(detImg, detImg, cv::COLOR_RGB2GRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
re = pBackPlate_Pin->AIDet(detImg, mask);
|
|
||||||
if (re != 0)
|
|
||||||
{
|
|
||||||
m_pdetlog->AddCheckstr(PrintLevel_3, DET_LOG_LEVEL_3, "AI_Pin ", "AICheck_Pin----error %d ", re);
|
|
||||||
int re123 = 100 + re;
|
|
||||||
return re123;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDetConfig->bSaveResultImg)
|
|
||||||
{
|
|
||||||
cv::imwrite(pDetConfig->strChannel +"_pin_" +"in.png", detImg);
|
|
||||||
cv::imwrite(pDetConfig->strChannel +"_pin_" +"out_mask.png", mask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue