新增G300/G400速率可配,处理G300/G400图片保存问题

This commit is contained in:
13038267101 2021-09-14 16:45:12 +08:00
parent f1f2c4ccd3
commit 9eae141ee4
8 changed files with 112 additions and 19 deletions

View File

@ -8,6 +8,10 @@
2021年7月31日
1.增加3399 板子g100 g200 校正及配置功能
2021年9月14日
1、增加G300/G400速率可配置
2、处理G300/G400不能出图问题
2021年8月17日
1. 界面增加速度模式配置功能;
2. 增加明场暗场校正最大明场值配置;

View File

@ -60,6 +60,13 @@ BOOL CA3::OnInitDialog()
{
m_cmbSpeedmode.InsertString(i, speedmodeMapString[i]);
}
speedemodelen = speedmodeMap.size() + G300G400speedmodeMapString.size();
size_t j = 1;
for (size_t i = speedmodeMap.size(); i < speedemodelen; i++)
{
m_cmbSpeedmode.InsertString(i, G300G400speedmodeMapString[j]);
++j;
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
@ -288,12 +295,20 @@ void CA3::updatespeedmode(bool get)
auto parent = (CHuaGoCorrectDlg*)GetParent();
if (parent != NULL)
{
if (parent->m_drv.get() && parent->m_drv->IsConnected()) {
if (parent->m_drv.get() && parent->m_drv->IsConnected())
{
int speedmode;
std::string ver = parent->m_drv->GetFWVersion();
if (!ver.empty())
{
ver = ver.substr(0, 2);
}
if (get)
{
parent->m_drv->GetSpeedMode(speedmode, true);
bool bfound = false;
if (ver != "G3" && ver != "G4")
{
for (size_t i = 0; i < speedmodeMap.size(); i++)
{
if (speedmodeMap[i].Speedmode == speedmode)
@ -305,18 +320,51 @@ void CA3::updatespeedmode(bool get)
break;
}
}
}
else
{
size_t j = 1;
for (size_t i = speedmodeMap.size(); i < speedemodelen; i++)
{
if (j == speedmode)
{
m_cmbSpeedmode.SetCurSel(i);
bfound = true;
break;
}
++j;
}
}
if (!bfound)
MessageBox(L"未找到对应的速度模式!", L"提示", MB_OK | MB_ICONINFORMATION);
}
else
{
int cmbindex = m_cmbSpeedmode.GetCurSel();
if (cmbindex != -1)
if (cmbindex != -1 && cmbindex < speedmodeMap.size())
{
if (ver == "G3" || ver == "G4")
{
MessageBox(L"设备序列号前两位为G3/G4请确认设备", L"速率选择错误", MB_OK | MB_ICONINFORMATION);
return;
}
auto t_speedmode = speedmodeMap[cmbindex];
parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false);
parent->m_drv->SetSptime(0, t_speedmode.GraySp);
parent->m_drv->SetSptime(1, t_speedmode.ColorSp);
}
else
{
if (ver != "G3" && ver != "G4")
{
MessageBox(L"设备序列号前两位不为G3/G4请确认设备", L"速率选择错误", MB_OK | MB_ICONINFORMATION);
return;
}
cmbindex = cmbindex - speedmodeMap.size() + 1;
parent->m_drv->GetSpeedMode(cmbindex, false);
}
}
}

View File

@ -51,6 +51,7 @@ private:
unsigned int ColorSp;
unsigned int GraySp;
};
int speedemodelen;
std::map<int, speedmodeparam> speedmodeMap = {
{0,{70,0x42d,0xc88}},
{1,{80,0x37f,0xa7f}},
@ -70,5 +71,13 @@ private:
{5,L"G200_120PPM"},
{6,L"G200_130PPM"}
};
std::map<int, CString> G300G400speedmodeMapString = {
{1,L"G300/G400_40PPM"},
{2,L"G300/G400_50PPM"},
{3,L"G300/G400_60PPM"},
{4,L"G300/G400_70PPM"},
{5,L"G400_80PPM"},
};
CComboBox m_cmbSpeedmode;
};

