200 lines
4.8 KiB
C++
200 lines
4.8 KiB
C++
|
|
#include <stdlib.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <iostream>
|
||
|
|
#include <fstream>
|
||
|
|
|
||
|
|
#include "PickLazerWin.h"
|
||
|
|
#include "ImgUtils.h"
|
||
|
|
#include "vz_ap_bmp.h"
|
||
|
|
|
||
|
|
#define SV_PICK_RGN_RSLT
|
||
|
|
|
||
|
|
struct ProcObj
|
||
|
|
{
|
||
|
|
short StartIdx;
|
||
|
|
short EndIdx;
|
||
|
|
char* SrcFileDir;
|
||
|
|
char* DstFileDir;
|
||
|
|
#ifdef FIXED_PROC
|
||
|
|
int MinStgTh; // = 10 ;
|
||
|
|
#else
|
||
|
|
float MinStgTh; // = 4.0f;
|
||
|
|
#endif
|
||
|
|
short LazerWMin;
|
||
|
|
short LazerWMax;
|
||
|
|
#ifdef FIXED_PROC
|
||
|
|
int RflctPixTh;
|
||
|
|
#else
|
||
|
|
float RflctPixTh;
|
||
|
|
#endif
|
||
|
|
unsigned char RflctOutEna;
|
||
|
|
int OverlapPixTh;
|
||
|
|
unsigned char EnhanStep;
|
||
|
|
unsigned char PickEna;
|
||
|
|
|
||
|
|
unsigned char RgnFltrTh;
|
||
|
|
unsigned char RmvWkEndEna;
|
||
|
|
unsigned char RmvWkEndTh;
|
||
|
|
unsigned char RmvWkEndMultCoe;
|
||
|
|
unsigned short RmvWkEndMinLen;
|
||
|
|
unsigned char PickBFEna;
|
||
|
|
unsigned char PickBkGrnd;
|
||
|
|
unsigned char PickRLenTh;
|
||
|
|
|
||
|
|
unsigned char EnergyPickEna;
|
||
|
|
unsigned short PickEnergyType;
|
||
|
|
unsigned short RgnEnergyPLen;
|
||
|
|
|
||
|
|
unsigned short RgnMeanETh;
|
||
|
|
};
|
||
|
|
|
||
|
|
int GrpId;
|
||
|
|
int EleIdx;
|
||
|
|
|
||
|
|
char SimRsltDir[1024];
|
||
|
|
|
||
|
|
PickLaserResult PickLaserResult_inst;
|
||
|
|
StdRgnRslt StdRgnRslt_inst;
|
||
|
|
|
||
|
|
int main(int argc, char** argv)
|
||
|
|
{
|
||
|
|
unsigned char* SrcR = (unsigned char*)malloc(MAX_H * MAX_W);
|
||
|
|
unsigned char* SrcG = (unsigned char*)malloc(MAX_H * MAX_W);
|
||
|
|
unsigned char* SrcB = (unsigned char*)malloc(MAX_H * MAX_W);
|
||
|
|
|
||
|
|
int FrmW;
|
||
|
|
int FrmH;
|
||
|
|
|
||
|
|
char* BmpSrcFileName = (char*)malloc(FILENAME_LEN);
|
||
|
|
char* BmpDstFileName = (char*)malloc(FILENAME_LEN);
|
||
|
|
char* TxtDstFileName = (char*)malloc(FILENAME_LEN);
|
||
|
|
|
||
|
|
int Grp_idx = 0;
|
||
|
|
ProcObj ProcObjInst[4];
|
||
|
|
|
||
|
|
Grp_idx = 0; //
|
||
|
|
|
||
|
|
ProcObjInst[Grp_idx].StartIdx = 0;
|
||
|
|
ProcObjInst[Grp_idx].EndIdx = 0;
|
||
|
|
ProcObjInst[Grp_idx].MinStgTh = 5;
|
||
|
|
ProcObjInst[Grp_idx].LazerWMin = 2;
|
||
|
|
ProcObjInst[Grp_idx].LazerWMax = 10;
|
||
|
|
ProcObjInst[Grp_idx].RflctPixTh = 128;
|
||
|
|
ProcObjInst[Grp_idx].RflctOutEna = 0;//??
|
||
|
|
ProcObjInst[Grp_idx].OverlapPixTh = 32;
|
||
|
|
ProcObjInst[Grp_idx].EnhanStep = 2;
|
||
|
|
ProcObjInst[Grp_idx].PickEna = 1;
|
||
|
|
ProcObjInst[Grp_idx].RgnFltrTh = 0;
|
||
|
|
ProcObjInst[Grp_idx].RmvWkEndEna = 1;
|
||
|
|
ProcObjInst[Grp_idx].RmvWkEndTh = 2;
|
||
|
|
ProcObjInst[Grp_idx].RmvWkEndMultCoe = 16;
|
||
|
|
ProcObjInst[Grp_idx].RmvWkEndMinLen = 3;
|
||
|
|
ProcObjInst[Grp_idx].PickBFEna = 0;
|
||
|
|
ProcObjInst[Grp_idx].PickBkGrnd = 0;
|
||
|
|
ProcObjInst[Grp_idx].PickRLenTh = 4;
|
||
|
|
|
||
|
|
ProcObjInst[Grp_idx].EnergyPickEna = 1;
|
||
|
|
ProcObjInst[Grp_idx].PickEnergyType = 0;
|
||
|
|
ProcObjInst[Grp_idx].RgnEnergyPLen = 32;
|
||
|
|
|
||
|
|
ProcObjInst[Grp_idx].RgnMeanETh = 0;
|
||
|
|
|
||
|
|
ProcObjInst[Grp_idx].SrcFileDir = (char*)malloc(FILENAME_LEN);
|
||
|
|
ProcObjInst[Grp_idx].DstFileDir = (char*)malloc(FILENAME_LEN);
|
||
|
|
sprintf(ProcObjInst[Grp_idx].SrcFileDir, "D:/LicgWork/ToExt/PickLazerWin/TstSrc/Grp_0/");
|
||
|
|
sprintf(ProcObjInst[Grp_idx].DstFileDir, "D:/LicgWork/ToExt/PickLazerWin/SimRslt/Grp_0/");
|
||
|
|
|
||
|
|
|
||
|
|
int ret = 0;
|
||
|
|
for (GrpId = 0; GrpId < 1; GrpId++)
|
||
|
|
{
|
||
|
|
if (GrpId >= 0 && GrpId <= 0)
|
||
|
|
{
|
||
|
|
sprintf(SimRsltDir, "%s", ProcObjInst[GrpId].DstFileDir);
|
||
|
|
|
||
|
|
for (EleIdx = ProcObjInst[GrpId].StartIdx; EleIdx < ProcObjInst[GrpId].EndIdx + 1; EleIdx++)
|
||
|
|
{
|
||
|
|
#if 1
|
||
|
|
sprintf((char*)BmpSrcFileName, "%s%d_L.bmp", ProcObjInst[GrpId].SrcFileDir, EleIdx);
|
||
|
|
|
||
|
|
ret = BMP_Read(
|
||
|
|
BmpSrcFileName,
|
||
|
|
&FrmH,
|
||
|
|
&FrmW,
|
||
|
|
SrcR,
|
||
|
|
SrcG,
|
||
|
|
SrcB
|
||
|
|
);
|
||
|
|
|
||
|
|
if (ret == 0)
|
||
|
|
{
|
||
|
|
std::cout << "#===ReadBmp L Successful::" << GrpId << "::" << EleIdx << "===#" << std::endl;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
std::cout << "#===ReadBmp L Failed::" << GrpId << "::" << EleIdx << "===#" << std::endl;
|
||
|
|
}
|
||
|
|
|
||
|
|
PickLazerWin(
|
||
|
|
1,
|
||
|
|
FrmW,
|
||
|
|
FrmH,
|
||
|
|
SrcR,
|
||
|
|
|
||
|
|
ProcObjInst[GrpId].MinStgTh,
|
||
|
|
ProcObjInst[GrpId].LazerWMin,
|
||
|
|
ProcObjInst[GrpId].LazerWMax,
|
||
|
|
ProcObjInst[GrpId].RflctPixTh,
|
||
|
|
ProcObjInst[GrpId].RflctOutEna,
|
||
|
|
ProcObjInst[GrpId].OverlapPixTh,
|
||
|
|
ProcObjInst[GrpId].EnhanStep,
|
||
|
|
ProcObjInst[GrpId].PickEna,
|
||
|
|
ProcObjInst[GrpId].RgnFltrTh,
|
||
|
|
ProcObjInst[GrpId].RmvWkEndEna,
|
||
|
|
ProcObjInst[GrpId].RmvWkEndTh,
|
||
|
|
ProcObjInst[GrpId].RmvWkEndMultCoe,
|
||
|
|
ProcObjInst[GrpId].RmvWkEndMinLen,
|
||
|
|
ProcObjInst[GrpId].PickBFEna,
|
||
|
|
ProcObjInst[GrpId].PickBkGrnd,
|
||
|
|
ProcObjInst[GrpId].PickRLenTh,
|
||
|
|
|
||
|
|
ProcObjInst[GrpId].EnergyPickEna,
|
||
|
|
ProcObjInst[GrpId].PickEnergyType,
|
||
|
|
ProcObjInst[GrpId].RgnEnergyPLen,
|
||
|
|
ProcObjInst[GrpId].RgnMeanETh,
|
||
|
|
|
||
|
|
&PickLaserResult_inst
|
||
|
|
);
|
||
|
|
//=======================Final Rslt=========================//
|
||
|
|
unsigned short WinNum = Cvt2StdRgbRslt(
|
||
|
|
SrcR,
|
||
|
|
&PickLaserResult_inst,
|
||
|
|
FrmH,
|
||
|
|
FrmW,
|
||
|
|
&StdRgnRslt_inst
|
||
|
|
);
|
||
|
|
//=======================End Final Rslt=====================//
|
||
|
|
|
||
|
|
#ifdef SV_PICK_RGN_RSLT
|
||
|
|
sprintf((char*)BmpDstFileName, "%sPickRgn_Rslt/Bmp/%d_PickRgn_L.bmp", ProcObjInst[GrpId].DstFileDir, EleIdx);
|
||
|
|
sprintf((char*)TxtDstFileName, "%sPickRgn_Rslt/Txt/%d_L_verilog.txt", ProcObjInst[GrpId].DstFileDir, EleIdx);
|
||
|
|
|
||
|
|
SvPickRgnRslt(
|
||
|
|
SrcR,
|
||
|
|
|
||
|
|
FrmH,
|
||
|
|
FrmW,
|
||
|
|
|
||
|
|
TxtDstFileName,
|
||
|
|
BmpDstFileName
|
||
|
|
);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif // #if 0
|
||
|
|
}
|
||
|
|
}
|
||
|
|
free(ProcObjInst[GrpId].SrcFileDir);
|
||
|
|
free(ProcObjInst[GrpId].DstFileDir);
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|