调整200 300 dpi速度模式

This commit is contained in:
modehua 2023-09-18 18:24:12 -07:00
parent 60827d3139
commit bc0fd68764
5 changed files with 67 additions and 31 deletions

View File

@ -195,7 +195,7 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
//int height = resolution_ == DPI_600 ? 342 : 900;
int height = config.params.dpi == 3 ? 342 :(config.params.dpi == 2?900:651);
int height = config.params.dpi == 3 ? 342 :(config.params.dpi == 2?900:513);
compute_height(WIDTH , height);
video->HtCamSetClolr(color_mode_);
@ -215,10 +215,10 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
int val = config.params.dpi == 3 ? 600 :(config.params.dpi == 2?300:200);
printf("val = %d\r\n",val);
uint32_t cnt = compute_frame(paper_size_ , val) ; //多设一帧
if (m_config.params.dpi == 3)
{
cnt +=1 ;
}
// if (m_config.params.dpi == 3)
// {
// cnt +=1 ;
// }
video->HtCamSetFrameCnt(cnt);
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
@ -288,6 +288,7 @@ void MultiFrameCapture::waitsnapdone(int state)
m_frameinfos.Put(info);
return;
}
sw.reset();
std::unique_lock<std::mutex> lock(m_mtx_snapdone);
m_cv_snapdone.wait(lock);
b_end_snap = true;
@ -387,7 +388,7 @@ void MultiFrameCapture::snaprun()
int t = resolution_ == DPI_600 ? sw.elapsed_ms() + 600 : sw.elapsed_ms() + 20;
time_out = t;
uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数
printf("--------------fpga send line ------------:%d \r\n",sendLine);
printf("--------------fpga send line ------------:%d HtCamReadCaptureFrame =%0.2f \r\n",sendLine,sw.elapsed_ms());
if (data)
{
@ -415,9 +416,14 @@ void MultiFrameCapture::snaprun()
printf("600做拷贝\r\n");
info.pJpegData = (unsigned char *)malloc(frame_info.height * frame_info.width);
memcpy(info.pJpegData , data , frame_info.height * frame_info.width);
info.dpi = true ;
}
else
{
info.pJpegData = data;
info.dpi = false ;
}
@ -428,7 +434,7 @@ void MultiFrameCapture::snaprun()
info.data_type = 0;
info.width = frame_info.width;
info.height = frame_info.height;
info.dpi = resolution_ ;
// printf("获取数据 width:%d height:%d is_first:%d is_last:%d DataLength:%d\r\n",frame_info.width,frame_info.height,info.first_frame,info.last_frame,info.DataLength);
m_glue.m_imageready(info);
@ -460,9 +466,14 @@ void MultiFrameCapture::snaprun()
int channels = color_mode_ == 1 ? 3 : 1;
int color_mode = video->HtCamGetColorMode();
int func_sig = 0;
int time_out = resolution_ == DPI_600 ? 1000 : 200; ///这个时间是根据每帧的数据量来进行调测的
int time_out = resolution_ == DPI_600 ? 1000 : 600; ///这个时间是根据每帧的数据量来进行调测的
int time_out_cnt = 0;
if (color_mode_)
{
time_out += 400;
}
uint32_t frame_num = 0;
uint32_t frame_cnt = 0;
@ -509,7 +520,7 @@ void MultiFrameCapture::snaprun()
if (b_stop_snap)
{
video->HtCamGetFrameNum(frame_num);
int ind = i; //已采集了的帧数
int ind = i + 1; //已采集了的帧数
int val = frame_num - ind; //剩余还未采集的帧数
while (val)
@ -517,7 +528,7 @@ void MultiFrameCapture::snaprun()
frame_info.last_frame = val == 1 ? true : false;
frame_info.frame_index = frame_num;
func_sig = snap_func(frame_info, channels,time_out ,ind);//同上面一样
//printf("-----------当前采集到第:[%d]帧 CIS总共采集[%d]帧 -------\r\n",ind,frame_num);
printf("-----------当前采集到第:[%d]帧 CIS总共采集[%d]帧 -------\r\n",ind,frame_num);
// if (func_sig == -1 )
// {
@ -532,7 +543,11 @@ void MultiFrameCapture::snaprun()
val--;
ind++;
//this_thread::sleep_for(std::chrono::milliseconds(mill));
if(m_config.params.dpi == 3)
{
int d = 80;
this_thread::sleep_for(std::chrono::milliseconds(d));
}
}
break;
}
@ -543,17 +558,21 @@ void MultiFrameCapture::snaprun()
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
if(m_config.params.dpi == 3)
this_thread::sleep_for(std::chrono::milliseconds(80));
else if(m_config.params.dpi == 2)
this_thread::sleep_for(std::chrono::milliseconds(5));
// else
{
int d = 80;
this_thread::sleep_for(std::chrono::milliseconds(d));
}
// else if(m_config.params.dpi == 2)
// this_thread::sleep_for(std::chrono::milliseconds(5));
// else
// this_thread::sleep_for(std::chrono::milliseconds(100));
}
uint32_t in=0;
StopWatch sw1;
video->HtCamStopVideoCapturing();
video->HtCamGetFrameNum(in);
printf("----------整张采集结束 总共采集帧数:%d 耗时:%f----------\r\n",in,sw.elapsed_ms());
printf("----------整张采集结束 总共采集帧数:%d 耗时:%f stop:%f----------\r\n",in,sw.elapsed_ms(),sw1.elapsed_ms());
m_cv_snapdone.notify_all();
b_end_snap = true;

