From 355b44018abc4f3e6ad067b98e73be5ab30fcccf Mon Sep 17 00:00:00 2001 From: lovelyyoung <1002639516@qq.com> Date: Tue, 18 Jul 2023 10:29:03 +0800 Subject: [PATCH] =?UTF-8?q?Scanner:=20=E6=89=AB=E6=8F=8F=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E9=87=87=E9=9B=86=E6=8E=A7=E5=88=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20MultiFrameCapture=20=E5=A2=9E=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E6=95=B0=E6=8D=AE=E4=BC=A0=E8=BE=93=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=EF=BC=8C=E8=AF=BB=E5=8F=96=E5=9B=BE=E5=83=8F?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=BA/home/root/color.jpg=20=E6=88=96/hom?= =?UTF-8?q?e/root/gray.jpg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MultiFrameCapture.cpp | 226 ++++++++++++++++++++++++------------------ MultiFrameCapture.h | 7 +- Scanner.cpp | 24 +---- 3 files changed, 137 insertions(+), 120 deletions(-) diff --git a/MultiFrameCapture.cpp b/MultiFrameCapture.cpp index 9b49f0d..686ff23 100644 --- a/MultiFrameCapture.cpp +++ b/MultiFrameCapture.cpp @@ -1,6 +1,6 @@ #include "MultiFrameCapture.h" #include -//#include +// #include #include "DevUtil.h" #include "Gpio.h" #include "FpgaComm.h" @@ -20,23 +20,25 @@ const int vsp_A = 45; const int vsp_B = 45; - -//using namespace cv; -MultiFrameCapture::MultiFrameCapture(ScannerGlue glue, - std::shared_ptr fpga, - CISVendor vendor) : - reset_pin(new GpioOut(Fpga_Reset)), - fpgaLoad(new Gpio(Fpga_Load)), - fpga_conf_initn(new Gpio(Fpga_InitN)), - snaped_index(0), - frame_count(1), - b_snap_run(true), - b_stop_snap(false), - b_imgproc(true), - m_glue(glue), - pimgdata_info({0}), - iImageremain(0), - bScanning(false) +// using namespace cv; +MultiFrameCapture::MultiFrameCapture(ScannerGlue glue, + std::shared_ptr fpga, + CISVendor vendor) : reset_pin(new GpioOut(Fpga_Reset)), + fpgaLoad(new Gpio(Fpga_Load)), + fpga_conf_initn(new Gpio(Fpga_InitN)), + snaped_index(0), + frame_count(1), + b_snap_run(true), + b_stop_snap(false), + b_imgproc(true), + m_glue(glue), + pimgdata_info({0}), + iImageremain(0), + bScanning(false) +#ifdef TEST_SIMCAP + , + m_test_pimg(nullptr), m_test_pimg_len(0) +#endif { m_capFpageregs = fpga; video.reset(new HCamDevice); @@ -49,6 +51,7 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue, // fpgaLoad->setValue(Gpio::High); reset_fpga(); + m_snap_thread.reset(new std::thread(&MultiFrameCapture::snaprun, this)); m_imgproc_thread.reset(new std::thread(&MultiFrameCapture::procimage, this)); } @@ -76,17 +79,21 @@ MultiFrameCapture::~MultiFrameCapture() free(pimgdata_info.pdata); pimgdata_info.pdata = nullptr; } +#ifdef TEST_SIMCAP + if (m_test_pimg) + free(m_test_pimg); +#endif } void MultiFrameCapture::SetParent(void *scanner) { } -void MultiFrameCapture::open() +void MultiFrameCapture::open_video() { - //reset_fpga(); + // reset_fpga(); m_capFpageregs->resetADC(); - m_capFpageregs->set_cis_type(false);//适配A4 CIS + m_capFpageregs->set_cis_type(false); // 适配A4 CIS const bool dunnancis = true; is_size_error = false; // m_frames.clear(); @@ -96,7 +103,7 @@ void MultiFrameCapture::open() if (((PaperSize)m_config.params.pageSize != PaperSize::G400_AUTO) && ((PaperSize)m_config.params.pageSize != PaperSize::G400_MAXAUTO)) { LOG("init CSizedetect \n"); - //m_preproclist.push_back(shared_ptr(new CSizedetect(m_config.params.pageSize, m_config.params.dpi))); + // m_preproclist.push_back(shared_ptr(new CSizedetect(m_config.params.pageSize, m_config.params.dpi))); } } int dpi = m_config.params.dpi == 0x02 ? 2 : (m_config.params.dpi == 0x03 ? 3 : 2); @@ -114,7 +121,7 @@ void MultiFrameCapture::open() unsigned int sp_dst = m_fpgaparam.Sp; if (m_config.params.pageSize == 17 || m_config.params.pageSize == 19) { - sp_dst = mode == 1 ? 4144 : 12432; //sp_dst = mode == 1 ? 3327 : 9981; + sp_dst = mode == 1 ? 4144 : 12432; // sp_dst = mode == 1 ? 3327 : 9981; tdpi = 300; } pixheight = ((int)((phyHeight / 25.4 * tdpi + 2) / 3)) * 3; @@ -125,13 +132,13 @@ void MultiFrameCapture::open() printf("########## pixheight = %d phyHeight = %d m_config.params.pageSize %d dpi = %d\n", pixheight, phyHeight, m_config.params.pageSize, dpi); frame_height = 300 * channels; - //frame_height = (dpi > 2 ? 300 : 180) * channels; + // frame_height = (dpi > 2 ? 300 : 180) * channels; frame_count = ceil((mode == 0x01 ? pixheight * 3 : pixheight) / (float)(frame_height)); // 彩色配置fpga 高度要为目标图像高度的3倍 - frame_count += 1; // 最后一帧丢帧,多采集一帧防止图像数据缺失 + frame_count += 1; // 最后一帧丢帧,多采集一帧防止图像数据缺失 if (frame_height * frame_count > FPGA_MAX_HEIGHT_SUP) frame_count = FPGA_MAX_HEIGHT_SUP / frame_height; - int startsample = 202; //205 + int startsample = 202; // 205 ModeFpga fpgamod = { .colorMode = mode, .dpi = dpi, @@ -141,8 +148,7 @@ void MultiFrameCapture::open() .adcB = 0, .selftest = 0, .sp = sp_dst}; // 600DPI 0x1450 300DPI 0xe10 - readframe_timeout = sp_dst / 4 /(mode == 1 ? 1 :3); - + readframe_timeout = sp_dst / 4 / (mode == 1 ? 1 : 3); m_capFpageregs->setRegs(0x01, *((int *)(&fpgamod))); m_capFpageregs->setSample(startsample); @@ -154,11 +160,11 @@ void MultiFrameCapture::open() m_capFpageregs->setEnTestCol(false); m_capFpageregs->setEnTestBit(false); - //m_capFpageregs->setFrame_interval_max(static_cast(sp_dst * 4 / (mode ? 1 : 3))); //dpi > 2 ? 7200 : 3600 - //m_capFpageregs->setFrame_interval_min(static_cast(sp_dst * 0.1 / (mode ? 1 : 3) )); //1540 - m_capFpageregs->setFrame_interval_max(0x1010); //dpi > 2 ? 7200 : 3600 - m_capFpageregs->setFrame_interval_min(0xa98); //dpi > 2 ? 900 : 1540 a98 - printf("interval_max = %d interval_min = %d \n", static_cast(sp_dst * 4 / (mode ? 1 : 3)), static_cast(sp_dst * 0.1 / (mode ? 1 : 3) )); + // m_capFpageregs->setFrame_interval_max(static_cast(sp_dst * 4 / (mode ? 1 : 3))); //dpi > 2 ? 7200 : 3600 + // m_capFpageregs->setFrame_interval_min(static_cast(sp_dst * 0.1 / (mode ? 1 : 3) )); //1540 + m_capFpageregs->setFrame_interval_max(0x1010); // dpi > 2 ? 7200 : 3600 + m_capFpageregs->setFrame_interval_min(0xa98); // dpi > 2 ? 900 : 1540 a98 + printf("interval_max = %d interval_min = %d \n", static_cast(sp_dst * 4 / (mode ? 1 : 3)), static_cast(sp_dst * 0.1 / (mode ? 1 : 3))); // m_capFpageregs->setFrameNum(1); configFPGAParam(mode, m_config.params.dpi); StopWatch swwv4l2open; @@ -170,14 +176,14 @@ void MultiFrameCapture::open() m_capFpageregs->setFrameHeight(frame_height); m_capFpageregs->update(); m_capFpageregs->capture(); // abort first frame - printf(" getFrame_counter_val %d \n",m_capFpageregs->getFrame_counter_val()); - // video->read_frame(,400); - unsigned char *buf = NULL; - video->HtCamReadCaptureFrame((void **)&buf,400); - //std::this_thread::sleep_for(std::chrono::milliseconds(50)); + printf(" getFrame_counter_val %d \n", m_capFpageregs->getFrame_counter_val()); + // video->read_frame(,400); + unsigned char *buf = NULL; + video->HtCamReadCaptureFrame((void **)&buf, 400); + // std::this_thread::sleep_for(std::chrono::milliseconds(50)); printf("abort first frame \n"); - //printf(" getFrame_counter_val %d \n",m_capFpageregs->getFrame_counter_val()); + // printf(" getFrame_counter_val %d \n",m_capFpageregs->getFrame_counter_val()); m_capFpageregs->setFrameNum(frame_count); printf("frame count = %d height = %d \n", frame_count, frame_height); m_capFpageregs->setFrameHeight(frame_height); @@ -193,11 +199,13 @@ void MultiFrameCapture::open() void MultiFrameCapture::snap() { +#ifndef TEST_SIMCAP std::lock_guard m_lock(m_mtx_snap); b_stop_snap = b_end_snap = false; m_capFpageregs->capture(); snaped_index++; m_cv_snap.notify_all(); +#endif } void MultiFrameCapture::stopsnap(bool autosize) @@ -230,13 +238,29 @@ void *MultiFrameCapture::readFrameTest(int timeout) void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) { m_config = config; - printf("pageSize:%d\r\n",m_config.params.pageSize); - printf("isColor:%d\r\n",m_config.params.isColor); - printf("dpi:%d\r\n",m_config.params.dpi); + printf("pageSize:%d\r\n", m_config.params.pageSize); + printf("isColor:%d\r\n", m_config.params.isColor); + printf("dpi:%d\r\n", m_config.params.dpi); +#ifdef TEST_SIMCAP + if (m_test_pimg) + free(m_test_pimg); + FILE *f_img; + if (m_config.params.isColor == 1) // color + f_img = fopen("/home/root/color.jpg", "rb"); + else + f_img = fopen("/home/root/gray.jpg", "rb"); - // m_config.params.pageSize = 1; + if (f_img == nullptr) + printf("!!!!!!!!!! error while reading image \r\n"); + + fseek(f_img, 0, SEEK_END); + m_test_pimg_len = ftell(f_img); + m_test_pimg = malloc(m_test_pimg_len); + printf("!!!!!!!!!! info: reading image len = %d m_test_pimg = %p \r\n", f_len, m_test_pimg); + fclose(f_img); +#endif } void MultiFrameCapture::createCorrect(int correctmode) @@ -310,26 +334,34 @@ bool MultiFrameCapture::capturerImage() void MultiFrameCapture::waitsnapdone(int state) { - // printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait \n"); - // V4L2_DATAINFO_Ex info; - // info.snaped_index = snaped_index; - // info.snap_end = true; - // info.error_code = state; - // if (b_end_snap) - // { - // m_frameinfos.Put(info); - // return; - // } - // std::unique_lock lock(m_mtx_snapdone); - // m_cv_snapdone.wait(lock); - // b_end_snap = true; - // m_frameinfos.Put(info); - // printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait done \n"); +#ifdef TEST_SIMCAP + HG_JpegCompressInfo info; + info.DataLength = m_test_pimg_len; + info.pJpegData = m_test_pimg; + + m_glue.m_imageready(&info); +#else + printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait \n"); + V4L2_DATAINFO_Ex info; + info.snaped_index = snaped_index; + info.snap_end = true; + info.error_code = state; + if (b_end_snap) + { + m_frameinfos.Put(info); + return; + } + std::unique_lock lock(m_mtx_snapdone); + m_cv_snapdone.wait(lock); + b_end_snap = true; + m_frameinfos.Put(info); + printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait done \n"); +#endif } bool MultiFrameCapture::IsImageQueueEmpty() { - printf(" m_frameinfos.Size = %d iImageremain = %d bScanning = %d\n",m_frameinfos.Size(),iImageremain.operator int(),bScanning); + printf(" m_frameinfos.Size = %d iImageremain = %d bScanning = %d\n", m_frameinfos.Size(), iImageremain.operator int(), bScanning); return (m_frameinfos.Size() == 0 && iImageremain == 0) && !bScanning; } @@ -446,23 +478,22 @@ void MultiFrameCapture::configFPGAParam(int mode, int dpi) set_expo(i, fpgaparam.ExposureB[i % 3]); LOG("fpgaparam.ExposureB[%d] = %d\n", i % 3, fpgaparam.ExposureB[i % 3]); } - int A_value,B_value; + int A_value, B_value; std::this_thread::sleep_for(std::chrono::milliseconds(3)); m_capFpageregs->setAOffset(i, fpgaparam.OffsetF[i]); LOG("fpgaparam.setAOffset[%d] = %d \n", i, fpgaparam.OffsetF[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); - m_capFpageregs->getAOffset(i,A_value,B_value); - LOG("fpgaparam.getAOffset[%d] = A_value = %d B_value = %d \n", i, A_value,B_value); + m_capFpageregs->getAOffset(i, A_value, B_value); + LOG("fpgaparam.getAOffset[%d] = A_value = %d B_value = %d \n", i, A_value, B_value); std::this_thread::sleep_for(std::chrono::milliseconds(3)); m_capFpageregs->setBOffset(i, fpgaparam.OffsetB[i]); LOG("fpgaparam.setBOffset[%d] = %d \n", i, fpgaparam.OffsetB[i]); - std::this_thread::sleep_for(std::chrono::milliseconds(3)); - m_capFpageregs->getBOffset(i,A_value,B_value); - LOG("fpgaparam.getBOffset[%d] = A_value = %d B_value = %d \n", i, A_value,B_value); + m_capFpageregs->getBOffset(i, A_value, B_value); + LOG("fpgaparam.getBOffset[%d] = A_value = %d B_value = %d \n", i, A_value, B_value); std::this_thread::sleep_for(std::chrono::milliseconds(3)); m_capFpageregs->setAGain(i, fpgaparam.GainF[i]); @@ -471,7 +502,7 @@ void MultiFrameCapture::configFPGAParam(int mode, int dpi) m_capFpageregs->setBGain(i, fpgaparam.GainB[i]); LOG("fpgaparam.GainB[%d] = %d\n", i, fpgaparam.GainB[i]); std::this_thread::sleep_for(std::chrono::milliseconds(3)); - + // m_capFpageregs->getAGain(i,A_value,B_value); // LOG("fpgaparam.getAGain[%d] = A_value = %d B_value = %d \n", i, A_value,B_value); // std::this_thread::sleep_for(std::chrono::milliseconds(3)); @@ -479,8 +510,7 @@ void MultiFrameCapture::configFPGAParam(int mode, int dpi) // LOG("fpgaparam.getBGain[%d] = A_value = %d B_value = %d \n", i, A_value,B_value); // std::this_thread::sleep_for(std::chrono::milliseconds(3)); } -} -; +}; int MultiFrameCapture::width() { int dpi = m_capFpageregs->getDpi(); @@ -502,16 +532,16 @@ void MultiFrameCapture::snaprun() { auto snap_func = [this](V4L2_DATAINFO_Ex frame_info, int channels, bool last_frame, unsigned int frame_index) { - //void *data = video->read_frame(500); + // void *data = video->read_frame(500); char *data = NULL; - video->HtCamReadCaptureFrame((void **)&data,400); + video->HtCamReadCaptureFrame((void **)&data, 400); frame_info.lost_frame = data ? false : true; frame_info.last_frame = last_frame; frame_info.frame_index = frame_index; if (data) { - // cv::Mat mat(frame_info.height, frame_info.width, CV_8UC1, data); + // cv::Mat mat(frame_info.height, frame_info.width, CV_8UC1, data); frame_info.data = (char *)data; m_frameinfos.Put(frame_info); } @@ -540,7 +570,6 @@ void MultiFrameCapture::snaprun() { snap_func(frame_info, channels, (i == frame_count), i); - if (b_stop_snap) { int snaped_frame_count = m_capFpageregs->getFrame_counter_val(); @@ -557,10 +586,10 @@ void MultiFrameCapture::snaprun() } } - //iImageremain++; + // iImageremain++; m_cv_snapdone.notify_all(); b_end_snap = true; - //printf("!!!!!!!!!!!!!!!! m_cv_snapdone notify_all \n"); + // printf("!!!!!!!!!!!!!!!! m_cv_snapdone notify_all \n"); } } @@ -574,7 +603,7 @@ void MultiFrameCapture::procimage() { static int idx = 0; ThreadPool prc_pool(4); - //td::queue> prc_fu; + // td::queue> prc_fu; unsigned int frames_height; unsigned int frames_width = 0; while (b_imgproc) @@ -582,9 +611,9 @@ void MultiFrameCapture::procimage() V4L2_DATAINFO_Ex frame = m_frameinfos.Take(); if (!frame.data) { - HG_JpegCompressInfo info ; + HG_JpegCompressInfo info; info.pJpegData = (unsigned char *)frame.data; - info .DataLength = frame.width *frame.height; + info.DataLength = frame.width * frame.height; m_glue.m_imageready(info); } @@ -608,7 +637,7 @@ void MultiFrameCapture::procimage() // if (m_config.params.isCorrect){ // myFloodFill(img,true); // } - + // } // else if (m_config.params.isCorrect) // correctColor(img, m_config.params.dpi, m_config.params.isColor, false); @@ -670,8 +699,7 @@ void MultiFrameCapture::procimage() // cv::Mat m_mat; // if (frames_height > 0 && frames_width > 0) // m_mat = cv::Mat(frames_height, frames_width, CV_8UC(m_config.params.isColor ? 3 : 1), pimgdata_info.pdata); - - + // float vratio = *((float *)&m_fpgaparam.VRatio); // float hratio = *((float *)&m_fpgaparam.HRatio); // if (!(vratio >= 0.8f && vratio <= 1.20f && hratio > 0.8f && hratio < 1.2f)) @@ -1075,7 +1103,7 @@ void MultiFrameCapture::openDevice(int dpi, int mode) int channels = mode == 0x01 ? 3 : 1; int width = channelwidth * channels; int frame_height = mode == 0x01 ? 60 * 3 : 60; - int startsample = 202; //205 + int startsample = 202; // 205 auto fpgaparam = GetFpgaparam(dpi, mode); int t_real_dpi = dpi == 1 ? 2 : (dpi == 2 ? 2 : 3); ModeFpga fpgamod = { @@ -1087,7 +1115,7 @@ void MultiFrameCapture::openDevice(int dpi, int mode) .adcB = 0, .selftest = 0, .sp = fpgaparam.Sp}; // 600DPI 0x1450 300DPI 0xe10 - + // 2023 7-15 屏蔽 // m_capFpageregs->setRegs(0x01, *((int *)(&fpgamod))); // m_capFpageregs->setSample(startsample); @@ -1096,21 +1124,21 @@ void MultiFrameCapture::openDevice(int dpi, int mode) // m_capFpageregs->setEnTestCol(false); // m_capFpageregs->setEnTestBit(false); - //m_capFpageregs->setFrame_interval_max(static_cast(sp_dst * 4 / (mode ? 1 : 3))); //dpi > 2 ? 7200 : 3600 - //m_capFpageregs->setFrame_interval_min(static_cast(sp_dst * 0.1 / (mode ? 1 : 3) )); //1540 - - // 2023 7-15 屏蔽 - // m_capFpageregs->setFrame_interval_max(0x1010); //dpi > 2 ? 7200 : 3600 - // m_capFpageregs->setFrame_interval_min(0xa98); //dpi > 2 ? 900 : 1540 - configFPGAParam(mode, dpi); + // m_capFpageregs->setFrame_interval_max(static_cast(sp_dst * 4 / (mode ? 1 : 3))); //dpi > 2 ? 7200 : 3600 + // m_capFpageregs->setFrame_interval_min(static_cast(sp_dst * 0.1 / (mode ? 1 : 3) )); //1540 + . + // 2023 7-15 屏蔽 + // m_capFpageregs->setFrame_interval_max(0x1010); //dpi > 2 ? 7200 : 3600 + // m_capFpageregs->setFrame_interval_min(0xa98); //dpi > 2 ? 900 : 1540 + configFPGAParam(mode, dpi); StopWatch swwv4l2open; - int ret = video->open_video(width, 60 * 2); // 300dpi 7344/2 600dpi 7344 //FRAME_HEIGHT * 2 - //int ret = video->open_video(); // 300dpi 7344/2 600dpi 7344 //FRAME_HEIGHT * 2 + // int ret = video->open_video(width, 60 * 2); // 300dpi 7344/2 600dpi 7344 //FRAME_HEIGHT * 2 + int ret = video->open_video(); // 300dpi 7344/2 600dpi 7344 //FRAME_HEIGHT * 2 if (ret < 0) { - return ; + return; } - + printf("opened video with width = %d height = %d time eplased = %.2f \n", width, 60 * 2, swwv4l2open.elapsed_ms()); // m_capFpageregs->setFrameHeight(12); m_capFpageregs->setFrameNum(1); @@ -1118,10 +1146,10 @@ void MultiFrameCapture::openDevice(int dpi, int mode) for (int i = 0; i < 1; i++) { m_capFpageregs->capture(); // abort first frame - - //video->read_frame(200); + + // video->read_frame(200); char *buf = NULL; - video->HtCamReadCaptureFrame((void **)&buf,200); + video->HtCamReadCaptureFrame((void **)&buf, 200); std::this_thread::sleep_for(std::chrono::milliseconds(100)); printf("abort first frame \n"); } @@ -1173,11 +1201,9 @@ void MultiFrameCapture::creatcorrectconfig(int dpi, int mode) video->close_video(); } - - // void MultiFrameCapture::myFloodFill(cv::Mat& image, bool isTwoSide) // { -// int w = image.cols; +// int w = image.cols; // int h = image.rows; // cv::Vec3b lt, rt, lb, rb; // const double threshold = 10; @@ -1239,6 +1265,7 @@ void MultiFrameCapture::creatcorrectconfig(int dpi, int mode) void MultiFrameCapture::init_imagedatabuffer() { +#ifndef TEST_SIMCAP printf("pimgdata_info.pdata = %p \n", pimgdata_info.pdata); if (pimgdata_info.pdata) { @@ -1264,6 +1291,7 @@ void MultiFrameCapture::init_imagedatabuffer() pimgdata_info.frame_count = 0; printf("pimgdata_info.pdata = %p malloc_size = %d per_frame_bytes = %d \n", pimgdata_info.pdata, total_buffer_need, per_frame_bytes); } +#endif } // void MultiFrameCapture::update_imgdatainfo(cv::Mat itemmat) diff --git a/MultiFrameCapture.h b/MultiFrameCapture.h index 9489251..03cb401 100644 --- a/MultiFrameCapture.h +++ b/MultiFrameCapture.h @@ -4,6 +4,8 @@ #include "CorrectParam.h" #include "IPreproc.h" +#define TEST_SIMCAP + class FpgaComm; class gVideo; class Gpio; @@ -51,7 +53,10 @@ private: int offsetStep[12]; int expStep[2][3]; double radio = 1; - +#ifdef TEST_SIMCAP + void* m_test_pimg; + unsigned int m_test_pimg_len; +#endif CamZ_Reg_4 reg_; private: void reset_fpga(); diff --git a/Scanner.cpp b/Scanner.cpp index 4706470..482cd4b 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -138,22 +138,6 @@ void Scanner::startScan() threadRunScan = std::thread(&Scanner::runScan, this); writesyslog(LOG_INFO, getmeminfo()); - - // HG_ScanConfiguration cfg; - // cfg.params.dpi=2; - // cfg.params.isColor = 1; - // cfg.params.pageSize = 1; - // capturer->UpdateScanParam(cfg); - - // for(int i = 0;i<1;i++) - // { - // capturer->open(); - // capturer->snap(); - // capturer->capturerImage(); - // capturer->close(); - // // std::this_thread::sleep_for(std::chrono::milliseconds(4000));//避免scanpin io 开始异常 - // } - // //capturer->close(); } void Scanner::runMessageLoop() @@ -305,7 +289,7 @@ void Scanner::runScan() break; } - //capturer->snap(); + capturer->snap(); motorCuozhi.pauseWaitForThread(); int i = 0; int max = 7; @@ -355,9 +339,9 @@ void Scanner::runScan() m_scaninfo.DoubleNum++; writesyslog(LOG_INFO, "paper double paper error\n"); } - //capturer->stopsnap(b_autosize); - //capturer->waitsnapdone(1);//等待采集完成 - //this_thread::sleep_for(std::chrono::milliseconds(500));//200 80ms 600 260ms + capturer->stopsnap(b_autosize); + capturer->waitsnapdone(1);//等待采集完成 + this_thread::sleep_for(std::chrono::milliseconds(500));//200 80ms 600 260ms LOG("\n ----------------EXIT 11111---------------- \n"); break; }