调整速度 和读取json文件路径
This commit is contained in:
parent
34472cf740
commit
60827d3139
|
@ -7,37 +7,37 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
#define JSONPATH "/mnt/conf-disk/huago/cameraparam.json"
|
||||
#define JSONPATH "/mnt/flash-disk/huago/cameraparam.json"
|
||||
|
||||
#define TEXTLUT200COLORPATH "/mnt/conf-disk/huago/Textlut200clr.bmp"
|
||||
#define LUT200COLORPATH "/mnt/conf-disk/huago/lut200clr.bmp"
|
||||
#define LUT200_COLOR_BLACKPATH "/mnt/conf-disk/huago/lut200clrbw.bmp"
|
||||
#define LUT200_COLOR_WHITEPATH "/mnt/conf-disk/huago/lut200clrwhite.bmp"
|
||||
#define TEXTLUT200COLORPATH "/mnt/flash-disk/huago/Textlut200clr.bmp"
|
||||
#define LUT200COLORPATH "/mnt/flash-disk/huago/lut200clr.bmp"
|
||||
#define LUT200_COLOR_BLACKPATH "/mnt/flash-disk/huago/lut200clrbw.bmp"
|
||||
#define LUT200_COLOR_WHITEPATH "/mnt/flash-disk/huago/lut200clrwhite.bmp"
|
||||
|
||||
#define TEXTLUT200GRAYPATH "/mnt/conf-disk/huago/Textlut200gray.bmp"
|
||||
#define LUT200GRAYPATH "/mnt/conf-disk/huago/lut200gray.bmp"
|
||||
#define LUT200_GRAY_BLACKPATH "/mnt/conf-disk/huago/lut200graybw.bmp"
|
||||
#define LUT200_GRAY_WHITEPATH "/mnt/conf-disk/huago/lut200graywhite.bmp"
|
||||
#define TEXTLUT200GRAYPATH "/mnt/flash-disk/huago/Textlut200gray.bmp"
|
||||
#define LUT200GRAYPATH "/mnt/flash-disk/huago/lut200gray.bmp"
|
||||
#define LUT200_GRAY_BLACKPATH "/mnt/flash-disk/huago/lut200graybw.bmp"
|
||||
#define LUT200_GRAY_WHITEPATH "/mnt/flash-disk/huago/lut200graywhite.bmp"
|
||||
|
||||
#define TEXTLUT300COLORPATH "/mnt/conf-disk/huago/Textlut300clr.bmp"
|
||||
#define LUT300COLORPATH "/mnt/conf-disk/huago/lut300clr.bmp"
|
||||
#define LUT300_COLOR_BLACKPATH "/mnt/conf-disk/huago/lut300clrbw.bmp"
|
||||
#define LUT300_COLOR_WHITEPATH "/mnt/conf-disk/huago/lut300clrwhite.bmp"
|
||||
#define TEXTLUT300COLORPATH "/mnt/flash-disk/huago/Textlut300clr.bmp"
|
||||
#define LUT300COLORPATH "/mnt/flash-disk/huago/lut300clr.bmp"
|
||||
#define LUT300_COLOR_BLACKPATH "/mnt/flash-disk/huago/lut300clrbw.bmp"
|
||||
#define LUT300_COLOR_WHITEPATH "/mnt/flash-disk/huago/lut300clrwhite.bmp"
|
||||
|
||||
#define TEXTLUT300GRAYPATH "/mnt/conf-disk/huago/Textlut300gray.bmp"
|
||||
#define LUT300GRAYPATH "/mnt/conf-disk/huago/lut300gray.bmp"
|
||||
#define LUT300_GRAY_BLACKPATH "/mnt/conf-disk/huago/lut300graybw.bmp"
|
||||
#define LUT300_GRAY_WHITEPATH "/mnt/conf-disk/huago/lut300graywhite.bmp"
|
||||
#define TEXTLUT300GRAYPATH "/mnt/flash-disk/huago/Textlut300gray.bmp"
|
||||
#define LUT300GRAYPATH "/mnt/flash-disk/huago/lut300gray.bmp"
|
||||
#define LUT300_GRAY_BLACKPATH "/mnt/flash-disk/huago/lut300graybw.bmp"
|
||||
#define LUT300_GRAY_WHITEPATH "/mnt/flash-disk/huago/lut300graywhite.bmp"
|
||||
|
||||
#define LUT600COLORPATH "/mnt/conf-disk/huago/lut600clr.bmp"
|
||||
#define TEXTLUT600COLORPATH "/mnt/conf-disk/huago/Textlut600clr.bmp"
|
||||
#define LUT600_COLOR_BLACKPATH "/mnt/conf-disk/huago/lut600clrbw.bmp"
|
||||
#define LUT600_COLOR_WHITEPATH "/mnt/conf-disk/huago/lut600clrwhite.bmp"
|
||||
#define LUT600COLORPATH "/mnt/flash-disk/huago/lut600clr.bmp"
|
||||
#define TEXTLUT600COLORPATH "/mnt/flash-disk/huago/Textlut600clr.bmp"
|
||||
#define LUT600_COLOR_BLACKPATH "/mnt/flash-disk/huago/lut600clrbw.bmp"
|
||||
#define LUT600_COLOR_WHITEPATH "/mnt/flash-disk/huago/lut600clrwhite.bmp"
|
||||
|
||||
#define LUT600GRAYPATH "/mnt/conf-disk/huago/lut600gray.bmp"
|
||||
#define TEXTLUT600GRAYPATH "/mnt/conf-disk/huago/Textlut600gray.bmp"
|
||||
#define LUT600_GRAY_BLACKPATH "/mnt/conf-disk/huago/lut600graybw.bmp"
|
||||
#define LUT600_GRAY_WHITEPATH "/mnt/conf-disk/huago/lut600graywhite.bmp"
|
||||
#define LUT600GRAYPATH "/mnt/flash-disk/huago/lut600gray.bmp"
|
||||
#define TEXTLUT600GRAYPATH "/mnt/flash-disk/huago/Textlut600gray.bmp"
|
||||
#define LUT600_GRAY_BLACKPATH "/mnt/flash-disk/huago/lut600graybw.bmp"
|
||||
#define LUT600_GRAY_WHITEPATH "/mnt/flash-disk/huago/lut600graywhite.bmp"
|
||||
|
||||
CorrectParam::CorrectParam()
|
||||
{
|
||||
|
|
|
@ -469,9 +469,9 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
|||
if (!HtCamWaitVideoCapture(timeout))
|
||||
{
|
||||
camera_err("read frame time out\n");
|
||||
// if ((lastSucceedBufferIndex + 1) >= v4lBufferCount)
|
||||
// *pbuf = captureBufers[0].start;
|
||||
// else
|
||||
if ((lastSucceedBufferIndex + 1) >= v4lBufferCount)
|
||||
*pbuf = captureBufers[0].start;
|
||||
else
|
||||
*pbuf = captureBufers[lastSucceedBufferIndex + 1].start;
|
||||
|
||||
printf("timeout !!! captureBufers[lastSucceedBufferIndex].length :%d\r\n",captureBufers[lastSucceedBufferIndex].length);
|
||||
|
@ -500,7 +500,7 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
|||
int ret = 0;
|
||||
if (( ret = ioctl(videofd, VIDIOC_DQBUF, &buf)) == 0) //这个地方入栈失败好像下面就都不用操作了 ??? 毕竟已经丢帧了算
|
||||
{
|
||||
camera_print("*****DQBUF[%d] FINISH*****\n", buf.index);
|
||||
camera_dbg("*****DQBUF[%d] FINISH*****\n", buf.index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -509,7 +509,7 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
|||
}
|
||||
if (ioctl(videofd, VIDIOC_QBUF, &buf) == 0) //出栈一样
|
||||
{
|
||||
camera_print("************QBUF[%d] FINISH**************\n", buf.index);
|
||||
camera_dbg("************QBUF[%d] FINISH**************\n", buf.index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
#define SCANNER_SCAN_INFO_PATH "/mnt/conf-disk/huago/jsonconfig.json"
|
||||
#define SCANNER_SCAN_INFO_PATH "/mnt/flash-disk/huago/jsonconfig.json"
|
||||
using namespace std;
|
||||
using json = nlohmann::json;
|
||||
class JsonConfig
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
using json= nlohmann::json;
|
||||
|
||||
#ifndef WIN32
|
||||
#define MT_DRV888_CUO_PATH "/mnt/conf-disk/huago/drv888_cuo.json"
|
||||
#define MT_DRV888_ZOU_PATH "/mnt/conf-disk/huago/drv888_zou.json"
|
||||
#define MT_TMC216_CUO_PATH "/mnt/conf-disk/huago/tmc216_cuo.json"
|
||||
#define MT_TMC216_ZOU_PATH "/mnt/conf-disk/huago/tmc216_zou.json"
|
||||
#define MT_DRV888_CUO_PATH "/mnt/flash-disk/huago/drv888_cuo.json"
|
||||
#define MT_DRV888_ZOU_PATH "/mnt/flash-disk/huago/drv888_zou.json"
|
||||
#define MT_TMC216_CUO_PATH "/mnt/flash-disk/huago/tmc216_cuo.json"
|
||||
#define MT_TMC216_ZOU_PATH "/mnt/flash-disk/huago/tmc216_zou.json"
|
||||
#else
|
||||
#define MT_DRV888_CUO_PATH "drv888_cuo.json"
|
||||
#define MT_DRV888_ZOU_PATH "drv888_zou.json"
|
||||
|
|
|
@ -106,11 +106,11 @@ void MultiFrameCapture::snap()
|
|||
#ifndef TEST_SIMCAP
|
||||
std::lock_guard<std::mutex> m_lock(m_mtx_snap);
|
||||
b_stop_snap = b_end_snap = false;
|
||||
// if (resolution_ == DPI_600)
|
||||
// {
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(30));
|
||||
// }
|
||||
|
||||
|
||||
if (m_config.params.dpi == 3)
|
||||
this_thread::sleep_for(std::chrono::milliseconds(160));
|
||||
else if(m_config.params.dpi == 2)
|
||||
this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
|
||||
video->HtCamStartVideoCapturing();
|
||||
|
||||
|
@ -150,7 +150,7 @@ uint32_t MultiFrameCapture::compute_frame(int paper_size,int dpi)
|
|||
{
|
||||
SIZE size = GetPaperSize((PaperSize)paper_size,dpi);
|
||||
int val = ceil((float)size.cy /(float)pixels_height_);
|
||||
return val + 1;
|
||||
return val;
|
||||
}
|
||||
void MultiFrameCapture::compute_height(int width,int height)
|
||||
{
|
||||
|
@ -194,8 +194,8 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
|
|||
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
|
||||
|
||||
|
||||
int height = resolution_ == DPI_600 ? 1200 : 660;
|
||||
|
||||
//int height = resolution_ == DPI_600 ? 342 : 900;
|
||||
int height = config.params.dpi == 3 ? 342 :(config.params.dpi == 2?900:651);
|
||||
compute_height(WIDTH , height);
|
||||
|
||||
video->HtCamSetClolr(color_mode_);
|
||||
|
@ -214,7 +214,12 @@ 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); //多设一帧
|
||||
uint32_t cnt = compute_frame(paper_size_ , val) ; //多设一帧
|
||||
if (m_config.params.dpi == 3)
|
||||
{
|
||||
cnt +=1 ;
|
||||
}
|
||||
|
||||
video->HtCamSetFrameCnt(cnt);
|
||||
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
|
||||
}
|
||||
|
@ -377,18 +382,21 @@ void MultiFrameCapture::snaprun()
|
|||
StopWatch sw;
|
||||
sw.reset();
|
||||
unsigned char *data = NULL;
|
||||
printf("设置超时时间:%d\r\n",time_out);
|
||||
//printf("设置超时时间:%d\r\n",time_out);
|
||||
int ret = video->HtCamReadCaptureFrame((void **)&data, time_out);
|
||||
time_out = 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;
|
||||
uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数
|
||||
printf("--------------fpga send line ------------:%d \r\n",sendLine);
|
||||
|
||||
if (data)
|
||||
{
|
||||
|
||||
//cv::Mat mat = cv::Mat(317, 15552, CV_8UC1, data, cv::Mat::AUTO_STEP);
|
||||
//cv::Mat mat = cv::Mat(frame_info.height, frame_info.width, CV_8UC1, data, cv::Mat::AUTO_STEP);
|
||||
|
||||
//cv::imwrite("/home/root/test.bmp", mat);
|
||||
// printf("获取数据 width:%d height:%d \r\n",frame_info.width,frame_info.height);
|
||||
|
||||
//cv::imwrite("/home/root/test+_" + to_string(i)+".bmp", mat);
|
||||
// printf("--------------frame_index------------:%d\r\n",frame_index);
|
||||
if (i == 2)
|
||||
{
|
||||
|
@ -402,9 +410,16 @@ void MultiFrameCapture::snaprun()
|
|||
//HG_JpegCompressInfo info = cmp.GetCompressedImg(mat);
|
||||
|
||||
HG_JpegCompressInfo info ;
|
||||
if (m_config.params.dpi == 3)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
info.pJpegData = data;
|
||||
|
||||
|
||||
info.pJpegData = data;//(unsigned char *)malloc(frame_info.height * frame_info.width);
|
||||
//memcpy(info.pJpegData , data , frame_info.height * frame_info.width);
|
||||
|
||||
info.DataLength = frame_info.width * frame_info.height;
|
||||
info.first_frame = frame_info.first_frame;
|
||||
|
@ -413,8 +428,8 @@ void MultiFrameCapture::snaprun()
|
|||
info.data_type = 0;
|
||||
info.width = frame_info.width;
|
||||
info.height = frame_info.height;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
@ -445,7 +460,7 @@ 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 ? 400 : 200; ///这个时间是根据每帧的数据量来进行调测的
|
||||
int time_out = resolution_ == DPI_600 ? 1000 : 200; ///这个时间是根据每帧的数据量来进行调测的
|
||||
int time_out_cnt = 0;
|
||||
|
||||
uint32_t frame_num = 0;
|
||||
|
@ -502,7 +517,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 )
|
||||
// {
|
||||
|
@ -527,8 +542,12 @@ void MultiFrameCapture::snaprun()
|
|||
////////////////////////////采集过快会导致队列堆积/////////////////////////
|
||||
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
|
||||
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
|
||||
// if(resolution_ == DPI_600)
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
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
|
||||
// this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
uint32_t in=0;
|
||||
|
||||
|
|
|
@ -426,7 +426,8 @@ void Scanner::runScan()
|
|||
|
||||
int t_delay = m_config.params.dpi == 0x02 ? 150 : (m_config.params.dpi == 0x03 ? 350 : 100);
|
||||
|
||||
//this_thread::sleep_for(std::chrono::milliseconds(2000)); //走纸多转一会儿 确保扫描传感器过了之后 纸能出完
|
||||
this_thread::sleep_for(std::chrono::milliseconds(t_delay)); //走纸多转一会儿 确保扫描传感器过了之后 纸能出完
|
||||
|
||||
capturer->setFanMode(0);
|
||||
|
||||
|
||||
|
|
13
main.cpp
13
main.cpp
|
@ -355,8 +355,8 @@ int main(int argc, char *argv[])
|
|||
// sw.reset();
|
||||
if (info.pJpegData != nullptr && info.DataLength != 0)
|
||||
{
|
||||
int tt = m_scanner->write_bulk((void *)&info, sizeof(int) * 7);
|
||||
printf("USB传输第一次write_bulk时间 :%f \r\n",sw.elapsed_ms());
|
||||
int tt = m_scanner->write_bulk((void *)&info, sizeof(int) * 8);
|
||||
//printf("USB传输第一次write_bulk时间 :%f \r\n",sw.elapsed_ms());
|
||||
// tt = m_scanner->write_bulk(info.pJpegData, info.DataLength);
|
||||
// //free(info.pJpegData);
|
||||
// printf("USB传输第二次write_bulk时间 :%f \r\n",sw.elapsed_ms());
|
||||
|
@ -397,6 +397,13 @@ int main(int argc, char *argv[])
|
|||
//dnasfree(info.pJpegData);
|
||||
//tjFree(info.pJpegData);
|
||||
//LOG("Free info.pJpegData done\n");
|
||||
if (info.dpi == 0)
|
||||
{
|
||||
//printf("111111111111111111111111111111111\r\n");
|
||||
free(info.pJpegData);
|
||||
}
|
||||
|
||||
|
||||
printf("USB传输一帧时间 :%f \r\n",sw.elapsed_ms());
|
||||
}
|
||||
}
|
||||
|
@ -782,7 +789,7 @@ int main(int argc, char *argv[])
|
|||
int dpi = flatinfo.params.dpi == 0x01 ? 200 : (flatinfo.params.dpi == 0x02 ? 300 : 600);
|
||||
std::string mode = flatinfo.params.colormode ? "clr" : "gray";
|
||||
std::string is_white_lut = flatinfo.params.is_whiteimage ? "white" : "bw";
|
||||
std::string lut_path = "/mnt/conf-disk/huago/lut" + std::to_string(dpi) + mode + is_white_lut + ".bmp";
|
||||
std::string lut_path = "/mnt/flash-disk/huago/lut" + std::to_string(dpi) + mode + is_white_lut + ".bmp";
|
||||
lut_item.open(lut_path, std::ios_base::in | std::ios_base::binary);
|
||||
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ struct HG_JpegCompressInfo
|
|||
unsigned int DataLength;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int dpi;
|
||||
unsigned char *pJpegData;
|
||||
//cv::Mat mat;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue