#include "MultiFrameCapture_8458Color.h" #include "config.h" #include "applog.h" #include "gvideoisp1.h" #include "Gpio.h" #include "DevUtil.h" #include "FpgaComm.h" #include "CorrectParam.h" #include "correct_ultis.h" #include "stringex.hpp" #include "filetools.h" #include "CImageMerge.h" #include "jsonconfig.h" #include "StopWatch.h" #include "linux\sched.h" #include "deviceconfig.h" #define LOG_PATH "/usr/local/correct.log" FileTools ft_m_log(LOG_PATH); static std::string loggername = "MultiFrameCapture_8458Color"; static double radio = 1.0; static int offsetStep1[12]; static int expStep1[2][3]; static int org_index = 0; static void initStep1() { printf("initStep aaaaaaaaaaa \n"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { expStep1[i][j] = 600; } } for (int i = 0; i < 12; i++) { offsetStep1[i] = 256; printf("offsetStep[%d]=%d \n",i,offsetStep1[i]); } } MultiFrameCapture_8458Color::MultiFrameCapture_8458Color() : reset_pin(new GpioOut(50)), fpgaLoad(new Gpio(70)), fpga_conf_done(new Gpio(69)), fpga_conf_initn(new Gpio(71)), bcorrecting(false), snapthread(1) { LOG_INIT(); fpga_conf_done->setDirection(Gpio::in); fpgaComm.reset(new FpgaComm()); pimgdata_info = {0}; //fpga_reload(); //fpga_reset(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); //fpgaComm->resetADC(); //fpgaComm->resetADC(); // fpgaComm->update(); video.reset(new VIDEO_CLASS()); set_ADC_config_frequency(12); init_adc_8458(); // GetFpgaparam(0x01,0); snapthread.enqueue([]{ cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(5, &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); }); } MultiFrameCapture_8458Color::~MultiFrameCapture_8458Color() { if (video.get()) video.reset(); printf("Exit ~MultiFrameCapture_8458Color() \n"); } void MultiFrameCapture_8458Color::open() { } void MultiFrameCapture_8458Color::open(HGScanConfig config,FPGAConfigParam fpgaparam) { // config.g200params.dpi = 3; uint32_t reg8 =0,reg5 = 0,reg12 =0,reg11 =0, reg10 =0; set_ADC_config_frequency(12); init_adc_8458(); if(config.g200params.dpi == 2) { set_exp_8458_double(1315,4100,true); //12214 300dpi 5632 80us 10138 144us 11378 200dpi 56 3942 set_exp_8458_double(1315,4100,false); } else { set_exp_8458_single(4315,14855,false); set_exp_8458_single(4315,14855,true); } printf(" dpi = %d \n",config.g200params.dpi); fpgaComm->read(11,reg11); fpgaComm->write(11,(reg11&0xffffffc0)|0x12); fpgaComm->write(13,0xdec0000); //fpgaComm->write(13,0xd680000); video->set_buf_count(10); fpgaComm->set_cis_type(true); m_config = config; m_fpgaparam = fpgaparam; bool dunnancis = true; int dpi = config.g200params.dpi == 0x02 ? 2 : (config.g200params.dpi == 0x03 ? 3 : 2); int mode = config.g200params.color; auto phyHeight = paperHeight[(PaperSize)config.g200params.paper]; int pixheight; // = ((int)((phyHeight / 25.4 * (dpi == 0x02 ? 300 : (dpi == 0x03 ? 600 : 200)) + 2) / 3)) * 3 * 2; int tdpi = config.g200params.dpi == 0x02 ? 300 : (config.g200params.dpi == 0x03 ? 600 : 200); pixheight = ((int)((phyHeight / 25.4 * tdpi + 2) / 3)) * 3; frame_height = 300; frame_count = ceil(pixheight / (float)(frame_height)); // frame_count = 10; // 最后一帧丢帧,多采集一帧防止图像数据缺失 if (frame_height * frame_count > FPGA_MAX_HEIGHT_SUP) frame_count = FPGA_MAX_HEIGHT_SUP / frame_height; fpgaComm->read(15,m_fpgaversion); int startsample = 0; ModeFpga fpgamod = { .colorMode = mode, .dpi = m_config.g200params.dpi, .led = 1, .sample = startsample, // 256+39 .adcA = 0, .adcB = 0, .selftest = 0, .sp = config.g200params.dpi == 3 ? 14855 : 12313 }; // 600DPI 0x1450 300DPI 0xe10 10138 fpgaComm->setRegs(0x01, *((int *)(&fpgamod))); fpgaComm->setSample(startsample); fpgaComm->enableLed(true); fpgaComm->setEnTestCol(false); fpgaComm->setEnTestBit(false); set_dpi_mode(config.g200params.dpi == 3); video->open(config.g200params.dpi == 0x03 ? 7344 : 3672,frame_height*2); fpgaComm->setFrameNum(frame_count); fpgaComm->setFrameHeight(frame_height); printf("fpgaComm set height = %d \n", frame_height); fpgaComm->read(8,reg8); //fpgaComm->write(8,reg8|0x100); //行号 enable fpgaComm->write(8,reg8&0xfffffeff); //行号 disable fpgaComm->read(5,reg5); //fpgaComm->write(5,reg5|0x2000); //测试数据 白+黑 enable fpgaComm->write(5,reg5&0xffffdfff); //测试数据 白+黑 disable fpgaComm->read(12,reg12); //fpgaComm->write(12,reg5&0xfffff000+0x97e); //帧间隔延迟 >=22.5us //fpgaComm->write(12,reg5&0xe000e000+0xfa0067e); //帧间隔延迟 >=22.5us //fpgaComm->write(12,0x04e20400); //0x494e491 0x79de496 范围 0-12 16-28 (16-28 > 0-12) fpgaComm->read(10,reg10); if(m_config.g200params.dpi == 3){ fpgaComm->write(10,0x03b0037a); //120 us 600*600 多帧 fpgaComm->write(12,0x02000100); //120 us 600*600 多帧 } else{ fpgaComm->write(12,0x00200010); //58us 300*600 多帧 fpgaComm->write(10,0x01b0017a); //58us 300*600 多帧 // fpgaComm->write(12,0x03b0037a); //58us 300*600 多帧 // fpgaComm->write(10,0x05b00500); //58us 300*600 多帧 } //fpgaComm->write(4,0x77204001); //fpgaComm->write(7,0x48004041); //if(m_config.g200params.dpi == 3) // fpgaComm->write(10,reg10&0xffff0000+0x3f8); //行间隔 低16位 // fpgaComm->write(10,reg10&0xffff0000+0x1f8); //行间隔 低16位 //fpgaComm->write(10,reg10&0xffff+0x4000000); //帧结束计数 高16位 fpgaComm->write(22,201); fpgaComm->setFrameNum(1); fpgaComm->update(3); fpgaComm->capture(); // abort first frame video->read_frame(1000); fpgaComm->setFrameNum(frame_count); fpgaComm->update(3); // initLut(fpgaparam.LutPath, config.g200params.color); // initLut(config.g200params.is_textcorrect?fpgaparam.LutPath:fpgaparam.TextLutPath,config.g200params.color); // initLut(fpgaparam.TextLutPath, config.g200params.color); init_lutdate(); // init_imagedatabuffer(); } void MultiFrameCapture_8458Color::init_lutdate() { DeviceConfig::Gray_Apply gray_; gray_.value = Get_static_deviceconfig().GetParam().gray_param; std::string lutpath = m_config.g200params.is_textcorrect ? m_fpgaparam.LutPath : m_fpgaparam.TextLutPath; if ((m_fpgaparam.DpiMode == 1) && (gray_.Param_Setting.en_200_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/Graylut200clr.bmp"; else if ((m_fpgaparam.DpiMode == 2) && (gray_.Param_Setting.en_300_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/Graylut300clr.bmp"; else if ((m_fpgaparam.DpiMode == 3) && (gray_.Param_Setting.en_600_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/Graylut600clr.bmp"; else if ((m_fpgaparam.DpiMode == 16) && (gray_.Param_Setting.en_slow_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/Graylutslow_moireclr.bmp"; else if ((m_fpgaparam.DpiMode == 17) && (gray_.Param_Setting.en_slow_300_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/Graylutslow_moire300clr.bmp"; else if ((m_fpgaparam.DpiMode == 32) && (gray_.Param_Setting.en_long_Manuscript_200_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/GraylutLong_Manuscript200clr.bmp"; else if ((m_fpgaparam.DpiMode == 33) && (gray_.Param_Setting.en_long_Manuscript_300_clr == 1 && m_config.g200params.color == true)) lutpath = "/usr/local/huago/GraylutLong_Manuscript300clr.bmp"; else if ((m_fpgaparam.DpiMode == 1) && (gray_.Param_Setting.en_200_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/Graylut200gray.bmp"; else if ((m_fpgaparam.DpiMode == 2) && (gray_.Param_Setting.en_300_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/Graylut300gray.bmp"; else if ((m_fpgaparam.DpiMode == 3) && (gray_.Param_Setting.en_600_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/Graylut600gray.bmp"; else if ((m_fpgaparam.DpiMode == 16) && (gray_.Param_Setting.en_slow_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/Graylutslow_moiregray.bmp"; else if ((m_fpgaparam.DpiMode == 17) && (gray_.Param_Setting.en_slow_300_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/Graylutslow_moire300gray.bmp"; else if ((m_fpgaparam.DpiMode == 32) && (gray_.Param_Setting.en_long_Manuscript_200_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/GraylutLong_Manuscript200gray.bmp"; else if ((m_fpgaparam.DpiMode == 33) && (gray_.Param_Setting.en_long_Manuscript_300_gray == 1 && m_config.g200params.color == false)) lutpath = "/usr/local/huago/GraylutLong_Manuscript300gray.bmp"; initLut(lutpath, m_config.g200params.color); } void MultiFrameCapture_8458Color::close() { if (video.get()) video->close(); // if(pimgdata_info.pdata) free(pimgdata_info.pdata); // pimgdata_info.pdata = nullptr; pimgdata_info.offset = pimgdata_info.frame_count = pimgdata_info.img_h = pimgdata_info.img_w = 0; printf("pimgdata_ free !!!!!\n"); // fpgaComm->resetADC(); // fpga_reload(); } void MultiFrameCapture_8458Color::Fpga_regsAccess_reset(bool enable){ if(fpgaComm.get()) fpgaComm->regsAccess_reset(enable); if (enable) { set_ADC_config_frequency(12); init_adc_8458(); } } void MultiFrameCapture_8458Color::start() { if (video.get()) video->start(); } void MultiFrameCapture_8458Color::MultiFrameCapture_8458Color::stop() { if (video.get()) video->stop(); } bool MultiFrameCapture_8458Color::is_runing() { return false; } // static void printlog(std::string str) // { // std::ofstream o("/root/log.txt",std::ios::app|std::ios::binary); // if(o.is_open()) // { // o << str <capture(); printf("snap start !!!!! \n"); b_stop_snap = false; pimgdata_info.offset = pimgdata_info.frame_count = pimgdata_info.img_h = pimgdata_info.img_w = 0; snap_fu = snapthread.enqueue([this]{ auto snap_func = [this](int height,int width, int channels, bool last_frame, unsigned int frame_index) { StopWatch sw; void *data = video->read_frame(500); if (data) { update_imgdatainfo(data,height,width); printf("memcpy date size = %d times = %f index = %d \n",height*width,sw.elapsed_ms(),frame_index); } else { printf("!!!!!!!!!! error read frame losted, i = %d \n", frame_index); //printlog("!!!!!!!!!! error read frame losted"); } }; int width = 3672*3*(m_config.g200params.dpi == 3 ? 2 : 1)*2; int height = frame_height; for (int i = 1; i <= frame_count; i++) { curr_frame_snap_index = i; snap_func(height,width, 0, (i == frame_count), i); if (b_stop_snap) { int snaped_frame_count = fpgaComm->getFrame_counter_val(); printf("!!!!!!!!!! revsed frame count = %d i = %d \n", snaped_frame_count, i); if (snaped_frame_count > i && snaped_frame_count > 0) // 正常情况下 snaped_frame_count 一定大于0 { int reversed_frame_count = snaped_frame_count - i; for (int j = 1; j <= reversed_frame_count; j++) { curr_frame_snap_index =j+i; snap_func(height, width,0, ((i + j) == reversed_frame_count), i + j); } } break; // 跳出当前读取多帧循环 } } printf("snap end !!!!! \n"); }); } void MultiFrameCapture_8458Color::snap(frame_data_info info) { printf("snap start !!!!! \n"); b_stop_snap = false; info.offset = info.frame_count = info.img_h = info.img_w = 0; snap_fu = snapthread.enqueue([this, info]{ frame_data_info frame_info {0}; frame_info.pdata = info.pdata; frame_info.total = info.total; auto snap_func = [this,&frame_info](int height,int width, int channels, bool last_frame, unsigned int frame_index) { StopWatch sw; void *data = video->read_frame(500); if (data) { update_imgdatainfo(data,frame_info,height,width); printf("memcpy date size = %d times = %f index = %d \n",height*width,sw.elapsed_ms(),frame_index); } else printf("!!!!!!!!!! error read frame losted, i = %d \n", frame_index); }; int width = 3672*3*(m_config.g200params.dpi == 3 ? 2 : 1)*2; int height = frame_height; for (int i = 1; i <= frame_count; i++) { curr_frame_snap_index = i; snap_func(height,width, 0, (i == frame_count), i); if (b_stop_snap) { int snaped_frame_count = fpgaComm->getFrame_counter_val(); printf("!!!!!!!!!! revsed frame count = %d i = %d \n", snaped_frame_count, i); if (snaped_frame_count > i && snaped_frame_count > 0) // 正常情况下 snaped_frame_count 一定大于0 { int reversed_frame_count = snaped_frame_count - i; for (int j = 1; j <= reversed_frame_count; j++) { curr_frame_snap_index = i+j; snap_func(height, width,0, ((i + j) == reversed_frame_count), i + j); } } break; // 跳出当前读取多帧循环 } } pimgdata_info = frame_info; printf("snap end !!!!! \n"); }); } cv::Size MultiFrameCapture_8458Color::frame_data_size() { return {2 * 3672*3*(m_config.g200params.dpi == 3 ? 2 : 1), frame_height * frame_count}; } void MultiFrameCapture_8458Color::stopsnap() { b_stop_snap = true; if(snap_fu.valid()) snap_fu.get(); } int MultiFrameCapture_8458Color::getautosizeheight() { unsigned int val; unsigned int reg8 = 0; fpgaComm->read(8, reg8); // std::cout << "1 reg[8]:" << string_format("0x%08x", reg8) << std::endl; // fpgaComm->update(4); fpgaComm->read(14, val); int regv = val; val &= 0x0000ffff; // std::cout << string_format("ONE height = %d reg[14] = %d \n", val, regv); // fpgaComm->update(5); fpgaComm->write(8, reg8 & 0xfffffff7); // std::cout << string_format("ONE reg[8] = %d \n", reg8 & 0xfffffff7); std::this_thread::sleep_for(std::chrono::milliseconds(5)); // fpgaComm->update(6); fpgaComm->read(14, val); regv = val; val &= 0x0000ffff; fpgaComm->read(8, reg8); // std::cout << "2 reg[8]:" << string_format("0x%08x", reg8) << std::endl; std::cout << string_format("TWO height = %d reg[14] = %d \n", val, regv); std::this_thread::sleep_for(std::chrono::milliseconds(5)); fpgaComm->write(8, reg8 | 0x8); // fpgaComm->write(8,0x02260008); // fpgaComm->update(7); // fpgaComm->read(8, reg8); // std::cout << "2 reg[8]:" << string_format("0x%08x", reg8) << std::endl; return val; // return fpgaComm->getFrameHeight(); } void MultiFrameCapture_8458Color::set_size(int width, int height) { if (video.get()) video->set_size(width, height); } void MultiFrameCapture_8458Color::set_sp(int sp) { fpgaComm->setSp(sp); } void *MultiFrameCapture_8458Color::readFrame(int timeout) { return video->read_frame(timeout); } cv::Mat MultiFrameCapture_8458Color::read_one_frame() { return cv::Mat(); } frame_data_info MultiFrameCapture_8458Color::ReadMultiFrame(int state) { printf(" ReadMultiFrame state : %d \n", state); if (state & 1) b_stop_snap = true; if (snap_fu.valid()) snap_fu.get(); if ((state & 0x2) || (!pimgdata_info.pdata)) return {0}; return pimgdata_info; } void MultiFrameCapture_8458Color::set_gain(int ix, int val) { for (int i = 0; i < 6; i++) { if (ix) fpgaComm->setAGain(i, val); else fpgaComm->setBGain(i, val); } } void MultiFrameCapture_8458Color::set_offset(int ix, int val) { for (int i = 0; i < 6; i++) { if (ix) fpgaComm->setAOffset(i, val); else fpgaComm->setBOffset(i, val); std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } void MultiFrameCapture_8458Color::set_expo(int ix, int val) { switch (ix) { case 0: fpgaComm->setAExposureR(val); break; case 1: fpgaComm->setAExposureG(val); break; case 2: fpgaComm->setAExposureB(val); break; case 3: fpgaComm->setBExposureR(val); break; case 4: fpgaComm->setBExposureG(val); break; case 5: fpgaComm->setBExposureB(val); break; default: break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::shared_ptr MultiFrameCapture_8458Color::regs() { return fpgaComm; } void MultiFrameCapture_8458Color::reset() { fpga_reset(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); fpgaComm->resetADC(); // fpgaComm->setDelayTime(0X3e8); // fpgaComm->setRegs(0x00, fpgaComm->getRegs(0x00)); // fpgaComm->setRegs(0x01, fpgaComm->getRegs(0x01)); } int MultiFrameCapture_8458Color::width() { // int dpi = fpgaComm->getDpi(); // int channel = 1; // int width = dpi == 0x02 ? 1296 * channel : (dpi == 0x03 ? (2592 * channel) : (864 * channel)); // printf("get width = %d \n", width); //return width; return 3672 *(m_config.g200params.dpi == 3 ? 2 : 1); } int MultiFrameCapture_8458Color::height() { return fpgaComm->getFrameHeight(); } int MultiFrameCapture_8458Color::color() { return fpgaComm->getColorMode() ? 16 : 0; } void MultiFrameCapture_8458Color::init_autocorrect(int colormode) { std::thread t_correctthread = std::thread(&MultiFrameCapture_8458Color::correctcolor, this, colormode); t_correctthread.detach(); } void MultiFrameCapture_8458Color::configFPGAParam(int mode, int dpi) { printf("dpi = %d mode = %d \n", dpi, mode); //fpgaComm->resetADC(); FPGAConfigParam fpgaparam = GetFpgaparam(dpi, mode); // int offF[6]={0,0,0,0,0,200}; // int offB[6]={0,0,0,0,0,0}; for (int i = 0; i < 6; i++) { if (i < 3) { set_expo(i, fpgaparam.ExposureF[i]); printf("fpgaparam.ExposureF[%d] = %d \n", i, fpgaparam.ExposureF[i]); } else { set_expo(i, fpgaparam.ExposureB[i % 3]); printf("fpgaparam.ExposureB[%d] = %d \n", i, fpgaparam.ExposureB[i % 3]); } std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->setAOffset(i, fpgaparam.OffsetF[i]); // fpgaComm->setAOffset(i,offF[i]); printf("fpgaparam.setAOffset[%d] = %d \n", i, fpgaparam.OffsetF[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->setBOffset(i, fpgaparam.OffsetB[i]); // fpgaComm->setBOffset(i, offB[i]); printf("fpgaparam.OffsetB[%d] = %d \n", i, fpgaparam.OffsetB[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->setAGain(i, fpgaparam.GainF[i]); printf("fpgaparam.GainF[%d] = %d \n", i, fpgaparam.GainF[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->setBGain(i, fpgaparam.GainB[i]); printf("fpgaparam.GainB[%d] = %d \n", i, fpgaparam.GainB[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); } } void MultiFrameCapture_8458Color::openDevice(int dpi, int mode) { fpgaComm->set_cis_type(true); int config_dpi = dpi == 1 ? 2 : dpi; int channelwidth = config_dpi == 0x02 ? 1296 : (config_dpi == 0x03 ? 2592 : 864); int channels = mode == 0x01 ? 3 : 1; int width = channelwidth * channels; int c_frame_height = mode == 0x01 ? 100 * 3 : 100; FPGAConfigParam fpgaparam = GetFpgaparam(dpi, mode); fpgaComm->read(15,m_fpgaversion); printf("m_fpgaversion =%d \n",m_fpgaversion); int startsample = 208; printf("fpgaparam.sp=%d exp=%d gain=%d offset=%d LUT=%s", fpgaparam.Sp, fpgaparam.ExposureB[0], fpgaparam.GainB[0], fpgaparam.OffsetB[0], fpgaparam.LutPath.c_str()); // int startsample= cistype.GetCisType()==CISVendor::DUNNAN_CIS_V0?205:262; float v_ratio = *((float*)(&fpgaparam.VRatio)); fpgaparam.Sp *= v_ratio; printf("\n openDevice apply sp = %d, v_ratio =%f",fpgaparam.Sp,v_ratio); ModeFpga fpgamod = { .colorMode = mode, .dpi = config_dpi, .led = 1, .sample = startsample, // 256+39 .adcA = 0, .adcB = 0, .selftest = 0, .sp = fpgaparam.Sp}; // 600DPI 0x1450 300DPI 0xe10 fpgaComm->setRegs(0x01, *((int *)(&fpgamod))); fpgaComm->setSample(startsample); fpgaComm->enableLed(true); fpgaComm->setEnTestCol(false); fpgaComm->setEnTestBit(false); set_dpi_mode(dpi == 3); configFPGAParam(mode, dpi); fpgaComm->setFrame_interval_max(0x1010); //dpi > 2 ? 7200 : 3600 fpgaComm->setFrame_interval_min(0xa98); //dpi > 2 ? 900 : 1540 video->open(width, 100 * 2); // 300dpi 7344/2 600dpi 7344 //FRAME_HEIGHT * 2 printf("opened video with width = %d height = %d \n", width, c_frame_height); fpgaComm->setFrameHeight(c_frame_height); fpgaComm->setFrameNum(1); for (int i = 0; i < 1; i++) { fpgaComm->capture(); // abort first frame video->read_frame(200); std::this_thread::sleep_for(std::chrono::milliseconds(20)); printf("abort first frame \n"); } } void MultiFrameCapture_8458Color::creatcorrectconfig(int dpi, int mode) { printf(" opendevice"); openDevice(dpi, mode); printf(" opendevice end "); bool isDone = false; int i = 1; initStep1(); while (!isDone) //先暗场 { std::string log = "==============================第" + std::to_string(i) + "次==============================="; ft_m_log.append_log(log); configFPGAParam(mode, dpi); ft_m_log.append_log(log); fpgaComm->enableLed(false); std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->capture(); std::this_thread::sleep_for(std::chrono::milliseconds(3)); isDone = saveLutImg(dpi, mode, true); // 0 color_black 1 color_white 2 gray_balck 3 gray_white i++; } i = 1; isDone = false; initStep1(); while (!isDone) //后明场 { configFPGAParam(mode, dpi); std::string log = "==============================第" + std::to_string(i) + "次==============================="; ft_m_log.append_log(log); fpgaComm->enableLed(true); std::this_thread::sleep_for(std::chrono::milliseconds(3)); fpgaComm->capture(); std::this_thread::sleep_for(std::chrono::milliseconds(3)); isDone = saveLutImg(dpi, mode, false); i++; } printf("creatcorrectconfig %s \n", (mode == IMAGE_COLOR ? " Color" : " Gray")); //creatLUTData(dpi, mode); video->close(); } static int savelutindex = 0; bool MultiFrameCapture_8458Color::saveLutImg(int dpi, int mode, bool black) { int config_dpi = dpi == 1 ? 2 : dpi; int offset_indexs[] = {0, 1, 2, 5, 4, 3, 3, 4, 5, 2, 1, 0}; int channels = mode == IMAGE_COLOR ? 3 : 1; int height = 100; int width = config_dpi == 0x02 ? 1296 : (config_dpi == 0x03 ? 2592 : 864); int orgimgwidth = width * 2 * 3 * channels; int dstwidth = width * 2 * 3; bool isNeedSave = true; std::string log; void *data = video->read_frame(10000); if (data == NULL) { isNeedSave = false; log = "WARNNING WARNNING WARNNING FAILDED TO READ IMAGE DATA !!!!!!!!!!!!!!!!!!!\r\n"; ft_m_log.append_log(log); if (m_captureCallback) m_captureCallback(mode, log); return isNeedSave; } cv::Mat src(height, orgimgwidth, CV_8UC1, data); //cv::imwrite(std::to_string(savelutindex++) + ".jpg", src); CImageMerge t_marge; cv::Mat mrgmat = t_marge.MergeImage(mode == 0x01, src, dstwidth, height,m_fpgaversion); mrgmat = mrgmat(cv::Rect(0,20,mrgmat.cols,mrgmat.rows-20)); // return false; FPGAConfigParam param = GetFpgaparam(dpi, mode); if (black) //暗场 { double offValues[12]; std::vector bflags; for (volatile int n = 0; n < 2; n++) { cv::Mat img = mrgmat(cv::Rect(mrgmat.cols * n / 2, 10, mrgmat.cols / 2, mrgmat.rows - 10)).clone(); int offset_total = 0; for (volatile int s = 0; s < 6; s++) // { int k = n * 6 + s; int offset_wdth; if ((k == 5) || (k == 6)) { offset_wdth = config_dpi == 0x03 ? 864 : (config_dpi == 0x02 ? 432 : 288); } else { offset_wdth = config_dpi == 0x03 ? 1296 : (config_dpi == 0x02 ? 648 : 432); } double min,max; //auto t_mat= img(cv::Rect(offset_total, 10, offset_wdth, img.rows - 10)); //cv::minMaxLoc(t_mat,&min,&max); cv::Scalar mean = cv::mean(img(cv::Rect(offset_total, 10, offset_wdth, img.rows - 10))); //printf("AAAAAAAAAAAAAAAAAAAAAAAAAAA min = %.2f max= %.2f mean = %0.2f \n",min,max); offset_total += offset_wdth; offValues[k] = mean.val[0]; printf("\noffValues[%d] = %f",k,mean.val[0]); bflags.push_back(false); //offValues[k] = min; } } // std::string clrmode = (mode == 0x01 ? "彩色" : " 灰度"); // log = "开始" + clrmode + "暗场校正 \n"; for (volatile int s = 0; s < 2; s++) { int offsets[6]; // = (int *)(s == 0 ? ¶m.OffsetF[0] : ¶m.OffsetB[0]); memcpy(offsets, (s == 0 ? ¶m.OffsetF[0] : ¶m.OffsetB[0]), sizeof(param.OffsetF)); for (volatile int j = 0; j < 6; j++) { int k = s * 6 + j; double diff = BLACK_DIFF(offValues[k]); //double diff = 3-offValues[k]; double step = radio * diff; int preStep = offsetStep1[k]; printf("offsetStep1[%d]=%d \n",k,offsetStep1[k]); if (step * preStep < 0) { step = 0 - preStep / 2; } else { radio = 1; } if (step < 1 && step > 0) step = 1; if (step < 0 && step > -1) step = -1; // FMT_STEP(step); bool isMinStep = abs(step) == 1 && step == offsetStep1[k]; bool isOutBounds = offsets[j] >= 255 && step > 0; isOutBounds |= offsets[j] <= 0 && step < 0; log += " 暗场校正 :" + std::to_string(k) + ";diff:" + std::to_string(diff) + ";light:" + std::to_string(offValues[k]) + ";offset:" + std::to_string(offsets[j]) + ";step:" + std::to_string(step) + "\r\n"; if (isOutBounds) log += " 第" + std::to_string(k) + "条带暗场校正异常,暗场值无法降低 \r\n"; else if (abs(step) > 1 || isMinStep) { offsetStep1[k] = (int)(step); offsets[offset_indexs[k]] += step; log += "offsetStep1" + std::to_string(k) + " = " + std::to_string(offsetStep1[k]) + ", offset_indexs" + std::to_string(k) + " =" + std::to_string(offset_indexs[k]) + "\r\n"; if (offsets[offset_indexs[k]] < 1) offsets[offset_indexs[k]] = 1; if (offsets[offset_indexs[k]] > 255) offsets[offset_indexs[k]] = 255; //isNeedSave = false; bflags[k] = false; } else { bflags[k] = true; printf("channel[%d] black correct done\n",k); } log += (s == 0 ? "彩色正面" : "彩色背面"); log += "偏移值:" + std::to_string(offsets[0]) + "," + std::to_string(offsets[1]) + "," + std::to_string(offsets[2]) + "," + std::to_string(offsets[3]) + "," + std::to_string(offsets[4]) + "," + std::to_string(offsets[5]) + "\r\n"; // log += (s == 0 ? "彩色正面暗场校正完成 \r\n" : "彩色背面暗场校正完成 \r\n"); ft_m_log.append_log(log); if (m_captureCallback) m_captureCallback(mode, log); log = ""; } auto siez = sizeof(param.OffsetF); memcpy((s == 0 ? ¶m.OffsetF[0] : ¶m.OffsetB[0]), offsets, sizeof(param.OffsetF)); } for(int i = 0;i 30) radio = 2; else radio = 1; double step = diff * radio; int preStep = *((int *)expStep + k); if (step * preStep < 0) { step = 0 - preStep / 2; } if (step < 1 && step > 0) step = 1; if (step < 0 && step > -1) step = -1; bool isMinStep = abs(step) == 1 && step == *((int *)expStep + k); bool isOutBounds = exposures[x] >= (param.Sp -5) && step > 0; isOutBounds |= exposures[x] <= 0 && step < 0; if (isOutBounds) log += " 第" + std::to_string(x) + "个明场校正异常 \r\n"; else if (abs(diff) >= 1 || isMinStep) { *((int *)expStep + k) = (int)(step); exposures[x] += step; if (exposures[x] > (param.Sp -5)) { exposures[x] = (param.Sp -5); } if (exposures[x] < 0) exposures[x] = 0; isNeedSave = false; } log += " 曝光值:" + std::to_string(exposures[x]) + "\r\n"; log += " 调整步长:" + std::to_string(*((int *)expStep + k)) + "\r\n"; } memcpy((s == 0 ? ¶m.ExposureF[0] : ¶m.ExposureB[0]), exposures, sizeof(param.ExposureB)); } ft_m_log.append_log(log); if (m_captureCallback) m_captureCallback(mode, log); if (isNeedSave) { log = "彩色明场校正完成\r\n"; if (m_captureCallback) m_captureCallback(mode, log); // log =""; imwrite(param.Flat_WhitePath, mrgmat); } } else { double values[2]; values[0] = cv::mean(mrgmat(cv::Rect(0, 0, mrgmat.cols / 2, mrgmat.rows))).val[0]; values[1] = cv::mean(mrgmat(cv::Rect(mrgmat.cols / 2, 0, mrgmat.cols / 2, mrgmat.rows))).val[0]; log = "-----开始灰色明场校正-----\r\n"; log += " 灰色扫描灰度明场均值:" + std::to_string(values[0]) + "," + std::to_string(values[1]) + "\r\n"; if (m_captureCallback) m_captureCallback(mode, log); for (int s = 0; s < 2; s++) { int *exposures = (int *)(s == 0 ? param.ExposureF : param.ExposureB); int diff = LIGHT_DIFF(param.MaxBright, values[s]); if(abs(diff) > 30) radio = 2; else radio = 1; double step = diff * radio; log += " 明场:" + std::to_string(s) + ";diff:" + std::to_string(diff) + "\r\n"; int preStep = expStep[s][0]; if (step * preStep < 0) { step = 0 - preStep / 2; } else { radio = 1; } if (step < 1 && step > 0) step = 1; if (step < 0 && step > -1) step = -1; int exp = *(exposures + 1); // std::string ss1(string_format("exp[%d] = %d step = %.3f \r\n", s, exp, step)); // log += ss1; bool isMinStep = abs(step) == 1 && step == expStep[s][0]; bool isOutBounds = exp >= (param.Sp -5) && step > 0; isOutBounds |= exp <= 0 && step < 0; if (isOutBounds) log += " 第" + std::to_string(s) + "个明场校正异常 \r\n"; else if (abs(diff) > 1 || isMinStep) { exp += step; if (exp < 0) exp = 0; if (exp >(param.Sp -5)) exp = (param.Sp -5); float coffe[3] = {1, 1, 1}; // 0.2, 1,0.51 for (int k = 0; k < 3; k++) { *(exposures + k) = (int)(exp * coffe[k]); expStep[s][k] = (int)(step); std::string exps(string_format("expStep[%d][%d] = %.3f\r\n", s, k, step)); log += exps; std::string ss(string_format("exposures[%d] = %0.3f \r\n", k, exposures[k])); log += ss; } isNeedSave = false; } } ft_m_log.append_log(log); if (m_captureCallback) m_captureCallback(mode, log); if (isNeedSave) { printf("Save LUT image path :%s \n", param.Flat_WhitePath.c_str()); log = "灰度明场校正完成\r\n"; if (m_captureCallback) m_captureCallback(mode, log); log = ""; imwrite(param.Flat_WhitePath, mrgmat); } } } SaveFpgaparam(param); printf("exit Save_lut \n"); return isNeedSave; } void MultiFrameCapture_8458Color::correctcolor(int correctmode) { printf(" correctcolor start \n"); auto _start = std::chrono::steady_clock::now(); ThreadPool pool(2); std::queue> fu_correct; std::string loginfo = "Start Correctcolor 200DPI COLOR \r\n"; // if (m_captureCallback) // m_captureCallback(0x01, loginfo); creatcorrectconfig(0x01, IMAGE_COLOR); auto param = GetFpgaparam(0x01,IMAGE_COLOR); fu_correct.emplace(pool.enqueue([param](){creatLUTData(0x01,IMAGE_COLOR,param);})); loginfo = "-----------200DPI COLOR Correct Done----------- \r\n\r\n Start Correctcolor 200DPI GRAY \r\n"; if (m_captureCallback) m_captureCallback(0x01, loginfo); creatcorrectconfig(0x01, IMAGE_GRAY); param = GetFpgaparam(0x01,IMAGE_GRAY); fu_correct.emplace(pool.enqueue([param](){creatLUTData(0x01,IMAGE_GRAY,param);})); loginfo = "-----------200DPI Gray Correct Done----------- \r\n\r\n Start Correctcolor 200DPI COLOR \r\n"; if (m_captureCallback) m_captureCallback(0x02, loginfo); creatcorrectconfig(0x02, IMAGE_COLOR); param = GetFpgaparam(0x02,IMAGE_COLOR); fu_correct.emplace(pool.enqueue([param](){creatLUTData(0x02,IMAGE_COLOR,param);})); loginfo = "-----------300DPI COLOR Correct Done----------- \r\n\r\n Start Correctcolor 300DPI GRAY \r\n"; if (m_captureCallback) m_captureCallback(0x02, loginfo); creatcorrectconfig(0x02, IMAGE_GRAY); param = GetFpgaparam(0x02,IMAGE_GRAY); fu_correct.emplace(pool.enqueue([param](){creatLUTData(0x02,IMAGE_GRAY,param);})); loginfo = "-----------300DPI Gray Correct Done----------- \r\n\r\n Start Correctcolor 600DPI COLOR \r\n"; while(fu_correct.size()) { fu_correct.front().get(); fu_correct.pop(); } loginfo = "******Correct Done****** time " + std::to_string(std::chrono::duration(std::chrono::steady_clock::now() - _start).count())+"s"; if (m_captureCallback) m_captureCallback(0x03, loginfo); } void MultiFrameCapture_8458Color::fpga_reset() { reset_pin->setValue(Gpio::Low); std::this_thread::sleep_for(std::chrono::milliseconds(50)); reset_pin->setValue(Gpio::High); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } void MultiFrameCapture_8458Color::fpga_reload() { // fpga 代码重载 fpgaLoad->setValue(Gpio::Low); std::this_thread::sleep_for(std::chrono::milliseconds(15)); fpga_conf_initn->setValue(Gpio::Low); std::this_thread::sleep_for(std::chrono::milliseconds(15)); printf("\n fpga_conf_done value %d",fpga_conf_done->getValue()); fpgaLoad->setValue(Gpio::High); std::this_thread::sleep_for(std::chrono::milliseconds(15)); fpga_conf_initn->setValue(Gpio::High); //std::this_thread::sleep_for(std::chrono::milliseconds(5)); printf("\n fpga_conf_done value %d",fpga_conf_done->getValue()); // while(fpga_conf_done->getValue() == Gpio::GpioLevel::Low) // std::this_thread::sleep_for(std::chrono::milliseconds(5)); std::this_thread::sleep_for(std::chrono::seconds(3)); printf("\n fpga_conf_done value %d",fpga_conf_done->getValue()); fpgaComm->resetADC(); fpgaComm->update(0); } void MultiFrameCapture_8458Color::init_imagedatabuffer() { printf("pimgdata_info.pdata = %p \n", pimgdata_info.pdata); if (pimgdata_info.pdata) { free(pimgdata_info.pdata); pimgdata_info.pdata = nullptr; } if (frame_count != 0) { int t_frame_count = fpgaComm->getFrameNum(); int width = this->width()*(m_config.g200params.color ? 3 : 1); int height = frame_height*2; pimgdata_info.pdata = malloc(height * t_frame_count*width ); pimgdata_info.total = height * t_frame_count; pimgdata_info.offset = 0; pimgdata_info.frame_count = 0; pimgdata_info.img_h = 0; pimgdata_info.img_w = 0; printf("pimgdata_info.pdata = %p malloc_size = %d \n", pimgdata_info.pdata, height * t_frame_count*width,t_frame_count,width,height); } } void MultiFrameCapture_8458Color::free_imagedatabuffer() { if (pimgdata_info.pdata) { free(pimgdata_info.pdata); pimgdata_info.pdata = nullptr; } printf("--- free pimgdata_info.pdata --- \n"); } // static void neon_memcpy(volatile void *dst, volatile void *src, int sz) // { // if (sz & 63) // sz = (sz & -64) + 64; // asm volatile ( // "NEONCopyPLD: \n" // " VLDM %[src]!,{d0-d7} \n" // " VSTM %[dst]!,{d0-d7} \n" // " SUBS %[sz],%[sz],#0x40 \n" // " BGT NEONCopyPLD \n" // : [dst]"+r"(dst), [src]"+r"(src), [sz]"+r"(sz) : : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "cc", "memory"); // } void MultiFrameCapture_8458Color::update_imgdatainfo(void *itemmat, frame_data_info &info, uint32_t h, uint32_t w) { // StopWatch sw; if (info.pdata && itemmat) { // neon_memcpy(pimgdata_info.pdata + pimgdata_info.offset,itemmat,h*w); memcpy(info.pdata + info.offset, itemmat, h * w); info.offset += h * w; info.frame_count++; info.img_h += h; info.img_w = w; // printf("offset = %d item_total = %d \n", pimgdata_info.offset,pimgdata_info.frame_count); } // printf("size = %d frame memcpy time = %fms \n", h*w,sw.elapsed_ms()); } void MultiFrameCapture_8458Color::update_imgdatainfo(void *itemmat, uint32_t h, uint32_t w) { if (pimgdata_info.pdata && itemmat) { memcpy(pimgdata_info.pdata + pimgdata_info.offset, itemmat, h * w); pimgdata_info.offset += h * w; pimgdata_info.frame_count++; pimgdata_info.img_h += h; pimgdata_info.img_w = w; } } void MultiFrameCapture_8458Color::init_adc_8458() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); for(int i =0;i<192;i++){ write_adc_8458(bank_change[i/64],i%64,bank_value[i],1); write_adc_8458(bank_change[i/64],i%64,bank_value[i],0); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } void MultiFrameCapture_8458Color::write_adc_8458(int bank, int addr, int val,bool A_or_B) { uint32_t reg5 = 0; fpgaComm->read(5,reg5); fpgaComm->write(5,reg5|0xc000); // adc 配置使能打开 //std::this_thread::sleep_for(std::chrono::milliseconds(1)); adc_8458_param p_adc{0}; p_adc.param.r_or_w_h = p_adc.param.r_or_w_l = 1; p_adc.param.addr_l = 0; p_adc.param.addr_h = addr; p_adc.param.val_l = bank; p_adc.param.val_h = val; fpgaComm->write(A_or_B ?4:7,p_adc.value); uint32_t reg1_v; fpgaComm->read(1,reg1_v); Mode_FPGA reg1 = *((Mode_FPGA*)®1_v); A_or_B ? reg1.adcA = 1 :reg1.adcB = 1 ; fpgaComm->write(1,*((uint32_t*)®1)); A_or_B ? reg1.adcA = 0 :reg1.adcB = 0 ; fpgaComm->write(1,*((uint32_t*)®1)); //std::this_thread::sleep_for(std::chrono::milliseconds(1)); fpgaComm->write(5,reg5&0xffff3fff);// adc 配置使能关闭 } uint32_t MultiFrameCapture_8458Color::read_adc_8458(int bank, int addr,bool A_or_B) { uint32_t reg5 = 0; fpgaComm->read(5,reg5); fpgaComm->write(5,reg5|0xc000); // adc 配置使能打开 std::this_thread::sleep_for(std::chrono::milliseconds(1)); adc_8458_param p_adc{0}; p_adc.param.r_or_w_h = 1; p_adc.param.r_or_w_l = 3; p_adc.param.addr_l = 0; p_adc.param.addr_h = addr; p_adc.param.val_l = bank; p_adc.param.val_h = 0; fpgaComm->write(A_or_B ?4:7,p_adc.value); uint32_t reg1_v; fpgaComm->read(1,reg1_v); Mode_FPGA reg1 = *((Mode_FPGA*)®1_v); A_or_B ? reg1.adcA = 1 :reg1.adcB = 1 ; fpgaComm->write(1,*((uint32_t*)®1)); A_or_B ? reg1.adcA = 0 :reg1.adcB = 0 ; fpgaComm->write(1,*((uint32_t*)®1)); std::this_thread::sleep_for(std::chrono::milliseconds(1)); fpgaComm->write(5,reg5&0xffff3fff);// adc 配置使能关闭 uint32_t read_reg =0; fpgaComm->read(3,read_reg); return read_reg; } void MultiFrameCapture_8458Color::set_dpi_mode(bool is_600) { if(is_600) { write_adc_8458(bank_change[2],0x14,0x01,false); write_adc_8458(bank_change[2],0x14,0x01,true); write_adc_8458(bank_change[2],0x16,0x01,false); write_adc_8458(bank_change[2],0x16,0x01,true); } else { write_adc_8458(bank_change[2],0x14,0x02,false); write_adc_8458(bank_change[2],0x14,0x02,true); write_adc_8458(bank_change[2],0x16,0x03,false); write_adc_8458(bank_change[2],0x16,0x03,true); } } void MultiFrameCapture_8458Color::set_exp_8458_double(int exp, int sp,bool A_or_B) { int pix_counter = (sp -10) /2; set_pixel_count_8458(pix_counter); int exp_max = pix_counter - 80 - 80 - 10; if((exp * 2) > exp_max) exp = exp_max / 2; write_adc_8458(bank_change[1],1,0,A_or_B); write_adc_8458(bank_change[1],2,80,A_or_B); write_adc_8458(bank_change[1],3,((exp+80)&0xff00)/0x100,A_or_B); write_adc_8458(bank_change[1],4,(exp+80)&0xff,A_or_B); write_adc_8458(bank_change[1],5,((pix_counter/2+80)&0xff00)/0x100,A_or_B); write_adc_8458(bank_change[1],6,(pix_counter/2+80)&0xff,A_or_B); write_adc_8458(bank_change[1],7,((pix_counter/2+exp+80)&0xff00)/0x100,A_or_B); write_adc_8458(bank_change[1],8,(pix_counter/2+exp+80)&0xff,A_or_B); } void MultiFrameCapture_8458Color::set_led_off() { for(int i =0; i < 2 ;i++){ write_adc_8458(bank_change[1],1,0,i); //led off write_adc_8458(bank_change[1],2,0,i); write_adc_8458(bank_change[1],3,0,i); write_adc_8458(bank_change[1],4,0,i); write_adc_8458(bank_change[1],5,0,i); write_adc_8458(bank_change[1],6,0,i); write_adc_8458(bank_change[1],7,0,i); write_adc_8458(bank_change[1],8,0,i); } } void MultiFrameCapture_8458Color::set_exp_8458_single(int exp,int sp,bool A_or_B){ int pix_counter = (sp -10) /2; set_pixel_count_8458(pix_counter); int exp_max = pix_counter - 80 - 10; if(exp > exp_max) exp = exp_max; write_adc_8458(bank_change[1],1,0,A_or_B); write_adc_8458(bank_change[1],2,1,A_or_B); write_adc_8458(bank_change[1],3,((exp+80)&0xff00)/0x100,A_or_B); write_adc_8458(bank_change[1],4,(exp+80)&0xff,A_or_B); write_adc_8458(bank_change[1],5,0,A_or_B); write_adc_8458(bank_change[1],6,0,A_or_B); write_adc_8458(bank_change[1],7,0,A_or_B); write_adc_8458(bank_change[1],8,0,A_or_B); } void MultiFrameCapture_8458Color::set_pixel_count_8458(int val) { write_adc_8458(bank_change[0],54,(val&0xff00)/0x100,true); write_adc_8458(bank_change[0],54,(val&0xff00)/0x100,false); write_adc_8458(bank_change[0],55,val&0xff,true); write_adc_8458(bank_change[0],55,val&0xff,false); } void MultiFrameCapture_8458Color::set_analog_gain_8458(int r1, int r2, int g1, int g2, int b1, int b2, bool A_or_B) { write_adc_8458(bank_change[0],10,r1*0x10+g1,A_or_B); //max 7 write_adc_8458(bank_change[0],11,b1*0x10+r2,A_or_B); write_adc_8458(bank_change[0],12,g2*0x10+b2,A_or_B); } void MultiFrameCapture_8458Color::set_analog_offset_8458(int type,int val,bool A_or_B){ if(type >=4 && type <= 9) write_adc_8458(bank_change[0],type,val,A_or_B); //max 32 299mv 8.3mv } void MultiFrameCapture_8458Color::set_digital_offset_8458(int type,int val, bool A_or_B) { int addr = 13 + type*2; write_adc_8458(bank_change[0],addr,(val&0x700)/0x100,A_or_B); write_adc_8458(bank_change[0],addr+1,val&0xff,A_or_B); } void MultiFrameCapture_8458Color::set_digital_gain_8458(int type,int val, bool A_or_B) { int addr = 19 + type*2; write_adc_8458(bank_change[0],addr,(val&0xff00)/0x100,A_or_B); write_adc_8458(bank_change[0],addr+1,val&0xff,A_or_B); } void MultiFrameCapture_8458Color::set_ADC_config_frequency(uint32_t freq) { uint32_t reg2 = 0; fpgaComm->read(2, reg2); fpgaComm->write(2, (reg2 & 0xffffffe1) | (freq << 1)); // adc 配置 频率 } void MultiFrameCapture_8458Color::single_correct(std::uint32_t mode) { std::vector sup_correct_dpi{1, 2, 3, 0x10, 0x11,0x20,0x21}; union correct_mode_ { struct { uint32_t dpi : 16; uint32_t color_mode : 8; uint32_t correct_mode : 8; } param; uint32_t value; }; correct_mode_ tmp; tmp.value = mode; if (std::count(sup_correct_dpi.begin(), sup_correct_dpi.end(), tmp.param.dpi) && (tmp.param.color_mode < 2)) { auto param = Get_Static_CorrectParam().GetFpgaparam(tmp.param.dpi, tmp.param.color_mode); if (tmp.param.correct_mode == 1) creatLUTData(tmp.param.dpi, tmp.param.color_mode, param); else if (tmp.param.correct_mode == 2) creatLUTData_gray(tmp.param.dpi, tmp.param.color_mode, param); } }