View File

@ -400,12 +400,20 @@ void CA4::OnBnClickedBtnbdown()
void CA4::UpdateGains(int id, bool increase)
{
UpdateData(TRUE);
int offect;
CString offectstr;
GetDlgItemText(IDC_tbxOffect, offectstr);
USES_CONVERSION;
std::string str_b(W2A(offectstr));
offect = atoi(str_b.c_str());
if (offect <= 0)
offect = 1;
if ((id == IDC_BTNAUP || id == IDC_BTNBUP) && increase)
{
int startindex = id == IDC_BTNAUP ? 0 : 6;
for (size_t i = startindex; i < (6+ startindex); i++)
{
params.Gain[i] = params.Gain[i]++;
params.Gain[i] += offect;
}
}
else if((id==IDC_BTNADOWN||id==IDC_BTNBDOWN)&&!increase)
@ -413,7 +421,7 @@ void CA4::UpdateGains(int id, bool increase)
int startindex = id == IDC_BTNADOWN ? 0 : 6;
for (size_t i = startindex; i < (6 + startindex); i++)
{
params.Gain[i] = params.Gain[i]--;
params.Gain[i] -= offect;
}
}
UpdateData(FALSE);

Binary file not shown.

View File

@ -4,6 +4,8 @@
#include "filetools.h"
#include "imageprocess.h"
#include <atlconv.h>
#include<iostream>
using namespace std;
static int imgindex = 0;
ImageMatQueue::ImageMatQueue(void)
{
@ -111,11 +113,13 @@ void ImageMatQueue::proc()
{
if (pixType != -1)
{
std::string csName;
//string csName;
SYSTEMTIME st = { 0 };
GetLocalTime(&st); //获取当前时间 可精确到ms
//csName.Format("%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond,++imgindex);
//csName.Format(_T("%02d%02d%02d-%d.bmp"), st.wHour, st.wMinute, st.wSecond,++imgindex);
char szDateTime[20] = { 0 };
sprintf(szDateTime,"%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond, ++imgindex);
string csName(szDateTime);
cv::Mat matPicImage;
cv::Mat matFront, matBack;
//vector<cv::Mat> mats;
@ -138,13 +142,16 @@ void ImageMatQueue::proc()
case 4://G500 正反面图像在一副图上,需要均分图像
{
std::string csImage;
csImage = csPath + "\\G300" + csName;
csImage = csPath + "\\G300"+ csName;
//cv::Mat mat = m_pImages.Take().getMat(pixType);
//matPicImage = mat(cv::Rect(0, 0, mat.cols, mat.rows));
////mats.push_back(matPicImage);
//IplImage qqImg;
//qqImg = IplImage(matPicImage); // cv::Mat -> IplImage
//cvSaveImage(csImage, &qqImg);
cv::Mat mat = m_pImages.Take().getMat(pixType);//1 color 6 gray
cv::imwrite(csImage, mat);
m_images.Put(csImage);
}
break;

Binary file not shown.

View File

@ -238,6 +238,23 @@ void GScn_Drv::SetFlatCallback(std::function<void(std::string)> func)
void GScn_Drv::GetSpeedMode(int& speedmode, bool get)
{
if (m_usb.get() && m_usb->is_connected())
{
if (get)
{
USBCB usb = { GET_SPEED_MODE ,speedmode,0 };
m_usb->write_bulk(&usb, sizeof(usb));
m_usb->read_bulk(&usb, sizeof(usb));
speedmode = usb.u32_Data;
}
else
{
USBCB usb = { SET_SPEED_MODE,speedmode,0 };
m_usb->write_bulk(&usb, sizeof(usb));
}
}
}
void GScn_Drv::reset()