出图流程调整
This commit is contained in:
parent
c48acfbbdc
commit
34472cf740
|
@ -15,6 +15,12 @@ union CamZ_Reg_2Short
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union CamZ_Reg_2char
|
||||||
|
{
|
||||||
|
unsigned char NChar[2];
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
union CamZ_Reg_4
|
union CamZ_Reg_4
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
@ -55,6 +61,7 @@ union CamZ_Reg_4_New
|
||||||
unsigned int clr_exp:1; //曝光清除 低电平 有效
|
unsigned int clr_exp:1; //曝光清除 低电平 有效
|
||||||
unsigned int soft_rst_n:1; //软复位
|
unsigned int soft_rst_n:1; //软复位
|
||||||
unsigned int en_pattern:1; //使能自测试数据
|
unsigned int en_pattern:1; //使能自测试数据
|
||||||
|
unsigned int en_line:1; //行计数
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
CuoZhiMotor::CuoZhiMotor()
|
CuoZhiMotor::CuoZhiMotor()
|
||||||
: Motor(motorPorts_Cuozhi)
|
: Motor(motorPorts_Cuozhi)
|
||||||
{
|
{
|
||||||
auto t_smbtype = smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;//smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
||||||
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, 4, 1, 1);
|
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, 4, 1, 1);
|
||||||
speedConfig();
|
speedConfig();
|
||||||
mspCuozhiFeeding = {.finalPeriod = 1427500, .Fmin = 2027500, .stepnum = 30, .a = 100, .offset = 4, .finalDelay = 3000};
|
mspCuozhiFeeding = {.finalPeriod = 1427500, .Fmin = 2027500, .stepnum = 30, .a = 100, .offset = 4, .finalDelay = 3000};
|
||||||
|
@ -100,7 +100,7 @@ void CuoZhiMotor::feeding()
|
||||||
|
|
||||||
void CuoZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
void CuoZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
||||||
{
|
{
|
||||||
auto t_smbtype = smbtype == SMBType::MB_DRV_8825 ? MotorConfig::MTBDType::MT_DRV : MotorConfig::MTBDType::MT_TMC;
|
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;//smbtype == SMBType::MB_DRV_8825 ? MotorConfig::MTBDType::MT_DRV : MotorConfig::MTBDType::MT_TMC;
|
||||||
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, speed, colormode, dpi);
|
m_cuoparamex = m_mtconfig->GetMotorSpeedParam(false, t_smbtype, speed, colormode, dpi);
|
||||||
speedConfig();
|
speedConfig();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void CuoZhiMotor::speedRecover()
|
||||||
|
|
||||||
void CuoZhiMotor::speedConfig()
|
void CuoZhiMotor::speedConfig()
|
||||||
{
|
{
|
||||||
LOG("CuoZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ",
|
printf("CuoZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ",
|
||||||
m_cuoparamex.speed,
|
m_cuoparamex.speed,
|
||||||
m_cuoparamex.dpi,
|
m_cuoparamex.dpi,
|
||||||
m_cuoparamex.colormode,
|
m_cuoparamex.colormode,
|
||||||
|
|
|
@ -96,15 +96,16 @@ HCamDevice::HCamDevice()
|
||||||
memfd = 0;
|
memfd = 0;
|
||||||
subDeviceName = "/dev/v4l-subdev0";
|
subDeviceName = "/dev/v4l-subdev0";
|
||||||
videoDevName = "/dev/video0";
|
videoDevName = "/dev/video0";
|
||||||
subDevicefd = 0;
|
subDevicefd = -1;
|
||||||
videofd = 0;
|
videofd = -1;
|
||||||
|
|
||||||
v4lWidth = 5184;//@300dpi 5184 @600dpi 5184*2
|
v4lWidth = 5184;//@300dpi 5184 @600dpi 5184*2
|
||||||
v4lHeight = 513 ;//* 3;//color_h/gray_h = 3 比如:目标复原图像高度为128 则灰度需要FPGA采集128 彩色采集128*3
|
v4lHeight = 513 ;//* 3;//color_h/gray_h = 3 比如:目标复原图像高度为128 则灰度需要FPGA采集128 彩色采集128*3
|
||||||
v4lBufferCount = 30;
|
v4lBufferCount = 32;
|
||||||
v4l2buftype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
v4l2buftype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||||
nplanes = 1; // only use one plane
|
nplanes = 1; // only use one plane
|
||||||
drivertype = V4L2_CAP_VIDEO_CAPTURE_MPLANE;
|
drivertype = V4L2_CAP_VIDEO_CAPTURE_MPLANE;
|
||||||
|
//drivertype == V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
v4l2memtype = V4L2_MEMORY_MMAP;
|
v4l2memtype = V4L2_MEMORY_MMAP;
|
||||||
captureBufers = NULL;
|
captureBufers = NULL;
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ HCamDevice::HCamDevice()
|
||||||
HtCamWriteFpgaRegs(16, VSNP | value);
|
HtCamWriteFpgaRegs(16, VSNP | value);
|
||||||
}
|
}
|
||||||
|
|
||||||
HtCamWriteFpgaRegs(16, 0x0B0B); //相位
|
HtCamWriteFpgaRegs(16, 0x0A0A); //相位0x0B0B 2023-9-4 0A0B, 2023-9-11 0a0a
|
||||||
|
|
||||||
|
|
||||||
//HtCamChangeTriggerInAndEXt(1);
|
//HtCamChangeTriggerInAndEXt(1);
|
||||||
|
@ -241,6 +242,12 @@ int HCamDevice::open_device(int width , int height)
|
||||||
}
|
}
|
||||||
int HCamDevice::close_device()
|
int HCamDevice::close_device()
|
||||||
{
|
{
|
||||||
|
printf("videofd:%d subDevicefd:%d\r\n",videofd,subDevicefd);
|
||||||
|
if (videofd == -1 || subDevicefd == -1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
HtCamStopVideoCapturing();
|
HtCamStopVideoCapturing();
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -252,9 +259,11 @@ int HCamDevice::close_device()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = close(videofd);
|
ret = close(videofd);
|
||||||
|
videofd = -1;
|
||||||
camera_print("close video_fd :%s is:[%s] \n",videoDevName.c_str(),ret < 0 ? "fail" : "succeed");
|
camera_print("close video_fd :%s is:[%s] \n",videoDevName.c_str(),ret < 0 ? "fail" : "succeed");
|
||||||
|
|
||||||
ret = close(subDevicefd);
|
ret = close(subDevicefd);
|
||||||
|
subDevicefd = -1;
|
||||||
camera_print("close sub_device_fd :%s is:[%s] \n",subDeviceName.c_str(),ret < 0 ? "fail" : "succeed");
|
camera_print("close sub_device_fd :%s is:[%s] \n",subDeviceName.c_str(),ret < 0 ? "fail" : "succeed");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -460,7 +469,12 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
||||||
if (!HtCamWaitVideoCapture(timeout))
|
if (!HtCamWaitVideoCapture(timeout))
|
||||||
{
|
{
|
||||||
camera_err("read frame time out\n");
|
camera_err("read frame time out\n");
|
||||||
|
// 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);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
struct v4l2_buffer buf;
|
struct v4l2_buffer buf;
|
||||||
|
@ -486,7 +500,7 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (( ret = ioctl(videofd, VIDIOC_DQBUF, &buf)) == 0) //这个地方入栈失败好像下面就都不用操作了 ??? 毕竟已经丢帧了算
|
if (( ret = ioctl(videofd, VIDIOC_DQBUF, &buf)) == 0) //这个地方入栈失败好像下面就都不用操作了 ??? 毕竟已经丢帧了算
|
||||||
{
|
{
|
||||||
camera_dbg("*****DQBUF[%d] FINISH*****\n", buf.index);
|
camera_print("*****DQBUF[%d] FINISH*****\n", buf.index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -495,7 +509,7 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout)
|
||||||
}
|
}
|
||||||
if (ioctl(videofd, VIDIOC_QBUF, &buf) == 0) //出栈一样
|
if (ioctl(videofd, VIDIOC_QBUF, &buf) == 0) //出栈一样
|
||||||
{
|
{
|
||||||
camera_dbg("************QBUF[%d] FINISH**************\n", buf.index);
|
camera_print("************QBUF[%d] FINISH**************\n", buf.index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -603,6 +617,7 @@ void HCamDevice::HtCamChangeAdjustPhase(uint16_t times, uint8_t dir)
|
||||||
// This function is prohibited
|
// This function is prohibited
|
||||||
int HCamDevice::HtCamStartSampling()
|
int HCamDevice::HtCamStartSampling()
|
||||||
{
|
{
|
||||||
|
//ioctl(subDevicefd,0x40,NULL);
|
||||||
uint32_t *CamReg;
|
uint32_t *CamReg;
|
||||||
if (virBaseAddr == NULL)
|
if (virBaseAddr == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -626,6 +641,7 @@ int HCamDevice::HtCamStopSampling()
|
||||||
CamReg[10] |= (HT_CAM_REG_CR_STOPSAMPLE_MASK);
|
CamReg[10] |= (HT_CAM_REG_CR_STOPSAMPLE_MASK);
|
||||||
CamReg[10] &= ~(HT_CAM_REG_CR_STOPSAMPLE_MASK);
|
CamReg[10] &= ~(HT_CAM_REG_CR_STOPSAMPLE_MASK);
|
||||||
|
|
||||||
|
//ioctl(subDevicefd,0x40,NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,6 +763,7 @@ int HCamDevice::init_video_buffer()
|
||||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
|
||||||
else
|
else
|
||||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
req.memory = v4l2memtype;
|
req.memory = v4l2memtype;
|
||||||
|
|
||||||
printf("I GET THE drivertype %d\n",drivertype);
|
printf("I GET THE drivertype %d\n",drivertype);
|
||||||
|
@ -759,7 +776,7 @@ int HCamDevice::init_video_buffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
v4lBufferCount = req.count;
|
v4lBufferCount = req.count;
|
||||||
camera_dbg(" reqbuf number is %d\n", v4lBufferCount);
|
camera_print(" reqbuf number is %d\n", v4lBufferCount);
|
||||||
|
|
||||||
if (captureBufers != NULL)
|
if (captureBufers != NULL)
|
||||||
free(captureBufers);
|
free(captureBufers);
|
||||||
|
@ -1179,10 +1196,10 @@ void HCamDevice::HtCamGetStSp(uint32_t &start_smaple)
|
||||||
|
|
||||||
void HCamDevice::HtCamSetVsnpTime(int color)
|
void HCamDevice::HtCamSetVsnpTime(int color)
|
||||||
{
|
{
|
||||||
CamZ_Reg_2Short st_sp;
|
CamZ_Reg_2char st_sp;
|
||||||
st_sp.value = HtCamReadFpgaRegs(0x10);
|
st_sp.value = HtCamReadFpgaRegs(0x10);
|
||||||
st_sp.NShort[0] = color;
|
st_sp.NChar[0] = color;
|
||||||
st_sp.NShort[1] = 0;
|
st_sp.NChar[1] = color;
|
||||||
HtCamWriteFpgaRegs(0x10 , st_sp.value);
|
HtCamWriteFpgaRegs(0x10 , st_sp.value);
|
||||||
}
|
}
|
||||||
void HCamDevice::HtCamSetFrameCnt(uint32_t val)
|
void HCamDevice::HtCamSetFrameCnt(uint32_t val)
|
||||||
|
@ -1270,6 +1287,7 @@ void HCamDevice::HtCamSetClolr(int color)
|
||||||
reg_4.color_mode = color;
|
reg_4.color_mode = color;
|
||||||
reg_4.en_frameset = 1; //帧计数默认开启
|
reg_4.en_frameset = 1; //帧计数默认开启
|
||||||
reg_4.en_pattern = 0;
|
reg_4.en_pattern = 0;
|
||||||
|
reg_4.en_line = 1;
|
||||||
HtCamWriteFpgaRegs(0x04,reg_4.value);
|
HtCamWriteFpgaRegs(0x04,reg_4.value);
|
||||||
|
|
||||||
// HtCamSetStSp(color);
|
// HtCamSetStSp(color);
|
||||||
|
|
|
@ -51,12 +51,12 @@ public:
|
||||||
|
|
||||||
void HtCamSetPeriod(uint32_t *reg_value); //设置扫描仪传感器占空比
|
void HtCamSetPeriod(uint32_t *reg_value); //设置扫描仪传感器占空比
|
||||||
|
|
||||||
void HtCamGetFrameCnt(uint32_t &val);//获取设置采集的帧数
|
void HtCamGetFrameCnt(uint32_t &val);//获取设置采集的帧数 需要采集的帧数,设置为0x05表示采集六帧后停止
|
||||||
void HtCamGetFrameNum(uint32_t &val);//获取当前已经采集到的第几帧
|
void HtCamSetFrameCnt(uint32_t val);//需要采集的帧数,设置为0x05表示采集六帧后停止
|
||||||
|
|
||||||
|
void HtCamGetFrameNum(uint32_t &val);//采集到的帧数,如果为0x0005则表示采集到了5帧
|
||||||
|
|
||||||
|
|
||||||
void HtCamSetFrameCnt(uint32_t val);//设置需要采集的帧数
|
|
||||||
|
|
||||||
uint32_t HtCamReadFpgaRegs(uint8_t reg_addr); //读取寄存器值
|
uint32_t HtCamReadFpgaRegs(uint8_t reg_addr); //读取寄存器值
|
||||||
void HtCamSetSpTime(uint32_t reg_value,uint32_t val);//0x03 reg_value //灰度内触发间隔 val读写间隔//影响到图像得拉伸 //2023-8-28 val 改为曝光间隔,
|
void HtCamSetSpTime(uint32_t reg_value,uint32_t val);//0x03 reg_value //灰度内触发间隔 val读写间隔//影响到图像得拉伸 //2023-8-28 val 改为曝光间隔,
|
||||||
void HtCamGetSpTime(uint32_t ®_value); //获取当前sptime
|
void HtCamGetSpTime(uint32_t ®_value); //获取当前sptime
|
||||||
|
|
|
@ -12,6 +12,7 @@ class FpgaComm;
|
||||||
class ICapturer
|
class ICapturer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
bool is_image_ = false;
|
||||||
ICapturer() {}
|
ICapturer() {}
|
||||||
|
|
||||||
virtual ~ICapturer() {}
|
virtual ~ICapturer() {}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
virtual ScannerScanInfo GetScanInfo() = 0;
|
virtual ScannerScanInfo GetScanInfo() = 0;
|
||||||
virtual void SetLEDStatus(LedStatus status) = 0;
|
virtual void SetLEDStatus(LedStatus status) = 0;
|
||||||
|
|
||||||
|
virtual void close_v4l2()= 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlockingQueue<HG_JpegCompressInfo> m_images;
|
BlockingQueue<HG_JpegCompressInfo> m_images;
|
||||||
BlockingQueue<HG_Msg> m_scannerEvents;
|
BlockingQueue<HG_Msg> m_scannerEvents;
|
||||||
|
|
|
@ -36,10 +36,10 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue,std::shared_ptr<FpgaComm>
|
||||||
|
|
||||||
////////////////默认300dpi 和灰度设置
|
////////////////默认300dpi 和灰度设置
|
||||||
resolution_(DPI_300),
|
resolution_(DPI_300),
|
||||||
cis_width_(WIDTH),
|
v4l2_width_(WIDTH),
|
||||||
cis_height_(HEIGHT),
|
v4l2_height_(HEIGHT),
|
||||||
pixels_width_(WIDTH),
|
pixels_width_(WIDTH),
|
||||||
pixels_height_(HEIGHT),
|
fpga_height_(HEIGHT),
|
||||||
paper_size_((unsigned int)PaperSize::G400_AUTO),
|
paper_size_((unsigned int)PaperSize::G400_AUTO),
|
||||||
color_mode_(GRAY),
|
color_mode_(GRAY),
|
||||||
is_correct_(0),
|
is_correct_(0),
|
||||||
|
@ -88,7 +88,7 @@ void MultiFrameCapture::SetParent(void *scanner)
|
||||||
|
|
||||||
void MultiFrameCapture::open()
|
void MultiFrameCapture::open()
|
||||||
{
|
{
|
||||||
int ret = video->open_device(cis_width_,cis_height_);
|
int ret = video->open_device(v4l2_width_,v4l2_height_);
|
||||||
if(ret < -1)
|
if(ret < -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -106,7 +106,12 @@ void MultiFrameCapture::snap()
|
||||||
#ifndef TEST_SIMCAP
|
#ifndef TEST_SIMCAP
|
||||||
std::lock_guard<std::mutex> m_lock(m_mtx_snap);
|
std::lock_guard<std::mutex> m_lock(m_mtx_snap);
|
||||||
b_stop_snap = b_end_snap = false;
|
b_stop_snap = b_end_snap = false;
|
||||||
|
// if (resolution_ == DPI_600)
|
||||||
|
// {
|
||||||
|
// this_thread::sleep_for(std::chrono::milliseconds(30));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
video->HtCamStartVideoCapturing();
|
video->HtCamStartVideoCapturing();
|
||||||
|
|
||||||
snaped_index++;
|
snaped_index++;
|
||||||
|
@ -140,21 +145,31 @@ void *MultiFrameCapture::readFrameTest(int timeout)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
#include<math.h>
|
||||||
uint32_t MultiFrameCapture::compute_frame(int paper_size,int dpi)
|
uint32_t MultiFrameCapture::compute_frame(int paper_size,int dpi)
|
||||||
{
|
{
|
||||||
SIZE size = GetPaperSize((PaperSize)paper_size,dpi);
|
SIZE size = GetPaperSize((PaperSize)paper_size,dpi);
|
||||||
int val = size.cy /cis_height_ + 1; //1:可能会被四舍五入,只能大不能小
|
int val = ceil((float)size.cy /(float)pixels_height_);
|
||||||
int cnt = color_mode_ ? val * 3 : val; //val * 3 彩色设置 513 但是采集实际高度是513 / 3
|
return val + 1;
|
||||||
return cnt; //四舍五入的情况下再多去一帧
|
}
|
||||||
|
void MultiFrameCapture::compute_height(int width,int height)
|
||||||
|
{
|
||||||
|
//////这块配置一定要注意
|
||||||
|
v4l2_width_ = resolution_ == 0 ? width * 2 : width; //宽 :DPI不变下 彩色灰度是一样的
|
||||||
|
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
|
||||||
|
v4l2_height_ = height;
|
||||||
|
|
||||||
|
pixels_width_ = color_mode_ == 1 ? v4l2_width_ * 3 : v4l2_width_;
|
||||||
|
pixels_height_ = color_mode_ == 1 ? v4l2_height_ / 3 : v4l2_height_;
|
||||||
}
|
}
|
||||||
SIZE MultiFrameCapture::GetPaperSize(PaperSize paper, int dpi)
|
SIZE MultiFrameCapture::GetPaperSize(PaperSize paper, int dpi)
|
||||||
{
|
{
|
||||||
if (paper_map_.find(paper) != paper_map_.end())
|
if (paper_map_.find(paper) != paper_map_.end())
|
||||||
{
|
{
|
||||||
SIZE resize{2338,3307};
|
SIZE resize{2480,3507};
|
||||||
resize.cx = paper_map_[paper].cx * dpi / 25.4;
|
resize.cx = paper_map_[paper].cx * dpi / 25.4;
|
||||||
resize.cy = paper_map_[paper].cy * dpi / 25.4;
|
resize.cy = paper_map_[paper].cy * dpi / 25.4;
|
||||||
printf("resize.cx:%d resize.cy:%d\r\n",resize.cy / cis_height_,resize.cx);
|
printf("resize.cx:%d resize.cy:%d\r\n",resize.cx,resize.cy);
|
||||||
return resize;
|
return resize;
|
||||||
}
|
}
|
||||||
return SIZE{2338, 3307};
|
return SIZE{2338, 3307};
|
||||||
|
@ -175,30 +190,27 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
|
||||||
is_correct_ = config.params.isCorrect;
|
is_correct_ = config.params.isCorrect;
|
||||||
paper_size_ = config.params.pageSize;
|
paper_size_ = config.params.pageSize;
|
||||||
is_double_paper_ = config.params.doubleFeeded;
|
is_double_paper_ = config.params.doubleFeeded;
|
||||||
|
|
||||||
cis_width_ = resolution_ == 0 ? WIDTH * 2 : WIDTH; //宽 :DPI不变下 彩色灰度是一样的
|
|
||||||
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
|
|
||||||
cis_height_ = HEIGHT;
|
|
||||||
|
|
||||||
pixels_width_ = color_mode_ == 1 ? cis_width_ * 3 : cis_width_;
|
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
|
||||||
pixels_height_ = color_mode_ == 1 ? cis_height_ / 3 : cis_height_;
|
|
||||||
|
|
||||||
|
int height = resolution_ == DPI_600 ? 1200 : 660;
|
||||||
|
|
||||||
|
compute_height(WIDTH , height);
|
||||||
|
|
||||||
video->HtCamSetClolr(color_mode_);
|
video->HtCamSetClolr(color_mode_);
|
||||||
video->HtCamSetDpi(resolution_);
|
video->HtCamSetDpi(resolution_);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FPGAConfigParam fpgaparam = GetFpgaparam(config_dpi, config_color);
|
FPGAConfigParam fpgaparam = GetFpgaparam(config_dpi, config_color);
|
||||||
video->HtCamSetSpTime(fpgaparam.Sp, 49); // 2344 灰色 //2023-8-10 最新2650
|
video->HtCamSetSpTime(fpgaparam.Sp, fpgaparam.MaxExp); // 2344 灰色 //2023-8-10 最新2650
|
||||||
if (color_mode_)
|
if (color_mode_)
|
||||||
{
|
{
|
||||||
video->HtCamSetSpTime2(fpgaparam.HRatio);
|
video->HtCamSetSpTime2(fpgaparam.HRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
video->HtCamSetStSp(fpgaparam.MaxBright);
|
video->HtCamSetStSp(fpgaparam.MaxBright);
|
||||||
|
|
||||||
configFPGAParam(config_color, config_dpi);
|
configFPGAParam(config_color, config_dpi);
|
||||||
printf(" -----------------------resolution = %d color_mode_ = %d config_dpi:%d------------------\r\n",resolution_, color_mode_,config_dpi);
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -206,40 +218,18 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
|
||||||
video->HtCamSetFrameCnt(cnt);
|
video->HtCamSetFrameCnt(cnt);
|
||||||
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
|
printf(" -----------------------设置帧数:%d------------------\r\n",cnt);
|
||||||
}
|
}
|
||||||
//if(!lut.empty())
|
|
||||||
//lut.release();
|
|
||||||
|
|
||||||
//calcLUT(config.params.dpi,config.params.isColor,true,lut);
|
|
||||||
printf("lut channels = %d lut width = %d \n",lut.channels(),lut.cols);
|
printf("颜色模式:%s\r\n",color_mode_== COLOR ? "彩色":"灰色");
|
||||||
|
printf("分辨率:%d\r\n",resolution_ == DPI_600?600:300);
|
||||||
|
printf("V4L2宽:%d 高:%d\r\n",v4l2_width_,v4l2_height_);
|
||||||
|
printf("像素宽:%d 高: %d\r\n",pixels_width_,pixels_height_);
|
||||||
|
printf("fpga_height_:%d\r\n", fpga_height_);
|
||||||
|
|
||||||
printf("resolution_:%d\r\n", resolution_);
|
printf("resolution_:%d\r\n", resolution_);
|
||||||
printf("color_mode_:%d\r\n", color_mode_);
|
printf("color_mode_:%d\r\n", color_mode_);
|
||||||
printf("paper_size_:%d\r\n", paper_size_);
|
printf("paper_size_:%d\r\n", paper_size_);
|
||||||
printf("cis_width_:%d\r\n", cis_width_);
|
printf("paper_size_:%d\r\n", paper_size_);
|
||||||
printf("cis_height_:%d\r\n", cis_height_);
|
|
||||||
printf("pixels_width_:%d\r\n", pixels_width_);
|
|
||||||
printf("pixels_height_:%d\r\n", pixels_height_);
|
|
||||||
|
|
||||||
#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.bmp", "rb");
|
|
||||||
else
|
|
||||||
f_img = fopen("/home/root/gray.bmp", "rb");
|
|
||||||
|
|
||||||
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 = (unsigned char*)malloc(m_test_pimg_len);
|
|
||||||
fseek(f_img, 0, SEEK_SET);
|
|
||||||
fread(m_test_pimg,1,m_test_pimg_len,f_img);
|
|
||||||
printf("!!!!!!!!!! info: reading image len = %d m_test_pimg = %p \r\n", m_test_pimg_len, m_test_pimg);
|
|
||||||
fclose(f_img);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiFrameCapture::createCorrect(int correctmode)
|
void MultiFrameCapture::createCorrect(int correctmode)
|
||||||
|
@ -274,6 +264,8 @@ bool MultiFrameCapture::capturerImage()
|
||||||
|
|
||||||
void MultiFrameCapture::waitsnapdone(int state)
|
void MultiFrameCapture::waitsnapdone(int state)
|
||||||
{
|
{
|
||||||
|
StopWatch sw;
|
||||||
|
sw.reset();
|
||||||
#ifdef TEST_SIMCAP
|
#ifdef TEST_SIMCAP
|
||||||
HG_JpegCompressInfo info;
|
HG_JpegCompressInfo info;
|
||||||
info.DataLength = m_test_pimg_len;
|
info.DataLength = m_test_pimg_len;
|
||||||
|
@ -295,7 +287,7 @@ void MultiFrameCapture::waitsnapdone(int state)
|
||||||
m_cv_snapdone.wait(lock);
|
m_cv_snapdone.wait(lock);
|
||||||
b_end_snap = true;
|
b_end_snap = true;
|
||||||
m_frameinfos.Put(info);
|
m_frameinfos.Put(info);
|
||||||
//printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait done \n");
|
printf("!!!!!!!!!!!!!!!! m_cv_snapdone wait done :%f \n",sw.elapsed_ms());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,29 +372,27 @@ int MultiFrameCapture::color()
|
||||||
void MultiFrameCapture::snaprun()
|
void MultiFrameCapture::snaprun()
|
||||||
{
|
{
|
||||||
//frame_info 发送得数据信息 channels 图像位深 num 需要取得帧数 time_out读图超时时间设置
|
//frame_info 发送得数据信息 channels 图像位深 num 需要取得帧数 time_out读图超时时间设置
|
||||||
auto snap_func = [this](V4L2_DATAINFO_Ex frame_info, int channels,int time_out,int i)
|
auto snap_func = [this](V4L2_DATAINFO_Ex frame_info, int channels,int &time_out,int i)
|
||||||
{
|
{
|
||||||
StopWatch sw;
|
StopWatch sw;
|
||||||
sw.reset();
|
sw.reset();
|
||||||
unsigned char *data = NULL;
|
unsigned char *data = NULL;
|
||||||
|
printf("设置超时时间:%d\r\n",time_out);
|
||||||
int ret = video->HtCamReadCaptureFrame((void **)&data, time_out);
|
int ret = video->HtCamReadCaptureFrame((void **)&data, time_out);
|
||||||
|
time_out = resolution_ == DPI_600 ? sw.elapsed_ms() + 600 : sw.elapsed_ms() + 20;
|
||||||
if (ret == -1 || ret == -2)
|
|
||||||
{
|
|
||||||
printf("----------------获取图像超时或者失败------------\r\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 \r\n",sendLine);
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
//cv::Mat mat = cv::Mat(frame_info.height, frame_info.width, CV_8UC1, data, cv::Mat::AUTO_STEP);
|
|
||||||
//cv::imwrite("/home/root/test.png", mat);
|
//cv::Mat mat = cv::Mat(317, 15552, CV_8UC1, data, cv::Mat::AUTO_STEP);
|
||||||
|
|
||||||
|
//cv::imwrite("/home/root/test.bmp", mat);
|
||||||
// printf("--------------frame_index------------:%d\r\n",frame_index);
|
// printf("--------------frame_index------------:%d\r\n",frame_index);
|
||||||
if (i == 5)
|
if (i == 2)
|
||||||
{
|
{
|
||||||
//cv::imwrite("/home/root/test.bmp", mat);
|
// cv::imwrite("/home/root/test.bmp", mat);
|
||||||
//cv::imwrite("/home/root/test.bmp", mat);
|
//cv::imwrite("/home/root/test.bmp", mat);
|
||||||
//savebitmap(data,15552,512,"1.bmp");
|
//savebitmap(data,15552,512,"1.bmp");
|
||||||
}
|
}
|
||||||
|
@ -412,9 +402,10 @@ void MultiFrameCapture::snaprun()
|
||||||
//HG_JpegCompressInfo info = cmp.GetCompressedImg(mat);
|
//HG_JpegCompressInfo info = cmp.GetCompressedImg(mat);
|
||||||
|
|
||||||
HG_JpegCompressInfo info ;
|
HG_JpegCompressInfo info ;
|
||||||
|
|
||||||
info.pJpegData = (unsigned char *)malloc(frame_info.height * frame_info.width);
|
info.pJpegData = data;//(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.DataLength = frame_info.width * frame_info.height;
|
info.DataLength = frame_info.width * frame_info.height;
|
||||||
info.first_frame = frame_info.first_frame;
|
info.first_frame = frame_info.first_frame;
|
||||||
info.last_frame = frame_info.last_frame;
|
info.last_frame = frame_info.last_frame;
|
||||||
|
@ -424,8 +415,7 @@ void MultiFrameCapture::snaprun()
|
||||||
info.height = frame_info.height;
|
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);
|
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);
|
||||||
|
|
||||||
//cv::imwrite("/home/root/opencv"+to_string(cnt_++)+".bmp",frame.mat);
|
|
||||||
m_glue.m_imageready(info);
|
m_glue.m_imageready(info);
|
||||||
|
|
||||||
//m_frameinfos.Put(frame_info);
|
//m_frameinfos.Put(frame_info);
|
||||||
|
@ -434,9 +424,11 @@ void MultiFrameCapture::snaprun()
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
//static int ti = 0;
|
static int ti = 100;
|
||||||
while (b_snap_run)
|
while (b_snap_run)
|
||||||
{
|
{
|
||||||
|
StopWatch sw;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_mtx_snap);
|
std::unique_lock<std::mutex> lock(m_mtx_snap);
|
||||||
m_cv_snap.wait(lock);
|
m_cv_snap.wait(lock);
|
||||||
|
|
||||||
|
@ -453,50 +445,58 @@ 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 = color_mode == 1 ? 800 : 400;
|
int time_out = resolution_ == DPI_600 ? 400 : 200; ///这个时间是根据每帧的数据量来进行调测的
|
||||||
int time_out_cnt = 0;
|
int time_out_cnt = 0;
|
||||||
|
|
||||||
uint32_t frame_num = 0;
|
uint32_t frame_num = 0;
|
||||||
uint32_t frame_cnt = 0;
|
uint32_t frame_cnt = 0;
|
||||||
|
|
||||||
video->HtCamGetFrameCnt(frame_cnt);
|
|
||||||
frame_info.frame_index = frame_cnt + 1;
|
|
||||||
//video->HtCamSetVsnpTime(6);
|
|
||||||
//printf("设置 vsnp:%d\r\n",ti);
|
|
||||||
//ti++;
|
|
||||||
|
|
||||||
|
video->HtCamGetFrameCnt(frame_cnt);
|
||||||
|
|
||||||
|
printf("获取设置的帧数:%d\r\n",frame_cnt);
|
||||||
|
frame_info.frame_index = frame_cnt + 1;
|
||||||
|
// video->HtCamSetVsnpTime(ti);
|
||||||
|
// printf("设置 vsnp:%d\r\n",ti);
|
||||||
|
//ti++;
|
||||||
|
// video->HtCamSetStSp(ti);
|
||||||
|
// printf("设置 StSp%d\r\n",ti);
|
||||||
|
// ti++;
|
||||||
|
int mill = 0; //= resolution_ == DPI_600 ? 30 : 25;
|
||||||
|
//mill = color_mode == 1?mill*3:mill;
|
||||||
|
printf("mill:%d\r\n",mill);
|
||||||
// printf("--------------------- frame_info.width ------------------ :%d\r\n",frame_info.width );
|
// printf("--------------------- frame_info.width ------------------ :%d\r\n",frame_info.width );
|
||||||
// printf("--------------------- frame_info.height ------------------ :%d\r\n",frame_info.height );
|
// printf("--------------------- frame_info.height ------------------ :%d\r\n",frame_info.height );
|
||||||
// printf("--------------------- frame_info.pixtype ------------------ :%d\r\n",frame_info.pixtype );
|
// printf("--------------------- frame_info.pixtype ------------------ :%d\r\n",frame_info.pixtype );
|
||||||
// printf("--------------------- frame_info.dpi ------------------ :%d\r\n",frame_info.dpi );
|
// printf("--------------------- frame_info.dpi ------------------ :%d\r\n",frame_info.dpi );
|
||||||
|
|
||||||
|
sw.reset();
|
||||||
for (size_t i = 1; i <= frame_cnt; i++)
|
for (size_t i = 0; i <= frame_cnt ; i++) //frame_cnt -1 目前最好一帧采集会超时 所以多采集一帧
|
||||||
{
|
{
|
||||||
printf("***********设置的帧数:%d 正在采集第[%d]帧************\r\n",frame_info.frame_index,i);
|
printf("***********设置的帧数:%d 正在采集第[%d]帧************\r\n",frame_info.frame_index,i);
|
||||||
|
|
||||||
frame_info.first_frame = i == 1 ? true : false;
|
frame_info.first_frame = i == 0 ? true : false;
|
||||||
frame_info.last_frame = i == frame_cnt ? true : false;
|
frame_info.last_frame = i == frame_cnt ? true : false;
|
||||||
|
|
||||||
func_sig = snap_func(frame_info, channels,time_out,i);
|
func_sig = snap_func(frame_info, channels,time_out,i);
|
||||||
if (func_sig == -1 ) //当前帧取图超时,在取一次!!! 一直超时 不就卡死了??? 这个地方还是需要加个时间限制几秒内一帧未取出就退了,返回异常状态吧?
|
|
||||||
{
|
// if (func_sig == -1 ) //当前帧取图超时,在取一次!!! 一直超时 不就卡死了??? 这个地方还是需要加个时间限制几秒内一帧未取出就退了,返回异常状态吧?
|
||||||
i--;
|
// {
|
||||||
time_out +=200;
|
// i--;
|
||||||
time_out_cnt ++;
|
// time_out +=200;
|
||||||
if (time_out_cnt >=5)
|
// time_out_cnt ++;
|
||||||
{
|
// if (time_out_cnt >=5)
|
||||||
break;
|
// {
|
||||||
}
|
// break;
|
||||||
continue;
|
// }
|
||||||
}
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
if (b_stop_snap)
|
if (b_stop_snap)
|
||||||
{
|
{
|
||||||
video->HtCamGetFrameNum(frame_num);
|
video->HtCamGetFrameNum(frame_num);
|
||||||
int val = frame_num - i; //剩余还未采集的帧数
|
int ind = i; //已采集了的帧数
|
||||||
int ind = i + 1; //只是计数确认采集到低多少帧,无其他实用意义
|
int val = frame_num - ind; //剩余还未采集的帧数
|
||||||
|
|
||||||
while (val)
|
while (val)
|
||||||
{
|
{
|
||||||
frame_info.last_frame = val == 1 ? true : false;
|
frame_info.last_frame = val == 1 ? true : false;
|
||||||
|
@ -504,19 +504,20 @@ void MultiFrameCapture::snaprun()
|
||||||
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 )
|
||||||
{
|
// {
|
||||||
time_out +=200;
|
// time_out +=200;
|
||||||
time_out_cnt ++;
|
// time_out_cnt ++;
|
||||||
if (time_out_cnt >=5)
|
// if (time_out_cnt >=5)
|
||||||
{
|
// {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
val--;
|
val--;
|
||||||
ind++;
|
ind++;
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(65));
|
|
||||||
|
//this_thread::sleep_for(std::chrono::milliseconds(mill));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -526,14 +527,14 @@ void MultiFrameCapture::snaprun()
|
||||||
////////////////////////////采集过快会导致队列堆积/////////////////////////
|
////////////////////////////采集过快会导致队列堆积/////////////////////////
|
||||||
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
|
////////////////////////////所以这个延时是采集速度和传图速度的差值/////////////////////////
|
||||||
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
|
////////////////////////////DPI 颜色不同 会导致数据大小不同所以这个地方延时肯定不一样 目前 60是200dpi/////////////////////////
|
||||||
int mill = resolution_ == DPI_600 ? 60 * 10 : 60;
|
// if(resolution_ == DPI_600)
|
||||||
printf("mill:%d\r\n",mill);
|
// this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(mill));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
uint32_t in=0;
|
||||||
|
|
||||||
video->HtCamStopVideoCapturing();
|
video->HtCamStopVideoCapturing();
|
||||||
printf("---------- 退出图像采集流程 ----------\r\n");
|
video->HtCamGetFrameNum(in);
|
||||||
|
printf("----------整张采集结束 总共采集帧数:%d 耗时:%f----------\r\n",in,sw.elapsed_ms());
|
||||||
|
|
||||||
m_cv_snapdone.notify_all();
|
m_cv_snapdone.notify_all();
|
||||||
b_end_snap = true;
|
b_end_snap = true;
|
||||||
|
@ -548,7 +549,6 @@ void MultiFrameCapture::updatesnapstatus(int papertype)
|
||||||
|
|
||||||
void MultiFrameCapture::procimage()
|
void MultiFrameCapture::procimage()
|
||||||
{
|
{
|
||||||
|
|
||||||
static int idx = 0;
|
static int idx = 0;
|
||||||
ThreadPool prc_pool(4);
|
ThreadPool prc_pool(4);
|
||||||
std::queue<std::future<cv::Mat>> prc_fu;
|
std::queue<std::future<cv::Mat>> prc_fu;
|
||||||
|
@ -782,7 +782,7 @@ bool MultiFrameCapture::saveLutImg(int dpi, int mode, bool black)
|
||||||
{
|
{
|
||||||
int k = (3 * s + x);
|
int k = (3 * s + x);
|
||||||
// int diff = LIGHT_DIFF(*((double *)values + k));
|
// int diff = LIGHT_DIFF(*((double *)values + k));
|
||||||
int diff = 170 - *((double *)values + k);;//param.MaxBright - *((double *)values + k);
|
int diff = 210 - *((double *)values + k);;//param.MaxBright - *((double *)values + k);
|
||||||
log += " 明场:" + std::to_string(k) + ";diff:" + std::to_string(diff) + "\r\n";
|
log += " 明场:" + std::to_string(k) + ";diff:" + std::to_string(diff) + "\r\n";
|
||||||
|
|
||||||
double step = diff * radio;
|
double step = diff * radio;
|
||||||
|
@ -848,7 +848,7 @@ bool MultiFrameCapture::saveLutImg(int dpi, int mode, bool black)
|
||||||
{
|
{
|
||||||
int *exposures = (int *)(s == 0 ? param.ExposureF : param.ExposureB);
|
int *exposures = (int *)(s == 0 ? param.ExposureF : param.ExposureB);
|
||||||
// int diff = LIGHT_DIFF(values[s]);
|
// int diff = LIGHT_DIFF(values[s]);
|
||||||
int diff = 170 - values[s];;//param.MaxBright - values[s];
|
int diff = 200 - values[s];
|
||||||
double step = diff * radio;
|
double step = diff * radio;
|
||||||
log += " 明场:" + to_string(s) + ";diff:" + to_string(diff) + "\r\n";
|
log += " 明场:" + to_string(s) + ";diff:" + to_string(diff) + "\r\n";
|
||||||
int preStep = expStep[s][0];
|
int preStep = expStep[s][0];
|
||||||
|
@ -932,76 +932,67 @@ void MultiFrameCapture::correctcolor(int correctmode)
|
||||||
{
|
{
|
||||||
StopWatch sw_correct;
|
StopWatch sw_correct;
|
||||||
std::string loginfo = "Start Correctcolor 300DPI Gray \r\n";
|
std::string loginfo = "Start Correctcolor 300DPI Gray \r\n";
|
||||||
//printf("----------- %s \n",loginfo.c_str());
|
|
||||||
//creatcorrectconfig(0x02, IMAGE_GRAY);
|
|
||||||
//printf("----------- done \n",loginfo.c_str());
|
|
||||||
|
|
||||||
loginfo = "Start Correctcolor 300DPI COLOR \r\n";
|
if ((correctmode == 0) || (correctmode == 2))
|
||||||
printf("----------- %s \n",loginfo.c_str());
|
{
|
||||||
creatcorrectconfig(0x02, IMAGE_COLOR);
|
loginfo = "Start Correctcolor 200DPI COLOR \r\n";
|
||||||
printf("----------- done \n",loginfo.c_str());
|
if (m_glue.m_deviceevent)
|
||||||
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
|
creatcorrectconfig(0x01, IMAGE_COLOR);
|
||||||
// if ((correctmode == 0) || (correctmode == 2))
|
loginfo = "-----------200DPI COLOR Correct Done----------- \r\n\r\n ";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = "Start Correctcolor 200DPI COLOR \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
if ((correctmode == 0) || (correctmode == 1))
|
||||||
// creatcorrectconfig(0x01, IMAGE_COLOR);
|
{
|
||||||
// loginfo = "-----------200DPI COLOR Correct Done----------- \r\n\r\n ";
|
loginfo = "Start Correctcolor 200DPI GRAY \r\n";
|
||||||
// if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// }
|
creatcorrectconfig(0x01, IMAGE_GRAY);
|
||||||
// if ((correctmode == 0) || (correctmode == 1))
|
loginfo = "-----------200DPI Gray Correct Done----------- \r\n\r\n";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = "Start Correctcolor 200DPI GRAY \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
if ((correctmode == 0) || (correctmode == 4))
|
||||||
// creatcorrectconfig(0x01, IMAGE_GRAY);
|
{
|
||||||
// loginfo = "-----------200DPI Gray Correct Done----------- \r\n\r\n";
|
loginfo = " Start Correctcolor 300DPI COLOR \r\n";
|
||||||
// if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// }
|
creatcorrectconfig(0x02, IMAGE_COLOR);
|
||||||
// if ((correctmode == 0) || (correctmode == 4))
|
loginfo = "-----------300DPI COLOR Correct Done----------- \r\n\r\n ";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = " Start Correctcolor 300DPI COLOR \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
if ((correctmode == 0) || (correctmode == 3))
|
||||||
// creatcorrectconfig(0x02, IMAGE_COLOR);
|
{
|
||||||
// loginfo = "-----------300DPI COLOR Correct Done----------- \r\n\r\n ";
|
loginfo = "Start Correctcolor 300DPI GRAY \r\n";
|
||||||
// if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// }
|
creatcorrectconfig(0x02, IMAGE_GRAY);
|
||||||
// if ((correctmode == 0) || (correctmode == 3))
|
loginfo = "-----------300DPI Gray Correct Done----------- \r\n\r\n ";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = "Start Correctcolor 300DPI GRAY \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
if ((correctmode == 0) || (correctmode == 6))
|
||||||
// creatcorrectconfig(0x02, IMAGE_GRAY);
|
{
|
||||||
// loginfo = "-----------300DPI Gray Correct Done----------- \r\n\r\n ";
|
loginfo = "Start Correctcolor 600DPI COLOR \r\n";
|
||||||
// if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// }
|
creatcorrectconfig(0x03, IMAGE_COLOR);
|
||||||
// if ((correctmode == 0) || (correctmode == 6))
|
loginfo = "-----------600DPI COLOR Correct Done----------- \r\n\r\n";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = "Start Correctcolor 600DPI COLOR \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
if ((correctmode == 0) || (correctmode == 5))
|
||||||
// creatcorrectconfig(0x03, IMAGE_COLOR);
|
{
|
||||||
// loginfo = "-----------600DPI COLOR Correct Done----------- \r\n\r\n";
|
loginfo = " Start Correctcolor 600DPI GRAY \r\n";
|
||||||
// if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// }
|
creatcorrectconfig(0x03, IMAGE_GRAY);
|
||||||
// if ((correctmode == 0) || (correctmode == 5))
|
loginfo = "-----------600DPI Gray Correct Done----------- \r\n\r\n ";
|
||||||
// {
|
if (m_glue.m_deviceevent)
|
||||||
// loginfo = " Start Correctcolor 600DPI GRAY \r\n";
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
||||||
// if (m_glue.m_deviceevent)
|
}
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
|
||||||
// creatcorrectconfig(0x03, IMAGE_GRAY);
|
|
||||||
// loginfo = "-----------600DPI Gray Correct Done----------- \r\n\r\n ";
|
|
||||||
// if (m_glue.m_deviceevent)
|
|
||||||
// m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, loginfo);
|
|
||||||
// }
|
|
||||||
if ((correctmode < 0) || (correctmode > 6))
|
if ((correctmode < 0) || (correctmode > 6))
|
||||||
{
|
{
|
||||||
loginfo = "不支持的校正模式...\r\n";
|
loginfo = "不支持的校正模式...\r\n";
|
||||||
|
@ -1027,13 +1018,10 @@ void MultiFrameCapture::openDevice(int dpi, int mode)
|
||||||
|
|
||||||
resolution_ = dpi == 3 ? DPI_600 : DPI_300; //0:600dpi 1:300dpi config.params.dpi = 2||3 pc 2代表300 3代表600
|
resolution_ = dpi == 3 ? DPI_600 : DPI_300; //0:600dpi 1:300dpi config.params.dpi = 2||3 pc 2代表300 3代表600
|
||||||
color_mode_ = mode == 1 ? COLOR : GRAY;
|
color_mode_ = mode == 1 ? COLOR : GRAY;
|
||||||
cis_width_ = resolution_ == 0 ? WIDTH * 2 : WIDTH; //宽 :DPI不变下 彩色灰度是一样的
|
|
||||||
cis_height_ = mode == 0x01 ? 60 * 3 : 60;
|
compute_height(WIDTH , HEIGHT);
|
||||||
pixels_width_ = color_mode_ == 1 ? cis_width_ * 3 : cis_width_;
|
|
||||||
pixels_height_ = color_mode_ == 1 ? cis_height_ / 3 : cis_height_;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int config_dpi = resolution_ == DPI_600 ? 3 : 2;
|
int config_dpi = resolution_ == DPI_600 ? 3 : 2;
|
||||||
int config_color = color_mode_ ==COLOR ? 1:0;
|
int config_color = color_mode_ ==COLOR ? 1:0;
|
||||||
|
|
||||||
|
@ -1060,23 +1048,19 @@ void MultiFrameCapture::openDevice(int dpi, int mode)
|
||||||
video->HtCamSetFrameCnt(val);
|
video->HtCamSetFrameCnt(val);
|
||||||
printf(" -----------------------设置帧数:%d------------------\r\n",val);
|
printf(" -----------------------设置帧数:%d------------------\r\n",val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("颜色模式:%s\r\n",color_mode_== COLOR ? "彩色":"灰色");
|
printf("颜色模式:%s\r\n",color_mode_== COLOR ? "彩色":"灰色");
|
||||||
printf("分辨率:%d\r\n",resolution_ == DPI_600?600:300);
|
printf("分辨率:%d\r\n",resolution_ == DPI_600?600:300);
|
||||||
printf("采集宽:%d 高:%d\r\n",cis_width_,cis_height_);
|
printf("V4L2宽:%d 高:%d\r\n",v4l2_width_,v4l2_height_);
|
||||||
printf("像素宽:%d 高: %d\r\n",pixels_width_,pixels_height_);
|
printf("像素宽:%d 高: %d\r\n",pixels_width_,pixels_height_);
|
||||||
|
|
||||||
printf("resolution_:%d\r\n", resolution_);
|
printf("resolution_:%d\r\n", resolution_);
|
||||||
printf("color_mode_:%d\r\n", color_mode_);
|
printf("color_mode_:%d\r\n", color_mode_);
|
||||||
printf("paper_size_:%d\r\n", paper_size_);
|
printf("paper_size_:%d\r\n", paper_size_);
|
||||||
printf("paper_size_:%d\r\n", paper_size_);
|
printf("paper_size_:%d\r\n", paper_size_);
|
||||||
printf("cis_width_:%d\r\n", cis_width_);
|
|
||||||
printf("cis_height_:%d\r\n", cis_height_);
|
|
||||||
printf("pixels_width_:%d\r\n", pixels_width_);
|
|
||||||
printf("pixels_height_:%d\r\n", pixels_height_);
|
|
||||||
|
|
||||||
|
|
||||||
int ret = video->open_device(cis_width_,cis_height_);
|
int ret = video->open_device(v4l2_width_,v4l2_height_);
|
||||||
if(ret < -1)
|
if(ret < -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1086,7 +1070,6 @@ void MultiFrameCapture::openDevice(int dpi, int mode)
|
||||||
{
|
{
|
||||||
i = video->HtCamReadCaptureFrame((void **)&buf, 500);
|
i = video->HtCamReadCaptureFrame((void **)&buf, 500);
|
||||||
}
|
}
|
||||||
//video->close_video();
|
|
||||||
|
|
||||||
printf("opened video with width = %d height = %d time eplased = %.2f pbuffer = %p \n", width, 60 * 2, swwv4l2open.elapsed_ms(),buf);
|
printf("opened video with width = %d height = %d time eplased = %.2f pbuffer = %p \n", width, 60 * 2, swwv4l2open.elapsed_ms(),buf);
|
||||||
}
|
}
|
||||||
|
@ -1109,7 +1092,7 @@ void MultiFrameCapture::creatcorrectconfig(int dpi, int mode)
|
||||||
int config_dpi = resolution_ == DPI_600 ? 3 : 2;
|
int config_dpi = resolution_ == DPI_600 ? 3 : 2;
|
||||||
int config_color = color_mode_ ==COLOR ? 1:0;
|
int config_color = color_mode_ ==COLOR ? 1:0;
|
||||||
|
|
||||||
configFPGAParam(config_color, config_dpi);
|
configFPGAParam(mode, dpi);
|
||||||
// ftt.append_log(log);
|
// ftt.append_log(log);
|
||||||
printf("log :%s\r\n",log.c_str());
|
printf("log :%s\r\n",log.c_str());
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
|
@ -1119,43 +1102,33 @@ void MultiFrameCapture::creatcorrectconfig(int dpi, int mode)
|
||||||
video->HtCamChangeExposureValueB(F);
|
video->HtCamChangeExposureValueB(F);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
video->HtCamStartVideoCapturing();
|
video->HtCamStartVideoCapturing();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
isDone = saveLutImg(dpi, mode, true); // 0 color_black 1 color_white 2 gray_balck 3 gray_white
|
isDone = saveLutImg(dpi, mode, true); // 0 color_black 1 color_white 2 gray_balck 3 gray_white
|
||||||
video->HtCamStopVideoCapturing();
|
video->HtCamStopVideoCapturing();
|
||||||
|
|
||||||
//video->close_device();
|
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
//return ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isDone = false;
|
isDone = false;
|
||||||
formatStep();
|
formatStep();
|
||||||
while (!isDone) // 后明场
|
while (!isDone) // 后明场
|
||||||
{
|
{
|
||||||
string log = "==============================第" + to_string(i) + "次===============================\r\n";
|
string log = "==============================第" + to_string(i) + "次===============================\r\n";
|
||||||
// ftt.append_log(log);
|
|
||||||
if (m_glue.m_deviceevent)
|
if (m_glue.m_deviceevent)
|
||||||
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, log);
|
m_glue.m_deviceevent((int)HG_ScannerStatus::AUTO_FLATTING, log);
|
||||||
configFPGAParam(mode, dpi);
|
configFPGAParam(mode, dpi);
|
||||||
|
|
||||||
// ftt.append_log(log);
|
|
||||||
printf("log :%s\r\n", log.c_str());
|
printf("log :%s\r\n", log.c_str());
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
|
|
||||||
//unsigned int F[3] = {1, 1, 1};
|
|
||||||
//video->HtCamChangeExposureValueF(F);
|
|
||||||
//video->HtCamChangeExposureValueB(F);
|
|
||||||
//std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
|
||||||
|
|
||||||
video->HtCamStartVideoCapturing();
|
video->HtCamStartVideoCapturing();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
isDone = saveLutImg(dpi, mode, false); // 0 color_black 1 color_white 2 gray_balck 3 gray_white
|
isDone = saveLutImg(dpi, mode, false); // 0 color_black 1 color_white 2 gray_balck 3 gray_white
|
||||||
video->HtCamStopVideoCapturing();
|
video->HtCamStopVideoCapturing();
|
||||||
// video->close_device();
|
|
||||||
this_thread::sleep_for(std::chrono::seconds(2));
|
this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1164,65 +1137,3 @@ void MultiFrameCapture::creatcorrectconfig(int dpi, int mode)
|
||||||
video->close_device();
|
video->close_device();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void MultiFrameCapture::myFloodFill(cv::Mat& image, bool isTwoSide)
|
|
||||||
// {
|
|
||||||
// int w = image.cols;
|
|
||||||
// int h = image.rows;
|
|
||||||
// cv::Vec3b lt, rt, lb, rb;
|
|
||||||
// const double threshold = 10;
|
|
||||||
|
|
||||||
// if (!isTwoSide)
|
|
||||||
// {
|
|
||||||
// lt = image.channels() == 3 ? image.at<cv::Vec3b>(0, 0) : image.at<uchar>(0, 0);
|
|
||||||
// if (lt[0] < threshold && lt[1] < threshold && lt[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(0, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rt = image.channels() == 3 ? image.at<cv::Vec3b>(0, w - 1) : image.at<uchar>(0, w - 1);
|
|
||||||
// if (rt[0] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w - 1, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// lb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, 0) : image.at<uchar>(h - 1, 0);
|
|
||||||
// if (lb[0] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(0, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, w - 1) : image.at<uchar>(h - 1, w - 1);
|
|
||||||
// if (rb[0] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w - 1, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// int w_ = w / 2;
|
|
||||||
// lt = image.channels() == 3 ? image.at<cv::Vec3b>(0, 0) : image.at<uchar>(0, 0);
|
|
||||||
// if (lt[0] < threshold && lt[1] < threshold && lt[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(0, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rt = image.channels() == 3 ? image.at<cv::Vec3b>(0, w_ - 1) : image.at<uchar>(0, w_ - 1);
|
|
||||||
// if (rt[0] < threshold && rt[1] < threshold && rt[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w_ - 1, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// lb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, 0) : image.at<uchar>(h - 1, 0);
|
|
||||||
// if (lb[0] < threshold && lb[1] < threshold && lb[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(0, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, w_ - 1) : image.at<uchar>(h - 1, w_ - 1);
|
|
||||||
// if (rb[0] < threshold && rb[1] < threshold && rb[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w_ - 1, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// lt = image.channels() == 3 ? image.at<cv::Vec3b>(0, w_) : image.at<uchar>(0, w_);
|
|
||||||
// if (lt[0] < threshold && lt[1] < threshold && lt[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w_, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rt = image.channels() == 3 ? image.at<cv::Vec3b>(0, w - 1) : image.at<uchar>(0, w - 1);
|
|
||||||
// if (rt[0] < threshold && rt[1] < threshold && rt[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w - 1, 0), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// lb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, w_) : image.at<uchar>(h - 1, w_);
|
|
||||||
// if (lb[0] < threshold && lb[1] < threshold && lb[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w_, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
|
|
||||||
// rb = image.channels() == 3 ? image.at<cv::Vec3b>(h - 1, w - 1) : image.at<uchar>(h - 1, w - 1);
|
|
||||||
// if (rb[0] < threshold && rb[1] < threshold && rb[2] < threshold)
|
|
||||||
// cv::floodFill(image, cv::Point(w - 1, h - 1), cv::Scalar::all(255), 0, cv::Scalar::all(5), cv::Scalar::all(40), cv::FLOODFILL_FIXED_RANGE);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Gpio;
|
||||||
class GpioOut;
|
class GpioOut;
|
||||||
|
|
||||||
#define WIDTH 5184
|
#define WIDTH 5184
|
||||||
#define HEIGHT 650 //只能为3的倍数
|
#define HEIGHT 951 //只能为3的倍数
|
||||||
#define DPI_600 0
|
#define DPI_600 0
|
||||||
#define DPI_300 1
|
#define DPI_300 1
|
||||||
#define COLOR 1
|
#define COLOR 1
|
||||||
|
@ -85,14 +85,18 @@ private:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int resolution_; // 分辨率 //0:600dpi 1:300dpi
|
unsigned int resolution_; // 分辨率 //0:600dpi 1:300dpi
|
||||||
unsigned int cis_width_; // CIS 图像宽
|
|
||||||
unsigned int cis_height_; // CIS 图像高
|
unsigned int v4l2_width_; // v4l2 图像宽
|
||||||
|
unsigned int v4l2_height_; // v4l2 图像高
|
||||||
unsigned int pixels_height_; // opencv需要生成的高
|
unsigned int pixels_height_; // opencv需要生成的高
|
||||||
unsigned int pixels_width_ ; // opencv需要生成的宽
|
unsigned int pixels_width_ ; // opencv需要生成的宽
|
||||||
|
unsigned int fpga_height_; // PGPA 需要的高的是三倍数 ,发950 就是指951
|
||||||
|
|
||||||
unsigned int paper_size_; // 纸张大小
|
unsigned int paper_size_; // 纸张大小
|
||||||
unsigned int color_mode_; // 颜色模式
|
unsigned int color_mode_; // 颜色模式
|
||||||
unsigned int is_correct_; // 是否校正
|
unsigned int is_correct_; // 是否校正
|
||||||
unsigned int is_double_paper_; // 是否启动双张检测
|
unsigned int is_double_paper_; // 是否启动双张检测
|
||||||
|
|
||||||
|
|
||||||
cv::Mat lut;
|
cv::Mat lut;
|
||||||
std::map<PaperSize, SIZE> paper_map_
|
std::map<PaperSize, SIZE> paper_map_
|
||||||
|
@ -115,6 +119,7 @@ private:
|
||||||
|
|
||||||
SIZE GetPaperSize(PaperSize paper, int dpi);
|
SIZE GetPaperSize(PaperSize paper, int dpi);
|
||||||
uint32_t compute_frame(int paper_size,int dpi); //计算固定幅面需要采集的帧数
|
uint32_t compute_frame(int paper_size,int dpi); //计算固定幅面需要采集的帧数
|
||||||
|
void compute_height(int width,int height); //在open 之前调用
|
||||||
public:
|
public:
|
||||||
MultiFrameCapture(ScannerGlue glue, std::shared_ptr<FpgaComm> fpga, CISVendor vendor);
|
MultiFrameCapture(ScannerGlue glue, std::shared_ptr<FpgaComm> fpga, CISVendor vendor);
|
||||||
|
|
||||||
|
@ -124,6 +129,8 @@ public:
|
||||||
|
|
||||||
virtual void open() override;
|
virtual void open() override;
|
||||||
|
|
||||||
|
////这个地方非常重要 目的是检测到有纸之后 ,继续走纸接近CIS 在启动采集 ,但是这个地方风险也很大,需要调的尽量完美,如果出现最上面几行图像和最下面图像不显示请看一下这里吧!!!!
|
||||||
|
////走纸速度影响吗??? YES
|
||||||
virtual void snap() override;
|
virtual void snap() override;
|
||||||
|
|
||||||
virtual void stopsnap(bool autosize) override;
|
virtual void stopsnap(bool autosize) override;
|
||||||
|
|
61
Scanner.cpp
61
Scanner.cpp
|
@ -113,8 +113,8 @@ void Scanner::updateSpeedMode(int speed)
|
||||||
m_scaninfo = GetScanInfoFromJson();
|
m_scaninfo = GetScanInfoFromJson();
|
||||||
if(m_scaninfo.SpeedMode==0)
|
if(m_scaninfo.SpeedMode==0)
|
||||||
m_scaninfo.SpeedMode=3;
|
m_scaninfo.SpeedMode=3;
|
||||||
LOG("Scanner SET updateSpeedMode %d------ \n",m_scaninfo.SpeedMode);
|
printf("速度模式:%d dpi:%d 颜色:%d \n",m_scaninfo.SpeedMode,m_config.params.dpi,m_config.params.isColor);
|
||||||
unsigned int t_dpi=m_config.params.dpi;
|
unsigned int t_dpi = m_config.params.dpi;
|
||||||
// if(typeid(*capturer)==typeid(MonoCapturer))
|
// if(typeid(*capturer)==typeid(MonoCapturer))
|
||||||
// {
|
// {
|
||||||
// if(m_config.params.dpi==0x03&& m_scansysinfo->IsSmallRam())
|
// if(m_config.params.dpi==0x03&& m_scansysinfo->IsSmallRam())
|
||||||
|
@ -122,9 +122,11 @@ void Scanner::updateSpeedMode(int speed)
|
||||||
// else
|
// else
|
||||||
// t_dpi = m_config.params.dpi;
|
// t_dpi = m_config.params.dpi;
|
||||||
// }
|
// }
|
||||||
//if(typeid(*capturer)==typeid(MultiFrameCapture))
|
if(typeid(*capturer)==typeid(MultiFrameCapture))
|
||||||
//if(m_config.params.pageSize == 17 || m_config.params.pageSize == 19) //长文稿采用600dpi模式扫描
|
if(m_config.params.pageSize == 17 || m_config.params.pageSize == 19) //长文稿采用600dpi模式扫描
|
||||||
t_dpi = 1;
|
t_dpi = 3;
|
||||||
|
|
||||||
|
|
||||||
motorCuozhi.speedChange(m_scaninfo.SpeedMode, t_dpi,m_config.params.isColor);
|
motorCuozhi.speedChange(m_scaninfo.SpeedMode, t_dpi,m_config.params.isColor);
|
||||||
motorZouzhi.speedChange(m_scaninfo.SpeedMode, t_dpi,m_config.params.isColor);
|
motorZouzhi.speedChange(m_scaninfo.SpeedMode, t_dpi,m_config.params.isColor);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +240,11 @@ void Scanner::runScan()
|
||||||
m_config.params.pageSize==(int)PaperSize::G400_MAXAUTO ||
|
m_config.params.pageSize==(int)PaperSize::G400_MAXAUTO ||
|
||||||
m_config.params.pageSize==(int)PaperSize::G400_MAXSIZE;
|
m_config.params.pageSize==(int)PaperSize::G400_MAXSIZE;
|
||||||
StopWatch sw;
|
StopWatch sw;
|
||||||
|
StopWatch sw1;
|
||||||
|
StopWatch sw2;
|
||||||
while (m_DstScannum > 0)
|
while (m_DstScannum > 0)
|
||||||
{
|
{
|
||||||
|
sw1.reset();
|
||||||
m_isDoublePaper = false;
|
m_isDoublePaper = false;
|
||||||
m_jamPaper = false;
|
m_jamPaper = false;
|
||||||
m_jamIn = false;
|
m_jamIn = false;
|
||||||
|
@ -288,30 +293,31 @@ void Scanner::runScan()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
printf("检测到纸张的时间:%f\r\n",sw.elapsed_ms());//检测到纸张
|
||||||
|
|
||||||
capturer->snap();
|
capturer->snap();
|
||||||
motorCuozhi.pauseWaitForThread();
|
motorCuozhi.pauseWaitForThread();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int max = 7;
|
int max = 7;
|
||||||
#ifdef G400
|
|
||||||
if(m_config.params.pageSize >= (int)PaperSize::G400_LONGLETTER)
|
|
||||||
max = m_scaninfo.SpeedMode>3?10:16;
|
|
||||||
else
|
|
||||||
max = m_scaninfo.SpeedMode>3?5:8;
|
|
||||||
#else
|
|
||||||
if(m_config.params.pageSize >= (int)PaperSize::G400_LONGLETTER)
|
if(m_config.params.pageSize >= (int)PaperSize::G400_LONGLETTER)
|
||||||
max = m_scaninfo.SpeedMode>3?10:25;
|
max = m_scaninfo.SpeedMode>3?10:25;
|
||||||
else
|
else
|
||||||
max = m_scaninfo.SpeedMode>3?5:8;
|
max = m_scaninfo.SpeedMode>3?5:8;
|
||||||
#endif
|
|
||||||
|
|
||||||
max = m_config.params.dpi > 2 ? 30 : max * m_config.params.dpi;
|
max = m_config.params.dpi > 2 ? 30 : max * m_config.params.dpi;
|
||||||
|
|
||||||
if(m_config.params.pageSize == 17 || m_config.params.pageSize == 19)
|
if(m_config.params.pageSize == 17 || m_config.params.pageSize == 19)
|
||||||
|
{
|
||||||
max = 200;
|
max = 200;
|
||||||
|
}
|
||||||
|
|
||||||
LOG("paper pauseWaitForThread \n");
|
LOG("paper pauseWaitForThread \n");
|
||||||
waitpapertime = 200;
|
waitpapertime = 200;
|
||||||
|
sw2.reset();
|
||||||
while (!sensor->waitPaperOut(waitpapertime) && i < max)
|
while (!sensor->waitPaperOut(waitpapertime) && i < max)
|
||||||
{
|
{
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (!sensor->isPaperIn())
|
if (!sensor->isPaperIn())
|
||||||
{
|
{
|
||||||
|
@ -319,6 +325,7 @@ void Scanner::runScan()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("等待纸张出去?????????????%f\r\n",sw2.elapsed_ms());
|
||||||
LOG("paper isPaperIn \n");
|
LOG("paper isPaperIn \n");
|
||||||
if (i == max && sensor->isPaperIn())
|
if (i == max && sensor->isPaperIn())
|
||||||
{
|
{
|
||||||
|
@ -351,10 +358,14 @@ void Scanner::runScan()
|
||||||
int dly_speed= (5 - m_scaninfo.SpeedMode)*10;
|
int dly_speed= (5 - m_scaninfo.SpeedMode)*10;
|
||||||
int delay = m_config.params.dpi==0x02?70:(m_config.params.dpi==0x03?350: 20);
|
int delay = m_config.params.dpi==0x02?70:(m_config.params.dpi==0x03?350: 20);
|
||||||
if((m_config.params.pageSize == 17 || m_config.params.pageSize == 19)&&(delay < 350))
|
if((m_config.params.pageSize == 17 || m_config.params.pageSize == 19)&&(delay < 350))
|
||||||
|
{
|
||||||
delay = 350;
|
delay = 350;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_config.params.pageSize == 18)
|
if(m_config.params.pageSize == 18)
|
||||||
delay = std::max(delay,80);
|
delay = std::max(delay,80);
|
||||||
delay+=dly_speed;
|
|
||||||
|
delay += dly_speed;
|
||||||
//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
|
||||||
}
|
}
|
||||||
|
@ -370,9 +381,9 @@ void Scanner::runScan()
|
||||||
capturer->stopsnap(b_autosize);
|
capturer->stopsnap(b_autosize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
//std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
//std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
LOG("\nclose b_autosize %s\n",GetCurrentTimeStamp(2).c_str());
|
LOG("\nclose b_autosize %s\n",GetCurrentTimeStamp(2).c_str());
|
||||||
capturer->stopsnap(b_autosize);
|
capturer->stopsnap(b_autosize);
|
||||||
capturer->waitsnapdone(m_isDoublePaper || m_jamPaper);//等待采集完成
|
capturer->waitsnapdone(m_isDoublePaper || m_jamPaper);//等待采集完成
|
||||||
|
@ -389,15 +400,11 @@ void Scanner::runScan()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sw.reset();
|
sw.reset();
|
||||||
while (meminfo->GetMemoryUsed() > 85.0f||(m_config.params.dpi ==0x03 && capturer->getimageremain()>1)) //内存占用高于75%
|
while (meminfo->GetMemoryUsed() > 90.0f||(m_config.params.dpi ==0x03 && capturer->getimageremain()>1)) //内存占用高于75%
|
||||||
{
|
{
|
||||||
if (sw.elapsed_s() < 50.0)
|
if (sw.elapsed_s() < 50.0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
|
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -407,7 +414,9 @@ void Scanner::runScan()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("正常结束\r\n");
|
printf("一张纸完成时间:%f\r\n",sw1.elapsed_ms());
|
||||||
|
if( m_config.params.dpi == 3)
|
||||||
|
this_thread::sleep_for(std::chrono::milliseconds(3000));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DstScannum = 0;
|
m_DstScannum = 0;
|
||||||
|
@ -417,11 +426,11 @@ void Scanner::runScan()
|
||||||
|
|
||||||
int t_delay = m_config.params.dpi == 0x02 ? 150 : (m_config.params.dpi == 0x03 ? 350 : 100);
|
int t_delay = m_config.params.dpi == 0x02 ? 150 : (m_config.params.dpi == 0x03 ? 350 : 100);
|
||||||
|
|
||||||
this_thread::sleep_for(std::chrono::milliseconds(t_delay)); //走纸多转一会儿 确保扫描传感器过了之后 纸能出完
|
//this_thread::sleep_for(std::chrono::milliseconds(2000)); //走纸多转一会儿 确保扫描传感器过了之后 纸能出完
|
||||||
capturer->setFanMode(0);
|
capturer->setFanMode(0);
|
||||||
|
|
||||||
|
|
||||||
|
//capturer->close();
|
||||||
capturer->close();
|
|
||||||
|
|
||||||
LOG("\n--------------------------scan done --------------------------------\n");
|
LOG("\n--------------------------scan done --------------------------------\n");
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,11 @@ public:
|
||||||
return !capturer->IsImageQueueEmpty();
|
return !capturer->IsImageQueueEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void close_v4l2()
|
||||||
|
{
|
||||||
|
capturer->close();
|
||||||
|
}
|
||||||
|
|
||||||
void writeParamars(std::string type, int *value)
|
void writeParamars(std::string type, int *value)
|
||||||
{
|
{
|
||||||
// capturer->m_configprop->writeParamars(type, value);
|
// capturer->m_configprop->writeParamars(type, value);
|
||||||
|
|
|
@ -126,7 +126,7 @@ UsbScanner::UsbScanner() : m_startscan(false),
|
||||||
{
|
{
|
||||||
imageremain++;
|
imageremain++;
|
||||||
m_images.Put(imageinfo);
|
m_images.Put(imageinfo);
|
||||||
printf("m_images size :%d\r\n",m_images.Size());
|
printf("队列缓存张数 :%d\r\n",m_images.Size());
|
||||||
// LOG("Enqueue image index :%d ptr:%p length:%d\n", ++enqueueindex,imageinfo.pJpegData, imageinfo.DataLength);
|
// LOG("Enqueue image index :%d ptr:%p length:%d\n", ++enqueueindex,imageinfo.pJpegData, imageinfo.DataLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -307,6 +307,10 @@ bool UsbScanner::GetEventQueueEmpty()
|
||||||
return eventsramain == 0;
|
return eventsramain == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UsbScanner::close_v4l2()
|
||||||
|
{
|
||||||
|
m_hgScanner->close_v4l2();
|
||||||
|
}
|
||||||
HG_JpegCompressInfo UsbScanner::GetFrontImage()
|
HG_JpegCompressInfo UsbScanner::GetFrontImage()
|
||||||
{
|
{
|
||||||
HG_JpegCompressInfo ret = {0};
|
HG_JpegCompressInfo ret = {0};
|
||||||
|
|
|
@ -39,6 +39,10 @@ public:
|
||||||
virtual void UpdateScanInfo(int type,void* data) override;
|
virtual void UpdateScanInfo(int type,void* data) override;
|
||||||
virtual ScannerScanInfo GetScanInfo() override;
|
virtual ScannerScanInfo GetScanInfo() override;
|
||||||
virtual void SetLEDStatus(LedStatus status) override;
|
virtual void SetLEDStatus(LedStatus status) override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual void close_v4l2()override;
|
||||||
std::string GetSysInfo();
|
std::string GetSysInfo();
|
||||||
int read_bulk(void *pdata, int length);
|
int read_bulk(void *pdata, int length);
|
||||||
int write_bulk(void *pdata, int length);
|
int write_bulk(void *pdata, int length);
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
ZouZhiMotor::ZouZhiMotor()
|
ZouZhiMotor::ZouZhiMotor()
|
||||||
: Motor(motorPorts_Zouzhi)
|
: Motor(motorPorts_Zouzhi)
|
||||||
{
|
{
|
||||||
//auto t_smbtype = smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
auto t_smbtype =MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;// smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
||||||
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;
|
|
||||||
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, 4, 1, 1);
|
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, 4, 1, 1);
|
||||||
speedConfig();
|
speedConfig();
|
||||||
}
|
}
|
||||||
|
@ -16,14 +15,12 @@ ZouZhiMotor::~ZouZhiMotor()
|
||||||
|
|
||||||
void ZouZhiMotor::start()
|
void ZouZhiMotor::start()
|
||||||
{
|
{
|
||||||
Motor::setDirection(0);
|
|
||||||
Motor::start(delays, m_zouparamex.mt_param);
|
Motor::start(delays, m_zouparamex.mt_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZouZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
void ZouZhiMotor::speedChange(int speed, int dpi, int colormode) // speed should be in range [0,5] (by ply,at 2019.5.23)
|
||||||
{
|
{
|
||||||
//auto t_smbtype = smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;//SMBType::MB_DRV_TMC216;//smbtype == SMBType::MB_DRV_TMC216 ? MotorConfig::MTBDType::MT_TMC : MotorConfig::MTBDType::MT_DRV;
|
||||||
auto t_smbtype = MotorConfig::MTBDType::MT_TMC;
|
|
||||||
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, speed, colormode, dpi);
|
m_zouparamex = m_mtconfig->GetMotorSpeedParam(true, t_smbtype, speed, colormode, dpi);
|
||||||
speedConfig();
|
speedConfig();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +32,7 @@ void ZouZhiMotor::speedRecover()
|
||||||
|
|
||||||
void ZouZhiMotor::speedConfig()
|
void ZouZhiMotor::speedConfig()
|
||||||
{
|
{
|
||||||
LOG("ZouZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ",
|
printf("ZouZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ",
|
||||||
m_zouparamex.speed,
|
m_zouparamex.speed,
|
||||||
m_zouparamex.dpi,
|
m_zouparamex.dpi,
|
||||||
m_zouparamex.colormode,
|
m_zouparamex.colormode,
|
||||||
|
@ -50,5 +47,4 @@ void ZouZhiMotor::speedConfig()
|
||||||
|
|
||||||
delays = speedup_cfg(m_zouparamex.mt_param.finalPeriod, m_zouparamex.mt_param.Fmin, m_zouparamex.mt_param.stepnum, m_zouparamex.mt_param.a,
|
delays = speedup_cfg(m_zouparamex.mt_param.finalPeriod, m_zouparamex.mt_param.Fmin, m_zouparamex.mt_param.stepnum, m_zouparamex.mt_param.a,
|
||||||
m_zouparamex.mt_param.offset, m_zouparamex.mt_param.finalDelay);
|
m_zouparamex.mt_param.offset, m_zouparamex.mt_param.finalDelay);
|
||||||
}
|
}
|
||||||
|
|
93
main.cpp
93
main.cpp
|
@ -292,6 +292,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
sts.Data = m_scanner->GetEvent().code; // 确保第一张扫描之前所发生的异常事件能够被通知
|
sts.Data = m_scanner->GetEvent().code; // 确保第一张扫描之前所发生的异常事件能够被通知
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -300,6 +301,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");
|
||||||
|
m_scanner->close_v4l2();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -322,7 +325,13 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
auto data = m_scanner->GetEvent();
|
auto data = m_scanner->GetEvent();
|
||||||
if (data.code == (int)(HG_ScannerStatus::STOP_SCAN))
|
if (data.code == (int)(HG_ScannerStatus::STOP_SCAN))
|
||||||
|
{
|
||||||
system("cpufreq-set -g ondemand");
|
system("cpufreq-set -g ondemand");
|
||||||
|
printf("关闭V4L2 4444\r\n");
|
||||||
|
m_scanner->close_v4l2();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sts.Data = data.code;
|
sts.Data = data.code;
|
||||||
if (data.code == (int)HG_ScannerStatus::AUTO_FLATTING || data.code == (int)HG_ScannerStatus::AUTO_FLAT_FINISHED)
|
if (data.code == (int)HG_ScannerStatus::AUTO_FLATTING || data.code == (int)HG_ScannerStatus::AUTO_FLAT_FINISHED)
|
||||||
{
|
{
|
||||||
|
@ -330,6 +339,8 @@ int main(int argc, char *argv[])
|
||||||
m_scanner->write_bulk(&sts, sizeof(sts));
|
m_scanner->write_bulk(&sts, sizeof(sts));
|
||||||
auto msg = data.msg;
|
auto msg = data.msg;
|
||||||
m_scanner->write_bulk(&msg[0], msg.length());
|
m_scanner->write_bulk(&msg[0], msg.length());
|
||||||
|
//printf("关闭V4L2 111\r\n");
|
||||||
|
//m_scanner->close_v4l2();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,10 +356,10 @@ int main(int argc, char *argv[])
|
||||||
if (info.pJpegData != nullptr && info.DataLength != 0)
|
if (info.pJpegData != nullptr && info.DataLength != 0)
|
||||||
{
|
{
|
||||||
int tt = m_scanner->write_bulk((void *)&info, sizeof(int) * 7);
|
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(info.pJpegData, info.DataLength);
|
// tt = m_scanner->write_bulk(info.pJpegData, info.DataLength);
|
||||||
// free(info.pJpegData);
|
// //free(info.pJpegData);
|
||||||
|
// printf("USB传输第二次write_bulk时间 :%f \r\n",sw.elapsed_ms());
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// tt = m_scanner->write_bulk(info.mat.data, info.DataLength);
|
// tt = m_scanner->write_bulk(info.mat.data, info.DataLength);
|
||||||
|
@ -359,7 +370,7 @@ int main(int argc, char *argv[])
|
||||||
int total = info.DataLength;
|
int total = info.DataLength;
|
||||||
while (total > 0)
|
while (total > 0)
|
||||||
{
|
{
|
||||||
int dstlength = 1024 * 512;
|
int dstlength = 1024 * 1024;
|
||||||
if (total <= dstlength)
|
if (total <= dstlength)
|
||||||
{
|
{
|
||||||
dstlength = total;
|
dstlength = total;
|
||||||
|
@ -371,6 +382,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
int tt = m_scanner->write_bulk(info.pJpegData + index, dstlength);
|
int tt = m_scanner->write_bulk(info.pJpegData + index, dstlength);
|
||||||
|
//printf("USB传输第二次write_bulk时间 :%f \r\n",sw.elapsed_ms());
|
||||||
|
|
||||||
// printf("write_bulk info.pJpegData+index = %p index = %d dstlength =%d tt = %d \n", info.pJpegData + index, index, dstlength, tt);
|
// printf("write_bulk info.pJpegData+index = %p index = %d dstlength =%d tt = %d \n", info.pJpegData + index, index, dstlength, tt);
|
||||||
if (tt <= -1)
|
if (tt <= -1)
|
||||||
|
@ -382,10 +394,10 @@ int main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
index += tt;
|
index += tt;
|
||||||
}
|
}
|
||||||
// free(info.pJpegData);
|
//dnasfree(info.pJpegData);
|
||||||
tjFree(info.pJpegData);
|
//tjFree(info.pJpegData);
|
||||||
LOG("Free info.pJpegData done\n");
|
//LOG("Free info.pJpegData done\n");
|
||||||
// printf("TIME!!!!!!!!!!!!! :%f info.DataLength:%d\r\n",sw.elapsed_ms(),info.DataLength);
|
printf("USB传输一帧时间 :%f \r\n",sw.elapsed_ms());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -504,16 +516,16 @@ int main(int argc, char *argv[])
|
||||||
m_scanner->SetFlatParam(usbcb.Command, buffer);
|
m_scanner->SetFlatParam(usbcb.Command, buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case USBCommand::GET_FLAT_DATA:
|
// case USBCommand::GET_FLAT_DATA:
|
||||||
{
|
// {
|
||||||
LOG("enter GET_FLAT_DATA \n");
|
// LOG("enter GET_FLAT_DATA \n");
|
||||||
int buffer[128];
|
// int buffer[128];
|
||||||
auto params = m_scanner->GetCaptureParams();
|
// auto params = m_scanner->GetCaptureParams();
|
||||||
LOG("size of params %d \n", sizeof(params));
|
// LOG("size of params %d \n", sizeof(params));
|
||||||
memcpy(buffer, ¶ms, sizeof(params));
|
// memcpy(buffer, ¶ms, sizeof(params));
|
||||||
m_scanner->write_bulk(&buffer, sizeof(int) * 128);
|
// m_scanner->write_bulk(&buffer, sizeof(int) * 128);
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case USBCommand::PRE_UPGRADE:
|
case USBCommand::PRE_UPGRADE:
|
||||||
{
|
{
|
||||||
writesyslog(LOG_INFO, "start updating system\n");
|
writesyslog(LOG_INFO, "start updating system\n");
|
||||||
|
@ -760,54 +772,63 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case USBCommand::GET_FLAT_DATA:
|
case USBCommand::GET_FLAT_DATA:
|
||||||
{
|
{
|
||||||
FLAT_INFO *flatinfo = static_cast<FLAT_INFO *>(usbcb.Data);
|
FLAT_INFO flatinfo ;
|
||||||
|
flatinfo.value = usbcb.Data;
|
||||||
|
flatinfo.params.status = 100; ////正常状态
|
||||||
unsigned char *lut_buffer;
|
unsigned char *lut_buffer;
|
||||||
if (flatinfo->params.dpi != 0)
|
if (flatinfo.params.dpi != 0)
|
||||||
{
|
{
|
||||||
std::ifstream lut_item;
|
std::ifstream lut_item;
|
||||||
int dpi = flatinfo->params.dpi == 0x01 ? 200 : (flatinfo->params.dpi == 0x02 ? 300 : 600);
|
int dpi = flatinfo.params.dpi == 0x01 ? 200 : (flatinfo.params.dpi == 0x02 ? 300 : 600);
|
||||||
std::string mode = flatinfo->params.colormode ? "clr" : "gray";
|
std::string mode = flatinfo.params.colormode ? "clr" : "gray";
|
||||||
std::string is_white_lut = flatinfo->params.is_whiteimage ? "white" : "bw";
|
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/conf-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);
|
lut_item.open(lut_path, std::ios_base::in | std::ios_base::binary);
|
||||||
|
|
||||||
|
|
||||||
if (!lut_item.is_open())
|
if (!lut_item.is_open())
|
||||||
{
|
{
|
||||||
flatinfo->params.datalen = 0;
|
flatinfo.params.datalen = 0;
|
||||||
flatinfo->params.status = 1; // 文件打开失败
|
flatinfo.params.status = 1; // 文件打开失败
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lut_item.seekg(0, std::ios::end);
|
lut_item.seekg(0, std::ios::end);
|
||||||
size_t length = lut_item.tellg();
|
size_t length = lut_item.tellg();
|
||||||
lut_item.seekg(0, std::ios::beg);
|
lut_item.seekg(0, std::ios::beg);
|
||||||
flatinfo->params.datalen = length
|
flatinfo.params.datalen = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flatinfo->params.datalen != 0)
|
if (flatinfo.params.datalen != 0 && flatinfo.params.status == 100)
|
||||||
{
|
{
|
||||||
lut_buffer = new unsigned char[flatinfo->params.datalen];
|
lut_buffer = new unsigned char[flatinfo.params.datalen];
|
||||||
if (lut_buffer)
|
if (lut_buffer)
|
||||||
lut_item.read(lut_buffer, flatinfo->params.datalen);
|
{
|
||||||
|
lut_item.read((char *)lut_buffer, flatinfo.params.datalen);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flatinfo->params.status = 2; // OOM 异常
|
flatinfo.params.status = 2; // OOM 异常
|
||||||
flatinfo->params.datalen = 0;
|
flatinfo.params.datalen = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flatinfo->params.datalen = 0;
|
flatinfo.params.datalen = 0;
|
||||||
flatinfo->params.status = 3; // 未知dpi
|
flatinfo.params.status = 3; // 未知dpi
|
||||||
}
|
}
|
||||||
|
|
||||||
usbcb.Data = flatinfo->value;
|
usbcb.Data = flatinfo.value;
|
||||||
|
printf("flatinfo.params.status:%d flatinfo.params.datalen:%d flatinfo.value:%d\r\n",flatinfo.params.status,flatinfo.params.datalen,flatinfo.value);
|
||||||
m_scanner->write_bulk(&usbcb, sizeof(usbcb));
|
m_scanner->write_bulk(&usbcb, sizeof(usbcb));
|
||||||
|
|
||||||
if (lut_buffer)
|
if (lut_buffer)
|
||||||
{
|
{
|
||||||
m_scanner->write_bulk(lut_buffer, flatinfo->params.datalen);
|
m_scanner->write_bulk(lut_buffer, flatinfo.params.datalen);
|
||||||
delete[] lut_buffer;
|
delete[] lut_buffer;
|
||||||
|
lut_buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue