#include #include #include #include #include "vz_ap_bmp.h" #include "ImgUtils.h" // extern RGB RGB_Inst[32] ; RGB RGB_Inst[] = { {0, 162, 232}, //0 {237, 28, 36}, //1 {0, 255, 128}, //2 {255, 174, 201}, //3 {0, 0, 255}, //4 {128, 128, 0}, //5 {255, 242, 0}, //6 {163, 74, 164}, //7 {153, 217, 234}, //8 {200, 191, 231}, //9 {150, 154, 1}, //10 {181, 230, 29}, //11 {0, 128, 255}, //12 {239, 228, 176}, //13 {112, 146, 190}, //14 {43, 113, 83}, //15 {232, 162, 0}, //0 {36, 28, 237}, //1 {128, 255, 0}, //2 {201, 174, 255}, //3 {255, 0, 0}, //4 {0, 128, 128}, //5 {0, 242, 255}, //6 {74, 164, 163}, //7 {234, 217, 153}, //8 {231, 191, 200}, //9 {1, 154, 150}, //10 {29, 230, 181}, //11 {255, 128, 0}, //12 {176, 228, 239}, //13 {190, 146, 112}, //14 {83, 113, 43}, //15 }; extern PickLaserResult PickLaserResult_inst; extern StdRgnRslt StdRgnRslt_inst; unsigned short Cvt2StdRgbRslt( const unsigned char* SrcPixel, const PickLaserResult* PickLaserResult_inst, int FrmH, int FrmW, StdRgnRslt* StdRgnRslt_inst ) { unsigned short WinNum = 0; for (unsigned short y = 0; y < FrmH; y++) { for (int PickId = 0; PickId < PICK_RGN_MAX; PickId++) { if (PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_PickMsk[y][PickId] == 1) { StdRgnRslt_inst->WinRdx[WinNum] = PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_WinRdx[y][PickId]; StdRgnRslt_inst->WinRltvStr[WinNum] = PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_LazerRdx[y][PickId] - StdRgnRslt_inst->WinRdx[WinNum]; StdRgnRslt_inst->WinRltvEnd[WinNum] = PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_LazerRdx[y][PickId] + PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_LazerW[y][PickId] - 1 - StdRgnRslt_inst->WinRdx[WinNum]; StdRgnRslt_inst->WinY[WinNum] = y; StdRgnRslt_inst->WinRid[WinNum] = PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_Rid[y][PickId]; StdRgnRslt_inst->WinRflct[WinNum] = (PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_RflctMsk[y][PickId] & (~PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_LiteRflct[y][PickId])); StdRgnRslt_inst->WinOvrlp[WinNum] = PickLaserResult_inst->PickRgn_FrmMaxDeltaStg_OverlapMsk[y][PickId]; for (short WinPixCnt = 0; WinPixCnt < SV_WIN_SIZE; WinPixCnt++)//MEANSTG_WIN_SIZE; WinPixCnt++) { int PixIdx = y * FrmW + StdRgnRslt_inst->WinRdx[WinNum] + WinPixCnt; unsigned char PixVlu = 0;//SrcPixel[PixIdx]; if (StdRgnRslt_inst->WinRflct[WinNum] == 1) { if ((WinPixCnt >= (SV_WIN_SIZE / 2 - 1)) && (WinPixCnt <= (SV_WIN_SIZE / 2))) { PixVlu = 255; } else { PixVlu = 0; } } else { PixVlu = SrcPixel[PixIdx]; } StdRgnRslt_inst->WinPix[WinNum][WinPixCnt] = PixVlu; } WinNum++; } } } return WinNum; } //#ifdef PICK_RGN void SvPickRgnRslt( const unsigned char * SrcPixel, int FrmH, int FrmW, char * TxtDstFileName, char * BmpDstFileName ) { char *TXTData = (char *)malloc(256); memset(TXTData,0,256); std::ofstream TXTFile(TxtDstFileName); int LazerWinNum = 0; snprintf(TXTData, sizeof(TXTData), "%3x", (0x800 | SV_WIN_SIZE));//MEANSTG_WIN_SIZE); TXTFile << TXTData << std::endl; for(unsigned short y=0; y= (SV_WIN_SIZE/2-1)) && (WinPixCnt <= (SV_WIN_SIZE/2))) { PixVlu = 255; } else { PixVlu = 0; } } else { PixVlu = SrcPixel[PixIdx]; } snprintf(TXTData, sizeof(TXTData), "%02x", PixVlu); TXTFile << TXTData << std::endl; } WinNumPerLine++; } } if(LazerWinNum > (MAX_WIN_NUM-WinNumPerLine)) { // while(1) // { std::cout << "#===WinNumExceed::" << MAX_WIN_NUM << "===#"<< std::endl; // } break; } LazerWinNum += WinNumPerLine; } TXTFile.close(); free(TXTData); unsigned char *DstR = (unsigned char *)malloc(FrmH*FrmW); unsigned char *DstG = (unsigned char *)malloc(FrmH*FrmW); unsigned char *DstB = (unsigned char *)malloc(FrmH*FrmW); for(int y = 0; y < FrmH; y++) { for(int x = 0; x < FrmW; x++) { DstR[y * FrmW + x] = SrcPixel[y * FrmW + x]; DstG[y * FrmW + x] = SrcPixel[y * FrmW + x]; DstB[y * FrmW + x] = SrcPixel[y * FrmW + x]; } } for(unsigned short y=0; y