View File

@ -113,7 +113,7 @@ private:
{PaperSize::G400_LETTER,SIZE{216,279}},
//{PaperSize::G400_LONGLETTER},
{PaperSize::G400_MAXSIZE,SIZE{210,297 * 2}},
{PaperSize::G400_AUTO,SIZE{210,(long)(297 * 1.5)}},
{PaperSize::G400_AUTO,SIZE{210,297}},
{PaperSize::G400_MAXAUTO,SIZE{210,(long)(297 * 1.5)}},
};

View File

@ -280,7 +280,7 @@ void Scanner::runScan()
break;
}
isRested = false;
if (!sensor->waitPaperIn(3000))
if (!sensor->waitPaperIn(3000))//
{
LOG("START SCAN LOOP S_EVT_JAM_IN S_EVT_JAM_IN S_EVT_JAM_IN\n");
if (!m_isDoublePaper)
@ -366,12 +366,22 @@ void Scanner::runScan()
delay = std::max(delay,80);
delay += dly_speed;
if (m_config.params.dpi == 3)
{
delay = 0;
}
//LOG("AutoSize sleep_for delay=%d \n",delay);
this_thread::sleep_for(std::chrono::milliseconds(delay));//200 80ms 600 260ms
}
if(b_autosize)
{
std::this_thread::sleep_for(std::chrono::milliseconds((5 - m_scaninfo.SpeedMode)*10*m_config.params.dpi));
int de = (5 - m_scaninfo.SpeedMode)*10*m_config.params.dpi;
if (de == 3)
{
de = 0;
}
std::this_thread::sleep_for(std::chrono::milliseconds(de));
if(sensor->isPaperAtScan())
{
m_glue.m_deviceevent((int)HG_ScannerStatus::PAPER_HOLE,"paper have hole");
@ -417,6 +427,8 @@ void Scanner::runScan()
printf("一张纸完成时间:%f\r\n",sw1.elapsed_ms());
if( m_config.params.dpi == 3)
this_thread::sleep_for(std::chrono::milliseconds(3000));
//else if( m_config.params.dpi == 1)
//this_thread::sleep_for(std::chrono::milliseconds(50));
}
m_DstScannum = 0;

View File

@ -252,10 +252,11 @@ int main(int argc, char *argv[])
LOG("onboard unkown command!\n");
}
}
StopWatch sw;
StopWatch sw1;
while (b_runloop)
{
StopWatch sw;
sw.reset();
if (!m_scanner->is_connect())
{
@ -301,8 +302,8 @@ int main(int argc, char *argv[])
if (evt != (int)HG_ScannerStatus::NORMAL && evt != (int)HG_ScannerStatus::STOP_SCAN)
{
sts.Data = m_scanner->GetEvent().code; // 扫描中途的事件能够被通知
printf("关闭V4L2 333\r\n");
m_scanner->close_v4l2();
// printf("关闭V4L2 333\r\n");
// m_scanner->close_v4l2();
}
else
{
@ -350,6 +351,9 @@ int main(int argc, char *argv[])
break;
case USBCommand::GET_IMAGE:
{
static int indx = 1;
printf("接受第二帧的时间:%f\r\n",sw.elapsed_ms());
HG_JpegCompressInfo info = m_scanner->GetImage();
// sw.reset();
@ -397,14 +401,15 @@ int main(int argc, char *argv[])
//dnasfree(info.pJpegData);
//tjFree(info.pJpegData);
//LOG("Free info.pJpegData done\n");
if (info.dpi == 0)
if (info.dpi)
{
//printf("111111111111111111111111111111111\r\n");
free(info.pJpegData);
}
printf("USB传输一帧时间 :%f \r\n",sw.elapsed_ms());
sw1.reset();
printf("USB传输一帧第[%d]次时间 :%f \r\n",indx,sw.elapsed_ms());
indx++;
}
}
break;

View File

@ -45,7 +45,7 @@ using namespace std;
#define SERIALNUM "HG1060A38001P1"
#else
#define FWVERSION "G340230429"
#define FWVERSION "G345230918"
#define SERIALNUM "HS6010A38001P1"
#endif
typedef struct
@ -285,7 +285,7 @@ struct ScannerGlue
struct V4L2_DATAINFO
{
cv::Mat mat;
//unsigned char *data;
unsigned char *data;
int width;
int height;
int pixtype;