调整200 300 dpi速度模式
This commit is contained in:
parent
60827d3139
commit
bc0fd68764
|
@ -195,7 +195,7 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
|
||||||
|
|
||||||
|
|
||||||
//int height = resolution_ == DPI_600 ? 342 : 900;
|
//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);
|
compute_height(WIDTH , height);
|
||||||
|
|
||||||
video->HtCamSetClolr(color_mode_);
|
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);
|
int val = config.params.dpi == 3 ? 600 :(config.params.dpi == 2?300:200);
|
||||||
printf("val = %d\r\n",val);
|
printf("val = %d\r\n",val);
|
||||||
uint32_t cnt = compute_frame(paper_size_ , val) ; //多设一帧
|
uint32_t cnt = compute_frame(paper_size_ , val) ; //多设一帧
|
||||||
if (m_config.params.dpi == 3)
|
// if (m_config.params.dpi == 3)
|
||||||
{
|
// {
|
||||||
cnt +=1 ;
|
// cnt +=1 ;
|
||||||
}
|
// }
|
||||||
|
|
||||||
video->HtCamSetFrameCnt(cnt);
|
video->HtCamSetFrameCnt(cnt);
|
||||||
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
|
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
|
||||||
|
@ -288,6 +288,7 @@ void MultiFrameCapture::waitsnapdone(int state)
|
||||||
m_frameinfos.Put(info);
|
m_frameinfos.Put(info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sw.reset();
|
||||||
std::unique_lock<std::mutex> lock(m_mtx_snapdone);
|
std::unique_lock<std::mutex> lock(m_mtx_snapdone);
|
||||||
m_cv_snapdone.wait(lock);
|
m_cv_snapdone.wait(lock);
|
||||||
b_end_snap = true;
|
b_end_snap = true;
|
||||||
|
@ -387,7 +388,7 @@ void MultiFrameCapture::snaprun()
|
||||||
int t = resolution_ == DPI_600 ? sw.elapsed_ms() + 600 : sw.elapsed_ms() + 20;
|
int t = resolution_ == DPI_600 ? sw.elapsed_ms() + 600 : sw.elapsed_ms() + 20;
|
||||||
time_out = t;
|
time_out = t;
|
||||||
uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数
|
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)
|
if (data)
|
||||||
{
|
{
|
||||||
|
@ -415,9 +416,14 @@ void MultiFrameCapture::snaprun()
|
||||||
printf("600做拷贝\r\n");
|
printf("600做拷贝\r\n");
|
||||||
info.pJpegData = (unsigned char *)malloc(frame_info.height * frame_info.width);
|
info.pJpegData = (unsigned char *)malloc(frame_info.height * frame_info.width);
|
||||||
memcpy(info.pJpegData , data , frame_info.height * frame_info.width);
|
memcpy(info.pJpegData , data , frame_info.height * frame_info.width);
|
||||||
|
info.dpi = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
info.pJpegData = data;
|
info.pJpegData = data;
|
||||||
|
info.dpi = false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -428,7 +434,7 @@ void MultiFrameCapture::snaprun()
|
||||||
info.data_type = 0;
|
info.data_type = 0;
|
||||||
info.width = frame_info.width;
|
info.width = frame_info.width;
|
||||||
info.height = frame_info.height;
|
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);
|
// 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);
|
m_glue.m_imageready(info);
|
||||||
|
@ -460,9 +466,14 @@ void MultiFrameCapture::snaprun()
|
||||||
int channels = color_mode_ == 1 ? 3 : 1;
|
int channels = color_mode_ == 1 ? 3 : 1;
|
||||||
int color_mode = video->HtCamGetColorMode();
|
int color_mode = video->HtCamGetColorMode();
|
||||||
int func_sig = 0;
|
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;
|
int time_out_cnt = 0;
|
||||||
|
|
||||||
|
if (color_mode_)
|
||||||
|
{
|
||||||
|
time_out += 400;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t frame_num = 0;
|
uint32_t frame_num = 0;
|
||||||
uint32_t frame_cnt = 0;
|
uint32_t frame_cnt = 0;
|
||||||
|
|
||||||
|
@ -509,7 +520,7 @@ void MultiFrameCapture::snaprun()
|
||||||
if (b_stop_snap)
|
if (b_stop_snap)
|
||||||
{
|
{
|
||||||
video->HtCamGetFrameNum(frame_num);
|
video->HtCamGetFrameNum(frame_num);
|
||||||
int ind = i; //已采集了的帧数
|
int ind = i + 1; //已采集了的帧数
|
||||||
int val = frame_num - ind; //剩余还未采集的帧数
|
int val = frame_num - ind; //剩余还未采集的帧数
|
||||||
|
|
||||||
while (val)
|
while (val)
|
||||||
|
@ -517,7 +528,7 @@ void MultiFrameCapture::snaprun()
|
||||||
frame_info.last_frame = val == 1 ? true : false;
|
frame_info.last_frame = val == 1 ? true : false;
|
||||||
frame_info.frame_index = frame_num;
|
frame_info.frame_index = frame_num;
|
||||||
func_sig = snap_func(frame_info, channels,time_out ,ind);//同上面一样
|
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 )
|
// if (func_sig == -1 )
|
||||||
// {
|
// {
|
||||||
|
@ -532,7 +543,11 @@ void MultiFrameCapture::snaprun()
|
||||||
val--;
|
val--;
|
||||||
ind++;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -543,17 +558,21 @@ void MultiFrameCapture::snaprun()
|
||||||
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
|
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
|
||||||
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
|
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
|
||||||
if(m_config.params.dpi == 3)
|
if(m_config.params.dpi == 3)
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(80));
|
{
|
||||||
else if(m_config.params.dpi == 2)
|
int d = 80;
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(5));
|
this_thread::sleep_for(std::chrono::milliseconds(d));
|
||||||
// else
|
}
|
||||||
|
|
||||||
|
// else if(m_config.params.dpi == 2)
|
||||||
// this_thread::sleep_for(std::chrono::milliseconds(5));
|
// this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
|
// else
|
||||||
|
// this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
uint32_t in=0;
|
uint32_t in=0;
|
||||||
|
StopWatch sw1;
|
||||||
video->HtCamStopVideoCapturing();
|
video->HtCamStopVideoCapturing();
|
||||||
video->HtCamGetFrameNum(in);
|
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();
|
m_cv_snapdone.notify_all();
|
||||||
b_end_snap = true;
|
b_end_snap = true;
|
||||||
|
|
|
@ -113,7 +113,7 @@ private:
|
||||||
{PaperSize::G400_LETTER,SIZE{216,279}},
|
{PaperSize::G400_LETTER,SIZE{216,279}},
|
||||||
//{PaperSize::G400_LONGLETTER},
|
//{PaperSize::G400_LONGLETTER},
|
||||||
{PaperSize::G400_MAXSIZE,SIZE{210,297 * 2}},
|
{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)}},
|
{PaperSize::G400_MAXAUTO,SIZE{210,(long)(297 * 1.5)}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
16
Scanner.cpp
16
Scanner.cpp
|
@ -280,7 +280,7 @@ void Scanner::runScan()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
isRested = false;
|
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");
|
LOG("START SCAN LOOP S_EVT_JAM_IN S_EVT_JAM_IN S_EVT_JAM_IN\n");
|
||||||
if (!m_isDoublePaper)
|
if (!m_isDoublePaper)
|
||||||
|
@ -366,12 +366,22 @@ void Scanner::runScan()
|
||||||
delay = std::max(delay,80);
|
delay = std::max(delay,80);
|
||||||
|
|
||||||
delay += dly_speed;
|
delay += dly_speed;
|
||||||
|
if (m_config.params.dpi == 3)
|
||||||
|
{
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//LOG("AutoSize sleep_for delay=%d \n",delay);
|
//LOG("AutoSize sleep_for delay=%d \n",delay);
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(delay));//200 80ms 600 260ms
|
this_thread::sleep_for(std::chrono::milliseconds(delay));//200 80ms 600 260ms
|
||||||
}
|
}
|
||||||
if(b_autosize)
|
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())
|
if(sensor->isPaperAtScan())
|
||||||
{
|
{
|
||||||
m_glue.m_deviceevent((int)HG_ScannerStatus::PAPER_HOLE,"paper have hole");
|
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());
|
printf("一张纸完成时间:%f\r\n",sw1.elapsed_ms());
|
||||||
if( m_config.params.dpi == 3)
|
if( m_config.params.dpi == 3)
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(3000));
|
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;
|
m_DstScannum = 0;
|
||||||
|
|
19
main.cpp
19
main.cpp
|
@ -252,10 +252,11 @@ int main(int argc, char *argv[])
|
||||||
LOG("onboard unkown command!\n");
|
LOG("onboard unkown command!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StopWatch sw;
|
||||||
|
StopWatch sw1;
|
||||||
while (b_runloop)
|
while (b_runloop)
|
||||||
{
|
{
|
||||||
StopWatch sw;
|
|
||||||
sw.reset();
|
sw.reset();
|
||||||
if (!m_scanner->is_connect())
|
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)
|
if (evt != (int)HG_ScannerStatus::NORMAL && evt != (int)HG_ScannerStatus::STOP_SCAN)
|
||||||
{
|
{
|
||||||
sts.Data = m_scanner->GetEvent().code; // 扫描中途的事件能够被通知
|
sts.Data = m_scanner->GetEvent().code; // 扫描中途的事件能够被通知
|
||||||
printf("关闭V4L2 333\r\n");
|
// printf("关闭V4L2 333\r\n");
|
||||||
m_scanner->close_v4l2();
|
// m_scanner->close_v4l2();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -350,6 +351,9 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case USBCommand::GET_IMAGE:
|
case USBCommand::GET_IMAGE:
|
||||||
{
|
{
|
||||||
|
static int indx = 1;
|
||||||
|
|
||||||
|
printf("接受第二帧的时间:%f\r\n",sw.elapsed_ms());
|
||||||
HG_JpegCompressInfo info = m_scanner->GetImage();
|
HG_JpegCompressInfo info = m_scanner->GetImage();
|
||||||
|
|
||||||
// sw.reset();
|
// sw.reset();
|
||||||
|
@ -397,14 +401,15 @@ int main(int argc, char *argv[])
|
||||||
//dnasfree(info.pJpegData);
|
//dnasfree(info.pJpegData);
|
||||||
//tjFree(info.pJpegData);
|
//tjFree(info.pJpegData);
|
||||||
//LOG("Free info.pJpegData done\n");
|
//LOG("Free info.pJpegData done\n");
|
||||||
if (info.dpi == 0)
|
if (info.dpi)
|
||||||
{
|
{
|
||||||
//printf("111111111111111111111111111111111\r\n");
|
//printf("111111111111111111111111111111111\r\n");
|
||||||
free(info.pJpegData);
|
free(info.pJpegData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw1.reset();
|
||||||
printf("USB传输一帧时间 :%f \r\n",sw.elapsed_ms());
|
printf("USB传输一帧第[%d]次时间 :%f \r\n",indx,sw.elapsed_ms());
|
||||||
|
indx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -45,7 +45,7 @@ using namespace std;
|
||||||
#define SERIALNUM "HG1060A38001P1"
|
#define SERIALNUM "HG1060A38001P1"
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define FWVERSION "G340230429"
|
#define FWVERSION "G345230918"
|
||||||
#define SERIALNUM "HS6010A38001P1"
|
#define SERIALNUM "HS6010A38001P1"
|
||||||
#endif
|
#endif
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -285,7 +285,7 @@ struct ScannerGlue
|
||||||
struct V4L2_DATAINFO
|
struct V4L2_DATAINFO
|
||||||
{
|
{
|
||||||
cv::Mat mat;
|
cv::Mat mat;
|
||||||
//unsigned char *data;
|
unsigned char *data;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int pixtype;
|
int pixtype;
|
||||||
|
|
Loading…
Reference in New Issue