first init

This commit is contained in:
lovelyyoung 2020-08-31 16:08:50 +08:00
commit ed041c441c
709 changed files with 494056 additions and 0 deletions

View File

@ -0,0 +1,6 @@
2020.8.31
1增加CIS检测工具畸变检测
2通过选择扫描框中的保存校正前后原图进行图片保存
3软件打开时自动查找已有设备打开然后将打开的型号显示在型号选择框中也可以通过型号选择框更换型号
4界面整合幅面页面等设置统一在扫描框中
5CIS的通道阀值以及畸变检测中目标值偏差值等参数自动加载和保存

31
HuaGoCorrect.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.960
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HuaGoCorrect_V3.0", "HuaGoCorrect\HuaGoCorrect.vcxproj", "{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Debug|Win32.ActiveCfg = Debug|Win32
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Debug|Win32.Build.0 = Debug|Win32
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Debug|x64.ActiveCfg = Debug|x64
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Debug|x64.Build.0 = Debug|x64
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Release|Win32.ActiveCfg = Release|Win32
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Release|Win32.Build.0 = Release|Win32
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Release|x64.ActiveCfg = Release|x64
{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B23184A-7ABD-4E4F-B3EC-DFE00243E802}
EndGlobalSection
EndGlobal

BIN
HuaGoCorrect.suo Normal file

Binary file not shown.

45
HuaGoCorrect/A3.cpp Normal file
View File

@ -0,0 +1,45 @@
// A3.cpp : 实现文件
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "A3.h"
#include "afxdialogex.h"
// CA3 对话框
IMPLEMENT_DYNAMIC(CA3, CDialog)
CA3::CA3(CWnd* pParent /*=NULL*/)
: CDialog(CA3::IDD, pParent)
{
}
CA3::~CA3()
{
}
void CA3::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CA3, CDialog)
END_MESSAGE_MAP()
// CA3 消息处理程序
BOOL CA3::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}

23
HuaGoCorrect/A3.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
// CA3 对话框
class CA3 : public CDialog
{
DECLARE_DYNAMIC(CA3)
public:
CA3(CWnd* pParent = NULL); // 标准构造函数
virtual ~CA3();
// 对话框数据
enum { IDD = IDD_A3_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
};

867
HuaGoCorrect/A4.cpp Normal file
View File

@ -0,0 +1,867 @@
// A4.cpp : 实现文件
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "A4.h"
#include "afxdialogex.h"
// CA4 对话框
IMPLEMENT_DYNAMIC(CA4, CDialog)
CA4::CA4(CWnd* pParent /*=NULL*/)
: CDialog(CA4::IDD, pParent)
, m_tbxAGain(0)
, m_tbxBGain(0)
, m_tbxAOffset(0)
, m_tbxBOffset(0)
{
m_iLastIndex = 0;
m_iSelIndex = 0;
m_tbxFRExposure = 0;
m_tbxFGExposure = 0;
m_tbxFBExposure = 0;
m_tbxF1Gain = 0;
m_tbxF2Gain = 0;
m_tbxF3Gain = 0;
m_tbxF4Gain = 0;
m_tbxF5Gain = 0;
m_tbxF6Gain = 0;
m_tbxF1Offset = 0;
m_tbxF2Offset = 0;
m_tbxF3Offset = 0;
m_tbxF4Offset = 0;
m_tbxF5Offset = 0;
m_tbxF6Offset = 0;
m_tbxBRExposure = 0;
m_tbxBGExposure = 0;
m_tbxBBExposure = 0;
m_tbxB1Gain = 0;
m_tbxB2Gain = 0;
m_tbxB3Gain = 0;
m_tbxB4Gain = 0;
m_tbxB5Gain = 0;
m_tbxB6Gain = 0;
m_tbxB1Offset = 0;
m_tbxB2Offset = 0;
m_tbxB3Offset = 0;
m_tbxB4Offset = 0;
m_tbxB5Offset = 0;
m_tbxB6Offset = 0;
}
CA4::~CA4()
{
}
void CA4::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_tbxFRExposure, m_tbxFRExposure);
DDX_Text(pDX, IDC_tbxFGExposure, m_tbxFGExposure);
DDX_Text(pDX, IDC_tbxFBExposure, m_tbxFBExposure);
DDX_Text(pDX, IDC_tbxF1Gain, m_tbxF1Gain);
DDX_Text(pDX, IDC_tbxF2Gain, m_tbxF2Gain);
DDX_Text(pDX, IDC_tbxF3Gain, m_tbxF3Gain);
DDX_Text(pDX, IDC_tbxF4Gain, m_tbxF4Gain);
DDX_Text(pDX, IDC_tbxF5Gain, m_tbxF5Gain);
DDX_Text(pDX, IDC_tbxF6Gain, m_tbxF6Gain);
DDX_Text(pDX, IDC_tbxF1Offset, m_tbxF1Offset);
DDX_Text(pDX, IDC_tbxF2Offset, m_tbxF2Offset);
DDX_Text(pDX, IDC_tbxF3Offset, m_tbxF3Offset);
DDX_Text(pDX, IDC_tbxF4Offset, m_tbxF4Offset);
DDX_Text(pDX, IDC_tbxF5Offset, m_tbxF5Offset);
DDX_Text(pDX, IDC_tbxF6Offset, m_tbxF6Offset);
DDX_Text(pDX, IDC_tbxBRExposure, m_tbxBRExposure);
DDX_Text(pDX, IDC_tbxBGExposure, m_tbxBGExposure);
DDX_Text(pDX, IDC_tbxBBExposure, m_tbxBBExposure);
DDX_Text(pDX, IDC_tbxB1Gain, m_tbxB1Gain);
DDX_Text(pDX, IDC_tbxB2Gain, m_tbxB2Gain);
DDX_Text(pDX, IDC_tbxB3Gain, m_tbxB3Gain);
DDX_Text(pDX, IDC_tbxB4Gain, m_tbxB4Gain);
DDX_Text(pDX, IDC_tbxB5Gain, m_tbxB5Gain);
DDX_Text(pDX, IDC_tbxB6Gain, m_tbxB6Gain);
DDX_Text(pDX, IDC_tbxB1Offset, m_tbxB1Offset);
DDX_Text(pDX, IDC_tbxB2Offset, m_tbxB2Offset);
DDX_Text(pDX, IDC_tbxB3Offset, m_tbxB3Offset);
DDX_Text(pDX, IDC_tbxB4Offset, m_tbxB4Offset);
DDX_Text(pDX, IDC_tbxB5Offset, m_tbxB5Offset);
DDX_Text(pDX, IDC_tbxB6Offset, m_tbxB6Offset);
DDX_Control(pDX, IDC_CMB_A4FlatModel, m_A4FlatModel);
DDX_Text(pDX, IDC_EDIT_AGAIN, m_tbxAGain);
DDV_MinMaxUInt(pDX, m_tbxAGain, 0, 1000);
DDX_Text(pDX, IDC_EDIT_BGAIN, m_tbxBGain);
DDV_MinMaxUInt(pDX, m_tbxBGain, 0, 1000);
DDX_Text(pDX, IDC_EDIT_AOFFSET, m_tbxAOffset);
DDV_MinMaxUInt(pDX, m_tbxAOffset, 0, 1000);
DDX_Text(pDX, IDC_EDIT_BOFFSET, m_tbxBOffset);
DDV_MinMaxUInt(pDX, m_tbxBOffset, 0, 1000);
}
BEGIN_MESSAGE_MAP(CA4, CDialog)
ON_CBN_SELCHANGE(IDC_CMB_A4FlatModel, &CA4::OnCbnSelChangeA4FlatModel)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_AGAIN, &CA4::OnDeltaposSpinAgain)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_AOFFSET, &CA4::OnDeltaposSpinAoffset)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BGAIN, &CA4::OnDeltaposSpinBgain)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BOFFSET, &CA4::OnDeltaposSpinBoffset)
END_MESSAGE_MAP()
// CA4 消息处理程序
BOOL CA4::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
LoadCfg();
m_A4FlatModel.InsertString(0, _T("彩色校正模式"));
m_A4FlatModel.InsertString(1, _T("彩色"));
m_A4FlatModel.InsertString(2, _T("灰度校正模式"));
m_A4FlatModel.InsertString(3, _T("灰度"));
m_A4FlatModel.SetCurSel(0);
//GetDlgItem(IDC_CMB_A4FlatModel)->EnableWindow(FALSE);
default0param();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CA4::OnCbnSelChangeA4FlatModel()
{
// TODO: 在此添加控件通知处理程序代码
//int nSel;
// 获取组合框控件的列表框中选中项的索引
m_iSelIndex = m_A4FlatModel.GetCurSel();
if(m_iLastIndex != m_iSelIndex)
{
SaveNewParam(m_iLastIndex);
m_iLastIndex = m_iSelIndex;
}
switch (m_iSelIndex)
{
case 0:
default0param();
break;
case 1:
default1param();
break;
case 2:
default2param();
break;
case 3:
default3param();
break;
default:
break;
}
}
void CA4::default0param()
{
UpdateData(TRUE);
m_tbxFRExposure = m_sFlatCorrection.ColorCorrection[0];
m_tbxFGExposure = m_sFlatCorrection.ColorCorrection[1];
m_tbxFBExposure = m_sFlatCorrection.ColorCorrection[2];
m_tbxF1Gain = m_sFlatCorrection.ColorCorrection[3];
m_tbxF2Gain = m_sFlatCorrection.ColorCorrection[4];
m_tbxF3Gain = m_sFlatCorrection.ColorCorrection[5];
m_tbxF4Gain = m_sFlatCorrection.ColorCorrection[6];
m_tbxF5Gain = m_sFlatCorrection.ColorCorrection[7];
m_tbxF6Gain = m_sFlatCorrection.ColorCorrection[8];
m_tbxF1Offset = m_sFlatCorrection.ColorCorrection[9];
m_tbxF2Offset = m_sFlatCorrection.ColorCorrection[10];
m_tbxF3Offset = m_sFlatCorrection.ColorCorrection[11];
m_tbxF4Offset = m_sFlatCorrection.ColorCorrection[12];
m_tbxF5Offset = m_sFlatCorrection.ColorCorrection[13];
m_tbxF6Offset = m_sFlatCorrection.ColorCorrection[14];
m_tbxBRExposure = m_sFlatCorrection.ColorCorrection[15];
m_tbxBGExposure = m_sFlatCorrection.ColorCorrection[16];
m_tbxBBExposure = m_sFlatCorrection.ColorCorrection[17];
m_tbxB1Gain = m_sFlatCorrection.ColorCorrection[18];
m_tbxB2Gain = m_sFlatCorrection.ColorCorrection[19];
m_tbxB3Gain = m_sFlatCorrection.ColorCorrection[20];
m_tbxB4Gain = m_sFlatCorrection.ColorCorrection[21];
m_tbxB5Gain = m_sFlatCorrection.ColorCorrection[22];
m_tbxB6Gain = m_sFlatCorrection.ColorCorrection[23];
m_tbxB1Offset = m_sFlatCorrection.ColorCorrection[24];
m_tbxB2Offset = m_sFlatCorrection.ColorCorrection[25];
m_tbxB3Offset = m_sFlatCorrection.ColorCorrection[26];
m_tbxB4Offset = m_sFlatCorrection.ColorCorrection[27];
m_tbxB5Offset = m_sFlatCorrection.ColorCorrection[28];
m_tbxB6Offset = m_sFlatCorrection.ColorCorrection[29];
UpdateData(FALSE);
}
void CA4::default1param()
{
UpdateData(TRUE);
m_tbxFRExposure = m_sFlatCorrection.ColorFlat[0];
m_tbxFGExposure = m_sFlatCorrection.ColorFlat[1];
m_tbxFBExposure = m_sFlatCorrection.ColorFlat[2];
m_tbxF1Gain = m_sFlatCorrection.ColorFlat[3];
m_tbxF2Gain = m_sFlatCorrection.ColorFlat[4];
m_tbxF3Gain = m_sFlatCorrection.ColorFlat[5];
m_tbxF4Gain = m_sFlatCorrection.ColorFlat[6];
m_tbxF5Gain = m_sFlatCorrection.ColorFlat[7];
m_tbxF6Gain = m_sFlatCorrection.ColorFlat[8];
m_tbxF1Offset = m_sFlatCorrection.ColorFlat[9];
m_tbxF2Offset = m_sFlatCorrection.ColorFlat[10];
m_tbxF3Offset = m_sFlatCorrection.ColorFlat[11];
m_tbxF4Offset = m_sFlatCorrection.ColorFlat[12];
m_tbxF5Offset = m_sFlatCorrection.ColorFlat[13];
m_tbxF6Offset = m_sFlatCorrection.ColorFlat[14];
m_tbxBRExposure = m_sFlatCorrection.ColorFlat[15];
m_tbxBGExposure = m_sFlatCorrection.ColorFlat[16];
m_tbxBBExposure = m_sFlatCorrection.ColorFlat[17];
m_tbxB1Gain = m_sFlatCorrection.ColorFlat[18];
m_tbxB2Gain = m_sFlatCorrection.ColorFlat[19];
m_tbxB3Gain = m_sFlatCorrection.ColorFlat[20];
m_tbxB4Gain = m_sFlatCorrection.ColorFlat[21];
m_tbxB5Gain = m_sFlatCorrection.ColorFlat[22];
m_tbxB6Gain = m_sFlatCorrection.ColorFlat[23];
m_tbxB1Offset = m_sFlatCorrection.ColorFlat[24];
m_tbxB2Offset = m_sFlatCorrection.ColorFlat[25];
m_tbxB3Offset = m_sFlatCorrection.ColorFlat[26];
m_tbxB4Offset = m_sFlatCorrection.ColorFlat[27];
m_tbxB5Offset = m_sFlatCorrection.ColorFlat[28];
m_tbxB6Offset = m_sFlatCorrection.ColorFlat[29];
UpdateData(FALSE);
}
void CA4::default2param()
{
UpdateData(TRUE);
m_tbxFRExposure = m_sFlatCorrection.GrayCorrection[0];
m_tbxFGExposure = m_sFlatCorrection.GrayCorrection[1];
m_tbxFBExposure = m_sFlatCorrection.GrayCorrection[2];
m_tbxF1Gain = m_sFlatCorrection.GrayCorrection[3];
m_tbxF2Gain = m_sFlatCorrection.GrayCorrection[4];
m_tbxF3Gain = m_sFlatCorrection.GrayCorrection[5];
m_tbxF4Gain = m_sFlatCorrection.GrayCorrection[6];
m_tbxF5Gain = m_sFlatCorrection.GrayCorrection[7];
m_tbxF6Gain = m_sFlatCorrection.GrayCorrection[8];
m_tbxF1Offset = m_sFlatCorrection.GrayCorrection[9];
m_tbxF2Offset = m_sFlatCorrection.GrayCorrection[10];
m_tbxF3Offset = m_sFlatCorrection.GrayCorrection[11];
m_tbxF4Offset = m_sFlatCorrection.GrayCorrection[12];
m_tbxF5Offset = m_sFlatCorrection.GrayCorrection[13];
m_tbxF6Offset = m_sFlatCorrection.GrayCorrection[14];
m_tbxBRExposure = m_sFlatCorrection.GrayCorrection[15];
m_tbxBGExposure = m_sFlatCorrection.GrayCorrection[16];
m_tbxBBExposure = m_sFlatCorrection.GrayCorrection[17];
m_tbxB1Gain = m_sFlatCorrection.GrayCorrection[18];
m_tbxB2Gain = m_sFlatCorrection.GrayCorrection[19];
m_tbxB3Gain = m_sFlatCorrection.GrayCorrection[20];
m_tbxB4Gain = m_sFlatCorrection.GrayCorrection[21];
m_tbxB5Gain = m_sFlatCorrection.GrayCorrection[22];
m_tbxB6Gain = m_sFlatCorrection.GrayCorrection[23];
m_tbxB1Offset = m_sFlatCorrection.GrayCorrection[24];
m_tbxB2Offset = m_sFlatCorrection.GrayCorrection[25];
m_tbxB3Offset = m_sFlatCorrection.GrayCorrection[26];
m_tbxB4Offset = m_sFlatCorrection.GrayCorrection[27];
m_tbxB5Offset = m_sFlatCorrection.GrayCorrection[28];
m_tbxB6Offset = m_sFlatCorrection.GrayCorrection[29];
UpdateData(FALSE);
}
void CA4::default3param()
{
UpdateData(TRUE);
m_tbxFRExposure = m_sFlatCorrection.GrayFlat[0];
m_tbxFGExposure = m_sFlatCorrection.GrayFlat[1];
m_tbxFBExposure = m_sFlatCorrection.GrayFlat[2];
m_tbxF1Gain = m_sFlatCorrection.GrayFlat[3];
m_tbxF2Gain = m_sFlatCorrection.GrayFlat[4];
m_tbxF3Gain = m_sFlatCorrection.GrayFlat[5];
m_tbxF4Gain = m_sFlatCorrection.GrayFlat[6];
m_tbxF5Gain = m_sFlatCorrection.GrayFlat[7];
m_tbxF6Gain = m_sFlatCorrection.GrayFlat[8];
m_tbxF1Offset = m_sFlatCorrection.GrayFlat[9];
m_tbxF2Offset = m_sFlatCorrection.GrayFlat[10];
m_tbxF3Offset = m_sFlatCorrection.GrayFlat[11];
m_tbxF4Offset = m_sFlatCorrection.GrayFlat[12];
m_tbxF5Offset = m_sFlatCorrection.GrayFlat[13];
m_tbxF6Offset = m_sFlatCorrection.GrayFlat[14];
m_tbxBRExposure = m_sFlatCorrection.GrayFlat[15];
m_tbxBGExposure = m_sFlatCorrection.GrayFlat[16];
m_tbxBBExposure = m_sFlatCorrection.GrayFlat[17];
m_tbxB1Gain = m_sFlatCorrection.GrayFlat[18];
m_tbxB2Gain = m_sFlatCorrection.GrayFlat[19];
m_tbxB3Gain = m_sFlatCorrection.GrayFlat[20];
m_tbxB4Gain = m_sFlatCorrection.GrayFlat[21];
m_tbxB5Gain = m_sFlatCorrection.GrayFlat[22];
m_tbxB6Gain = m_sFlatCorrection.GrayFlat[23];
m_tbxB1Offset = m_sFlatCorrection.GrayFlat[24];
m_tbxB2Offset = m_sFlatCorrection.GrayFlat[25];
m_tbxB3Offset = m_sFlatCorrection.GrayFlat[26];
m_tbxB4Offset = m_sFlatCorrection.GrayFlat[27];
m_tbxB5Offset = m_sFlatCorrection.GrayFlat[28];
m_tbxB6Offset = m_sFlatCorrection.GrayFlat[29];
UpdateData(FALSE);
}
void CA4::updateA4Config(int *pValues)
{
UpdateData(TRUE);
m_tbxFRExposure = pValues[0];
m_tbxFGExposure = pValues[1];
m_tbxFBExposure = pValues[2];
m_tbxF1Gain = pValues[6];
m_tbxF2Gain = pValues[7];
m_tbxF3Gain = pValues[8];
m_tbxF4Gain = pValues[9];
m_tbxF5Gain = pValues[10];
m_tbxF6Gain = pValues[11];
m_tbxF1Offset = pValues[18];
m_tbxF2Offset = pValues[19];
m_tbxF3Offset = pValues[20];
m_tbxF4Offset = pValues[21];
m_tbxF5Offset = pValues[22];
m_tbxF6Offset = pValues[23];
m_tbxBRExposure = pValues[3];
m_tbxBGExposure = pValues[4];
m_tbxBBExposure = pValues[5];
m_tbxB1Gain = pValues[12];
m_tbxB2Gain = pValues[13];
m_tbxB3Gain = pValues[14];
m_tbxB4Gain = pValues[15];
m_tbxB5Gain = pValues[16];
m_tbxB6Gain = pValues[17];
m_tbxB1Offset = pValues[24];
m_tbxB2Offset = pValues[25];
m_tbxB3Offset = pValues[26];
m_tbxB4Offset = pValues[27];
m_tbxB5Offset = pValues[28];
m_tbxB6Offset = pValues[29];
UpdateData(FALSE);
}
void CA4::LoadCfg()
{
UINT iColorCorrectionParam[30] = {0};
UINT iColorFlatParam[30] = {0};
UINT iGrayCorrectionParam[30] = {0};
UINT iGrayFlatParam[30] = {0};
//GetDlgItem(IDC_CMB_A4FlatModel)->EnableWindow(TRUE);
iColorCorrectionParam[0] = ::GetPrivateProfileInt("ColorCorrection", "FBExposure", 340, INI_FILE_NAME);
iColorCorrectionParam[1] = ::GetPrivateProfileInt("ColorCorrection", "FGExposure", 620, INI_FILE_NAME);
iColorCorrectionParam[2] = ::GetPrivateProfileInt("ColorCorrection", "FRExposure", 324, INI_FILE_NAME);
iColorCorrectionParam[3] = ::GetPrivateProfileInt("ColorCorrection", "F3Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[4] = ::GetPrivateProfileInt("ColorCorrection", "F2Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[5] = ::GetPrivateProfileInt("ColorCorrection", "F1Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[6] = ::GetPrivateProfileInt("ColorCorrection", "F6Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[7] = ::GetPrivateProfileInt("ColorCorrection", "F5Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[8] = ::GetPrivateProfileInt("ColorCorrection", "F4Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[9] = ::GetPrivateProfileInt("ColorCorrection", "F3Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[10] = ::GetPrivateProfileInt("ColorCorrection", "F2Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[11] = ::GetPrivateProfileInt("ColorCorrection", "F1Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[12] = ::GetPrivateProfileInt("ColorCorrection", "F6Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[13] = ::GetPrivateProfileInt("ColorCorrection", "F5Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[14] = ::GetPrivateProfileInt("ColorCorrection", "F4Offset", 117, INI_FILE_NAME);
iColorCorrectionParam[15] = ::GetPrivateProfileInt("ColorCorrection", "BBExposure", 233, INI_FILE_NAME);
iColorCorrectionParam[16] = ::GetPrivateProfileInt("ColorCorrection", "BGExposure", 418, INI_FILE_NAME);
iColorCorrectionParam[17] = ::GetPrivateProfileInt("ColorCorrection", "BRExposure", 220, INI_FILE_NAME);
iColorCorrectionParam[18] = ::GetPrivateProfileInt("ColorCorrection", "B3Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[19] = ::GetPrivateProfileInt("ColorCorrection", "B2Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[20] = ::GetPrivateProfileInt("ColorCorrection", "B1Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[21] = ::GetPrivateProfileInt("ColorCorrection", "B6Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[22] = ::GetPrivateProfileInt("ColorCorrection", "B5Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[23] = ::GetPrivateProfileInt("ColorCorrection", "B4Gain", 24, INI_FILE_NAME);
iColorCorrectionParam[24] = ::GetPrivateProfileInt("ColorCorrection", "B3Offset", 64, INI_FILE_NAME);
iColorCorrectionParam[25] = ::GetPrivateProfileInt("ColorCorrection", "B2Offset", 64, INI_FILE_NAME);
iColorCorrectionParam[26] = ::GetPrivateProfileInt("ColorCorrection", "B1Offset", 64, INI_FILE_NAME);
iColorCorrectionParam[27] = ::GetPrivateProfileInt("ColorCorrection", "B6Offset", 64, INI_FILE_NAME);
iColorCorrectionParam[28] = ::GetPrivateProfileInt("ColorCorrection", "B5Offset", 64, INI_FILE_NAME);
iColorCorrectionParam[29] = ::GetPrivateProfileInt("ColorCorrection", "B4Offset", 64, INI_FILE_NAME);
memcpy(m_sFlatCorrection.ColorCorrection,iColorCorrectionParam,sizeof(iColorCorrectionParam));
iColorFlatParam[0] = ::GetPrivateProfileInt("ColorFlat", "FBExposure", 340, INI_FILE_NAME);
iColorFlatParam[1] = ::GetPrivateProfileInt("ColorFlat", "FGExposure", 620, INI_FILE_NAME);
iColorFlatParam[2] = ::GetPrivateProfileInt("ColorFlat", "FRExposure", 324, INI_FILE_NAME);
iColorFlatParam[3] = ::GetPrivateProfileInt("ColorFlat", "F3Gain", 24, INI_FILE_NAME);
iColorFlatParam[4] = ::GetPrivateProfileInt("ColorFlat", "F2Gain", 24, INI_FILE_NAME);
iColorFlatParam[5] = ::GetPrivateProfileInt("ColorFlat", "F1Gain", 24, INI_FILE_NAME);
iColorFlatParam[6] = ::GetPrivateProfileInt("ColorFlat", "F6Gain", 24, INI_FILE_NAME);
iColorFlatParam[7] = ::GetPrivateProfileInt("ColorFlat", "F5Gain", 24, INI_FILE_NAME);
iColorFlatParam[8] = ::GetPrivateProfileInt("ColorFlat", "F4Gain", 24, INI_FILE_NAME);
iColorFlatParam[9] = ::GetPrivateProfileInt("ColorFlat", "F3Offset", 117, INI_FILE_NAME);
iColorFlatParam[10] = ::GetPrivateProfileInt("ColorFlat", "F2Offset", 117, INI_FILE_NAME);
iColorFlatParam[11] = ::GetPrivateProfileInt("ColorFlat", "F1Offset", 117, INI_FILE_NAME);
iColorFlatParam[12] = ::GetPrivateProfileInt("ColorFlat", "F6Offset", 117, INI_FILE_NAME);
iColorFlatParam[13] = ::GetPrivateProfileInt("ColorFlat", "F5Offset", 117, INI_FILE_NAME);
iColorFlatParam[14] = ::GetPrivateProfileInt("ColorFlat", "F4Offset", 117, INI_FILE_NAME);
iColorFlatParam[15] = ::GetPrivateProfileInt("ColorFlat", "BBExposure", 233, INI_FILE_NAME);
iColorFlatParam[16] = ::GetPrivateProfileInt("ColorFlat", "BGExposure", 418, INI_FILE_NAME);
iColorFlatParam[17] = ::GetPrivateProfileInt("ColorFlat", "BRExposure", 220, INI_FILE_NAME);
iColorFlatParam[18] = ::GetPrivateProfileInt("ColorFlat", "B3Gain", 24, INI_FILE_NAME);
iColorFlatParam[19] = ::GetPrivateProfileInt("ColorFlat", "B2Gain", 24, INI_FILE_NAME);
iColorFlatParam[20] = ::GetPrivateProfileInt("ColorFlat", "B1Gain", 24, INI_FILE_NAME);
iColorFlatParam[21] = ::GetPrivateProfileInt("ColorFlat", "B6Gain", 24, INI_FILE_NAME);
iColorFlatParam[22] = ::GetPrivateProfileInt("ColorFlat", "B5Gain", 24, INI_FILE_NAME);
iColorFlatParam[23] = ::GetPrivateProfileInt("ColorFlat", "B4Gain", 24, INI_FILE_NAME);
iColorFlatParam[24] = ::GetPrivateProfileInt("ColorFlat", "B3Offset", 64, INI_FILE_NAME);
iColorFlatParam[25] = ::GetPrivateProfileInt("ColorFlat", "B2Offset", 64, INI_FILE_NAME);
iColorFlatParam[26] = ::GetPrivateProfileInt("ColorFlat", "B1Offset", 64, INI_FILE_NAME);
iColorFlatParam[27] = ::GetPrivateProfileInt("ColorFlat", "B6Offset", 64, INI_FILE_NAME);
iColorFlatParam[28] = ::GetPrivateProfileInt("ColorFlat", "B5Offset", 64, INI_FILE_NAME);
iColorFlatParam[29] = ::GetPrivateProfileInt("ColorFlat", "B4Offset", 64, INI_FILE_NAME);
memcpy(m_sFlatCorrection.ColorFlat,iColorFlatParam,sizeof(iColorFlatParam));
iGrayCorrectionParam[0] = ::GetPrivateProfileInt("GrayCorrection", "FBExposure", 340, INI_FILE_NAME);
iGrayCorrectionParam[1] = ::GetPrivateProfileInt("GrayCorrection", "FGExposure", 620, INI_FILE_NAME);
iGrayCorrectionParam[2] = ::GetPrivateProfileInt("GrayCorrection", "FRExposure", 324, INI_FILE_NAME);
iGrayCorrectionParam[3] = ::GetPrivateProfileInt("GrayCorrection", "F3Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[4] = ::GetPrivateProfileInt("GrayCorrection", "F2Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[5] = ::GetPrivateProfileInt("GrayCorrection", "F1Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[6] = ::GetPrivateProfileInt("GrayCorrection", "F6Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[7] = ::GetPrivateProfileInt("GrayCorrection", "F5Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[8] = ::GetPrivateProfileInt("GrayCorrection", "F4Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[9] = ::GetPrivateProfileInt("GrayCorrection", "F3Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[10] = ::GetPrivateProfileInt("GrayCorrection", "F2Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[11] = ::GetPrivateProfileInt("GrayCorrection", "F1Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[12] = ::GetPrivateProfileInt("GrayCorrection", "F6Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[13] = ::GetPrivateProfileInt("GrayCorrection", "F5Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[14] = ::GetPrivateProfileInt("GrayCorrection", "F4Offset", 117, INI_FILE_NAME);
iGrayCorrectionParam[15] = ::GetPrivateProfileInt("GrayCorrection", "BBExposure", 233, INI_FILE_NAME);
iGrayCorrectionParam[16] = ::GetPrivateProfileInt("GrayCorrection", "BGExposure", 418, INI_FILE_NAME);
iGrayCorrectionParam[17] = ::GetPrivateProfileInt("GrayCorrection", "BRExposure", 220, INI_FILE_NAME);
iGrayCorrectionParam[18] = ::GetPrivateProfileInt("GrayCorrection", "B3Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[19] = ::GetPrivateProfileInt("GrayCorrection", "B2Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[20] = ::GetPrivateProfileInt("GrayCorrection", "B1Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[21] = ::GetPrivateProfileInt("GrayCorrection", "B6Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[22] = ::GetPrivateProfileInt("GrayCorrection", "B5Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[23] = ::GetPrivateProfileInt("GrayCorrection", "B4Gain", 24, INI_FILE_NAME);
iGrayCorrectionParam[24] = ::GetPrivateProfileInt("GrayCorrection", "B3Offset", 64, INI_FILE_NAME);
iGrayCorrectionParam[25] = ::GetPrivateProfileInt("GrayCorrection", "B2Offset", 64, INI_FILE_NAME);
iGrayCorrectionParam[26] = ::GetPrivateProfileInt("GrayCorrection", "B1Offset", 64, INI_FILE_NAME);
iGrayCorrectionParam[27] = ::GetPrivateProfileInt("GrayCorrection", "B6Offset", 64, INI_FILE_NAME);
iGrayCorrectionParam[28] = ::GetPrivateProfileInt("GrayCorrection", "B5Offset", 64, INI_FILE_NAME);
iGrayCorrectionParam[29] = ::GetPrivateProfileInt("GrayCorrection", "B4Offset", 64, INI_FILE_NAME);
memcpy(m_sFlatCorrection.GrayCorrection,iGrayCorrectionParam,sizeof(iGrayCorrectionParam));
iGrayFlatParam[0] = ::GetPrivateProfileInt("GrayFlat", "FBExposure", 340, INI_FILE_NAME);
iGrayFlatParam[1] = ::GetPrivateProfileInt("GrayFlat", "FGExposure", 620, INI_FILE_NAME);
iGrayFlatParam[2] = ::GetPrivateProfileInt("GrayFlat", "FRExposure", 324, INI_FILE_NAME);
iGrayFlatParam[3] = ::GetPrivateProfileInt("GrayFlat", "F3Gain", 24, INI_FILE_NAME);
iGrayFlatParam[4] = ::GetPrivateProfileInt("GrayFlat", "F2Gain", 24, INI_FILE_NAME);
iGrayFlatParam[5] = ::GetPrivateProfileInt("GrayFlat", "F1Gain", 24, INI_FILE_NAME);
iGrayFlatParam[6] = ::GetPrivateProfileInt("GrayFlat", "F6Gain", 24, INI_FILE_NAME);
iGrayFlatParam[7] = ::GetPrivateProfileInt("GrayFlat", "F5Gain", 24, INI_FILE_NAME);
iGrayFlatParam[8] = ::GetPrivateProfileInt("GrayFlat", "F4Gain", 24, INI_FILE_NAME);
iGrayFlatParam[9] = ::GetPrivateProfileInt("GrayFlat", "F3Offset", 117, INI_FILE_NAME);
iGrayFlatParam[10] = ::GetPrivateProfileInt("GrayFlat", "F2Offset", 117, INI_FILE_NAME);
iGrayFlatParam[11] = ::GetPrivateProfileInt("GrayFlat", "F1Offset", 117, INI_FILE_NAME);
iGrayFlatParam[12] = ::GetPrivateProfileInt("GrayFlat", "F6Offset", 117, INI_FILE_NAME);
iGrayFlatParam[13] = ::GetPrivateProfileInt("GrayFlat", "F5Offset", 117, INI_FILE_NAME);
iGrayFlatParam[14] = ::GetPrivateProfileInt("GrayFlat", "F4Offset", 117, INI_FILE_NAME);
iGrayFlatParam[15] = ::GetPrivateProfileInt("GrayFlat", "BBExposure", 233, INI_FILE_NAME);
iGrayFlatParam[16] = ::GetPrivateProfileInt("GrayFlat", "BGExposure", 418, INI_FILE_NAME);
iGrayFlatParam[17] = ::GetPrivateProfileInt("GrayFlat", "BRExposure", 220, INI_FILE_NAME);
iGrayFlatParam[18] = ::GetPrivateProfileInt("GrayFlat", "B3Gain", 24, INI_FILE_NAME);
iGrayFlatParam[19] = ::GetPrivateProfileInt("GrayFlat", "B2Gain", 24, INI_FILE_NAME);
iGrayFlatParam[20] = ::GetPrivateProfileInt("GrayFlat", "B1Gain", 24, INI_FILE_NAME);
iGrayFlatParam[21] = ::GetPrivateProfileInt("GrayFlat", "B6Gain", 24, INI_FILE_NAME);
iGrayFlatParam[22] = ::GetPrivateProfileInt("GrayFlat", "B5Gain", 24, INI_FILE_NAME);
iGrayFlatParam[23] = ::GetPrivateProfileInt("GrayFlat", "B4Gain", 24, INI_FILE_NAME);
iGrayFlatParam[24] = ::GetPrivateProfileInt("GrayFlat", "B3Offset", 64, INI_FILE_NAME);
iGrayFlatParam[25] = ::GetPrivateProfileInt("GrayFlat", "B2Offset", 64, INI_FILE_NAME);
iGrayFlatParam[26] = ::GetPrivateProfileInt("GrayFlat", "B1Offset", 64, INI_FILE_NAME);
iGrayFlatParam[27] = ::GetPrivateProfileInt("GrayFlat", "B6Offset", 64, INI_FILE_NAME);
iGrayFlatParam[28] = ::GetPrivateProfileInt("GrayFlat", "B5Offset", 64, INI_FILE_NAME);
iGrayFlatParam[29] = ::GetPrivateProfileInt("GrayFlat", "B4Offset", 64, INI_FILE_NAME);
memcpy(m_sFlatCorrection.GrayFlat,iGrayFlatParam,sizeof(iGrayFlatParam));
}
void CA4::SaveNewParam(int iIndex)
{
UINT iTempParam[30] = {0};
UpdateData(TRUE);
iTempParam[0] = m_tbxFRExposure;
iTempParam[1] = m_tbxFGExposure;
iTempParam[2] = m_tbxFBExposure;
iTempParam[3] = m_tbxF1Gain;
iTempParam[4] = m_tbxF2Gain;
iTempParam[5] = m_tbxF3Gain;
iTempParam[6] = m_tbxF4Gain;
iTempParam[7] = m_tbxF5Gain;
iTempParam[8] = m_tbxF6Gain;
iTempParam[9] = m_tbxF1Offset;
iTempParam[10] = m_tbxF2Offset;
iTempParam[11] = m_tbxF3Offset;
iTempParam[12] = m_tbxF4Offset;
iTempParam[13] = m_tbxF5Offset;
iTempParam[14] = m_tbxF6Offset;
iTempParam[15] = m_tbxBRExposure;
iTempParam[16] = m_tbxBGExposure;
iTempParam[17] = m_tbxBBExposure;
iTempParam[18] = m_tbxB1Gain;
iTempParam[19] = m_tbxB2Gain;
iTempParam[20] = m_tbxB3Gain;
iTempParam[21] = m_tbxB4Gain;
iTempParam[22] = m_tbxB5Gain;
iTempParam[23] = m_tbxB6Gain;
iTempParam[24] = m_tbxB1Offset;
iTempParam[25] = m_tbxB2Offset;
iTempParam[26] = m_tbxB3Offset;
iTempParam[27] = m_tbxB4Offset;
iTempParam[28] = m_tbxB5Offset;
iTempParam[29] = m_tbxB6Offset;
UpdateData(FALSE);
switch (iIndex)
{
case 0:
memcpy(m_sFlatCorrection.ColorCorrection, iTempParam, sizeof(iTempParam));
WriteParamFile();
break;
case 1:
memcpy(m_sFlatCorrection.ColorFlat, iTempParam, sizeof(iTempParam));
WriteParamFile();
break;
case 2:
memcpy(m_sFlatCorrection.GrayCorrection, iTempParam, sizeof(iTempParam));
WriteParamFile();
break;
case 3:
memcpy(m_sFlatCorrection.GrayFlat, iTempParam, sizeof(iTempParam));
WriteParamFile();
break;
default:
break;
}
}
void CA4::WriteParamFile()
{
CString csColorCorrection[30];
CString csColorFlat[30];
CString csGrayCorrection[30];
CString csGrayFlat[30];
for(int i = 0;i < 30; i++)
{
csColorCorrection[i].Format(_T("%d"),m_sFlatCorrection.ColorCorrection[i]);
csColorFlat[i].Format(_T("%d"),m_sFlatCorrection.ColorFlat[i]);
csGrayCorrection[i].Format(_T("%d"),m_sFlatCorrection.GrayCorrection[i]);
csGrayFlat[i].Format(_T("%d"),m_sFlatCorrection.GrayFlat[i]);
}
WritePrivateProfileString("ColorCorrection", "FBExposure", csColorCorrection[0], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "FGExposure", csColorCorrection[1], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "FRExposure", csColorCorrection[2], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F3Gain", csColorCorrection[3], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F2Gain", csColorCorrection[4], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F1Gain", csColorCorrection[5], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F6Gain", csColorCorrection[6], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F5Gain", csColorCorrection[7], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F4Gain", csColorCorrection[8], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F3Offset", csColorCorrection[9], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F2Offset", csColorCorrection[10], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F1Offset", csColorCorrection[11], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F6Offset", csColorCorrection[12], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F5Offset", csColorCorrection[13], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F4Offset", csColorCorrection[14], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BBExposure", csColorCorrection[15], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BGExposure", csColorCorrection[16], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BRExposure", csColorCorrection[17], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B3Gain", csColorCorrection[18], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B2Gain", csColorCorrection[19], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B1Gain", csColorCorrection[20], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B6Gain", csColorCorrection[21], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B5Gain", csColorCorrection[22], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B4Gain", csColorCorrection[23], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B3Offset", csColorCorrection[24], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B2Offset", csColorCorrection[25], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B1Offset", csColorCorrection[26], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B6Offset", csColorCorrection[27], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B5Offset", csColorCorrection[28], INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B4Offset", csColorCorrection[29], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "FBExposure", csColorFlat[0], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "FGExposure", csColorFlat[1], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "FRExposure", csColorFlat[2], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F3Gain", csColorFlat[3], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F2Gain", csColorFlat[4], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F1Gain", csColorFlat[5], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F6Gain", csColorFlat[6], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F5Gain", csColorFlat[7], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F4Gain", csColorFlat[8], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F3Offset", csColorFlat[9], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F2Offset", csColorFlat[10], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F1Offset", csColorFlat[11], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F6Offset", csColorFlat[12], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F5Offset", csColorFlat[13], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "F4Offset", csColorFlat[14], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "BBExposure", csColorFlat[15], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "BGExposure", csColorFlat[16], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "BRExposure", csColorFlat[17], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B3Gain", csColorFlat[18], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B2Gain", csColorFlat[19], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B1Gain", csColorFlat[20], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B6Gain", csColorFlat[21], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B5Gain", csColorFlat[22], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B4Gain", csColorFlat[23], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B3Offset", csColorFlat[24], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B2Offset", csColorFlat[25], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B1Offset", csColorFlat[26], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B6Offset", csColorFlat[27], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B5Offset", csColorFlat[28], INI_FILE_NAME);
WritePrivateProfileString("ColorFlat", "B4Offset", csColorFlat[29], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "FBExposure", csGrayCorrection[0], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "FGExposure", csGrayCorrection[1], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "FRExposure", csGrayCorrection[2], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F3Gain", csGrayCorrection[3], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F2Gain", csGrayCorrection[4], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F1Gain", csGrayCorrection[5], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F6Gain", csGrayCorrection[6], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F5Gain", csGrayCorrection[7], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F4Gain", csGrayCorrection[8], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F3Offset", csGrayCorrection[9], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F2Offset", csGrayCorrection[10], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F1Offset", csGrayCorrection[11], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F6Offset", csGrayCorrection[12], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F5Offset", csGrayCorrection[13], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F4Offset", csGrayCorrection[14], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "BBExposure", csGrayCorrection[15], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "BGExposure", csGrayCorrection[16], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "BRExposure", csGrayCorrection[17], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B3Gain", csGrayCorrection[18], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B2Gain", csGrayCorrection[19], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B1Gain", csGrayCorrection[20], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B6Gain", csGrayCorrection[21], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B5Gain", csGrayCorrection[22], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B4Gain", csGrayCorrection[23], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B3Offset", csGrayCorrection[24], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B2Offset", csGrayCorrection[25], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B1Offset", csGrayCorrection[26], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B6Offset", csGrayCorrection[27], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B5Offset", csGrayCorrection[28], INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B4Offset", csGrayCorrection[29], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "FBExposure", csGrayFlat[0], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "FGExposure", csGrayFlat[1], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "FRExposure", csGrayFlat[2], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F3Gain", csGrayFlat[3], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F2Gain", csGrayFlat[4], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F1Gain", csGrayFlat[5], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F6Gain", csGrayFlat[6], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F5Gain", csGrayFlat[7], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F4Gain", csGrayFlat[8], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F3Offset", csGrayFlat[9], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F2Offset", csGrayFlat[10], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F1Offset", csGrayFlat[11], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F6Offset", csGrayFlat[12], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F5Offset", csGrayFlat[13], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "F4Offset", csGrayFlat[14], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "BBExposure", csGrayFlat[15], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "BGExposure", csGrayFlat[16], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "BRExposure", csGrayFlat[17], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B3Gain", csGrayFlat[18], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B2Gain", csGrayFlat[19], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B1Gain", csGrayFlat[20], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B6Gain", csGrayFlat[21], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B5Gain", csGrayFlat[22], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B4Gain", csGrayFlat[23], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B3Offset", csGrayFlat[24], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B2Offset", csGrayFlat[25], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B1Offset", csGrayFlat[26], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B6Offset", csGrayFlat[27], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B5Offset", csGrayFlat[28], INI_FILE_NAME);
WritePrivateProfileString("GrayFlat", "B4Offset", csGrayFlat[29], INI_FILE_NAME);
}
void CA4::OnDeltaposSpinAgain(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
if(pNMUpDown->iDelta == -1) // 如果此值为-1 , 说明点击了Spin的往下的箭头
{
AUpGain();
}
else if(pNMUpDown->iDelta == 1) // 如果此值为1, 说明点击了Spin的往上的箭头
{
ADownGain();
}
UpdateData(false);
*pResult = 0;
}
void CA4::OnDeltaposSpinAoffset(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
if(pNMUpDown->iDelta == -1) // 如果此值为-1 , 说明点击了Spin的往下的箭头
{
AUpOffset();
}
else if(pNMUpDown->iDelta == 1) // 如果此值为1, 说明点击了Spin的往上的箭头
{
ADownOffset();
}
UpdateData(false);
*pResult = 0;
}
void CA4::OnDeltaposSpinBgain(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
if(pNMUpDown->iDelta == -1) // 如果此值为-1 , 说明点击了Spin的往下的箭头
{
BUpGain();
}
else if(pNMUpDown->iDelta == 1) // 如果此值为1, 说明点击了Spin的往上的箭头
{
BDownGain();
}
UpdateData(false);
*pResult = 0;
}
void CA4::OnDeltaposSpinBoffset(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
if(pNMUpDown->iDelta == -1) // 如果此值为-1 , 说明点击了Spin的往下的箭头
{
BUpOffset();
}
else if(pNMUpDown->iDelta == 1) // 如果此值为1, 说明点击了Spin的往上的箭头
{
BDownOffset();
}
UpdateData(false);
*pResult = 0;
}
void CA4::ADownGain()
{
UpdateData(true);
m_tbxF1Gain -= m_tbxAGain;
m_tbxF2Gain -= m_tbxAGain;
m_tbxF3Gain -= m_tbxAGain;
m_tbxF4Gain -= m_tbxAGain;
m_tbxF5Gain -= m_tbxAGain;
m_tbxF6Gain -= m_tbxAGain;
UpdateData(false);
}
void CA4::AUpGain()
{
UpdateData(true);
m_tbxF1Gain += m_tbxAGain;
m_tbxF2Gain += m_tbxAGain;
m_tbxF3Gain += m_tbxAGain;
m_tbxF4Gain += m_tbxAGain;
m_tbxF5Gain += m_tbxAGain;
m_tbxF6Gain += m_tbxAGain;
UpdateData(false);
}
void CA4::BDownGain()
{
UpdateData(true);
m_tbxB1Gain -= m_tbxBGain;
m_tbxB2Gain -= m_tbxBGain;
m_tbxB3Gain -= m_tbxBGain;
m_tbxB4Gain -= m_tbxBGain;
m_tbxB5Gain -= m_tbxBGain;
m_tbxB6Gain -= m_tbxBGain;
UpdateData(false);
}
void CA4::BUpGain()
{
UpdateData(true);
m_tbxB1Gain += m_tbxBGain;
m_tbxB2Gain += m_tbxBGain;
m_tbxB3Gain += m_tbxBGain;
m_tbxB4Gain += m_tbxBGain;
m_tbxB5Gain += m_tbxBGain;
m_tbxB6Gain += m_tbxBGain;
UpdateData(false);
}
void CA4::ADownOffset()
{
UpdateData(true);
m_tbxF1Offset -= m_tbxAOffset;
m_tbxF2Offset -= m_tbxAOffset;
m_tbxF3Offset -= m_tbxAOffset;
m_tbxF4Offset -= m_tbxAOffset;
m_tbxF5Offset -= m_tbxAOffset;
m_tbxF6Offset -= m_tbxAOffset;
UpdateData(false);
}
void CA4::AUpOffset()
{
UpdateData(true);
m_tbxF1Offset += m_tbxAOffset;
m_tbxF2Offset += m_tbxAOffset;
m_tbxF3Offset += m_tbxAOffset;
m_tbxF4Offset += m_tbxAOffset;
m_tbxF5Offset += m_tbxAOffset;
m_tbxF6Offset += m_tbxAOffset;
UpdateData(false);
}
void CA4::BDownOffset()
{
UpdateData(true);
m_tbxB1Offset -= m_tbxBOffset;
m_tbxB2Offset -= m_tbxBOffset;
m_tbxB3Offset -= m_tbxBOffset;
m_tbxB4Offset -= m_tbxBOffset;
m_tbxB5Offset -= m_tbxBOffset;
m_tbxB6Offset -= m_tbxBOffset;
UpdateData(false);
}
void CA4::BUpOffset()
{
UpdateData(true);
m_tbxB1Offset += m_tbxBOffset;
m_tbxB2Offset += m_tbxBOffset;
m_tbxB3Offset += m_tbxBOffset;
m_tbxB4Offset += m_tbxBOffset;
m_tbxB5Offset += m_tbxBOffset;
m_tbxB6Offset += m_tbxBOffset;
UpdateData(false);
}

91
HuaGoCorrect/A4.h Normal file
View File

@ -0,0 +1,91 @@
#pragma once
#include "Config.h"
#include "DefHSStructure.h"
#include "afxwin.h"
// CA4 对话框
#define INI_FILE_NAME "./HuaGoScan.ini"
class CA4 : public CDialog
{
DECLARE_DYNAMIC(CA4)
public:
CA4(CWnd* pParent = NULL); // 标准构造函数
virtual ~CA4();
CConfig m_Cfg;
void default0param();
void default1param();
void default2param();
void default3param();
void updateA4Config(int *pValues);
void LoadCfg();
void SaveNewParam(int iIndex);
void WriteParamFile();
// 对话框数据
enum { IDD = IDD_A4_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
FlatCorrection m_sFlatCorrection;
int m_iLastIndex;
int m_iSelIndex;
UINT m_tbxFRExposure;
UINT m_tbxFGExposure;
UINT m_tbxFBExposure;
UINT m_tbxF1Gain;
UINT m_tbxF2Gain;
UINT m_tbxF3Gain;
UINT m_tbxF4Gain;
UINT m_tbxF5Gain;
UINT m_tbxF6Gain;
UINT m_tbxF1Offset;
UINT m_tbxF2Offset;
UINT m_tbxF3Offset;
UINT m_tbxF4Offset;
UINT m_tbxF5Offset;
UINT m_tbxF6Offset;
UINT m_tbxBRExposure;
UINT m_tbxBGExposure;
UINT m_tbxBBExposure;
UINT m_tbxB1Gain;
UINT m_tbxB2Gain;
UINT m_tbxB3Gain;
UINT m_tbxB4Gain;
UINT m_tbxB5Gain;
UINT m_tbxB6Gain;
UINT m_tbxB1Offset;
UINT m_tbxB2Offset;
UINT m_tbxB3Offset;
UINT m_tbxB4Offset;
UINT m_tbxB5Offset;
UINT m_tbxB6Offset;
afx_msg void OnCbnSelChangeA4FlatModel();
CComboBox m_A4FlatModel;
UINT m_tbxAGain;
UINT m_tbxBGain;
UINT m_tbxAOffset;
UINT m_tbxBOffset;
afx_msg void OnDeltaposSpinAgain(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAoffset(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinBgain(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinBoffset(NMHDR *pNMHDR, LRESULT *pResult);
void ADownGain();
void AUpGain();
void BDownGain();
void BUpGain();
void ADownOffset();
void AUpOffset();
void BDownOffset();
void BUpOffset();
};

View File

@ -0,0 +1,93 @@
#pragma once
#include <mutex>
#include <condition_variable>
#include <deque>
template <typename T>
class BlockingQueue
{
private:
BlockingQueue(const BlockingQueue& rhs);
BlockingQueue& operator =(const BlockingQueue& rhs);
mutable std::mutex _mutex;
std::condition_variable _condvar;
std::deque<T> _queue;
volatile bool isShutDown = false;
T tRet;
public:
BlockingQueue()
: _mutex()
, _condvar()
, _queue()
{
}
~BlockingQueue()
{
ShutDown();
}
void Clear()
{
std::lock_guard<std::mutex> lock(_mutex);
_condvar.notify_all();
_queue.clear();
}
void ShutDown()
{
isShutDown = true;
_condvar.notify_all();
_queue.clear();
}
bool IsShutDown()
{
return isShutDown;
}
void Put(const T task)
{
std::lock_guard<std::mutex> lock(_mutex);
if (!isShutDown) {
_queue.push_back(task);
_condvar.notify_all();
}
}
T Take()
{
std::unique_lock<std::mutex> lock(_mutex);
if (_queue.size() <= 0)
_condvar.wait(lock);
if (isShutDown || _queue.empty())
return tRet;
T front(_queue.front());
_queue.pop_front();
return front;
}
T Front()
{
std::unique_lock<std::mutex> lock(_mutex);
if (_queue.size() <= 0)
_condvar.wait(lock);
if (isShutDown || _queue.empty())
return tRet;
T front(_queue.front());
return front;
}
size_t Size() const
{
std::lock_guard<std::mutex> lock(_mutex);
return _queue.size();
}
};

540
HuaGoCorrect/CIS.cpp Normal file
View File

@ -0,0 +1,540 @@
// CIS.cpp: 实现文件
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "CIS.h"
#include "afxdialogex.h"
#include <thread>
// CIS 对话框
IMPLEMENT_DYNAMIC(CIS, CDialog)
CIS::CIS(CWnd* pParent /*=nullptr*/ )
: CDialog(IDD_CIS_DIALOG1, pParent),
b_run(false),
C_drv(NULL),
b_canget(false)
, c_channel(0)
, spin_up(50)
, spin_low(30)
, spin_area_up(400)
, spin_area_low(400)
, isduplex(true)
{
b_run = true;
c_thread = std::thread(&CIS::Cis_start,this);
/*
* Gscndrv对象传进来
* gscandrv.aquireimage
* mat转换成picturebox支持的图像格式
*/
}
CIS::~CIS()
{
if (c_thread.joinable())
{
b_run = false;
c_thread.join();
}
}
void CIS::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_COMBO1, Cis_box);
DDX_CBIndex(pDX, IDC_COMBO1, c_channel);
DDX_Text(pDX, IDC_EDIT2, spin_up);
DDX_Text(pDX, IDC_EDIT3, spin_low);
DDX_Text(pDX, IDC_EDIT4, spin_area_up);
DDX_Text(pDX, IDC_EDIT5, spin_area_low);
DDX_Control(pDX, IDC_EDIT2, edit_up);
DDX_Control(pDX, IDC_EDIT3, edit_low);
DDX_Control(pDX, IDC_EDIT4, edit_area_up);
DDX_Control(pDX, IDC_EDIT5, edit_area_low);
}
int num = 0;
int row = 0;
void CIS::Cis_start()
{
while (b_run)
{
if (b_canget)
{
if (C_drv)
{
if (!C_drv->Get_IsImageQueueEmpty())
{
cv::Mat mat;
C_drv->aquire_image(mat);
detect_start(mat);
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
void CIS::get_config()
{
char text[20];
spin_up = ::GetPrivateProfileInt(_T("CIS"), _T("total_up"), 0, INI_FILE_NAME);
spin_low = ::GetPrivateProfileInt(_T("CIS"), _T("total_low"), 0, INI_FILE_NAME);
spin_area_up = ::GetPrivateProfileInt(_T("CIS"), _T("total_area_up"), 0, INI_FILE_NAME);
spin_area_low = ::GetPrivateProfileInt(_T("CIS"), _T("total_area_low"), 0, INI_FILE_NAME);
c_channel = ::GetPrivateProfileInt(_T("CIS"), _T("channle"), 0, INI_FILE_NAME);
sprintf(text, "%d", spin_up);
edit_up.SetWindowTextA(text);
sprintf(text, "%d", spin_low);
edit_low.SetWindowTextA(text);
sprintf(text, "%d", spin_area_up);
edit_area_up.SetWindowTextA(text);
sprintf(text, "%d", spin_area_low);
edit_area_low.SetWindowTextA(text);
Cis_box.SetCurSel(c_channel);
}
void CIS::set_config()
{
CString text[5];
edit_up.GetWindowTextA(text[0]);
edit_low.GetWindowTextA(text[1]);
edit_area_up.GetWindowTextA(text[2]);
edit_area_low.GetWindowTextA(text[3]);
text[4].Format("%d", c_channel);
::WritePrivateProfileString(_T("CIS"), _T("total_up"), _T(text[0]), INI_FILE_NAME);
::WritePrivateProfileString(_T("CIS"), _T("total_low"), _T(text[1]), INI_FILE_NAME);
::WritePrivateProfileString(_T("CIS"), _T("total_area_up"), _T(text[2]), INI_FILE_NAME);
::WritePrivateProfileString(_T("CIS"), _T("total_area_low"), _T(text[3]), INI_FILE_NAME);
::WritePrivateProfileString(_T("CIS"), _T("channle"), _T(text[4]), INI_FILE_NAME);
}
BOOL CIS::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateData(TRUE);
CRect rect;
m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_list.GetClientRect(&rect);
m_list.InsertColumn(0, _T("类型"), LVCFMT_CENTER, rect.Width() / 3, 0);
m_list.InsertColumn(1, _T("值%"), LVCFMT_CENTER, rect.Width() / 3, 1);
m_list.InsertColumn(2, _T("合格"), LVCFMT_CENTER, rect.Width() / 3, 2);
Cis_box.InsertString(0, _T("R"));
Cis_box.InsertString(1, _T("G"));
Cis_box.InsertString(2, _T("B"));
get_config();
UpdateData(false);
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CIS::SetGscan_drv(GScn_Drv* c_drv)
{
if (C_drv != c_drv)
{
C_drv = c_drv;
}
}
//std::vector<cv::Mat> image_bgr;
void CIS::detect_start(cv::Mat& image)
{
//image_bgr.clear();
if (!isduplex)
{
num = 0;
m_list.DeleteAllItems();
}
if(row==0)
m_list.DeleteAllItems();
c_channel = Cis_box.GetCurSel();
if (image.empty())
return;
cv::Mat src;
if (image.channels() == 3)
{
cv::Mat image_bgr[3];
cv::split(image, image_bgr);
src = image_bgr[c_channel].clone();
}
else
src = image.clone();
Cis_box.EnableWindow(image.channels() == 3);
double average = cv::mean(src)[0];
Result r_low = lessenColor(src, cv::Range(0, average - spin_up), spin_low);
Result r_up = lessenColor(src, cv::Range(average +spin_up, 256), spin_low);
if (src.cols % 4 != 0)
cv::copyMakeBorder(src, src, 0, 0, 0, 4 - (src.cols % 4), cv::BORDER_CONSTANT);
cv::cvtColor(src, src, cv::COLOR_GRAY2BGR);
cv::drawContours(src, r_low.contours, -1, cv::Scalar(255, 0, 0));
cv::drawContours(src, r_up.contours, -1, cv::Scalar(0, 0, 255));
CImage img;
MatToCImage(image, img);
int xt = image.cols;
int yt = image.rows;
CRect rectf;
int cx = img.GetWidth();
int cy = img.GetHeight();
CWnd *pWnd = GetDlgItem(IDC_STATIC_PICTURE_CIS);
pWnd->GetClientRect(&rectf);
CDC *pDC = pWnd->GetDC();
SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
int max = (cx >= cy) ? cx : cy;
float scale;
scale = (float)((float)max / 260.0f);
int nw = (int)(cx / scale);
int nh = (int)(cy / scale);
CPoint pos= rectf.TopLeft();
if (num == 0)
{
rectf = CRect(pos, CSize(nw, nh));
rect_front = rectf;
img_front = img;
}
else
{
pos = CPoint(0, nh);
rectf = CRect(pos,CSize(nw,nh));
rect_reverse = rectf;
img_reverse = img;
}
img.Draw(pDC->m_hDC, rectf);
ReleaseDC(pDC);
img.Destroy();
//ui->tableWidget->setRowCount(r_low.area.size() + r_up.area.size() + 3);
double total = src.total();
double total_up = 0;
double total_low = 0;
if (num == 0)
{
if(isduplex)
row=m_list.InsertItem(0, (LPCTSTR)"正面");
m_list.SetItemText(row, 1, (LPCTSTR)"");
m_list.SetItemText(row, 2, (LPCTSTR)"");
}
else
{
row=m_list.InsertItem(0, (LPCTSTR)"反面");
m_list.SetItemText(row, 1, (LPCTSTR)"");
m_list.SetItemText(row, 2, (LPCTSTR)"");
}
row++;
for (size_t i = 0; i < r_low.area.size(); i++)
{
CString text;
text.Format(_T("暗斑%d"), i);
row=m_list.InsertItem(row, (LPCTSTR)text);
text.Format(_T("%lf"), r_low.area[i] * 100 / total);
m_list.SetItemText(row, 1, (LPCTSTR)text);
total_low += r_low.area[i] * 100 / total;
if ((r_low.area[i] * 100 / total) <= spin_low)
m_list.SetItemText(row, 2, (LPCTSTR)"通过");
else
m_list.SetItemText(row, 2, (LPCTSTR)"不通过");
row++;
}
for (size_t i = 0; i < r_up.area.size(); i++)
{
CString text;
text.Format(_T("亮斑%d"),i+ r_low.area.size());
row =m_list.InsertItem(i+ r_low.area.size(), text);
text.Format(_T("%lf"), r_low.area[i] * 100 / total);
m_list.SetItemText(row, 1, text);
total_up += r_up.area[i] * 100 / total;
if ((r_up.area[i] * 100 / total) <= spin_up)
m_list.SetItemText(row, 2, (LPCTSTR)"通过");
else
m_list.SetItemText(row, 2, (LPCTSTR)"不通过");
row++;
}
CString text_0[3] = { "亮斑面积" ,"暗斑面积" ,"剩余面积" };
for (int i = 0; i < 3;i++)
{
CString text;
m_list.InsertItem(row, text_0[i]);
if (i == 0)
text.Format(_T("%lf"), total_up);
else
text.Format(_T("%lf"), total_low);
m_list.SetItemText(row, 1, text);
if (i == 0)
{
if (total_up <= spin_area_up)
m_list.SetItemText(row, 2, (LPCTSTR)"通过");
else
m_list.SetItemText(row, 2, (LPCTSTR)"不通过");
}
else if (i == 1)
{
if (total_low <= spin_area_low)
m_list.SetItemText(row, 2, (LPCTSTR)"通过");
else
m_list.SetItemText(row, 2, (LPCTSTR)"不通过");
}
else
{
text.Format(_T("%lf"), 100-total_low- total_up);
m_list.SetItemText(row, 1, text);
}
row++;
}
num++;
if (num > 1)
{
num = 0;
row = 0;
}
}
void CIS::findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy, int retr, int method, cv::Point offset)
{
CvMat c_image = src;
cv::MemStorage storage(cvCreateMemStorage());
CvSeq* _ccontours = nullptr;
cvFindContours(&c_image, storage, &_ccontours, sizeof(CvContour), retr, method, CvPoint(offset));
if (!_ccontours)
{
contours.clear();
return;
}
cv::Seq<CvSeq*> all_contours(cvTreeToNodeSeq(_ccontours, sizeof(CvSeq), storage));
size_t total = all_contours.size();
contours.resize(total);
cv::SeqIterator<CvSeq*> it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
reinterpret_cast<CvContour*>(c)->color = static_cast<int>(i);
int count = c->total;
int* data = new int[static_cast<size_t>(count * 2)];
cvCvtSeqToArray(c, data);
for (int j = 0; j < count; j++)
{
contours[i].push_back(cv::Point(data[j * 2], data[j * 2 + 1]));
}
delete[] data;
}
hierarchy.resize(total);
it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
int h_next = c->h_next ? reinterpret_cast<CvContour*>(c->h_next)->color : -1;
int h_prev = c->h_prev ? reinterpret_cast<CvContour*>(c->h_prev)->color : -1;
int v_next = c->v_next ? reinterpret_cast<CvContour*>(c->v_next)->color : -1;
int v_prev = c->v_prev ? reinterpret_cast<CvContour*>(c->v_prev)->color : -1;
hierarchy[i] = cv::Vec4i(h_next, h_prev, v_next, v_prev);
}
storage.release();
}
void CIS::MatToCImage(Mat& mat, CImage& cimage)
{
if (0 == mat.total())
{
return;
}
int nChannels = mat.channels();
if ((1 != nChannels) && (3 != nChannels))
{
return;
}
int nWidth = mat.cols;
int nHeight = mat.rows;
//重建cimage
cimage.Destroy();
cimage.Create(nWidth, nHeight, 8 * nChannels);
//拷贝数据
uchar* pucRow;//指向数据区的行指针
uchar* pucImage = (uchar*)cimage.GetBits();//指向数据区的指针
int nStep = cimage.GetPitch();//每行的字节数,注意这个返回值有正有负
if (1 == nChannels)//对于单通道的图像需要初始化调色板
{
RGBQUAD* rgbquadColorTable;
int nMaxColors = 256;
rgbquadColorTable = new RGBQUAD[nMaxColors];
cimage.GetColorTable(0, nMaxColors, rgbquadColorTable);
for (int nColor = 0; nColor < nMaxColors; nColor++)
{
rgbquadColorTable[nColor].rgbBlue = (uchar)nColor;
rgbquadColorTable[nColor].rgbGreen = (uchar)nColor;
rgbquadColorTable[nColor].rgbRed = (uchar)nColor;
}
cimage.SetColorTable(0, nMaxColors, rgbquadColorTable);
delete[]rgbquadColorTable;
}
for (int nRow = 0; nRow < nHeight; nRow++)
{
pucRow = (mat.ptr<uchar>(nRow));
for (int nCol = 0; nCol < nWidth; nCol++)
{
if (1 == nChannels)
{
*(pucImage + nRow * nStep + nCol) = pucRow[nCol];
}
else if (3 == nChannels)
{
for (int nCha = 0; nCha < 3; nCha++)
{
*(pucImage + nRow * nStep + nCol * 3 + nCha) = pucRow[nCol * 3 + nCha];
}
}
}
}
}
Result CIS::lessenColor(const cv::Mat &image, cv::Range range, int areaThre)
{
cv::Mat thre;
cv::inRange(image, range.start, range.end, thre);
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy;
findContours(thre, contours, hierarchy, cv::RETR_EXTERNAL);
Result result;
for (int i = 0; i < contours.size(); i++)
{
double area = cv::contourArea(contours[i]);
if (area >= areaThre)
{
result.contours.push_back(contours[i]);
result.area.push_back(static_cast<int>(area));
}
}
return result;
}
BEGIN_MESSAGE_MAP(CIS, CDialog)
ON_CBN_SELCHANGE(IDC_COMBO1, &CIS::OnCbnSelchangeCombo1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN3, &CIS::OnDeltaposSpin3)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN4, &CIS::OnDeltaposSpin4)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN5, &CIS::OnDeltaposSpin5)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN6, &CIS::OnDeltaposSpin6)
ON_WM_PAINT()
END_MESSAGE_MAP()
// CIS 消息处理程序
void CIS::OnCbnSelchangeCombo1()
{
// TODO: 在此添加控件通知处理程序代码
c_channel = Cis_box.GetCurSel();
}
void CIS::OnDeltaposSpin3(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
if (pNMUpDown->iDelta == -1)
{
spin_up += 1;
}
else if(pNMUpDown->iDelta==1)
{
spin_up -= 1;
}
char text[10];
itoa(spin_up, text, 10);
edit_up.SetWindowTextA(text);
}
void CIS::OnDeltaposSpin4(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
if (pNMUpDown->iDelta == -1)
{
spin_low += 1;
}
else if (pNMUpDown->iDelta == 1)
{
spin_low -= 1;
}
char text[10];
itoa(spin_low, text, 10);
edit_low.SetWindowTextA(text);
}
void CIS::OnDeltaposSpin5(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
if (pNMUpDown->iDelta == -1)
{
spin_area_up += 1;
}
else if (pNMUpDown->iDelta == 1)
{
spin_area_up -= 1;
}
char text[10];
itoa(spin_area_up, text, 10);
edit_area_up.SetWindowTextA(text);
}
void CIS::OnDeltaposSpin6(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
if (pNMUpDown->iDelta == -1)
{
spin_area_low += 1;
}
else if (pNMUpDown->iDelta == 1)
{
spin_area_low -= 1;
}
char text[10];
itoa(spin_area_low, text, 10);
edit_area_low.SetWindowTextA(text);
}
void CIS::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialog::OnPaint()
//if (img_front == NULL) //重绘扫描到的图片实现切换界面不刷新但draw时程序崩溃原因还未知
// return;
//CWnd *pWnd = GetDlgItem(IDC_STATIC_PICTURE_CIS);
//CImage *image = &img_front;
//pWnd->GetClientRect(&rect_front);
//CDC *pDC = pWnd->GetDC();
//SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
//CPoint pos = rect_front.TopLeft();
//image->Draw(pDC->m_hDC, rect_front);
//ReleaseDC(pDC);
//image->Destroy();
//delete image;
}

77
HuaGoCorrect/CIS.h Normal file
View File

@ -0,0 +1,77 @@
#pragma once
#include "DefHSStructure.h"
#include "afxwin.h"
#include "gscn_drv.h"
#include <opencv2/opencv.hpp>
#include "Config.h"
// CIS 对话框
struct Result
{
std::vector<std::vector<cv::Point>> contours;
std::vector<int> area;
};
class CIS : public CDialog
{
DECLARE_DYNAMIC(CIS)
public:
CIS(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CIS();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_CIS_DIALOG1 };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
CImage img_front;
CImage img_reverse;
CRect rect_front;
CRect rect_reverse;
CListCtrl m_list;
CComboBox Cis_box;
std::thread c_thread;
volatile bool b_run;
volatile bool b_canget;
volatile bool isduplex;
void Cis_start();
void get_config();
void set_config();
virtual BOOL OnInitDialog();
void SetGscan_drv(GScn_Drv* c_drv);
void detect_start(cv::Mat& sre);
void findContours(const cv::Mat & src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy, int retr, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0));
void MatToCImage(Mat & mat, CImage & cimage);
Result lessenColor(const cv::Mat &image, cv::Range range, int areaThre);
void SetEnableGetImage(bool enable) {
b_canget = enable;
}
private:
GScn_Drv* C_drv;
public:
int c_channel;
afx_msg void OnCbnSelchangeCombo1();
int spin_up;
int spin_low;
int spin_area_up;
int spin_area_low;
afx_msg void OnDeltaposSpin3(NMHDR *pNMHDR, LRESULT *pResult);
CEdit edit_up;
afx_msg void OnDeltaposSpin4(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpin5(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpin6(NMHDR *pNMHDR, LRESULT *pResult);
CEdit edit_low;
CEdit edit_area_up;
CEdit edit_area_low;
afx_msg void OnPaint();
};

43
HuaGoCorrect/CVISON.cpp Normal file
View File

@ -0,0 +1,43 @@
#include "stdafx.h"
#include "CVISON.h"
#include "HuaGoCorrect.h"
#include "afxdialogex.h"
// CA3 对话框
IMPLEMENT_DYNAMIC(CVISON, CDialog)
CVISON::CVISON(CWnd* pParent /*=NULL*/)
: CDialog(CVISON::IDD, pParent)
{
}
CVISON::~CVISON()
{
}
void CVISON::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CVISON, CDialog)
END_MESSAGE_MAP()
// CA3 消息处理程序
BOOL CVISON::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}

21
HuaGoCorrect/CVISON.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include "resource.h"
//cvision对话框
class CVISON : public CDialog
{
DECLARE_DYNAMIC(CVISON)
public:
CVISON(CWnd* pParent = NULL); // 标准构造函数
virtual ~CVISON();
// 对话框数据
enum { IDD = IDD_VISION_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
virtual BOOL OnInitDialog();
};

40
HuaGoCorrect/Config.cpp Normal file
View File

@ -0,0 +1,40 @@
// Config.cpp: implementation of the CConfig class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Config.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CConfig::CConfig()
{
}
CConfig::~CConfig()
{
}
void CConfig::GetTextInfo(CString strKeyName, CString &strText)
{
char cParam[256];
::GetPrivateProfileString("TextInfo", strKeyName, "", cParam, 255, INI_FILE_NAME);
strText = cParam;
}
void CConfig::LoadCfg()
{
UINT iParam[30] = {0};
iParam[0] = ::GetPrivateProfileInt("ColorCorrection", "FRExposure ", 340, INI_FILE_NAME);
}

42
HuaGoCorrect/Config.h Normal file
View File

@ -0,0 +1,42 @@
// Config.h: interface for the CConfig class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CONFIG_H__9AA09B6E_5336_4EBA_BF73_3B1389D6FAF0__INCLUDED_)
#define AFX_CONFIG_H__9AA09B6E_5336_4EBA_BF73_3B1389D6FAF0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define INI_FILE_NAME "./HuaGoScan.ini"
class CConfig
{
public:
CConfig();
virtual ~CConfig();
void LoadCfg();
void GetTextInfo(CString strKeyName, CString &strText);
DWORD GetPort()
{
return m_dwLocalPort;
}
const char *GetTitle()
{
return m_strTitle;
}
const char* GetSQLIP()
{
return m_strSQLIP;
}
private:
CString m_strTitle; // 主界面上显示的标题
CString m_strSQLIP;
DWORD m_dwLocalPort; // 开启的端口号
};
#endif // !defined(AFX_CONFIG_H__9AA09B6E_5336_4EBA_BF73_3B1389D6FAF0__INCLUDED_)

View File

@ -0,0 +1,220 @@
// ConfigParam.cpp : 实现文件
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "ConfigParam.h"
#include "afxdialogex.h"
// CConfigParam 对话框
IMPLEMENT_DYNAMIC(CConfigParam, CDialog)
CConfigParam::CConfigParam(CWnd* pParent /*=NULL*/)
: CDialog(CConfigParam::IDD, pParent)
, m_AMaxStep(0)
, m_AMinStep(0)
, m_BMaxStep(0)
, m_BMinStep(0)
, m_AERMaxStep(0)
, m_AERMinStep(0)
, m_AEGMaxStep(0)
, m_AEGMinStep(0)
, m_AEBMaxStep(0)
, m_AEBMinStep(0)
, m_BERMaxStep(0)
, m_BERMinStep(0)
, m_BEGMaxStep(0)
, m_BEGMinStep(0)
, m_BEBMaxStep(0)
, m_BEBMinStep(0)
, m_GainStep(0)
{
}
CConfigParam::~CConfigParam()
{
}
void CConfigParam::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_AMaxStep, m_AMaxStep);
DDV_MinMaxUInt(pDX, m_AMaxStep, 0, 255);
DDX_Text(pDX, IDC_AMinStep, m_AMinStep);
DDV_MinMaxUInt(pDX, m_AMinStep, 0, 255);
DDX_Text(pDX, IDC_BMaxStep, m_BMaxStep);
DDV_MinMaxUInt(pDX, m_BMaxStep, 0, 255);
DDX_Text(pDX, IDC_BMinStep, m_BMinStep);
DDV_MinMaxUInt(pDX, m_BMinStep, 0, 255);
DDX_Text(pDX, IDC_AERMaxStep, m_AERMaxStep);
DDV_MinMaxUInt(pDX, m_AERMaxStep, 0, 1000);
DDX_Text(pDX, IDC_AERMinStep, m_AERMinStep);
DDV_MinMaxUInt(pDX, m_AERMinStep, 0, 1000);
DDX_Text(pDX, IDC_AEGMaxStep, m_AEGMaxStep);
DDV_MinMaxUInt(pDX, m_AEGMaxStep, 0, 1000);
DDX_Text(pDX, IDC_AEGMinStep, m_AEGMinStep);
DDV_MinMaxUInt(pDX, m_AEGMinStep, 0, 1000);
DDX_Text(pDX, IDC_AEBMaxStep, m_AEBMaxStep);
DDV_MinMaxUInt(pDX, m_AEBMaxStep, 0, 1000);
DDX_Text(pDX, IDC_AEBMinStep, m_AEBMinStep);
DDV_MinMaxUInt(pDX, m_AEBMinStep, 0, 1000);
DDX_Text(pDX, IDC_BERMaxStep, m_BERMaxStep);
DDV_MinMaxUInt(pDX, m_BERMaxStep, 0, 1000);
DDX_Text(pDX, IDC_BERMinStep, m_BERMinStep);
DDV_MinMaxUInt(pDX, m_BERMinStep, 0, 1000);
DDX_Text(pDX, IDC_BEGMaxStep, m_BEGMaxStep);
DDV_MinMaxUInt(pDX, m_BEGMaxStep, 0, 1000);
DDX_Text(pDX, IDC_BEGMinStep, m_BEGMinStep);
DDV_MinMaxUInt(pDX, m_BEGMinStep, 0, 1000);
DDX_Text(pDX, IDC_BEBMaxStep, m_BEBMaxStep);
DDV_MinMaxUInt(pDX, m_BEBMaxStep, 0, 1000);
DDX_Text(pDX, IDC_BEBMinStep, m_BEBMinStep);
DDV_MinMaxUInt(pDX, m_BEBMinStep, 0, 1000);
DDX_Text(pDX, IDC_GainStep, m_GainStep);
DDV_MinMaxUInt(pDX, m_GainStep, 0, 1000);
}
BEGIN_MESSAGE_MAP(CConfigParam, CDialog)
ON_BN_CLICKED(IDC_BTN_SAVECFG, &CConfigParam::OnBtnSaveCFG)
END_MESSAGE_MAP()
// CConfigParam 消息处理程序
BOOL CConfigParam::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
LoadConfig();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CConfigParam::LoadConfig()
{
UpdateData(TRUE);
m_AMaxStep = ::GetPrivateProfileInt("GrayBlack", "AGMaxStep", 255, INI_FILE_NAME);
m_AMinStep = ::GetPrivateProfileInt("GrayBlack", "AGMinStep", 0, INI_FILE_NAME);
m_BMaxStep = ::GetPrivateProfileInt("GrayBlack", "BGMaxStep", 255, INI_FILE_NAME);
m_BMinStep = ::GetPrivateProfileInt("GrayBlack", "BGMinStep", 0, INI_FILE_NAME);
m_AERMaxStep = ::GetPrivateProfileInt("ColorWhite", "ACRMaxStep", 900, INI_FILE_NAME);
m_AERMinStep = ::GetPrivateProfileInt("ColorWhite", "ACRMinStep", 0, INI_FILE_NAME);
m_AEGMaxStep = ::GetPrivateProfileInt("ColorWhite", "ACGMaxStep", 900, INI_FILE_NAME);
m_AEGMinStep = ::GetPrivateProfileInt("ColorWhite", "ACGMinStep", 0, INI_FILE_NAME);
m_AEBMaxStep = ::GetPrivateProfileInt("ColorWhite", "ACBMaxStep", 900, INI_FILE_NAME);
m_AEBMinStep = ::GetPrivateProfileInt("ColorWhite", "ACBMinStep", 0, INI_FILE_NAME);
m_BERMaxStep = ::GetPrivateProfileInt("ColorWhite", "BCRMaxStep", 900, INI_FILE_NAME);
m_BERMinStep = ::GetPrivateProfileInt("ColorWhite", "BCRMinStep", 0, INI_FILE_NAME);
m_BEGMaxStep = ::GetPrivateProfileInt("ColorWhite", "BCGMaxStep", 900, INI_FILE_NAME);
m_BEGMinStep = ::GetPrivateProfileInt("ColorWhite", "BCGMinStep", 0, INI_FILE_NAME);
m_BEBMaxStep = ::GetPrivateProfileInt("ColorWhite", "BCBMaxStep", 900, INI_FILE_NAME);
m_BEBMinStep = ::GetPrivateProfileInt("ColorWhite", "BCBMinStep", 0, INI_FILE_NAME);
m_GainStep = ::GetPrivateProfileInt("GainStep", "ABGainStep", 24, INI_FILE_NAME);
UpdateData(FALSE);
}
void CConfigParam::OnBtnSaveCFG()
{
// TODO: 在此添加控件通知处理程序代码
SaveParam();
OnOK();
}
void CConfigParam::SaveParam()
{
UpdateData(TRUE);
CString csAMaxStep,csAMinStep,csBMaxStep,csBMinStep,csABGainStep;
CString csAERMaxStep,csAERMinStep,csAEGMaxStep,csAEGMinStep,csAEBMaxStep,csAEBMinStep;
CString csBERMaxStep,csBERMinStep,csBEGMaxStep,csBEGMinStep,csBEBMaxStep,csBEBMinStep;
csAMaxStep.Format(_T("%d"),m_AMaxStep);
csAMinStep.Format(_T("%d"),m_AMinStep);
csBMaxStep.Format(_T("%d"),m_BMaxStep);
csBMinStep.Format(_T("%d"),m_BMinStep);
csAERMaxStep.Format(_T("%d"),m_AERMaxStep);
csAERMinStep.Format(_T("%d"),m_AERMinStep);
csAEGMaxStep.Format(_T("%d"),m_AEGMaxStep);
csAEGMinStep.Format(_T("%d"),m_AEGMinStep);
csAEBMaxStep.Format(_T("%d"),m_AEBMaxStep);
csAEBMinStep.Format(_T("%d"),m_AEBMinStep);
csBERMaxStep.Format(_T("%d"),m_BERMaxStep);
csBERMinStep.Format(_T("%d"),m_BERMinStep);
csBEGMaxStep.Format(_T("%d"),m_BEGMaxStep);
csBEGMinStep.Format(_T("%d"),m_BEGMinStep);
csBEBMaxStep.Format(_T("%d"),m_BEBMaxStep);
csBEBMinStep.Format(_T("%d"),m_BEBMinStep);
csABGainStep.Format(_T("%d"),m_GainStep);
UpdateData(FALSE);
WritePrivateProfileString("GrayBlack", "AGMaxStep", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayBlack", "AGMinStep", csAMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F1Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F2Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F3Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F4Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F5Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "F6Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F1Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F2Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F3Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F4Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F5Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "F6Offset", csAMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayBlack", "BGMaxStep", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayBlack", "BGMinStep", csBMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B1Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B2Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B3Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B4Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B5Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "B6Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B1Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B2Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B3Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B4Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B5Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GrayCorrection", "B6Offset", csBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACRMaxStep", csAERMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACRMinStep", csAERMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "FRExposure", csAERMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACGMaxStep", csAEGMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACGMinStep", csAEGMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "FGExposure", csAEGMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACBMaxStep", csAEBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "ACBMinStep", csAEBMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "FBExposure", csAEBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCRMaxStep", csBERMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCRMinStep", csBERMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BRExposure", csBERMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCGMaxStep", csBEGMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCGMinStep", csBEGMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BGExposure", csBEGMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCBMaxStep", csBEBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("ColorWhite", "BCBMinStep", csBEBMinStep, INI_FILE_NAME);
WritePrivateProfileString("ColorCorrection", "BBExposure", csBEBMaxStep, INI_FILE_NAME);
WritePrivateProfileString("GainStep", "ABGainStep", csABGainStep, INI_FILE_NAME);
MessageBox(_T("配置完成"));
}
void CConfigParam::OnOK()
{
// TODO: 在此添加专用代码和/或调用基类
CDialog::OnOK();
}

View File

@ -0,0 +1,45 @@
#pragma once
#include "Config.h"
// CConfigParam 对话框
class CConfigParam : public CDialog
{
DECLARE_DYNAMIC(CConfigParam)
public:
CConfigParam(CWnd* pParent = NULL); // 标准构造函数
virtual ~CConfigParam();
// 对话框数据
enum { IDD = IDD_DIALOG_CONFIGPARAM };
void LoadConfig();
void SaveParam();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
UINT m_AMaxStep;
UINT m_AMinStep;
UINT m_BMaxStep;
UINT m_BMinStep;
UINT m_AERMaxStep;
UINT m_AERMinStep;
UINT m_AEGMaxStep;
UINT m_AEGMinStep;
UINT m_AEBMaxStep;
UINT m_AEBMinStep;
UINT m_BERMaxStep;
UINT m_BERMinStep;
UINT m_BEGMaxStep;
UINT m_BEGMinStep;
UINT m_BEBMaxStep;
UINT m_BEBMinStep;
UINT m_GainStep;
afx_msg void OnBtnSaveCFG();
virtual void OnOK();
};

View File

@ -0,0 +1,21 @@
/************************************************************************/
/*功能: 此头文件为公共调用头文件 */
/************************************************************************/
#ifndef _DEF_HS_COMMON_H_
#define _DEF_HS_COMMON_H_
#include "DefHSStructure.h" //结构
enum TimerId
{
Invalid_Timer = 0,
StatusBar_Timer,
LicenseCheck_Timer,
VideoUpdate_Timer,
ProgramCheck_Timer,
Max_TimerId,
};
#endif //end _DEF_HS_COMMON_H_

View File

@ -0,0 +1,22 @@
/************************************************************************/
/*功能: 此头文件定义使用到的结构定义 */
/************************************************************************/
#ifndef _DEF_HS_Structure_H_
#define _DEF_HS_Structure_H_
struct FlatCorrection {
UINT ColorCorrection[30];
UINT ColorFlat[30];
UINT GrayCorrection[30];
UINT GrayFlat[30];
FlatCorrection()
{
memset(GrayFlat,0,sizeof(GrayFlat));
memset(ColorFlat,0,sizeof(ColorFlat));
memset(GrayCorrection,0,sizeof(GrayCorrection));
memset(ColorCorrection,0,sizeof(ColorCorrection));
}
};
#endif //end _DEF_HS_Structure_H_

View File

@ -0,0 +1,122 @@
// HuaGoCorrect.cpp : 定义应用程序的类行为。
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "HuaGoCorrectDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CHuaGoCorrectApp
BEGIN_MESSAGE_MAP(CHuaGoCorrectApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CHuaGoCorrectApp 构造
CHuaGoCorrectApp::CHuaGoCorrectApp()
{
// 支持重新启动管理器
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}
// 唯一的一个 CHuaGoCorrectApp 对象
CHuaGoCorrectApp theApp;
CHuaGoCorrectApp *GetMainApp()
{
return &theApp;
}
// CHuaGoCorrectApp 初始化
BOOL CHuaGoCorrectApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = new CShellManager;
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
CreateScanFile();
CHuaGoCorrectDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
// 删除上面创建的 shell 管理器。
if (pShellManager != NULL)
{
delete pShellManager;
}
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
// 而不是启动应用程序的消息泵。
return FALSE;
}
void CHuaGoCorrectApp::CreateScanFile()
{
CString csDate;
char cTime[11];
CTime currTime = CTime::GetCurrentTime();
_snprintf(cTime, 11, "%04d-%02d-%02d", currTime.GetYear(), currTime.GetMonth(), currTime.GetDay());
csDate.Format("%s",cTime);
path = ".\\ScanPicture\\";
if (!PathIsDirectory(path))
{
::CreateDirectory(path, 0);
}
path += csDate;
if (!PathIsDirectory(path))
{
::CreateDirectory(path, 0);
}
}

View File

@ -0,0 +1,37 @@
// HuaGoCorrect.h : PROJECT_NAME 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
// CHuaGoCorrectApp:
// 有关此类的实现,请参阅 HuaGoCorrect.cpp
//
class CHuaGoCorrectApp : public CWinApp
{
public:
CHuaGoCorrectApp();
void CreateScanFile();
CString path;
// 重写
public:
virtual BOOL InitInstance();
// 实现
DECLARE_MESSAGE_MAP()
};
extern CHuaGoCorrectApp *GetMainApp();
//extern CHuaGoCorrectApp theApp;

Binary file not shown.

View File

@ -0,0 +1,311 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{988CC4D3-44EC-4A9D-AC05-B2AF0EA48E75}</ProjectGuid>
<RootNamespace>HuaGoCorrect</RootNamespace>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<ProjectName>HuaGoCorrect_V3.0</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<PlatformToolset>v141</PlatformToolset>
<VCToolsVersion>
</VCToolsVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<PlatformToolset>v142</PlatformToolset>
<VCToolsVersion>14.20.27508</VCToolsVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>./pub/opencv/include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\pub\opencv\bin;.\pub\external\bin;.\pub\opencv\include;.\pub\external\include;.\pub\ddk;.\pub\json;D:\local\boost_1_71_0_b1_rc1;D:\OpenCV2.4.10\opencv\build\include\opencv;D:\OpenCV2.4.10\opencv\build\include\opencv2</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>.\pub\external\lib;.\pub\opencv\lib;D:\local\boost_1_71_0_b1_rc1\lib32-msvc-14.1</AdditionalLibraryDirectories>
<AdditionalDependencies>./pub/external/lib/turbojpeg.lib;./pub/opencv/lib/opencv_world346d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\pub\opencv\bin;.\pub\external\bin;.\pub\opencv\include;.\pub\external\include;.\pub\ddk;.\pub\json;D:\local\boost_1_71_0_b1_rc1;D:\OpenCV2.4.10\opencv\build\include\opencv;D:\OpenCV2.4.10\opencv\build\include\opencv2</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>.\pub\external\lib;.\pub\opencv\lib;D:\local\boost_1_71_0_b1_rc1\lib32-msvc-14.1</AdditionalLibraryDirectories>
<AdditionalDependencies>turbojpeg.lib;opencv_core2410d.lib;opencv_highgui2410d.lib;
opencv_imgproc2410d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\pub\opencv\bin;.\pub\external\bin;.\pub\opencv\include;.\pub\external\include;.\pub\ddk;.\pub\json;D:\local\boost_1_71_0_b1_rc1;D:\OpenCV2.4.10\opencv\build\include\opencv;D:\OpenCV2.4.10\opencv\build\include\opencv2</AdditionalIncludeDirectories>
<WholeProgramOptimization>false</WholeProgramOptimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>.\pub\external\lib;.\pub\opencv\lib;D:\local\boost_1_71_0_b1_rc1\lib32-msvc-14.1</AdditionalLibraryDirectories>
<AdditionalDependencies>turbojpeg.lib;opencv_core2410.lib;opencv_highgui2410.lib;
opencv_imgproc2410.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\pub\opencv\bin;.\pub\external\bin;.\pub\opencv\include;.\pub\external\include;.\pub\ddk;.\pub\json;D:\local\boost_1_71_0_b1_rc1;D:\OpenCV2.4.10\opencv\build\include\opencv;D:\OpenCV2.4.10\opencv\build\include\opencv2</AdditionalIncludeDirectories>
<WholeProgramOptimization>false</WholeProgramOptimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>.\pub\external\lib;.\pub\opencv\lib;D:\local\boost_1_71_0_b1_rc1\lib32-msvc-14.1</AdditionalLibraryDirectories>
<AdditionalDependencies>turbojpeg.lib;opencv_core2410.lib;opencv_highgui2410.lib;
opencv_imgproc2410.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
<None Include="res\HuaGoCorrect.ico" />
<None Include="res\HuaGoCorrect.rc2" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="A3.h" />
<ClInclude Include="A4.h" />
<ClInclude Include="BlockingQueue.h" />
<ClInclude Include="CIS.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="ConfigParam.h" />
<ClInclude Include="CVISON.h" />
<ClInclude Include="DefHSCommon.h" />
<ClInclude Include="DefHSStructure.h" />
<ClInclude Include="filetools.h" />
<ClInclude Include="gscn_drv.h" />
<ClInclude Include="HuaGoCorrect.h" />
<ClInclude Include="HuaGoCorrectDlg.h" />
<ClInclude Include="ImageApply.h" />
<ClInclude Include="ImageApplyAdjustColors.h" />
<ClInclude Include="ImageApplyAutoCrop.h" />
<ClInclude Include="ImageApplyBWBinaray.h" />
<ClInclude Include="ImageApplyChannel.h" />
<ClInclude Include="ImageApplyCrop.h" />
<ClInclude Include="ImageApplyDiscardBlank.h" />
<ClInclude Include="ImageApplyHeaders.h" />
<ClInclude Include="ImageApplyResize.h" />
<ClInclude Include="ImageApplyRotation.h" />
<ClInclude Include="ImageApplySharpen.h" />
<ClInclude Include="ImageApplyTextureRemoval.h" />
<ClInclude Include="ImageApplyThreshold.h" />
<ClInclude Include="ImageMatQueue.h" />
<ClInclude Include="imageprocess.h" />
<ClInclude Include="ImageProcess_Public.h" />
<ClInclude Include="imgprocdefs.h" />
<ClInclude Include="JpegBuffer.h" />
<ClInclude Include="jpeglib.h" />
<ClInclude Include="json.h" />
<ClInclude Include="JsonConfig.h" />
<ClInclude Include="localTime.h" />
<ClInclude Include="MutexEx.h" />
<ClInclude Include="m_Dis.h" />
<ClInclude Include="PublicFunc.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="scn_config.h" />
<ClInclude Include="scn_usb.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="A3.cpp" />
<ClCompile Include="A4.cpp" />
<ClCompile Include="CIS.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="ConfigParam.cpp" />
<ClCompile Include="CVISON.cpp" />
<ClCompile Include="gscn_drv.cpp" />
<ClCompile Include="HuaGoCorrect.cpp" />
<ClCompile Include="HuaGoCorrectDlg.cpp" />
<ClCompile Include="ImageApply.cpp" />
<ClCompile Include="ImageApplyAdjustColors.cpp" />
<ClCompile Include="ImageApplyAutoCrop.cpp" />
<ClCompile Include="ImageApplyBWBinaray.cpp" />
<ClCompile Include="ImageApplyChannel.cpp" />
<ClCompile Include="ImageApplyCrop.cpp" />
<ClCompile Include="ImageApplyDiscardBlank.cpp" />
<ClCompile Include="ImageApplyResize.cpp" />
<ClCompile Include="ImageApplyRotation.cpp" />
<ClCompile Include="ImageApplySharpen.cpp" />
<ClCompile Include="ImageApplyTextureRemoval.cpp" />
<ClCompile Include="ImageApplyThreshold.cpp" />
<ClCompile Include="ImageMatQueue.cpp" />
<ClCompile Include="imageprocess.cpp" />
<ClCompile Include="ImageProcess_Public.cpp" />
<ClCompile Include="JpegBuffer.cpp" />
<ClCompile Include="jpeglib.cpp" />
<ClCompile Include="JsonConfig.cpp" />
<ClCompile Include="m_Dis.cpp" />
<ClCompile Include="PublicFunc.cpp" />
<ClCompile Include="scn_config.cpp" />
<ClCompile Include="scn_usb.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="HuaGoCorrect.rc" />
</ItemGroup>
<ItemGroup>
<Text Include="imgprc.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="HuaGoCorrect.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,277 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="头文件\USB通信">
<UniqueIdentifier>{aef23b0f-18bf-4ee4-b142-f0507dcb5553}</UniqueIdentifier>
</Filter>
<Filter Include="头文件\基础结构定义">
<UniqueIdentifier>{b7a31067-3de6-4e76-a00a-67c7cddad31c}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\USB通信">
<UniqueIdentifier>{4947e7b4-3e27-433f-a80c-23bc7a009204}</UniqueIdentifier>
</Filter>
<Filter Include="头文件\文件处理">
<UniqueIdentifier>{c3c1bbc0-cb36-414d-bab7-7d40e277918e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
<None Include="res\HuaGoCorrect.rc2">
<Filter>资源文件</Filter>
</None>
<None Include="res\HuaGoCorrect.ico">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="HuaGoCorrect.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="HuaGoCorrectDlg.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Config.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="filetools.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="imageprocess.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="localTime.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="MutexEx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="PublicFunc.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="gscn_drv.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="ImageMatQueue.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="JpegBuffer.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="jpeglib.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="scn_config.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="scn_usb.h">
<Filter>头文件\USB通信</Filter>
</ClInclude>
<ClInclude Include="DefHSCommon.h">
<Filter>头文件\基础结构定义</Filter>
</ClInclude>
<ClInclude Include="DefHSStructure.h">
<Filter>头文件\基础结构定义</Filter>
</ClInclude>
<ClInclude Include="A3.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="A4.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ConfigParam.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CVISON.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="BlockingQueue.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CIS.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="m_Dis.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="JsonConfig.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="json.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ImageApply.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyAdjustColors.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyAutoCrop.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyBWBinaray.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyChannel.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyCrop.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyDiscardBlank.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyHeaders.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyResize.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyRotation.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplySharpen.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyTextureRemoval.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageApplyThreshold.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="ImageProcess_Public.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
<ClInclude Include="imgprocdefs.h">
<Filter>头文件\文件处理</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="HuaGoCorrect.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="HuaGoCorrectDlg.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Config.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="imageprocess.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="PublicFunc.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="gscn_drv.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="ImageMatQueue.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="JpegBuffer.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="jpeglib.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="scn_config.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="scn_usb.cpp">
<Filter>源文件\USB通信</Filter>
</ClCompile>
<ClCompile Include="A3.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="A4.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ConfigParam.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CVISON.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CIS.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="m_Dis.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="JsonConfig.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ImageApply.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ImageApplyAdjustColors.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyAutoCrop.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyBWBinaray.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyChannel.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyCrop.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyDiscardBlank.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyResize.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyRotation.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplySharpen.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyTextureRemoval.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageApplyThreshold.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
<ClCompile Include="ImageProcess_Public.cpp">
<Filter>头文件\文件处理</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="HuaGoCorrect.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Text Include="imgprc.txt">
<Filter>头文件\文件处理</Filter>
</Text>
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RESOURCE_FILE>HuaGoCorrect.rc</RESOURCE_FILE>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,209 @@
// HuaGoCorrectDlg.h : 头文件
//
#pragma once
#include "afxcmn.h"
#include "HuaGoCorrect.h"
#include "DefHSCommon.h"
#include "gscn_drv.h"
#include "Config.h"
#include "twain.h"
#include "A3.h"
#include "A4.h"
#include "CIS.h"
#include "m_Dis.h"
#include "ConfigParam.h"
#include "afxwin.h"
#include "CVISON.h"
#include <memory>
#include "ImageApply.h"
#include "ImageApplyAdjustColors.h"
#include "ImageApplyAutoCrop.h"
#include "ImageApplyBWBinaray.h"
#include "ImageApplyChannel.h"
#include "ImageApplyCrop.h"
#include "ImageApplyDiscardBlank.h"
#include "ImageApplyResize.h"
#include "ImageApplyRotation.h"
#include "ImageApplySharpen.h"
using namespace std;
#define WM_MYMESSAGE (WM_USER+100)
enum TwSS : ushort
{
A4 = 1,
A3 = 11,
USStatement = 52
};
// CHuaGoCorrectDlg 对话框
class CHuaGoCorrectDlg : public CDialogEx
{
// 构造
public:
CHuaGoCorrectDlg(CWnd* pParent = NULL); // 标准构造函数
// 对话框数据
enum { IDD = IDD_HUAGOCORRECT_DIALOG };
bool m_bScanning;
bool ls_flat;
int papercount;
int m_iPicIndex;
int m_iflatIndex;
int m_iDpiIndex;
int m_iColorIndex;
int iAMaxStep;
int iAMiddleStep;
int iAMinStep;
int iBMaxStep;
int iBMiddleStep;
int iBMinStep;
int iAERMaxStep;
int iAERMiddleStep;
int iAERMinStep;
int iAEGMaxStep;
int iAEGMiddleStep;
int iAEGMinStep;
int iAEBMaxStep;
int iAEBMiddleStep;
int iAEBMinStep;
int iBERMaxStep;
int iBERMiddleStep;
int iBERMinStep;
int iBEGMaxStep;
int iBEGMiddleStep;
int iBEGMinStep;
int iBEBMaxStep;
int iBEBMiddleStep;
int iBEBMinStep;
int iGainStep;
int n_hour;
int n_minute;
int n_second;
int usb_vid;
int usb_pid;
BOOL b_review;
BOOL b_suspend;
CConfig m_Cfg;
CA3 m_A3Dlg;
CA4 m_A4Dlg;
CIS m_CISDlg;
m_Dis m_dis;
CVISON m_VisonDlg;
CConfigParam m_ConfigParam;
shared_ptr<GScn_Drv> m_drv;
CRect tabRect; // 标签控件客户区的位置和大小
void Scan();
void RefreshTabChange();
int Mat2CImage(Mat *mat, CImage &img);
cv::Mat m_matFImage;
cv::Mat m_matBImage;
int Version_id[5][2] = { {0x064b,0x7823},{0x3072,0x0100},{0x3072 ,0x0200},{0x3072 ,0x0300},{0x3072 ,0x0400} };
void ShowFrontImage(int index);
void ShowBackImage(int index);
void A3ParamSet();
void A4ParamSet();
void intToByte(UINT *src,byte *bytes,int iLength);
void bytesToInt(byte* bytes,UINT *des, int iLength);
void CorrectBlackImage();
void CorrectWhiteImage();
void CorrectWhiteGain();
void CorrectFinish();
void WriteLog(CString msg);
void CyclePro();
void CorrectCMDUpdate();
void CorrectEndUpdate();
void ConfigParamUpdate();
void InitButton();
void FSongleCorrect();
bool bABlackImage;
bool bBBlackImage;
bool bAGrayWhiteImage;
bool bBGrayWhiteImage;
bool bAColorWhiteImage;
bool bAcolr;
bool bAcolg;
bool bAcolb;
bool bBColorWhiteImage;
bool bBcolr;
bool bBcolg;
bool bBcolb;
bool bAGrayWhiteGain;
bool bBGrayWhiteGain;
bool bAColorWhiteGain;
bool bBColorWhiteGain;
std::vector<std::shared_ptr<CImageApply>> m_iaList;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICON m_hIcon;
HANDLE m_hThread;
BOOL m_bExit;
void CorrectThreadFunc();
static unsigned WINAPI CorrectThread(void* pCorrect);
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
CTabCtrl m_tab;
afx_msg BOOL PreCreateWindow(CREATESTRUCT& cs);
afx_msg void OnTcnSelChangeTab(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedCheckparamset();
afx_msg void OnBnClickedCheckparamread();
void UpdateList(CONFIGPARAMS configParams, bool canUpdate);
afx_msg void OnBnClickedBtnFlat();
CButton m_pBlack;
CButton m_pWExposure;
CButton m_pWGain;
afx_msg void OnBnClickedBtnFlatm();
CCriticalSection m_deviceLock;
virtual void OnCancel();
BOOL m_bPause;
BOOL m_bParamError;
afx_msg void OnBnClickedBtnBlackflat();
afx_msg void OnBnClickedBtnExflat();
afx_msg void OnBnClickedBtnGainflat();
afx_msg void OnBnClickedBtnContinue();
afx_msg void OnBnClickedBtnPause();
CComboBox m_ComboxDpi;
CComboBox m_ComboxColor;
afx_msg void OnCbnSelChangeDpi();
afx_msg void OnCbnSelChangeColor();
afx_msg void OnBnClickedConfirm();
afx_msg void OnBnClickedBtnParamcfg();
CButton m_check_FpgaFlat;
CString s_hour;
CString s_minute;
CString s_second;
afx_msg void OnBnClickedStopScan();
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg LRESULT OnMyMessage(/*HWND hWnd, UINT Msg,*/ WPARAM w,LPARAM l);
CButton close_butten;
CComboBox twss;
CComboBox duplex;
CComboBox Version;
afx_msg void OnCbnSelchangeCombo1();
};

181
HuaGoCorrect/HuaGoScan.ini Normal file
View File

@ -0,0 +1,181 @@
[ColorCorrection]
;彩色校正模式
FRExposure=442
FGExposure=629
FBExposure=998
F1Gain=45
F2Gain=45
F3Gain=45
F4Gain=45
F5Gain=45
F6Gain=45
F1Offset=122
F2Offset=122
F3Offset=122
F4Offset=122
F5Offset=122
F6Offset=122
BRExposure=416
BGExposure=682
BBExposure=792
B1Gain=45
B2Gain=45
B3Gain=45
B4Gain=45
B5Gain=45
B6Gain=45
B1Offset=120
B2Offset=120
B3Offset=120
B4Offset=120
B5Offset=120
B6Offset=120
[ColorFlat]
;彩色
FRExposure=402
FGExposure=649
FBExposure=958
F1Gain=60
F2Gain=60
F3Gain=60
F4Gain=60
F5Gain=60
F6Gain=60
F1Offset=122
F2Offset=122
F3Offset=122
F4Offset=122
F5Offset=122
F6Offset=122
BRExposure=376
BGExposure=702
BBExposure=752
B1Gain=60
B2Gain=60
B3Gain=60
B4Gain=60
B5Gain=60
B6Gain=60
B1Offset=120
B2Offset=120
B3Offset=120
B4Offset=120
B5Offset=120
B6Offset=120
[GrayCorrection]
;灰度校正模式
FRExposure=271
FGExposure=271
FBExposure=271
F1Gain=30
F2Gain=30
F3Gain=30
F4Gain=30
F5Gain=30
F6Gain=30
F1Offset=122
F2Offset=122
F3Offset=122
F4Offset=122
F5Offset=122
F6Offset=122
BRExposure=256
BGExposure=256
BBExposure=256
B1Gain=30
B2Gain=30
B3Gain=30
B4Gain=30
B5Gain=30
B6Gain=30
B1Offset=120
B2Offset=120
B3Offset=120
B4Offset=120
B5Offset=120
B6Offset=120
[GrayFlat]
;灰度
FRExposure=271
FGExposure=271
FBExposure=271
F1Gain=47
F2Gain=47
F3Gain=47
F4Gain=47
F5Gain=47
F6Gain=47
F1Offset=122
F2Offset=122
F3Offset=122
F4Offset=122
F5Offset=122
F6Offset=122
BRExposure=256
BGExposure=256
BBExposure=256
B1Gain=47
B2Gain=47
B3Gain=47
B4Gain=47
B5Gain=47
B6Gain=47
B1Offset=120
B2Offset=120
B3Offset=120
B4Offset=120
B5Offset=120
B6Offset=120
[GrayBlack]
;灰度暗场
AGMaxStep=255
AGMinStep=0
BGMaxStep=255
BGMinStep=0
[ColorWhite]
;彩色白场
ACRMaxStep=900
ACRMinStep=0
ACGMaxStep=900
ACGMinStep=0
ACBMaxStep=900
ACBMinStep=0
BCRMaxStep=900
BCRMinStep=0
BCGMaxStep=900
BCGMinStep=0
BCBMaxStep=900
BCBMinStep=0
[GainStep]
;增益步长
ABGainStep=24
[ObjValue]
;目标值
objvalue_x1=0
objvalue_x2=0
objvalue_x3=0
objvalue_y1=0
objvalue_y2=0
objvalue_y3=0
[LimitOffset]
;偏差值
limitoffset_x1=0
limitoffset_x2=0
limitoffset_x3=0
limitoffset_y1=0
limitoffset_y2=0
limitoffset_y3=0
[CIS]
;cis检测设置
channle=1
total_up=28
total_low=10
total_area_up=298
total_area_low=300
[USB]
;USB设备VIDPID
VID=0x064b
PID=0x7823
Version_num=1

View File

@ -0,0 +1,10 @@
#include "StdAfx.h"
#include "ImageApply.h"
CImageApply::CImageApply(void)
{
}
CImageApply::~CImageApply(void)
{
}

22
HuaGoCorrect/ImageApply.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include <vector>
#include <memory>
#include <opencv2/opencv.hpp>
#include "imgprocdefs.h"
#if defined(LOG)
#include "filetools.h"
#endif
class CImageApply
{
public:
CImageApply(void);
virtual ~CImageApply(void);
virtual void apply(cv::Mat& pDib,int side) = 0;
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide) = 0;
};
typedef std::shared_ptr<CImageApply> ImageApplyPtr;

View File

@ -0,0 +1,105 @@
#include "StdAfx.h"
#include "ImageApplyAdjustColors.h"
CImageApplyAdjustColors::CImageApplyAdjustColors(void)
: m_brightness(0)
, m_contrast(0)
, m_gamma(1.0f)
, lut(1, 256, CV_8UC1)
{
update_lutData();
}
CImageApplyAdjustColors::CImageApplyAdjustColors(int brightness, int contrast, float gamma)
: lut(1, 256, CV_8UC1)
{
setAdjustColors(brightness, contrast, gamma);
}
CImageApplyAdjustColors::~CImageApplyAdjustColors(void)
{
}
void CImageApplyAdjustColors::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyAdjustColors apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyAdjustColors apply");
#endif // LOG
return;
}
if (m_brightness != 0 || m_contrast != 0 || m_gamma != 1.0)
cv::LUT(pDib, lut, pDib);
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyAdjustColors apply");
#endif // LOG
}
void CImageApplyAdjustColors::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}
void CImageApplyAdjustColors::setAdjustColors(int brightness, int contrast, float gamma)
{
setBrightness(brightness);
setContrast(contrast);
setGamma(gamma);
update_lutData();
}
void CImageApplyAdjustColors::setBrightness(int brightness)
{
m_brightness = cv::max(-255, cv::min(brightness, 255));
update_lutData();
}
void CImageApplyAdjustColors::setContrast(int contrast)
{
m_contrast = cv::max(-127, cv::min(contrast, 127));
update_lutData();
}
void CImageApplyAdjustColors::setGamma(float gamma)
{
m_gamma = cv::max(0.1f, cv::min(gamma, 5.0f));
update_lutData();
}
void CImageApplyAdjustColors::update_lutData()
{
unsigned char* ptr = lut.data;
if (m_gamma != 1.0f)
{
float g = 1.0f / m_gamma;
for (int i = 0; i < 256; i++)
ptr[i] = static_cast<unsigned char>(cv::min(255, static_cast<int>(cv::pow(i / 255.0f, g) * 255.0f + 0.5f)));
}
else
{
for (int i = 0; i < 256; i++)
{
//update contrast
if (i < 128)
ptr[i] = static_cast<unsigned char>(cv::max(0, cv::min(i - m_contrast, 127)));
else
ptr[i] = static_cast<unsigned char>(cv::max(127, cv::min(i + m_contrast, 255)));
//update brightness
ptr[i] = static_cast<unsigned char>(cv::max(0, cv::min(ptr[i] + m_brightness, 255)));
}
}
}

View File

@ -0,0 +1,48 @@
#ifndef IMAGE_APPLY_ADJUST_COLOR_H
#define IMAGE_APPLY_ADJUST_COLOR_H
#include "ImageApply.h"
class CImageApplyAdjustColors : public CImageApply
{
public:
CImageApplyAdjustColors(void);
CImageApplyAdjustColors(int brightness, int contrast, float gamma);
virtual ~CImageApplyAdjustColors(void);
virtual void apply(cv::Mat& pDib, int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
void setAdjustColors(int brightness, int contrast, float gamma);
int getContrast() { return m_contrast; }
int getBrightness() { return m_brightness; }
double getGamma() { return m_gamma; }
void setBrightness(int brightness);
void setContrast(int contrast);
void setGamma(float gamma);
private:
void update_lutData();
private:
int m_brightness;
int m_contrast;
float m_gamma;
cv::Mat lut;
};
#endif // !IMAGE_APPLY_ADJUST_COLOR_H

View File

@ -0,0 +1,188 @@
#include "StdAfx.h"
#include "ImageApplyAutoCrop.h"
#include "ImageProcess_Public.h"
#define RE 2
CImageApplyAutoCrop::CImageApplyAutoCrop()
: m_isCrop(false)
, m_isDesaskew(false)
, m_isFillBlank(false)
, m_isConvexHull(true)
, m_threshold(40)
, m_noise(2)
, m_indent(5)
{
}
CImageApplyAutoCrop::CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex, double threshold, int noise, int indent)
: m_isCrop(isCrop)
, m_isDesaskew(isDesaskew)
, m_isFillBlank(isFillBlank)
, m_isConvexHull(isConvex)
, m_threshold(threshold)
, m_noise(noise)
, m_indent(indent)
, m_fixedSize(fixedSize)
{
}
CImageApplyAutoCrop::~CImageApplyAutoCrop()
{
}
void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
{
#ifdef LOG
FileTools::write_log("D:\\1.txt", "enter CImageApplyAutoCrop apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("D:\\1.txt", "exit CImageApplyAutoCrop apply");
#endif // LOG
return;
}
cv::Mat src = pDib;
cv::Mat dst;
cv::Mat src_resize;
cv::resize(src, src_resize, cv::Size(src.cols / RE, src.rows / RE));
cv::Mat scale_mat;
cv::Mat thre(src_resize.size(), CV_8UC1);
hg::threshold_Mat(src_resize, thre, m_threshold);
if (m_noise > RE)
{
cv::Mat element = getStructuringElement(cv::MORPH_RECT, cv::Size(m_noise / RE, m_noise / RE));
cv::morphologyEx(thre, thre, cv::MORPH_OPEN, element);
}
std::vector<cv::Vec4i> hierarchy;
std::vector<std::vector<cv::Point>> contours;
hg::findContours(thre, contours, hierarchy, cv::RETR_EXTERNAL);
std::vector<cv::Point> maxContour = hg::getMaxContour(contours, hierarchy);
//for (cv::Point& item : maxContour)
for (int i = 0;i < maxContour.size();i++)
{
maxContour[i].x = maxContour[i].x * RE - RE / 2;
maxContour[i].y = maxContour[i].y * RE - RE / 2;
}
if (maxContour.size() == 0)
{
thre.release();
#ifdef LOG
FileTools::write_log("D:\\1.txt", "exit CImageApplyAutoCrop apply");
#endif // LOG
return;
}
thre.release();
dst.release();
cv::RotatedRect rect = hg::getBoundingRect(maxContour);
if (m_isDesaskew)
{
cv::Point2f srcTri[4];
cv::Point2f dstTri[3];
rect.points(srcTri);
dstTri[0] = cv::Point2f(0, rect.size.height - 1);
dstTri[1] = cv::Point2f(0, 0);
dstTri[2] = cv::Point2f(rect.size.width - 1, 0);
cv::Mat warp_mat;
warp_mat = cv::getAffineTransform(srcTri, dstTri);
cv::warpAffine(src, dst, warp_mat, rect.size);
}
else
dst = src(rect.boundingRect() & cv::Rect(0, 0, src.cols, src.rows));
if (m_isFillBlank)
{
cv::Mat thre_dst;
hg::threshold_Mat(dst, thre_dst, m_threshold);
cv::erode(thre_dst, thre_dst, cv::Mat(), cv::Point(-1, -1), m_indent);
hierarchy.clear();
contours.clear();
maxContour.clear();
hg::findContours(thre_dst, contours, hierarchy, cv::RETR_EXTERNAL);
maxContour = hg::getMaxContour(contours, hierarchy);
if (m_isConvexHull)
hg::convexHull(maxContour, maxContour);
contours.clear();
contours.resize(2);
contours[0] = maxContour;
contours[1].push_back(cv::Point(0, dst.rows - 1));
contours[1].push_back(cv::Point(0, 0));
contours[1].push_back(cv::Point(dst.cols - 1, 0));
contours[1].push_back(cv::Point(dst.cols - 1, dst.rows - 1));
hg::fillPolys(dst, contours, cv::Scalar(255, 255, 255));
}
pDib.release();
if (/*(m_isCrop && side == 0) || (side == 1 && m_fixedSize.width * m_fixedSize.height == 0)*/ m_isCrop)
pDib = dst.clone();
else
{
#if 0
if (m_isCrop && side == 1 && !m_fixedSize.empty())
if (std::abs(m_fixedSize.width - dst.cols) > 50 || std::abs(m_fixedSize.height - dst.rows) > 50)
{
pDib = dst.clone();
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply");
#endif // LOG
FileTools::write_log("D:\\1.txt", "exit CImageApplyAutoCrop apply");
return;
}
#endif
pDib = cv::Mat(m_fixedSize, dst.type(), m_isFillBlank ? cv::Scalar(255, 255, 255) : cv::Scalar(0, 0, 0));
cv::Rect roi;
roi.x = dst.cols > pDib.cols ? (dst.cols - pDib.cols) / 2 : 0;
roi.width = cv::min(pDib.cols, dst.cols);
roi.y = dst.rows > pDib.rows ? (dst.rows - pDib.rows) / 2 : 0;
roi.height = cv::min(pDib.rows, dst.rows);
cv::Rect rect((pDib.cols - roi.width) / 2, (pDib.rows - roi.height) / 2, roi.width, roi.height);
#if 0
std::string outrectinfo ="copy to rect x: "+std::to_string(rect.x) + "y: "+std::to_string(rect.y) + "width: "+std::to_string(rect.width) + "height: "+std::to_string(rect.height);
std::string outroiinfo = "roi x: " + std::to_string(roi.x) + "y: " + std::to_string(roi.y) + "width: " + std::to_string(roi.width) + "height: " + std::to_string(roi.height);
std::string dstsize = "dst size: width:" + std::to_string(dst.cols) + "height: " + std::to_string(dst.rows);
std::string pDibszie= "pDib size: width: " + std::to_string(pDib.cols) + "height: " + std::to_string(pDib.rows);
FileTools::write_log("imgprc.txt", dstsize);
FileTools::write_log("imgprc.txt", pDibszie);
FileTools::write_log("imgprc.txt", outrectinfo);
FileTools::write_log("imgprc.txt", outroiinfo);
#endif // LOG
dst(roi).copyTo(pDib(rect));
}
#ifdef LOG
FileTools::write_log("D:\\1.txt", "exit CImageApplyAutoCrop apply8");
#endif // LOG
}
void CImageApplyAutoCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
{
cv::Size dSize = m_fixedSize;
if (!mats[0].empty())
m_fixedSize = mats[0].size();
apply(mats[1], 1);
if (!mats[0].empty())
m_fixedSize = dSize;
}
}

View File

@ -0,0 +1,66 @@
#ifndef IMAGE_APPLY_AUTO_CROP_H
#define IMAGE_APPLY_AUTO_CROP_H
#include "ImageApply.h"
class CImageApplyAutoCrop : public CImageApply
{
public:
CImageApplyAutoCrop();
CImageApplyAutoCrop(bool isCrop, bool isDesaskew, bool isFillBlank, const cv::Size& fixedSize, bool isConvex = true, double threshold = 40, int noise = 40, int indent = 5);
virtual ~CImageApplyAutoCrop();
virtual void apply(cv::Mat& pDib, int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
bool isAutoCrop() { return m_isCrop; }
bool isFillBlank() { return m_isFillBlank; }
bool isDesaskew() { return m_isDesaskew; }
bool isConvexHull() { return m_isConvexHull; }
double threshold() { return m_threshold; }
int noise() { return m_noise; }
int indent() { return m_indent; }
cv::Size fixedSize() { return m_fixedSize; }
void setAutoCrop(bool enabled) { m_isCrop = enabled; }
void setFillBlank(bool enabled) { m_isFillBlank = enabled; }
void setDesaskew(bool enabled) { m_isDesaskew = enabled; }
void setConvexHull(bool convex) { m_isConvexHull = convex; }
void setThreshold(double value) { m_threshold = value; }
void setNoise(int value) { m_noise = value; }
void setIndent(int value) { m_indent = value; }
void setFixedSize(cv::Size size) { m_fixedSize = size; }
private:
bool m_isCrop;
bool m_isDesaskew;
bool m_isFillBlank;
bool m_isConvexHull;
double m_threshold;
int m_noise;
int m_indent;
cv::Size m_fixedSize;
};
#endif // !IMAGE_APPLY_AUTO_CROP_H

View File

@ -0,0 +1,144 @@
#include "StdAfx.h"
#include "ImageApplyBWBinaray.h"
CImageApplyBWBinaray::CImageApplyBWBinaray(ThresholdType type, int threshold, int blockSize, int constant)
: m_threshold(threshold)
, m_type(type)
, m_blockSize(blockSize)
, m_constant(constant)
, m_table(new uchar[256])
{
memset(m_table, 255, 256);
memset(m_table, 0, static_cast<size_t>(m_threshold));
}
CImageApplyBWBinaray::CImageApplyBWBinaray()
: m_threshold(180)
, m_type(ThresholdType::THRESH_BINARY)
, m_blockSize(25)
, m_constant(5)
, m_table(new uchar[256])
{
memset(m_table, 255, 256);
memset(m_table, 0, static_cast<size_t>(m_threshold));
}
CImageApplyBWBinaray::~CImageApplyBWBinaray(void)
{
delete[] m_table;
}
void CImageApplyBWBinaray::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyBWBinaray apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyBWBinaray apply");
#endif // LOG
return;
}
if (pDib.channels() == 3)
cv::cvtColor(pDib, pDib, cv::COLOR_BGR2GRAY);
switch (m_type)
{
case ThresholdType::THRESH_BINARY:
cv::threshold(pDib, pDib, m_threshold, 255, CV_THRESH_BINARY);
break;
case ThresholdType::THRESH_OTSU:
cv::threshold(pDib, pDib, m_threshold, 255, CV_THRESH_OTSU);
break;
case ThresholdType::ADAPTIVE_GAUSSIAN:
cv::adaptiveThreshold(pDib, pDib, 255, cv::ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, m_blockSize, m_constant);
break;
case ThresholdType::ADAPTIVE_MEAN:
cv::adaptiveThreshold(pDib, pDib, 255, cv::ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, m_blockSize, m_constant);
break;
case ThresholdType::ERROR_DIFFUSION:
errorDiffuse(pDib);
break;
default:
break;
}
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyBWBinaray apply");
#endif // LOG
}
void CImageApplyBWBinaray::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}
void CImageApplyBWBinaray::errorDiffuse(cv::Mat & image)
{
if (image.rows < 3 || image.cols < 3)
{
cv::threshold(image, image, m_threshold, 255, CV_THRESH_BINARY);
return;
}
cv::Mat dst;
image.convertTo(dst, CV_16S);
size_t rows = static_cast<size_t>(image.rows) - 1;
size_t cols = static_cast<size_t>(image.cols) - 1;
short** pixels_dst = new short*[static_cast<size_t>(image.rows)];
for (int i = 0; i < image.rows; i++)
pixels_dst[i] = reinterpret_cast<short*>(dst.data + i * static_cast<int>(dst.step));
short error;
for (size_t y = 0; y < rows; y++)
for (size_t x = 1; x < cols; x++)
{
short dstPix = pixels_dst[y][x];
if (dstPix >= m_threshold)
{
pixels_dst[y][x] = 255;
error = dstPix - 255;
}
else
{
pixels_dst[y][x] = 0;
error = dstPix;
}
pixels_dst[y][x + 1] += error * 7 / 16;
pixels_dst[y + 1][x - 1] += error * 3 / 16;
pixels_dst[y + 1][x] += error * 5 / 16;
pixels_dst[y + 1][x + 1] += error * 1 / 16;
}
image.release();
dst.convertTo(image, CV_8U);
rows++;
uchar* ptr = image.data;
size_t step = image.step;
size_t offset;
for (size_t y = 0; y < rows; y++)
{
offset = y * step;
ptr[offset] = m_table[ptr[offset]];
offset += cols;
ptr[offset] = m_table[ptr[offset]];
}
cols++;
ptr = image.data + step * (rows - 1);
for (size_t x = 0; x < cols; x++)
ptr[x] = m_table[ptr[x]];
delete[] pixels_dst;
}

View File

@ -0,0 +1,64 @@
#ifndef IMAGE_APPLY_BW_BINARAY_H
#define IMAGE_APPLY_BW_BINARAY_H
#include "ImageApply.h"
class CImageApplyBWBinaray:public CImageApply
{
public:
enum ThresholdType
{
THRESH_BINARY = 0,
THRESH_OTSU,
ADAPTIVE_GAUSSIAN,
ADAPTIVE_MEAN,
ERROR_DIFFUSION
};
CImageApplyBWBinaray(ThresholdType type, int threshold = 180, int blockSize = 25, int constant = 5);
CImageApplyBWBinaray();
virtual ~CImageApplyBWBinaray(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
double getThreshold() { return m_threshold; }
ThresholdType getThresholdType() { return m_type; }
int getBlockSize() { return m_blockSize; }
double getConstant() { return m_constant; }
void setThreshold(double value) { m_threshold = value; }
void setThresholdType(ThresholdType type) { m_type = type; }
void setBlockSize(int value) { m_blockSize = value; }
void setConstant(double value) { m_constant = value; }
private:
void errorDiffuse(cv::Mat& image);
private:
double m_threshold;
ThresholdType m_type;
int m_blockSize;
double m_constant;
uchar* m_table;
};
#endif //!IMAGE_APPLY_BW_BINARAY_H

View File

@ -0,0 +1,99 @@
#include "StdAfx.h"
#include "ImageApplyChannel.h"
CImageApplyChannel::CImageApplyChannel()
: m_channel(Invalid)
{
}
CImageApplyChannel::CImageApplyChannel(Channel channel)
: m_channel(channel)
{
}
CImageApplyChannel::~CImageApplyChannel(void)
{
}
void CImageApplyChannel::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyChannel apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyChannel apply");
#endif // LOG
return;
}
cv::Mat dst(pDib.rows, pDib.cols, CV_8UC1);
switch (m_channel)
{
case Red:
cv::extractChannel(pDib, dst, 2);
break;
case Green:
cv::extractChannel(pDib, dst, 1);
break;
case Blue:
cv::extractChannel(pDib, dst, 0);
break;
case Except_Red:
except_channel(pDib, dst, 2);
break;
case Except_Green:
except_channel(pDib, dst, 1);
break;
case Except_Blue:
except_channel(pDib, dst, 0);
break;
default:
break;
}
pDib.release();
pDib = dst;
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyChannel apply");
#endif // LOG
}
void CImageApplyChannel::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}
void CImageApplyChannel::except_channel(const cv::Mat & src, cv::Mat & dst, int channel)
{
int rows = src.total();
cv::Mat src_temp(rows, 3, CV_8UC1, src.data);
cv::Mat dst_temp(rows, 1, CV_8UC1, dst.data);
cv::Mat temp1, temp2;
switch (channel)
{
case 0:
temp1 = src_temp(cv::Rect(1, 0, 1, rows));
temp2 = src_temp(cv::Rect(2, 0, 1, rows));
cv::addWeighted(temp1, 0.84, temp2, 0.16, 0, dst_temp);
break;
case 1:
temp1 = src_temp(cv::Rect(0, 0, 1, rows));
temp2 = src_temp(cv::Rect(2, 0, 1, rows));
cv::addWeighted(temp1, 0.73, temp2, 0.27, 0, dst_temp);
break;
case 2:
temp1 = src_temp(cv::Rect(0, 0, 1, rows));
temp2 = src_temp(cv::Rect(1, 0, 1, rows));
cv::addWeighted(temp1, 0.33, temp2, 0.67, 0, dst_temp);
break;
default:
break;
}
}

View File

@ -0,0 +1,42 @@
#ifndef IMAGE_APPLY_CHANNEL_H
#define IMAGE_APPLY_CHANNEL_H
#include "imageapply.h"
class CImageApplyChannel : public CImageApply
{
public:
typedef enum channel
{
Red,
Green,
Blue,
Invalid,
Except_Red,
Except_Green,
Except_Blue
}Channel;
public:
CImageApplyChannel();
CImageApplyChannel(Channel channel);
virtual ~CImageApplyChannel(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private:
void except_channel(const cv::Mat& src, cv::Mat& dst, int channel);
private:
Channel m_channel;
};
#endif // !IMAGE_APPLY_CHANNEL_H

View File

@ -0,0 +1,48 @@
#include "StdAfx.h"
#include "ImageApplyCrop.h"
CImageApplyCrop::CImageApplyCrop(void)
{
}
CImageApplyCrop::~CImageApplyCrop(void)
{
}
void CImageApplyCrop::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyCrop apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyCrop apply");
#endif // LOG
return;
}
if (m_roi.x < 0 || m_roi.y < 0 || m_roi.br().x >= pDib.cols || m_roi.br().y >= pDib.rows || m_roi.width == 0 || m_roi.height == 0)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyCrop apply");
#endif // LOG
return;
}
pDib = pDib(m_roi).clone();
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyCrop apply");
#endif // LOG
}
void CImageApplyCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,28 @@
#ifndef IMAGE_APPLY_CROP_H
#define IMAGE_APPLY_CROP_H
#include "imageapply.h"
class CImageApplyCrop : public CImageApply
{
public:
CImageApplyCrop(void);
virtual ~CImageApplyCrop(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
cv::Rect getROI() { return m_roi; }
void setROI(const cv::Rect& rect) { m_roi = rect; }
private:
cv::Rect m_roi;
};
#endif // !IMAGE_APPLY_CROP_H

View File

@ -0,0 +1,175 @@
#include "StdAfx.h"
#include "ImageApplyDiscardBlank.h"
#include "ImageProcess_Public.h"
CImageApplyDiscardBlank::CImageApplyDiscardBlank(bool isnormal)
: m_res(false)
, isNormalDiscard(isnormal)
, dSize(200)
, devTh(15, 15, 15, 15)
{
}
CImageApplyDiscardBlank::~CImageApplyDiscardBlank(void)
{
}
int CImageApplyDiscardBlank::processRectR(const cv::Mat& image, cv::RotatedRect& rotatedRect, std::vector<cv::Point>& maxContour,
double scale, double thresh, int blobAreaSize)
{
cv::Mat gray;
int blockCount = 0;
if (image.channels() == 3)
if (scale != 1.0f)
{
cv::Size ResImgSiz = cv::Size(image.cols * scale, image.rows * scale);
resize(image, gray, cv::Size(), scale, scale, 0);
cvtColor(gray, gray, CV_BGR2GRAY);
}
else
cvtColor(image, gray, CV_BGR2GRAY);
else
if (scale != 1.0f)
resize(image, gray, cv::Size(), scale, scale, 0);
else
gray = image;
cv::Mat threshold_img;
threshold(gray, threshold_img, thresh, 255.0, CV_THRESH_BINARY);
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> h1;
hg::findContours(threshold_img, contours, h1, CV_CHAIN_APPROX_SIMPLE);
threshold_img.release();
if (contours.size() == 0)
return blockCount;
std::vector<cv::Point2f> list_com;
for (int i = 0; i < contours.size(); i++)
{
double area = cv::contourArea(contours[i]);
if (area > blobAreaSize)
{
blockCount++;
for (int j = 0; j < contours[i].size(); j++)
list_com.push_back(contours[i][j]);
}
}
if (list_com.size() == 0)
return blockCount;
rotatedRect = cv::minAreaRect(list_com);
rotatedRect.center.x /= (float)scale;
rotatedRect.center.y /= (float)scale;
rotatedRect.size.width /= (float)scale;
rotatedRect.size.height /= (float)scale;
if (rotatedRect.angle < -45.0f)
{
rotatedRect.angle += 90.0f;
float l_temp = rotatedRect.size.width;
rotatedRect.size.width = rotatedRect.size.height;
rotatedRect.size.height = l_temp;
}
std::vector<int> hull(list_com.size());
cv::convexHull(list_com, hull);
for (int i = 0; i < hull.size(); i++)
{
cv::Point temp = list_com[hull[i]];
int x = (int)(temp.x / scale);
int y = (int)(temp.y / scale);
maxContour.push_back(cv::Point(x, y));
}
return blockCount;
}
bool CImageApplyDiscardBlank::scalar_LE(const cv::Scalar& val1, const cv::Scalar& val2)
{
for(int i = 0; i < 3; i++)
if(val1[i] > val2[i])
return false;
return true;
}
void CImageApplyDiscardBlank::setIntensity(int val)
{
val = cv::max(cv::min(20, val), 2);
devTh = cv::Scalar(val, val, val, val);
}
cv::Mat CImageApplyDiscardBlank::getRoiMat(const cv::Mat& image)
{
int gap = 100;
cv::RotatedRect rect;
std::vector<cv::Point> contour;
double scale = 0.25;
double thresh = 50;
int blobSize = 200;
int edgeWidth = 10;
processRectR(image, rect, contour, scale, thresh, blobSize);
cv::Rect rect2 = rect.boundingRect();
cv::Rect inRect = rect2 & cv::Rect(0, 0, image.cols, image.rows);
gap = cv::max(inRect.width - rect.size.width, inRect.height - rect.size.height) + 100;
inRect = cv::Rect(inRect.x + gap, inRect.y + gap, inRect.width - gap * 2, inRect.height - gap * 2);
return image(inRect);
}
void CImageApplyDiscardBlank::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyDiscardBlank apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyDiscardBlank apply");
#endif // LOG
return;
}
setIntensity(isNormalDiscard ? 8 : 20);
setMinArea(isNormalDiscard ? 200 : 300);
cv::Scalar mean;
cv::Scalar dev;
cv::Mat image = getRoiMat(pDib);
cv::Rect rect;
cv::Rect imRect(0, 0, image.cols, image.rows);
for(int i = 0; i < image.cols; i+= dSize)
for(int j = 0; j < image.rows; j+= dSize)
{
rect = cv::Rect(i, j,dSize, dSize) & imRect;
if(rect != cv::Rect())
{
cv::meanStdDev (image(rect) , mean, dev);
if(!scalar_LE(dev, devTh))
{
m_res = false;
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyDiscardBlank apply");
#endif // LOG
return;
}
}
}
m_res = true;
if (m_res)
pDib.release();
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyDiscardBlank apply");
#endif // LOG
}
void CImageApplyDiscardBlank::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,35 @@
#ifndef IMAGE_APPLY_DISCARD_BLANK_H
#define IMAGE_APPLY_DISCARD_BLANK_H
#include "ImageApply.h"
class CImageApplyDiscardBlank : public CImageApply
{
public:
CImageApplyDiscardBlank(bool isnormal = true);
virtual ~CImageApplyDiscardBlank(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private:
void setIntensity(int val);
void setMinArea(int val) { dSize = val; }
int processRectR(const cv::Mat& image, cv::RotatedRect& rotatedRect, std::vector<cv::Point>& maxContour,
double scale, double thresh, int blobAreaSize);
bool scalar_LE(const cv::Scalar& val1, const cv::Scalar& val2);
cv::Mat getRoiMat(const cv::Mat& pDib);
private:
bool m_res;
bool isNormalDiscard;
int dSize;
cv::Scalar devTh;
};
#endif // !IMAGE_APPLY_DISCARD_BLANK_H

View File

@ -0,0 +1,15 @@
#ifndef IMAGE_APPLY_HEADER_H
#define IMAGE_APPLY_HEADER_H
#include "ImageApply.h"
#include "ImageApplyAdjustColors.h"
#include "ImageApplyAutoCrop.h"
#include "ImageApplyBWBinaray.h"
#include "ImageApplyChannel.h"
#include "ImageApplyCrop.h"
#include "ImageApplyDiscardBlank.h"
#include "ImageApplyResize.h"
#include "ImageApplyRotation.h"
#include "ImageApplySharpen.h"
#endif

View File

@ -0,0 +1,55 @@
#include "StdAfx.h"
#include "ImageApplyResize.h"
CImageApplyResize::CImageApplyResize()
: m_fx(1.0)
, m_fy(1.0)
, m_type(ResizeType::RATIO)
{
}
CImageApplyResize::CImageApplyResize(ResizeType type, const cv::Size& size, double fx, double fy)
: m_type(type)
, m_dSize(size)
, m_fx(fx)
, m_fy(fy)
{
}
CImageApplyResize::~CImageApplyResize(void)
{
}
void CImageApplyResize::apply(cv::Mat& pDib,int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyResize apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyResize apply");
#endif // LOG
return;
}
if (m_type == ResizeType::RATIO)
cv::resize(pDib, pDib, cv::Size(0, 0), m_fx, m_fy);
else
cv::resize(pDib, pDib, m_dSize);
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyResize apply");
#endif // LOG
}
void CImageApplyResize::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,51 @@
#ifndef IMAGE_APPLY_RESIZE_H
#define IMAGE_APPLY_RESIZE_H
#include "imageapply.h"
class CImageApplyResize : public CImageApply
{
public:
enum ResizeType
{
RATIO,
DSIZE
};
public:
CImageApplyResize();
CImageApplyResize(ResizeType type, const cv::Size& size, double fx, double fy);
virtual ~CImageApplyResize(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
double getFX() { return m_fx; }
double getFY() { return m_fy; }
cv::Size getDSize() { return m_dSize; }
ResizeType getType() { return m_type; }
void setFX(double value) { m_fx = value; }
void setFY(double value) { m_fy = value; }
void setDSize(const cv::Size& size) { m_dSize = size; }
void setType(ResizeType type) { m_type = type; }
private:
double m_fx;
double m_fy;
cv::Size m_dSize;
ResizeType m_type;
};
#endif // !IMAGE_APPLY_RESIZE_H

View File

@ -0,0 +1,128 @@
#include "StdAfx.h"
#include "ImageApplyRotation.h"
#ifdef USE_TESSERCAT
#define HG_OCR4_BUILD
#include "hg_ocr4.h"
#endif
CImageApplyRotation::CImageApplyRotation(RotationType rotation, bool isBackTransposed, int dpi, const char* tessdataPath)
: m_rotation(rotation)
, m_backTranspose(isBackTransposed)
, m_dpi(dpi)
, osd(nullptr)
{
if (rotation == RotationType::AutoTextOrientation)
{
#ifdef USE_TESSERCAT
osd = new HG_OCR4();
reinterpret_cast<HG_OCR4*>(osd)->init(tessdataPath, HG_OCR4::Orientation);
#endif
}
}
CImageApplyRotation::~CImageApplyRotation()
{
#ifdef USE_TESSERCAT
if (osd) delete reinterpret_cast<HG_OCR4*>(osd);
#endif
}
void CImageApplyRotation::apply(cv::Mat & pDib, int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyRotation apply");
#endif // LOG
if (pDib.empty())
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyRotation apply");
#endif // LOG
return;
}
if (m_rotation == RotationType::AutoTextOrientation) //<2F>Զ<EFBFBD><D4B6>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>
{
#ifdef USE_TESSERCAT
if (osd)
{
cv::Mat temp;
if (m_dpi != 200)
{
double scale = 200 / static_cast<double>(m_dpi);
cv::resize(pDib, temp, cv::Size(), scale, scale);
}
else
temp = pDib.clone();
if (temp.channels() == 3)
cv::cvtColor(temp, temp, cv::COLOR_BGR2GRAY);
cv::threshold(temp, temp, 180, 255, cv::THRESH_OTSU);
HG_OCR4* ptr_osd = reinterpret_cast<HG_OCR4*>(osd);
int orientation = ptr_osd->getOrientation(temp.data, temp.cols, temp.rows, temp.channels(), temp.step);
switch (orientation)
{
case 1:
transpose(pDib, pDib);
flip(pDib, pDib, 0);
break;
case 2:
flip(pDib, pDib, 0);
flip(pDib, pDib, 1);
break;
case 3:
transpose(pDib, pDib);
flip(pDib, pDib, 1);
break;
default:
break;
}
}
#endif
}
else if (m_backTranspose && side == 1) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת180
{
if (m_rotation != RotationType::Rotate_180) //<2F><>ת180<38><30>
{
if (m_rotation == RotationType::Rotate_90_clockwise || m_rotation == RotationType::Rotate_90_anti_clockwise) //90<39><30> -90<39><30>
{
transpose(pDib, pDib);
flip(pDib, pDib, m_rotation == RotationType::Rotate_90_clockwise ? 0 : 1);
}
else
{
flip(pDib, pDib, 0);
flip(pDib, pDib, 1);
}
}
}
else //zh
{
if (m_rotation == RotationType::Rotate_90_clockwise || m_rotation == RotationType::Rotate_90_anti_clockwise) //90<39><30> -90<39><30>
{
transpose(pDib, pDib);
flip(pDib, pDib, m_rotation == RotationType::Rotate_90_clockwise ? 1 : 0);
}
else if (m_rotation == RotationType::Rotate_180)
{
flip(pDib, pDib, 0);
flip(pDib, pDib, 1);
}
}
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyRotation apply");
#endif // LOG
}
void CImageApplyRotation::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,49 @@
#ifndef IMAGE_APPLY_ROTATION_H
#define IMAGE_APPLY_ROTATION_H
#include "ImageApply.h"
class CImageApplyRotation : public CImageApply
{
public:
enum RotationType
{
Invalid,
Rotate_90_clockwise,
Rotate_180,
Rotate_90_anti_clockwise,
AutoTextOrientation
};
public:
CImageApplyRotation(RotationType rotation, bool isBackTransposed = false, int dpi = 200, const char* tessdataPath = nullptr);
virtual ~CImageApplyRotation();
virtual void apply(cv::Mat & pDib, int side) override;
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
bool isBackTransposed() { return m_backTranspose; }
int getDPI() { return m_dpi; }
RotationType getRotationType() { return m_rotation; }
void setBackTransposed(bool enabled) { m_backTranspose = enabled; }
void setDPI(int dpi) { m_dpi = dpi; }
void setRotationType(RotationType type) { m_rotation = type; }
private:
RotationType m_rotation;
bool m_backTranspose;
int m_dpi;
void* osd;
};
#endif // !IMAGE_APPLY_ROTATION_H

View File

@ -0,0 +1,37 @@
#include "StdAfx.h"
#include "ImageApplySharpen.h"
CImageApplySharpen::CImageApplySharpen()
: kernel(5, 5, CV_32FC1)
{
float kernel_data[] = { -0.1f, 0, 0, 0, -0.1f, 0, 0, 0, 0, 0, 0, 0, 1.5f, 0, 0, 0, 0, 0, 0, 0, -0.1f, 0, 0, 0, -0.1f };
memcpy(kernel.data, kernel_data, sizeof(float) * 25);
}
CImageApplySharpen::~CImageApplySharpen()
{
}
void CImageApplySharpen::apply(cv::Mat & pDib, int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplySharpen apply");
#endif // LOG
if (pDib.empty()) return;
cv::filter2D(pDib, pDib, pDib.depth(), kernel);
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplySharpen apply");
#endif // LOG
}
void CImageApplySharpen::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,20 @@
#ifndef IMAGE_APPLY_SHARPEN_H
#define IMAGE_APPLY_SHARPEN_H
#include "ImageApply.h"
class CImageApplySharpen : public CImageApply
{
public:
CImageApplySharpen();
virtual ~CImageApplySharpen();
virtual void apply(cv::Mat& pDib, int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
private:
cv::Mat kernel;
};
#endif // !IMAGE_APPLY_SHARPEN_H

View File

@ -0,0 +1,165 @@
#include "StdAfx.h"
#include "ImageApplyTextureRemoval.h"
//交换对角线
void zero_to_center(cv::Mat& image, int colToCut, int rowToCut)
{
cv::Mat q1(image, cv::Rect(0, 0, colToCut, rowToCut));
cv::Mat q2(image, cv::Rect(colToCut, 0, colToCut, rowToCut));
cv::Mat q3(image, cv::Rect(0, rowToCut, colToCut, rowToCut));
cv::Mat q4(image, cv::Rect(colToCut, rowToCut, colToCut, rowToCut));
//第二象限和第四象限进行交换
cv::Mat tmpImg;
q1.copyTo(tmpImg);
q4.copyTo(q1);
tmpImg.copyTo(q4);
//第一象限和第三象限进行交换
q2.copyTo(tmpImg);
q3.copyTo(q2);
tmpImg.copyTo(q3);
}
//创建光谱
cv::Mat create_spectrum(cv::Mat* matArray)
{
cv::Mat dst;
cv::magnitude(matArray[0], matArray[1], dst);
#if 1
cv::divide(dst, dst.cols * dst.rows, dst);
#else
dst += Scalar::all(1);
log(dst, dst);
normalize(dst, dst, 1, 0, CV_MINMAX);
#endif
#if 0
imshow("频谱", dst);
#endif
return dst;
}
//反傅里叶变换
void inverseFourierTransform(const cv::Mat& src, cv::Mat& dst)
{
cv::Mat complexIDFT;
cv::Mat matArray[2];
cv::idft(src, complexIDFT);
cv::split(complexIDFT, matArray);
cv::magnitude(matArray[0], matArray[1], dst);
cv::normalize(dst, dst, 0, 1, CV_MINMAX);
}
//制作陷波滤波器
cv::Mat createFilter(const cv::Mat& spectrum, int dilateSize, int erodeSize)
{
cv::Mat temp;
spectrum.convertTo(temp, CV_8UC1, 255);
cv::threshold(temp, temp, 0, 255, CV_THRESH_OTSU);
//imshow("二值化", temp);
cv::Mat element1 = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(dilateSize, dilateSize));
cv::Mat element2 = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(erodeSize, erodeSize));
cv::dilate(temp, temp, element1);
cv::erode(temp, temp, element2);
cv::floodFill(temp, cv::Point(temp.cols / 2, temp.rows / 2), cv::Scalar(0)); //漫水填充中心区域
//cv::imshow("二值化", temp);
cv::medianBlur(~temp, temp, 5); //中值滤波
//陷波滤波器复制
cv::Mat filter;
temp.convertTo(filter, CV_32FC1);
cv::normalize(filter, filter, 1, 0, CV_MINMAX);
std::vector<cv::Mat> mv;
mv.push_back(filter);
mv.push_back(filter);
cv::merge(mv, filter);
return filter;
}
void CImageApplyTextureRemoval::textureRemovalGray(cv::Mat& img)
{
//得到DFT的最佳尺寸2的指数以加速计算
cv::Mat paddedImg;
int m = cv::getOptimalDFTSize(img.rows);
int n = cv::getOptimalDFTSize(img.cols);
//填充图像的下端和右端
cv::copyMakeBorder(img, paddedImg, 0, m - img.rows, 0, n - img.cols,
cv::BORDER_CONSTANT, cv::Scalar::all(0));
//将填充的图像组成一个复数的二维数组两个通道的Mat用于DFT
cv::Mat matArray[] = { cv::Mat_<float>(paddedImg), cv::Mat::zeros(paddedImg.size(), CV_32F) };
cv::Mat complexInput, complexOutput;
cv::merge(matArray, 2, complexInput);
cv::dft(complexInput, complexOutput);
cv::split(complexOutput, matArray); //计算幅度谱(傅里叶谱)
//滤波
//将实部和虚部按照频谱图的方式换位
//低频在图像中心,用于滤波
zero_to_center(matArray[0], complexOutput.cols / 2, complexOutput.rows / 2);
zero_to_center(matArray[1], complexOutput.cols / 2, complexOutput.rows / 2);
cv::Mat spectrum = create_spectrum(matArray);
//创建滤波器
cv::Mat filter = createFilter(spectrum, m_dilateSize, m_erodeSize);
cv::merge(matArray, 2, complexOutput);
cv::multiply(complexOutput, filter, filter);
//IDFT得到滤波结果
cv::Size imgSize = img.size();
inverseFourierTransform(filter, img);
img = img(cv::Rect(cv::Point(0, 0), imgSize));
img *= 255;
img.convertTo(img, CV_8UC1);
}
CImageApplyTextureRemoval::CImageApplyTextureRemoval()
: CImageApply()
, m_dilateSize(11)
, m_erodeSize(7)
{
}
CImageApplyTextureRemoval::CImageApplyTextureRemoval(int dilateSize, int erodeSize)
: CImageApply()
, m_dilateSize(dilateSize)
, m_erodeSize(erodeSize)
{
}
CImageApplyTextureRemoval::~CImageApplyTextureRemoval()
{
}
void CImageApplyTextureRemoval::apply(cv::Mat &pDib, int side)
{
(void)side;
if (pDib.channels() == 1)
textureRemovalGray(pDib);
else
{
std::vector<cv::Mat> rgb(3);
cv::split(pDib, rgb);
for (int i = 0;i < rgb.size();i++)
//for (cv::Mat& var : rgb)
textureRemovalGray(rgb[i]);
cv::merge(rgb, pDib);
}
}
void CImageApplyTextureRemoval::apply(std::vector<cv::Mat> &mats, bool isTwoSide)
{
(void)isTwoSide;
//for (cv::Mat& var : mats)
for (int i = 0;i < mats.size();i++)
apply(mats[i], 0);
}

View File

@ -0,0 +1,34 @@
#ifndef IMAGE_APPLY_TEXTURE_REMOVAL_H
#define IMAGE_APPLY_TEXTURE_REMOVAL_H
#include "ImageApply.h"
class CImageApplyTextureRemoval : public CImageApply
{
public:
CImageApplyTextureRemoval(void);
CImageApplyTextureRemoval(int dilateSize, int erodeSize);
virtual ~CImageApplyTextureRemoval(void);
virtual void apply(cv::Mat& pDib,int side);
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
int getDilateSize() {return m_dilateSize;}
int getErodeSize() {return m_erodeSize;}
void setDilateSize(int size) {m_dilateSize = size;}
void setErodeSize(int size) {m_erodeSize = size;}
private:
void textureRemovalGray(cv::Mat& img);
private:
int m_dilateSize;
int m_erodeSize;
};
#endif

View File

@ -0,0 +1,35 @@
#include "StdAfx.h"
#include "ImageApplyThreshold.h"
CImageApplyThreshold::CImageApplyThreshold(float thre) :m_thresh(thre)
{
}
CImageApplyThreshold::~CImageApplyThreshold()
{
}
void CImageApplyThreshold::apply(cv::Mat& pDib, int side)
{
#ifdef LOG
FileTools::write_log("imgprc.txt", "enter CImageApplyThreshold apply");
#endif // LOG
if (pDib.channels() >= 3)
return;
if (m_thresh == 0.0f)
m_thresh = 140.0;
cv::threshold(pDib, pDib, m_thresh, 255.0,cv::THRESH_OTSU);
#ifdef LOG
FileTools::write_log("imgprc.txt", "exit CImageApplyThreshold apply");
#endif // LOG
}
void CImageApplyThreshold::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
{
if (mats.empty()) return;
apply(mats[0], 0);
if (isTwoSide && mats.size() > 1)
apply(mats[1], 1);
}

View File

@ -0,0 +1,14 @@
#ifndef IMAGE_APPLY_THRESHOLD_H
#define IMAGE_APPLY_THRESHOLD_H
#include "ImageApply.h"
class CImageApplyThreshold :public CImageApply {
public:
CImageApplyThreshold(float thre=128.0);
virtual ~CImageApplyThreshold();
virtual void apply(std::vector<cv::Mat>& mats, bool isTwoSide);
virtual void apply(cv::Mat& pDib, int side);
private:
float m_thresh;
};
#endif // !IMAGE_APPLY_THRESHOLD_H

View File

@ -0,0 +1,263 @@
#include "StdAfx.h"
#include "ImageMatQueue.h"
#include "PublicFunc.h"
#include "filetools.h"
#include "imageprocess.h"
#include <atlconv.h>
#include <queue>
//using namespace std::this_thread;
using namespace std;
ImageMatQueue::ImageMatQueue(void) :b_save_origin(false),
b_save_fixed_origin(false)
{
pixType=-1;
DevModel=-1;
if(!bRun)
{
m_threadProc = std::thread(&ImageMatQueue::proc, this);
bRun = true;
}
}
void ImageMatQueue::run()
{
if(m_threadProc.joinable())
{
bRun = false;
m_threadProc.join();
}
bRun = true;
m_threadProc = std::thread(&ImageMatQueue::proc, this);
}
void ImageMatQueue::setmultioutputR(bool canoutput/*=false*/)
{
can_multi_outputR=canoutput;
}
void ImageMatQueue::SetDevModel(int dev/*=-1*/)
{
DevModel=dev;
}
ImageMatQueue::~ImageMatQueue(void)
{
if (m_threadProc.joinable())
{
bRun = false;
m_threadProc.join();
XdPrint("m_threadProc Released True 111111111111111111111111111\n");
}
if (m_images.Size() > 0)
{
m_images.Clear();
m_images.ShutDown();
}
if (m_pImages.Size() > 0)
{
m_pImages.Clear();
m_pImages.ShutDown();
}
}
void ImageMatQueue::pushMat(JpegBuffer& data)
{
m_pImages.Put(data);
int k = 0;
}
void ImageMatQueue::UpdateSaveConfig(bool saveOrigin, bool saveFixedOrigin)
{
b_save_origin= saveOrigin;
b_save_fixed_origin=saveFixedOrigin ;
}
cv::Mat ImageMatQueue::popMat(int num)
{
return _popMat(num);
}
cv::Mat ImageMatQueue::popMat()
{
return m_images.Take();
}
bool ImageMatQueue::valid()
{
bool bIsEmpty = m_images.Size()==0;
return !bIsEmpty;
}
void ImageMatQueue::clear()
{
m_images.Clear();
m_pImages.Clear();
}
cv::Mat ImageMatQueue::_popMat(int num)
{
std::queue<cv::Mat> m_Tempimages; // 临时队列
cv::Mat Tempimage;
cv::Mat image;
int i = 0;
int iSize = m_images.Size();
for(i = 0;i < iSize;i++)
{
image = m_images.Front();
m_Tempimages.push(image);
image.release();
}
for(i = 0;i < iSize;i++)
{
Tempimage = m_Tempimages.front();
if(i == num)
{
return Tempimage;
}
m_Tempimages.pop();
}
return Tempimage;
}
void ImageMatQueue::saveimg(std::string csImage,cv::Mat& mat)
{
imwrite(csImage, mat);
}
int ImageMatQueue::getMatSum()
{
int iSum = 0;
iSum = m_images.Size();
return iSum;
}
bool ImageMatQueue::empty()
{
return m_images.Size()==0 && m_pImages.Size()==0;
}
void ImageMatQueue::proc()
{
while(bRun)
{
this_thread::sleep_for(std::chrono::milliseconds(5));
{
if(m_pImages.Size()>0)//m_images.empty() &&
{
if (pixType!=-1)
{
cv::Mat matPicImage;
cv::Mat matFront,matBack;
vector<cv::Mat> mats;
switch(DevModel)
{
case 0://G100
case 1://G200//正反面图像分开的
{
if (m_pImages.Size()>=2)
{
matFront=m_pImages.Take().getMat(pixType);
matBack=m_pImages.Take().getMat(pixType);
mats.push_back(matFront);
if (duplexFlag)
{
mats.push_back(matBack);
}
if (b_save_origin)
{
CString csName;
SYSTEMTIME st = { 0 };
GetLocalTime(&st); //获取当前时间 可精确到ms
csName.Format("%02d%02d%02d.jpg", st.wHour, st.wMinute, st.wSecond);
CString csImage;
csImage = csPath + "\\G200-Origin" + csName;
saveimg(std::string(csImage.GetBuffer()), matBack);
}
for (int j = 0; j < m_iaList.size(); j++)
{
m_iaList[j]->apply(mats, duplexFlag);//需要在每个图像处理apply的部分 增加判断里边的mat是否为空 目前还没加
}
}
}
break;
case 2://G300
case 3://G400
case 4://G500 正反面图像在一副图上,需要均分图像
{
cv::Mat mat=m_pImages.Take().getMat(pixType);
matFront=mat(cv::Rect(0,0,mat.cols/2,mat.rows));
matBack=mat(cv::Rect(mat.cols/2,0,mat.cols/2,mat.rows));
if (duplexFlag)
{
mats.push_back(matBack);
}
if (b_save_origin)
{
CString csName;
SYSTEMTIME st = { 0 };
GetLocalTime(&st); //获取当前时间 可精确到ms
csName.Format("%02d%02d%02d.jpg", st.wHour, st.wMinute, st.wSecond);
CString csImage;
csImage = csPath + "\\G500-Origin" + csName;
saveimg(std::string(csImage.GetBuffer()), matBack);
}
for (int j = 0; j < m_iaList.size(); j++)
{
m_iaList[j]->apply(mats, duplexFlag);//需要在每个图像处理apply的部分 增加判断里边的mat是否为空 目前还没加
}
mats.push_back(matFront);
XdPrint("m_pImages取完当前正反面==========================\n");
}
break;
default:
break;
}
static int index = 0;
if (b_save_fixed_origin)
{
for (int i = 0; i < mats.size(); i++)
{
//CString outinfo;
//outinfo.Format("Tring to save image index of %d \n", ++index);
//XdPrint(outinfo.GetBuffer());
if (!mats[i].empty())
{
CString csName;
SYSTEMTIME st = { 0 };
GetLocalTime(&st); //获取当前时间 可精确到ms
csName.Format("%02d%02d%02d.jpg", st.wHour, st.wMinute, st.wSecond);
CString csImage;
csImage = csPath + "\\G300-" + csName;
saveimg(std::string(csImage.GetBuffer()), mats[i]);
//outinfo.Format("Saved image index of %d \n", index);
//XdPrint(outinfo.GetBuffer());
}
}
}
//if (!mats[0].empty()&&!mats[1].empty())
if (!mats[0].empty())
{
for (int i=0,length=mats.size();i<length;i++)
{
if (!mats[i].empty())
{
m_images.Put(mats[i]);
}
}
}//end if !mats[0].empty()&&!mats[1].empty()
}
}
}
}
}

View File

@ -0,0 +1,62 @@
#pragma once
#include <thread>
#include <mutex>
#include <opencv2\opencv.hpp>
#include "JpegBuffer.h"
#include "BlockingQueue.h"
#include "PublicFunc.h"
#include "ImageApplyHeaders.h"
class ImageMatQueue
{
public:
ImageMatQueue(void);
virtual ~ImageMatQueue(void);
void pushMat(JpegBuffer& data);
void UpdateSaveConfig(bool saveOrigin, bool saveFixedOrigin);
cv::Mat popMat(int num);
cv::Mat popMat();
bool empty();
bool valid();
void clear();
void run();
int getMatSum();
bool b_save_origin;
bool b_save_fixed_origin;
volatile BOOL duplexFlag;
void SetFilePath(CString csFilePath)
{
csPath = csFilePath;
}
void ImageMatQueue::setduplexflag(BOOL value)
{
duplexFlag = value;
}
CString GetFilePath()
{
return csPath;
}
void ImageMatQueue::setlist(std::vector<std::shared_ptr<CImageApply>> list)
{
m_iaList = list;
}
public:
int pixType;
void setmultioutputR(bool canoutput=false);
void SetDevModel(int dev=-1);
std::vector<std::shared_ptr<CImageApply>> m_iaList;
CString csPath;
private:
void proc();
cv::Mat _popMat(int num);
void saveimg(std::string csImage,cv::Mat &mat);
BlockingQueue<cv::Mat> m_images; //!< ÒÑ´¦ÀíͼÏñ¶ÓÁÐ
BlockingQueue<JpegBuffer> m_pImages;
std::thread m_threadProc;
volatile bool bRun;
bool can_multi_outputR;
int DevModel;
};

View File

@ -0,0 +1,319 @@
#include "StdAfx.h"
#include "ImageProcess_Public.h"
namespace hg
{
typedef unsigned int uint;
void convexHull(const std::vector<cv::Point>& src, std::vector<cv::Point>& dst, bool clockwise)
{
CvMemStorage* storage = cvCreateMemStorage(); //
CvSeq* ptseq = cvCreateSeq(CV_SEQ_KIND_GENERIC | CV_32SC2, sizeof(CvContour), sizeof(CvPoint), storage); //ptseqstorage
//
//for (const cv::Point& item : src)
for (int i = 0;i < src.size();i++)
{
CvPoint p;
p.x = src[i].x;
p.y = src[i].y;
cvSeqPush(ptseq, &p);
}
//¦Ìhullstorage
CvSeq* hull = cvConvexHull2(ptseq, nullptr, clockwise ? CV_CLOCKWISE : CV_COUNTER_CLOCKWISE, 0);
//dst
dst.clear();
int hullCount = hull->total;
for (int i = 0; i < hullCount; i++)
dst.push_back(**CV_GET_SEQ_ELEM(CvPoint*, hull, i));
//storage
cvReleaseMemStorage(&storage);
}
#define R_COLOR 255
void fillConvexHull(cv::Mat& image, const std::vector<cv::Point>& points)
{
uint index_top = 0;
uint index_bottom = 0;
for (size_t i = 0, length = points.size(); i < length; i++)
{
if (points[i].y < points[index_top].y)
index_top = i;
if (points[i].y > points[index_bottom].y)
index_bottom = i;
}
std::vector<cv::Point> edge_left;
uint temp = index_top;
while (temp != index_bottom)
{
edge_left.push_back(points[temp]);
temp = (temp + points.size() - 1) % points.size();
}
edge_left.push_back(points[index_bottom]);
std::vector<cv::Point> edge_right;
temp = index_top;
while (temp != index_bottom)
{
edge_right.push_back(points[temp]);
temp = (temp + points.size() + 1) % points.size();
}
edge_right.push_back(points[index_bottom]);
std::vector<int> left_edge_x;
std::vector<int> left_edge_y;
for (size_t i = 0, length = edge_left.size() - 1; i < length; i++)
{
int y_top = edge_left[i].y;
int x_top = edge_left[i].x;
int y_bottom = edge_left[i + 1].y;
int x_bottom = edge_left[i + 1].x;
for (int y = y_top; y < y_bottom; y++)
if (y >= 0 && y_top != y_bottom && y < image.rows)
{
left_edge_x.push_back(((x_bottom - x_top) * y + x_top * y_bottom - x_bottom * y_top) / (y_bottom - y_top));
left_edge_y.push_back(y);
}
}
size_t step = image.step;
unsigned char* ptr;
ptr = image.data + static_cast<uint>(left_edge_y[0]) * step;
for (size_t i = 0, length = left_edge_x.size(); i < length; i++)
{
int pix = left_edge_x[i];
if (pix < image.cols - 1 && pix > 0)
memset(ptr + i * step, R_COLOR, static_cast<size_t>((pix + 1) * image.channels()));
}
std::vector<int> right_edge_x;
std::vector<int> right_edge_y;
for (size_t i = 0, length = edge_right.size() - 1; i < length; i++)
{
int y_top = edge_right[i].y;
int x_top = edge_right[i].x;
int y_bottom = edge_right[i + 1].y;
int x_bottom = edge_right[i + 1].x;
for (int y = y_top; y < y_bottom; y++)
if (y_top != y_bottom && y < image.rows && y >= 0)
{
right_edge_x.push_back(((x_bottom - x_top) * y + x_top * y_bottom - x_bottom * y_top) / (y_bottom - y_top));
right_edge_y.push_back(y);
}
}
ptr = image.data + static_cast<uint>(right_edge_y[0]) * step;
for (size_t i = 0, length = right_edge_x.size(); i < length; i++)
{
int pix = right_edge_x[i];
if (pix < image.cols - 1 && pix > 0)
memset(ptr + i * step + pix * image.channels(), R_COLOR, step - static_cast<size_t>(pix * image.channels()));
}
if (edge_left[0].y > 0)
memset(image.data, R_COLOR, static_cast<size_t>(edge_left[0].y) * step);
if (edge_left.back().y < image.rows - 1)
memset(image.data + static_cast<size_t>(edge_left.back().y) * step, R_COLOR,
static_cast<size_t>(image.rows - edge_left.back().y) * step);
}
void fillPolys(cv::Mat& image, const std::vector<std::vector<cv::Point>>& contours, const cv::Scalar& color)
{
if (contours.empty()) return;
size_t count = contours.size();
cv::Point** pointss = new cv::Point*[count];
int* npts = new int[count];
for (size_t i = 0; i < count; i++)
{
size_t length = contours[i].size();
npts[i] = length;
pointss[i] = new cv::Point[length];
for (size_t j = 0; j < length; j++)
pointss[i][j] = contours[i][j];
}
cv::fillPoly(image, const_cast<const cv::Point**>(pointss), npts, count, color);
for (size_t i = 0; i < count; i++)
delete[] pointss[i];
delete[] pointss;
delete[] npts;
}
void findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy, int retr, int method, cv::Point offset)
{
CvMat c_image = src;
cv::MemStorage storage(cvCreateMemStorage());
CvSeq* _ccontours = nullptr;
cvFindContours(&c_image, storage, &_ccontours, sizeof(CvContour), retr, method, CvPoint(offset));
if (!_ccontours)
{
contours.clear();
return;
}
cv::Seq<CvSeq*> all_contours(cvTreeToNodeSeq(_ccontours, sizeof(CvSeq), storage));
size_t total = all_contours.size();
contours.resize(total);
cv::SeqIterator<CvSeq*> it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
reinterpret_cast<CvContour*>(c)->color = static_cast<int>(i);
int count = c->total;
int* data = new int[static_cast<size_t>(count * 2)];
cvCvtSeqToArray(c, data);
for (int j = 0; j < count; j++)
{
contours[i].push_back(cv::Point(data[j * 2], data[j * 2 + 1]));
}
delete[] data;
}
hierarchy.resize(total);
it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
int h_next = c->h_next ? reinterpret_cast<CvContour*>(c->h_next)->color : -1;
int h_prev = c->h_prev ? reinterpret_cast<CvContour*>(c->h_prev)->color : -1;
int v_next = c->v_next ? reinterpret_cast<CvContour*>(c->v_next)->color : -1;
int v_prev = c->v_prev ? reinterpret_cast<CvContour*>(c->v_prev)->color : -1;
hierarchy[i] = cv::Vec4i(h_next, h_prev, v_next, v_prev);
}
storage.release();
}
cv::RotatedRect getBoundingRect(const std::vector<cv::Point>& contour)
{
cv::RotatedRect rect1;
if (contour.empty()) return rect1;
cv::RotatedRect rect = minAreaRect(contour);
if (rect.angle < -45)
{
rect.angle += 90;
float temp = rect.size.width;
rect.size.width = rect.size.height;
rect.size.height = temp;
}
return rect;
}
std::vector<cv::Point> getMaxContour(const std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& hierarchy)
{
std::vector<cv::Point> maxContour;
if (contours.size() < 1) return maxContour;
for (size_t i = 0, length = hierarchy.size(); i < length; i++)
if (hierarchy[i][3] == -1)
//for (const auto &item : contours[i])
for (int j = 0;j < contours[i].size();j++)
maxContour.push_back(contours[i][j]);
return maxContour;
}
std::vector<cv::Point> getVertices(const cv::RotatedRect& rect)
{
cv::Point2f box[4];
rect.points(box);
std::vector<cv::Point> points;
for (int i = 0; i < 4; i++)
points.push_back(cv::Point(box[i].x, box[i].y));
return points;
}
void polyIndent(std::vector<cv::Point>& points, const cv::Point& center, int indent)
{
static cv::Point zero(0, 0);
//for (cv::Point& item : points)
for (int i = 0;i < points.size();i++)
{
#if 0
cv::Point vec = item - center;
if (vec != zero)
{
int length = vec.x * vec.x + vec.y * vec.y;
float x = cv::sqrt(static_cast<float>(vec.x * vec.x / length)) * indent;
float y = cv::sqrt(static_cast<float>(vec.y * vec.y / length)) * indent;
if (vec.x < 0) x *= -1.0f;
if (vec.y < 0) y *= -1.0f;
item.x -= static_cast<int>(x);
item.y -= static_cast<int>(y);
}
#else
if (points[i].x > center.x)
points[i].x -= indent;
else
points[i].x += indent;
if (points[i].y > center.y)
points[i].y -= indent;
else
points[i].y += indent;
#endif
}
}
cv::Mat transforColor(const cv::Mat& src)
{
if (src.channels() == 1) return src.clone();
// std::vector<cv::Mat> channels(3);
// cv::split(src, channels);
cv::Mat channels[3];
cv::split(src, channels);
cv::Mat temp, dst;
bitwise_or(channels[0], channels[1], temp);
bitwise_or(channels[2], temp, dst);
temp.release();
//for (cv::Mat& index : channels)
for (int i = 0;i < 3;i++)
channels[i].release();
return dst;
}
void threshold_Mat(const cv::Mat& src, cv::Mat& dst, double thre)
{
if (src.channels() == 3)
{
#ifdef USE_ONENCL
if (cl_res.context)
transforColor_threshold_opencl(src, dst, static_cast<uchar>(thre));
else
#endif
{
cv::Mat gray = transforColor(src);
cv::threshold(gray, dst, thre, 255, cv::THRESH_BINARY);
gray.release();
}
}
else
cv::threshold(src, dst, thre, 255, cv::THRESH_BINARY);
}
cv::Point warpPoint(cv::Point p, const cv::Mat& warp_mat)
{
double src_data[3] = { static_cast<double>(p.x), static_cast<double>(p.y), 1 };
cv::Mat src(3, 1, warp_mat.type(), src_data); //warp_mat.type() == CV_64FC1
cv::Mat dst = warp_mat * src;
double* ptr = reinterpret_cast<double*>(dst.data);
return cv::Point(static_cast<int>(ptr[0]), static_cast<int>(ptr[1]));
}
}

View File

@ -0,0 +1,33 @@
#ifndef IMAGE_PROCESS_PUBLIC_H
#define IMAGE_PROCESS_PUBLIC_H
#include "opencv2/opencv.hpp"
#include <vector>
namespace hg
{
void convexHull(const std::vector<cv::Point>& src, std::vector<cv::Point>& dst, bool clockwise = false);
void fillConvexHull(cv::Mat& image, const std::vector<cv::Point>& points);
void fillPolys(cv::Mat& image, const std::vector<std::vector<cv::Point>>& contours, const cv::Scalar& color);
void findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy,
int retr = cv::RETR_LIST, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0));
cv::RotatedRect getBoundingRect(const std::vector<cv::Point>& contour);
std::vector<cv::Point> getMaxContour(const std::vector<std::vector<cv::Point>>& contours, const std::vector<cv::Vec4i>& hierarchy);
std::vector<cv::Point> getVertices(const cv::RotatedRect& rect);
void polyIndent(std::vector<cv::Point>& points, const cv::Point& center, int indent);
void threshold_Mat(const cv::Mat& src, cv::Mat& dst, double thre);
cv::Mat transforColor(const cv::Mat& src);
cv::Point warpPoint(cv::Point p, const cv::Mat& warp_mat);
}
#endif // !IMAGE_PROCESS_C_H

View File

@ -0,0 +1,80 @@
#include "StdAfx.h"
#include "JpegBuffer.h"
#include "jpeglib.h"
//#include "twain.h"
#include "filetools.h"
#include "PublicFunc.h"
using namespace std;
JpegBuffer::JpegBuffer(cv::Mat buffer, int color_type,int side,int mFilter)
{
this->m_buffer = buffer;
this->m_color_type=color_type;
this->m_side=side;
this->m_mFilter=mFilter;
}
JpegBuffer::~JpegBuffer(void)
{
}
unsigned char* JpegBuffer::getBuffer()
{
return m_buffer.data;
}
cv::Mat JpegBuffer::buffer()
{
return m_buffer;
}
int JpegBuffer::getSize()
{
return m_buffer.cols;
}
cv::Mat JpegBuffer::getMat( int pixType)
{
JpegLib jl;
//cv::Mat image = jl.decode(m_buffer, 6);//oixtype
StopWatch sw;
sw.start();
//XdPrint("buffer size is :%d ==========================\n",getSize());
cv::Mat image = jl.decode(m_buffer, pixType);//oixtype
sw.stop();
//XdPrint("Decode Image time epleased :%lf ==========================\n",sw.time_run());
//XdPrint("==image col is :%d, image row is :%d, image size is :%d===\n",image.cols, image.rows, image.size);
//FileTools::write_log("D:/1.txt",)
//cv::InputArray arr(m_buffer);
//
//cv::Mat image1=imdecode(arr,m_color_type==TWPT_RGB?CV_LOAD_IMAGE_COLOR:CV_LOAD_IMAGE_GRAYSCALE);
//cv::imwrite("0.bmp",image1);
//char str[256];
//sprintf(str, "%lf", sw.time_run());
//string res=str;
//FileTools::write_log("D:/1.txt",res);
//0 ÕýÃæ 1·´Ãæ
//if (!backRotate&&(m_side==0||m_side==1))
//{
// cv::Rect rect(0, m_side == 0 ? 0 : gap, image.cols,(image.rows-gap));
// image = image(rect);
//}
return image.clone();
}
int JpegBuffer::getMFilter()
{
return m_mFilter;
}
int JpegBuffer::getSide()
{
return m_side;
}

23
HuaGoCorrect/JpegBuffer.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <opencv2\opencv.hpp>
#include "jpeglib.h"
class JpegBuffer
{
public:
JpegBuffer() {}
JpegBuffer(cv::Mat buffer,int color_type=2,int side=0,int mFilter=0);
virtual ~JpegBuffer(void);
unsigned char* getBuffer();
cv::Mat buffer();
int getSize();
cv::Mat getMat( int pixType);
int getMFilter();
int getSide();
private:
cv::Mat m_buffer;
int m_color_type;
int m_side;
int m_mFilter;
};

552
HuaGoCorrect/JsonConfig.cpp Normal file
View File

@ -0,0 +1,552 @@
#include "StdAfx.h"
#include "JsonConfig.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
#include "CJsonObject.hpp"
JsonConfig::JsonConfig(void)
{
}
JsonConfig::~JsonConfig(void)
{
}
/************************************************************************/
/* ±£´æÅäÖòÎÊý */
/************************************************************************/
void JsonConfig::WriteToJson(PCONFIGPARAMS pConfigItem,const std::string fileNames,bool isConfigItem)
{
//neb::CJsonObject outJson;
//outJson.AddEmptySubObject("Config");//header
//outJson["Config"].Add(PIXTYPE,(int)(pConfigItem->Pixtype));
//outJson["Config"].Add(PAPARSIZE,(int)(pConfigItem->PaperSize));
//outJson["Config"].Add(RESOLUTION,(int)(pConfigItem->Resolution));
//outJson["Config"].Add(DUPLEX,(int)(pConfigItem->Duplex));
//std::ofstream os;
//os.open(fileNames.c_str());
//os<<outJson.ToFormattedString();
//os.close();
}
void JsonConfig::WriteJsonData(const std::string fileName)
{
}
void JsonConfig::WriteJsonArrayToFile(CONFIGPARAMS cfgConfig,const std::string filename)
{
//neb::CJsonObject root;
//
//root.AddEmptySubObject("Config");
//root["Config"].AddEmptySubArray(PIXTYPE);
//root["Config"].AddEmptySubArray(PAPARSIZE);
//root["Config"].AddEmptySubArray(RESOLUTION);
//root["Config"].AddEmptySubArray(DUPLEX);
//root["Config"].AddEmptySubArray(TABINDEX);
//
//root["Config"][PIXTYPE].Add(cfgConfig.Pixtype);
//root["Config"][PAPARSIZE].Add(cfgConfig.PaperSize);
//root["Config"][RESOLUTION].Add(cfgConfig.Resolution);
//root["Config"][DUPLEX].Add(cfgConfig.Duplex);
//root["Config"][TABINDEX].Add(cfgConfig.TabIndex);
//std::ofstream os;
//os.open(filename.c_str());
//os<<root.ToFormattedString();
//os.close();
}
void JsonConfig::WriteDistorJsonToFile(std::vector<DISTORTIONPARAMS> cfgArray,const std::string filename)
{
/*neb::CJsonObject root;
root.AddEmptySubObject("Distor");
root["Distor"].AddEmptySubArray(OBJVALUE1);
root["Distor"].AddEmptySubArray(OBJVALUE2);
root["Distor"].AddEmptySubArray(OBJVALUE3);
root["Distor"].AddEmptySubArray(OBJVALUE4);
root["Distor"].AddEmptySubArray(OBJVALUE5);
root["Distor"].AddEmptySubArray(OBJVALUE6);
root["Distor"].AddEmptySubArray(LIMITOFFSET1);
root["Distor"].AddEmptySubArray(LIMITOFFSET2);
root["Distor"].AddEmptySubArray(LIMITOFFSET3);
root["Distor"].AddEmptySubArray(LIMITOFFSET4);
root["Distor"].AddEmptySubArray(LIMITOFFSET5);
root["Distor"].AddEmptySubArray(LIMITOFFSET6);
for (int i=0;i<cfgArray.size();i++)
{
root["Distor"][OBJVALUE1].Add(cfgArray[i].ObjValues[0]);
root["Distor"][OBJVALUE2].Add(cfgArray[i].ObjValues[1]);
root["Distor"][OBJVALUE3].Add(cfgArray[i].ObjValues[2]);
root["Distor"][OBJVALUE4].Add(cfgArray[i].ObjValues[3]);
root["Distor"][OBJVALUE5].Add(cfgArray[i].ObjValues[4]);
root["Distor"][OBJVALUE6].Add(cfgArray[i].ObjValues[5]);
root["Distor"][LIMITOFFSET1].Add(cfgArray[i].LimitOffset[0]);
root["Distor"][LIMITOFFSET2].Add(cfgArray[i].LimitOffset[1]);
root["Distor"][LIMITOFFSET3].Add(cfgArray[i].LimitOffset[2]);
root["Distor"][LIMITOFFSET4].Add(cfgArray[i].LimitOffset[3]);
root["Distor"][LIMITOFFSET5].Add(cfgArray[i].LimitOffset[4]);
root["Distor"][LIMITOFFSET6].Add(cfgArray[i].LimitOffset[5]);
}
std::ofstream os;
os.open(filename.c_str());
os<<root.ToFormattedString();
os.close();*/
}
void JsonConfig::WriteMacthJsonToFile(std::vector<MATCHPARAMS> cfgArray,const std::string filename)
{
/*neb::CJsonObject root;
root.AddEmptySubObject("Match");
root["Match"].AddEmptySubArray(LOADNUM);
root["Match"].AddEmptySubArray(XPOINT);
root["Match"].AddEmptySubArray(YPOINT);
root["Match"].AddEmptySubArray(PWIGHT);
root["Match"].AddEmptySubArray(PHEIGHT);
root["Match"].AddEmptySubArray(MATCHPATH);
for (int i=0;i<cfgArray.size();i++)
{
root["Match"][LOADNUM].Add(cfgArray[i].LoadNum);
root["Match"][XPOINT].Add(cfgArray[i].XPoint);
root["Match"][YPOINT].Add(cfgArray[i].YPoint);
root["Match"][PWIGHT].Add(cfgArray[i].PWight);
root["Match"][PHEIGHT].Add(cfgArray[i].PHeight);
if (cfgArray[i].MatchPath.c_str()!=NULL)
{
root["Match"][MATCHPATH].Add(cfgArray[i].MatchPath);
}
}
std::ofstream os;
os.open(filename.c_str());
os<<root.ToFormattedString();
os.close();*/
}
CONFIGPARAMS JsonConfig::ReadDefaultConfig()
{
/*TCHAR szIniFile[MAX_PATH] = { 0 };
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
_tcscat(szIniFile, HUAGAO_SCAN);
_tcscat(szIniFile, PAPER_TEST);
_tcscat(szIniFile, TEXT("\\"));
_tcscat(szIniFile, PAPER_JSON_NAME);
std::string s_default(szIniFile);
vector<CONFIGPARAMS> vc;
vc=ReadJsonArrayFromFile(s_default.c_str());
if (vc.size()!=0)
{
return vc[0];
}
return GetDefaultConfigParams();*/
return CONFIGPARAMS();
}
DISTORTIONPARAMS JsonConfig::ReadDistorConfig()
{
//TCHAR szIniFile[MAX_PATH] = { 0 };
//SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
//_tcscat(szIniFile, HUAGAO_SCAN);
//_tcscat(szIniFile, PAPER_TEST);
//_tcscat(szIniFile, TEXT("\\"));
//_tcscat(szIniFile, DISTOR_JSON_NAME);
//std::string s_default(szIniFile);
//vector<DISTORTIONPARAMS> vc;
//vc=ReadDistorJsonFromFile(s_default.c_str());
//if (vc.size()!=0)
//{
// return vc[0];
//}
//return GetDistorConfigParams();
return GetDistorConfigParams();
}
MATCHPARAMS JsonConfig::ReadMacthConfig()
{
//TCHAR szIniFile[MAX_PATH] = { 0 };
//SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
//_tcscat(szIniFile, HUAGAO_SCAN);
//_tcscat(szIniFile, PAPER_TEST);
//_tcscat(szIniFile, TEXT("\\"));
//_tcscat(szIniFile, MATCH_JSON_NAME);
//std::string s_default(szIniFile);
//vector<MATCHPARAMS> vc;
//vc=ReadMacthJsonFromFile(s_default.c_str());
//if (vc.size()!=0)
//{
// return vc[0];
//}
//return GetMacthConfigParams();
return MATCHPARAMS();
}
bool JsonConfig::DeleteJsonFile(std::string path)
{
return (remove(path.c_str()));
}
std::vector<CONFIGPARAMS> JsonConfig::ReadJsonArrayFromFile(const std::string filename)
{
std::vector<CONFIGPARAMS> re;
/*FILE* file=fopen(filename.c_str(),"rb");
if (!file)
{
return re;
}
fseek(file,0,SEEK_END);
long size=ftell(file);
fseek(file,0,SEEK_SET);
std::string text;
char* buffer=new char[size+1];
buffer[size]=0;
if (!fread(buffer,1,size,file)==(unsigned long)size)
{
return re;
}
text=buffer;
fclose(file);
delete []buffer;
re=parseJsonFromString(text);*/
return re;
}
std::vector<DISTORTIONPARAMS> JsonConfig::ReadDistorJsonFromFile(const std::string filename)
{
std::vector<DISTORTIONPARAMS> re;
//FILE* file=fopen(filename.c_str(),"rb");
//if (!file)
//{
// return re;
//}
//fseek(file,0,SEEK_END);
//long size=ftell(file);
//fseek(file,0,SEEK_SET);
//std::string text;
//char* buffer=new char[size+1];
//buffer[size]=0;
//if (!fread(buffer,1,size,file)==(unsigned long)size)
//{
// return re;
//}
//text=buffer;
//fclose(file);
//delete []buffer;
//re=parseDistorFromString(text);
return re;
}
std::vector<MATCHPARAMS> JsonConfig::ReadMacthJsonFromFile(const std::string filename)
{
std::vector<MATCHPARAMS> re;
/*FILE* file=fopen(filename.c_str(),"rb");
if (!file)
{
return re;
}
fseek(file,0,SEEK_END);
long size=ftell(file);
fseek(file,0,SEEK_SET);
std::string text;
char* buffer=new char[size+1];
buffer[size]=0;
if (!fread(buffer,1,size,file)==(unsigned long)size)
{
return re;
}
text=buffer;
fclose(file);
delete []buffer;
re=parseMacthFromString(text);*/
return re;
}
CONFIGPARAMS JsonConfig::GetDefaultConfigParams()
{
CONFIGPARAMS params;
params.Pixtype=1;//»Ò¶È
params.PaperSize=11;//A3
params.Resolution=200;//200dpi
params.Duplex=1;//Ë«Ãæ
params.TabIndex = 1;
return params;
}
DISTORTIONPARAMS JsonConfig::GetDistorConfigParams()
{
DISTORTIONPARAMS params;
for(int i = 0;i < 6;i++)
{
params.ObjValues[i] = 10;
params.LimitOffset[i] = 2;
}
return params;
}
MATCHPARAMS JsonConfig::GetMacthConfigParams()
{
MATCHPARAMS params;
params.LoadNum = 4;
params.XPoint = 10;
params.YPoint = 10;
params.PWight = 100;
params.PHeight = 100;
return params;
}
std::vector<CONFIGPARAMS> JsonConfig::parseJsonFromString(const std::string str)
{
//neb::CJsonObject root(str);
vector<CONFIGPARAMS> vcConfig;
/*int size=0;
neb::CJsonObject itmPaparSize;
root["Config"].Get(PAPARSIZE,itmPaparSize);
size=itmPaparSize.GetArraySize();
if (size>0)
{
neb::CJsonObject itmPixType;
root["Config"].Get(PIXTYPE,itmPixType);
neb::CJsonObject itmRes;
root["Config"].Get(RESOLUTION,itmRes);
neb::CJsonObject itmDulpex;
root["Config"].Get(DUPLEX,itmDulpex);
neb::CJsonObject itmTabIndex;
root["Config"].Get(TABINDEX,itmTabIndex);
for (int i=0;i<size;i++)
{
CONFIGPARAMS cfp;
int i_value;
itmPixType.Get(i,i_value);
cfp.Pixtype=i_value;
itmPaparSize.Get(i,i_value);
cfp.PaperSize=i_value;
itmRes.Get(i,i_value);
cfp.Resolution=i_value;
itmDulpex.Get(i,i_value);
cfp.Duplex=i_value;
itmTabIndex.Get(i,i_value);
cfp.TabIndex=i_value;
vcConfig.push_back(cfp);
}
}
else
{
CONFIGPARAMS cfp;
int index;
root["Config"].Get(PIXTYPE,index);
cfp.Pixtype=index;
root["Config"].Get(PAPARSIZE,index);
cfp.PaperSize=index;
root["Config"].Get(RESOLUTION,index);
cfp.Resolution=index;
root["Config"].Get(DUPLEX,index);
cfp.Duplex=index;
root["Config"].Get(TABINDEX,index);
cfp.TabIndex=index;
vcConfig.push_back(cfp);
}*/
return vcConfig;
}
std::vector<DISTORTIONPARAMS> JsonConfig::parseDistorFromString(const std::string str)
{
//neb::CJsonObject root(str);
vector<DISTORTIONPARAMS> vcConfig;
//int size=0;
//neb::CJsonObject itmObjValue1;
//root["Distor"].Get(OBJVALUE1,itmObjValue1);
//size = itmObjValue1.GetArraySize();
//if (size>0)
//{
// neb::CJsonObject itmObjValue2;
// root["Distor"].Get(OBJVALUE2,itmObjValue2);
// neb::CJsonObject itmObjValue3;
// root["Distor"].Get(OBJVALUE3,itmObjValue3);
// neb::CJsonObject itmObjValue4;
// root["Distor"].Get(OBJVALUE4,itmObjValue4);
// neb::CJsonObject itmObjValue5;
// root["Distor"].Get(OBJVALUE5,itmObjValue5);
// neb::CJsonObject itmObjValue6;
// root["Distor"].Get(OBJVALUE6,itmObjValue6);
// neb::CJsonObject itmLimitOffset1;
// root["Distor"].Get(LIMITOFFSET1,itmLimitOffset1);
// neb::CJsonObject itmLimitOffset2;
// root["Distor"].Get(LIMITOFFSET2,itmLimitOffset2);
// neb::CJsonObject itmLimitOffset3;
// root["Distor"].Get(LIMITOFFSET3,itmLimitOffset3);
// neb::CJsonObject itmLimitOffset4;
// root["Distor"].Get(LIMITOFFSET4,itmLimitOffset4);
// neb::CJsonObject itmLimitOffset5;
// root["Distor"].Get(LIMITOFFSET5,itmLimitOffset5);
// neb::CJsonObject itmLimitOffset6;
// root["Distor"].Get(LIMITOFFSET6,itmLimitOffset6);
// for (int i=0;i<size;i++)
// {
// DISTORTIONPARAMS cfp;
// //float f_value;
// int i_value;
// itmObjValue1.Get(i,i_value);
// cfp.ObjValues[0]=i_value;
// itmObjValue2.Get(i,i_value);
// cfp.ObjValues[1]=i_value;
// itmObjValue3.Get(i,i_value);
// cfp.ObjValues[2]=i_value;
// itmObjValue4.Get(i,i_value);
// cfp.ObjValues[3]=i_value;
// itmObjValue5.Get(i,i_value);
// cfp.ObjValues[4]=i_value;
// itmObjValue6.Get(i,i_value);
// cfp.ObjValues[5]=i_value;
// itmLimitOffset1.Get(i,i_value);
// cfp.LimitOffset[0]=i_value;
// itmLimitOffset2.Get(i,i_value);
// cfp.LimitOffset[1]=i_value;
// itmLimitOffset3.Get(i,i_value);
// cfp.LimitOffset[2]=i_value;
// itmLimitOffset4.Get(i,i_value);
// cfp.LimitOffset[3]=i_value;
// itmLimitOffset5.Get(i,i_value);
// cfp.LimitOffset[4]=i_value;
// itmLimitOffset6.Get(i,i_value);
// cfp.LimitOffset[5]=i_value;
// vcConfig.push_back(cfp);
// }
//}
//else
//{
// DISTORTIONPARAMS cfp;
// int index;
// //float fndex;
// root["Distor"].Get(OBJVALUE1,index);
// cfp.ObjValues[0]=index;
// root["Distor"].Get(OBJVALUE2,index);
// cfp.ObjValues[1]=index;
// root["Distor"].Get(OBJVALUE3,index);
// cfp.ObjValues[2]=index;
// root["Distor"].Get(OBJVALUE4,index);
// cfp.ObjValues[3]=index;
// root["Distor"].Get(OBJVALUE5,index);
// cfp.ObjValues[4]=index;
// root["Distor"].Get(OBJVALUE6,index);
// cfp.ObjValues[5]=index;
// root["Distor"].Get(LIMITOFFSET1,index);
// cfp.LimitOffset[0]=index;
// root["Distor"].Get(LIMITOFFSET2,index);
// cfp.LimitOffset[1]=index;
// root["Distor"].Get(LIMITOFFSET3,index);
// cfp.LimitOffset[2]=index;
// root["Distor"].Get(LIMITOFFSET4,index);
// cfp.LimitOffset[3]=index;
// root["Distor"].Get(LIMITOFFSET5,index);
// cfp.LimitOffset[4]=index;
// root["Distor"].Get(LIMITOFFSET6,index);
// cfp.LimitOffset[5]=index;
// vcConfig.push_back(cfp);
//}
return vcConfig;
}
std::vector<MATCHPARAMS> JsonConfig::parseMacthFromString(const std::string str)
{
//neb::CJsonObject root(str);
vector<MATCHPARAMS> vcConfig;
/*int size=0;
neb::CJsonObject itmLoadNum;
root["Match"].Get(LOADNUM,itmLoadNum);
size=itmLoadNum.GetArraySize();
if (size>0)
{
neb::CJsonObject itmXPoint;
root["Match"].Get(XPOINT,itmXPoint);
neb::CJsonObject itmYPoint;
root["Match"].Get(YPOINT,itmYPoint);
neb::CJsonObject itmPWight;
root["Match"].Get(PWIGHT,itmPWight);
neb::CJsonObject itmPHeight;
root["Match"].Get(PHEIGHT,itmPHeight);
neb::CJsonObject itmMatchPath;
if (!root["Match"][MATCHPATH].IsEmpty())
{
root["Match"].Get(MATCHPATH,itmMatchPath);
}
for (int i=0;i<size;i++)
{
MATCHPARAMS cfp;
int i_value;
std::string s_value;
itmLoadNum.Get(i,i_value);
cfp.LoadNum=i_value;
itmXPoint.Get(i,i_value);
cfp.XPoint=i_value;
itmYPoint.Get(i,i_value);
cfp.YPoint=i_value;
itmPWight.Get(i,i_value);
cfp.PWight=i_value;
itmPHeight.Get(i,i_value);
cfp.PHeight=i_value;
if (!root["Match"][MATCHPATH].IsEmpty())
{
itmMatchPath.Get(i,s_value);
cfp.MatchPath=s_value;
}
vcConfig.push_back(cfp);
}
}
else
{
MATCHPARAMS cfp;
int index;
std::string svalue;
root["Match"].Get(LOADNUM,index);
cfp.LoadNum=index;
root["Match"].Get(XPOINT,index);
cfp.XPoint=index;
root["Match"].Get(YPOINT,index);
cfp.YPoint=index;
root["Match"].Get(PWIGHT,index);
cfp.PWight=index;
root["Match"].Get(PHEIGHT,index);
cfp.PHeight=index;
if (!root["Match"][MATCHPATH].IsEmpty())
{
root["Match"].Get(MATCHPATH,svalue);
cfp.MatchPath=svalue;
}
vcConfig.push_back(cfp);
}*/
return vcConfig;
}

41
HuaGoCorrect/JsonConfig.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include "PublicFunc.h"
#include <vector>
#include <json.h>
using namespace std;
struct DISTORTIONPARAMS
{
/*Ö÷½çÃæ²ÎÊý*/
INT ObjValues[6];
INT LimitOffset[6];
};
class JsonConfig
{
public:
JsonConfig(void);
~JsonConfig(void);
public:
void WriteToJson(PCONFIGPARAMS pConfigItem,const std::string fileName,bool isConfigItem=true);
//PCONFIGPARAMS ReadJsonFromFile(const char* fileNames);
void WriteJsonData(const std::string fileName);
void WriteJsonArrayToFile(CONFIGPARAMS cfgConfig,const std::string filename);
void WriteDistorJsonToFile(std::vector<DISTORTIONPARAMS> cfgArray,const std::string filename);
void WriteMacthJsonToFile(std::vector<MATCHPARAMS> cfgArray,const std::string filename);
CONFIGPARAMS ReadDefaultConfig();
DISTORTIONPARAMS ReadDistorConfig();
MATCHPARAMS ReadMacthConfig();
bool DeleteJsonFile(std::string path);
std::vector<CONFIGPARAMS> ReadJsonArrayFromFile(const std::string filename);
std::vector<DISTORTIONPARAMS> ReadDistorJsonFromFile(const std::string filename);
std::vector<MATCHPARAMS> ReadMacthJsonFromFile(const std::string filename);
CONFIGPARAMS GetDefaultConfigParams();
DISTORTIONPARAMS GetDistorConfigParams();
MATCHPARAMS GetMacthConfigParams();
private:
std::vector<CONFIGPARAMS> parseJsonFromString(const std::string str) ;
std::vector<DISTORTIONPARAMS> parseDistorFromString(const std::string str) ;
std::vector<MATCHPARAMS> parseMacthFromString(const std::string str) ;
};

53
HuaGoCorrect/MutexEx.h Normal file
View File

@ -0,0 +1,53 @@
#pragma once
#include <windows.h>
//对临界区同样进行封装
class CMyCriticalSection
{
public:
CMyCriticalSection()
{
InitializeCriticalSection(&m_cSection);
}
void Lock()
{
EnterCriticalSection(&m_cSection);
}
void UnLock()
{
LeaveCriticalSection(&m_cSection);
}
//利用析构函数删除临界区对象
virtual ~CMyCriticalSection()
{
DeleteCriticalSection(&m_cSection);
}
private:
CRITICAL_SECTION m_cSection;
};
class CCriticalSectionAutoLock
{
public:
//利用构造函数上锁,即进去临界区
CCriticalSectionAutoLock(CMyCriticalSection *mySection):pCMySection(mySection)
{
pCMySection->Lock();
}
//利用析构函数解锁,即离开临界区
virtual ~CCriticalSectionAutoLock()
{
pCMySection->UnLock();
}
private:
CMyCriticalSection *pCMySection;
};

830
HuaGoCorrect/PublicFunc.cpp Normal file
View File

@ -0,0 +1,830 @@
#include "stdafx.h"
#include "PublicFunc.h"
//#include "CTwainMutex.h"
#include <io.h>
#include <map>
using namespace std;
BOOL g_b_show_ui_flg = FALSE;
//WATER_PRO g_st_water_pro = {0};
BOOL g_add_water_flg = FALSE;
DWORD g_dw_white_bright_count = 40000;
//CDirectshowCaptureVideoUvc g_dc_uvc_video;
BOOL g_b_use_uvc_dev = FALSE;
TWAIN_IMAGE_DATA_INFO g_st_twain_bmp_info = {0};
BOOL g_b_brigth_show_flg = TRUE;
HWND g_hwnd_dlg = NULL;
//static std::map<int, SIZE> sizeS;
//
//
//static map<pair<TwSS, float>, CSize> dpiDct;
///*纸张类型分辨率-幅面字典*/
// void initialDictionary()
//{
// //自适应
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 50.0),CSize(594, 898)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 75),CSize(892, 1347)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 100),CSize(1189, 1795)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 150),CSize(1784, 2693)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 200),CSize(2338, 3307)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 240), CSize(2854, 4308)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 300),CSize(3567, 5385)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 400), CSize(4756, 7180) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)90, 600), CSize(7134, 10770)));
//
// //A3
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 50), CSize(585, 827)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 75), CSize(877, 1240)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 100), CSize(1169, 1653)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 150), CSize(1753, 2480)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 200), CSize(2338, 3307)));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 240), CSize(2806, 3968) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 300), CSize(3507, 4960) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 400), CSize(4677, 6614) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A3, 600), CSize(7015, 9921) ));
//
// //A4
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 50), CSize(413, 585) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 75), CSize(620, 877) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 100), CSize(826, 1169) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 150), CSize(1240, 1753) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 200), CSize(1653, 2338) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 240), CSize(1984, 2806) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 300), CSize(2480, 3507) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 400), CSize(3307, 4677) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4, 600), CSize(4960, 7015) ));
//
// //A4R
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 50), CSize(585, 413) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 75), CSize(877, 620) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 100), CSize(1169, 826) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 150), CSize(1753, 1240) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 200), CSize(2338,1653) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 240), CSize(2806,1984) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 300), CSize(3507,2480) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 400), CSize(4677,3307) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A4R, 600), CSize(7015,4960) ));
//
// //A5
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 50), CSize(291, 413) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 75), CSize(437, 620) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 100), CSize(582, 826) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 150), CSize(874, 1240) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 200), CSize(1165, 1653) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 240), CSize(1398, 1984) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 300), CSize(1748, 2480) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 400), CSize(2330, 3307) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5, 600), CSize(3496, 4960) ));
//
// //A5R
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 50), CSize(413, 291) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 75), CSize(620, 437) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 100), CSize(826, 582) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 150), CSize(1240, 874) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 200), CSize(1653, 1165) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 240), CSize(1984, 1398) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 300), CSize(2480, 1748) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 400), CSize(3307, 2330) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A5R, 600), CSize(4960, 3496) ));
//
// //A6
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 50), CSize(207, 291) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 75), CSize(310, 437) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 100), CSize(413, 582) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 150), CSize(620, 874) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 200), CSize(826, 1165) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 240), CSize(992, 1398) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 300), CSize(1240, 1748) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 400), CSize(1653, 2330) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6, 600), CSize(2480, 3496) ));
//
// //A6R
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 50), CSize(291, 207) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 75), CSize(437, 310) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 100), CSize(582, 413) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 150), CSize(874, 620) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 200), CSize(1165, 826) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 240), CSize(1398, 992) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 300), CSize(1748, 1240) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 400), CSize(2330, 1653) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(A6R, 600), CSize(3496, 2480) ));
//
// //长文稿2倍A3
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 50), CSize(585, 1653) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 75), CSize(877, 2480) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 100), CSize(1169, 1653*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 150), CSize(1753, 2480*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 200), CSize(2338, 3307*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 240), CSize(2806, 3968*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 300), CSize(3507, 4960*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 400), CSize(4677, 6614*2) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>((TwSS)91, 600), CSize(7015, 9921*2) ));
//
// //B4
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 50), CSize(506, 717) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 75), CSize(759, 1075) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 100), CSize(1011, 1433) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 150), CSize(1517, 2149) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 200), CSize(2023, 2866) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 240), CSize(2428, 3439) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 300), CSize(3035, 4299) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 400), CSize(4047, 5732) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B4, 600), CSize(6070, 8598) ));
//
// //B5
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 50), CSize(358, 506) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 75), CSize(537, 759) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 100), CSize(716, 1011) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 150), CSize(1074, 1517) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 200), CSize(1433, 2023) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 240), CSize(1719, 2428) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 300), CSize(2149, 3035) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 400), CSize(2866, 4047) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5, 600), CSize(4299, 6070) ));
//
// //B5R
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 50), CSize(506, 358) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 75), CSize(759, 537) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 100), CSize(1011, 716) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 150), CSize(1517, 1075) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 200), CSize(2023, 1433) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 240), CSize(2428, 1719) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 300), CSize(3035, 2149) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 400), CSize(4047, 2866) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B5R, 600), CSize(6070, 4299) ));
//
// //B6
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 50), CSize(252, 358) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 75), CSize(378, 537) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 100), CSize(503, 716) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 150), CSize(755, 1074) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 200), CSize(1007, 1433) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 240), CSize(1209, 1719) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 300), CSize(1511, 2149) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 400), CSize(2015, 2866) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6, 600), CSize(3023, 4299) ));
//
// //B6R
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 50), CSize(358, 252) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 75), CSize(537, 378) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 100), CSize(716, 503) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 150), CSize(1074, 755) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 200), CSize(1433, 1007) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 240), CSize(1719, 1209) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 300), CSize(2149, 1511) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 400), CSize(2866, 2015) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(B6R, 600), CSize(4299, 3023) ));
//
// //DOUBLE LETTER
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 50), CSize(550, 850) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 75), CSize(825, 1275) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 100), CSize(1100, 1700) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 150), CSize(1650, 2550) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 200), CSize(2200, 3400) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 240), CSize(2640, 4080) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 300), CSize(3300, 5100) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 400), CSize(4400, 6800) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(DOUBLELetter, 600), CSize(6600, 10200) ));
//
// //LETTER
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 50), CSize(425, 550) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 75), CSize(638, 825) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 100), CSize(850, 1100) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 150), CSize(1275, 1650) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 200), CSize(1700, 2200) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 240), CSize(2040, 2640) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 300), CSize(2550, 3300) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 400), CSize(3400, 4400) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetter, 600), CSize(5100, 6600) ));
//
// //LETTERR
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 50), CSize(550, 425) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 75), CSize(825, 638) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 100), CSize(1100, 850) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 150), CSize(1650, 1275) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 200), CSize(2200, 1700) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 240), CSize(2640, 2040) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 300), CSize(3300, 2550) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 400), CSize(4400, 3400) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLetterR, 600), CSize(6600, 5100) ));
//
// //LETTERR
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 50), CSize(425, 700) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 75), CSize(638, 1050) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 100), CSize(850, 1400) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 150), CSize(1275, 2100) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 200), CSize(1700, 2800) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 240), CSize(2040, 3360) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 300), CSize(2550, 4200) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 400), CSize(3400, 5600) ));
// dpiDct.insert(pair<pair<TwSS,float>,CSize>(pair<TwSS,float>(USLegal, 600), CSize(5100, 8400) ));
//}
//
///*根据纸张类型分辨率获取幅面大小*/
// CSize getSize(TwSS paperType, float dpi)
//{
// CSize retSize;
// map<pair<TwSS, float>, CSize>::iterator iter;
// iter = dpiDct.find(pair<TwSS, float>(paperType,dpi));
// if(iter != dpiDct.end()){
// retSize = (*iter).second;
// return retSize;
// }
// return CSize(2338, 3307);
//}
TCHAR* GetUserCustomFilePath(HWND hWin, TCHAR* lpFilePath, TCHAR *lp_head_text )
{
if ( lpFilePath == NULL )
{
return NULL;
}
BROWSEINFO bi = {0};
TCHAR szBuffer[MAX_PATH] = {0};
memset(&bi, 0, sizeof(BROWSEINFO));
bi.hwndOwner = hWin;
bi.pszDisplayName = GetExistFileDir(lpFilePath);
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_SHAREABLE | BIF_USENEWUI | BIF_RETURNFSANCESTORS ;
LPITEMIDLIST pIDList = NULL;
LPMALLOC lpMalloc = NULL;
//m_pUI_INI->GetMessageBoxStr(szBuffer, sizeof(szBuffer), 1041);
//bi.lpszTitle = szBuffer;//1041=请选择文件存储路径
bi.lpszTitle = lp_head_text;//TEXT("请选择新建文件夹");
bi.lpfn = (BFFCALLBACK)BrowserCallbackProc; //回调函数
bi.lParam = (LPARAM)lpFilePath; //回调函数的使用的参数,用来设定默认路径
pIDList = SHBrowseForFolder(&bi);
if ( pIDList != NULL )
{
SHGetPathFromIDList(pIDList, lpFilePath);
}
if ( SHGetMalloc( &lpMalloc ) )
{
return NULL; //释放内存   
}
if ( pIDList == NULL )
{
return NULL; //释放内存
}
lpMalloc->Free(pIDList);
lpMalloc->Release();
pIDList = NULL;
lpMalloc = NULL;
//_tcscpy(lpFilePath, szBuffer2);
return lpFilePath;
}
TCHAR* GetCurExeFilePath(HINSTANCE hInstance, TCHAR* lpPath, DWORD dwSize)
{
INT nRet = 0x0L;
TCHAR *p = NULL;
if ( lpPath == NULL || dwSize == 0 )
{
return NULL;
}
nRet = GetModuleFileName(hInstance, lpPath, dwSize);
if (nRet > 0)
{
p = _tcsrchr(lpPath, TEXT('\\'));
if ( p != NULL )
{
*(p+1) = TEXT('\0');
}
else
{
return NULL;
}
}
else
{
return NULL;
}
return lpPath;
}
TCHAR* GetExistFileDir(TCHAR* p_file_path)
{
WIN32_FIND_DATA wfd = {0};
LPSTR p_test = NULL;
HANDLE hFindFile = INVALID_HANDLE_VALUE;
if ( p_file_path == NULL )
return NULL;
hFindFile = FindFirstFile(p_file_path, &wfd);
if (hFindFile != NULL)
{
FindClose(hFindFile);
hFindFile= INVALID_HANDLE_VALUE;
}
if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
return p_file_path;
}
p_test = _tcsrchr(p_file_path, '\\');
if ( p_test != NULL )
{
*p_test = 0;
return GetExistFileDir(p_file_path);
}
else
{
return NULL;
}
}
DWORD CALLBACK BrowserCallbackProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case BFFM_INITIALIZED: //LPARAM(TEXT("D:\\test_adf_project"))
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lParam); //lpData就是上一个函数的 info.lParam ,也就是默认路径
break;
default:
break;
}
return 0;
}
BOOL CheckAndCreateFileDir(TCHAR* p_file_path, BOOL flg)
{
TCHAR szTmp[MAX_PATH] = {0};
WIN32_FIND_DATA wfd = {0};
INT len = 0;
INT pos = 0;
BOOL bFlg = FALSE;
HANDLE hFindFile = INVALID_HANDLE_VALUE;
if ( p_file_path == NULL )
return FALSE;
if ( *p_file_path >= 'a' && *p_file_path <= 'z' || *p_file_path >= 'A' && *p_file_path <= 'Z')
{
if ( *(p_file_path+1) != ':' && *(p_file_path+2) != '\\')
{
return FALSE;
}
}
if ( _access(p_file_path, 0) == 0)
{
return TRUE;
}
if ( !flg )
return FALSE;
if ( CreateDirectory(p_file_path, NULL) )
return TRUE;
_tcscpy(szTmp, p_file_path);
len = (INT)_tcslen(szTmp);
bFlg = FALSE;
while(len)
{
if ( *(szTmp+len-1) == '\\' )
{
bFlg = TRUE;
break;
}
len--;
}
if ( bFlg )
{
*(szTmp+len-1) = 0;
CheckAndCreateFileDir(szTmp, flg);
return CreateDirectory(p_file_path, NULL);
}
else
return FALSE;
}
BOOL CheckDiskFreeBitM(HWND hWin, TCHAR *p_disk_name, DWORD dw_min_bit_m)
{
TCHAR *p = NULL;
TCHAR sz_root_path_name[MAX_PATH + 1] = {0};
INT len = 0;
DWORD dwTotalDiskSpace = 0;
DWORD dwFreeDiskSpace = 0;
DWORD dwUsedDiskSpace = 0;
ULARGE_INTEGER uiFreeBytesAvailableToCaller;
ULARGE_INTEGER uiTotalNumberOfBytes;
ULARGE_INTEGER uiTotalNumberOfFreeBytes;
UINT un_ret = 0;
if ( p_disk_name == NULL )
return FALSE;
len = _tcslen(p_disk_name);
if ( len > MAX_PATH )
{
len = MAX_PATH;
}
memcpy(sz_root_path_name, p_disk_name, (size_t)len);
p = _tcsstr(sz_root_path_name, "\\");
if ( p == NULL )
{
if ( len == 2 )
{
if ( !((sz_root_path_name[0] >= 'A' && sz_root_path_name[0] <= 'Z' || sz_root_path_name[0] >= 'a' && sz_root_path_name[0] <= 'z') && sz_root_path_name[1]== ':') )
return FALSE;
}
else
return FALSE;
}
if ( p != NULL )
*(p+1) = 0;
un_ret = GetDriveType(sz_root_path_name);
if ( un_ret == 0 || un_ret == 1)
{
return FALSE;
}
if(GetDiskFreeSpaceEx(sz_root_path_name, &uiFreeBytesAvailableToCaller, &uiTotalNumberOfBytes, &uiTotalNumberOfFreeBytes))
{
//dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
//dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
if ( dwFreeDiskSpace < dw_min_bit_m )
{
//ShowErrorStr(hWin, 1101);//1101=磁盘空间不足
MyMessageBox( TEXT("磁盘分区可用空间不足"), 0, MB_ICONWARNING);
return FALSE;
}
}
else
{
MyMessageBox( TEXT("磁盘分区可用空间不足"), 0, MB_ICONWARNING);
//GetErrorMessage(NULL, 0, FALSE);
return FALSE;
}
//ShowErrorStr(hWin, 1101);//1101=磁盘空间不足
//return FALSE;
return TRUE;
}
HBITMAP SetButtonStaticBkBmp(HINSTANCE hInst, HWND hWin, UINT id, UINT iamge_id)
{
UINT ctr_msg = 0;
UINT str_iamge_type = 0;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
//BS_ICON BS_BITMAP
//SS_BITMAP|SS_CENTERIMAGE SS_ICON
LONG ctr_s = 0;
ctr_s = GetWindowLong(GetDlgItem(hWin, id), GWL_STYLE);
ctr_msg = STM_SETIMAGE;
ctr_s |= SS_BITMAP | SS_CENTERIMAGE | SS_RIGHT;
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(iamge_id));
if ( hBitmap == NULL )
{
return NULL;
}
SetWindowLong(GetDlgItem(hWin, id), GWL_STYLE, ctr_s);
hOldBitmap = (HBITMAP)SendDlgItemMessage(hWin, id, ctr_msg, IMAGE_BITMAP, (LPARAM)hBitmap);
if ( hOldBitmap != NULL )
{
DeleteObject(hOldBitmap);
hOldBitmap = NULL;
}
DeleteObject(hBitmap);
hBitmap = NULL;
return hBitmap;
}
VOID FreeTwainFileListMem()
{
if ( g_st_twain_bmp_info.p_wifl != NULL )
{
free(g_st_twain_bmp_info.p_wifl);
g_st_twain_bmp_info.p_wifl = NULL;
}
//if ( g_st_twain_bmp_info.st_bmp_info.p_image_data != NULL )
//{
// free(g_st_twain_bmp_info.st_bmp_info.p_image_data);
// g_st_twain_bmp_info.st_bmp_info.p_image_data = NULL;
//}
//memset(&g_st_twain_bmp_info, 0, sizeof(TWAIN_IMAGE_DATA_INFO));
}
BOOL MallocTwainFileListMem()
{
if ( g_st_twain_bmp_info.p_wifl == NULL )
{
memset(&g_st_twain_bmp_info, 0, sizeof(TWAIN_IMAGE_DATA_INFO));
}
else if ( g_st_twain_bmp_info.n_wifl_count != 0 && g_st_twain_bmp_info.p_wifl == NULL )
{
memset(&g_st_twain_bmp_info, 0, sizeof(TWAIN_IMAGE_DATA_INFO));
}
if ( g_st_twain_bmp_info.n_wifl_cur_count +3 > g_st_twain_bmp_info.n_wifl_count)
{
if ( SHGetSpecialFolderPath(NULL, g_st_twain_bmp_info.sz_path_dir, CSIDL_LOCAL_APPDATA, TRUE) )
{
INT len = _tcslen(g_st_twain_bmp_info.sz_path_dir);
if ( len > 0 )
{
//if ( g_st_twain_bmp_info.sz_path_dir[len -1] != '\\' )
// _tcscat(g_st_twain_bmp_info.sz_path_dir, TEXT("\\"));
//_tcscat(g_st_twain_bmp_info.sz_path_dir, TWAIN_DATA_PATH);
//CheckAndCreateFileDir(g_st_twain_bmp_info.sz_path_dir, TRUE);
}
}
else
return FALSE;
if ( g_st_twain_bmp_info.p_wifl == NULL )
{
g_st_twain_bmp_info.p_wifl = (PTWAIN_IMAGE_FILE_LIST)malloc(sizeof(TWAIN_IMAGE_FILE_LIST)* (g_st_twain_bmp_info.n_wifl_count + 20));
if ( g_st_twain_bmp_info.p_wifl != NULL )
{
memset(g_st_twain_bmp_info.p_wifl, 0, sizeof(TWAIN_IMAGE_FILE_LIST)* (g_st_twain_bmp_info.n_wifl_count + 20));
g_st_twain_bmp_info.n_wifl_count += 20;
}
else
return FALSE;
}
else
{
PTWAIN_IMAGE_FILE_LIST p_wifl = (PTWAIN_IMAGE_FILE_LIST)malloc(sizeof(TWAIN_IMAGE_FILE_LIST)* (g_st_twain_bmp_info.n_wifl_count + 20));
if ( g_st_twain_bmp_info.p_wifl != NULL )
{
memset(p_wifl, 0, sizeof(TWAIN_IMAGE_FILE_LIST)* (g_st_twain_bmp_info.n_wifl_count + 20));
memcpy(p_wifl, g_st_twain_bmp_info.p_wifl, sizeof(TWAIN_IMAGE_FILE_LIST)* g_st_twain_bmp_info.n_wifl_cur_count );
g_st_twain_bmp_info.n_wifl_count += 20;
free(g_st_twain_bmp_info.p_wifl);
g_st_twain_bmp_info.p_wifl = p_wifl;
p_wifl = NULL;
}
else
return FALSE;
}
}
return TRUE;
}
BOOL WriteTwianImageData(TCHAR *p_file_path, PBYTE p_data, DWORD dw_size)
{
DWORD dw_write_size = 0;
if ( p_file_path == NULL || p_data == NULL )
return FALSE;
if ( _msize(p_data) < dw_size )
return FALSE;
DeleteFile(p_file_path);
HANDLE h_file = CreateFile(p_file_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);
if ( h_file == INVALID_HANDLE_VALUE )
{
return FALSE;
}
BOOL b_flg = WriteFile(h_file, p_data, dw_size, &dw_write_size,0);
if ( !b_flg || dw_size != dw_write_size )
{
b_flg = FALSE;
}
CloseHandle(h_file);
h_file = INVALID_HANDLE_VALUE;
if ( !b_flg )
{
DeleteFile(p_file_path);
}
return TRUE;
}
DWORD ReadTwianImageData(TCHAR *p_file_path)
{
if ( p_file_path == NULL )
return 0;
DWORD dw_size = 0;
HANDLE h_file = CreateFile(p_file_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
if ( h_file == INVALID_HANDLE_VALUE )
{
return 0;
}
dw_size = GetFileSize(h_file, 0);
if ( dw_size == 0 )
{
CloseHandle(h_file);
return 0;
}
//if ( g_st_twain_bmp_info.st_bmp_info.p_image_data != NULL )
//{
// free(g_st_twain_bmp_info.st_bmp_info.p_image_data);
// g_st_twain_bmp_info.st_bmp_info.p_image_data = NULL;
//}
//DWORD dw_read_size = 0;
//g_st_twain_bmp_info.st_bmp_info.p_image_data = (PBYTE)malloc(dw_size);
//if ( g_st_twain_bmp_info.st_bmp_info.p_image_data == NULL )
//{
// CloseHandle(h_file);
// return 0;
//}
//BOOL b_flg = ReadFile(h_file, ////g_st_twain_bmp_info.st_bmp_info.p_image_data, dw_size, /&dw_read_size,/ 0);
////CloseHandle(h_file);
//h_file = INVALID_HANDLE_VALUE;
//if ( !b_flg || dw_size != dw_read_size)
//{
// //free(g_st_twain_bmp_info.st_bmp_info.p_image_data);
// dw_size = 0;
//}
//else
// DeleteFile(p_file_path);
return dw_size;
}
std::string UtfToString(std::string strValue)
{
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, strValue.c_str(), -1, NULL, 0);
wchar_t * pwBuf = new wchar_t[nwLen + 1];//加上末尾'\0'
ZeroMemory(pwBuf, nwLen * 2 + 2);
::MultiByteToWideChar(CP_ACP, 0, strValue.c_str(), strValue.length(), pwBuf, nwLen);
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char * pBuf = new char[nLen + 1];
ZeroMemory(pBuf, nLen + 1);
::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string retStr(pBuf);
delete []pwBuf;
delete []pBuf;
pwBuf = NULL;
pBuf = NULL;
return retStr;
}
std::string StringToUtf(std::string strValue)
{
int nwLen = MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), -1, NULL, 0);
wchar_t * pwBuf = new wchar_t[nwLen + 1];//加上末尾'\0'
memset(pwBuf, 0, nwLen * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), strValue.length(), pwBuf, nwLen);
int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char * pBuf = new char[nLen + 1];
memset(pBuf, 0, nLen + 1);
WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string retStr = pBuf;
delete []pBuf;
delete []pwBuf;
return retStr;
}
DWORD MyMessageBox(TCHAR *p_str, TCHAR *p_str2, DWORD dw_id)
{
if ( p_str2 == NULL )
{
return MessageBox(g_hwnd_dlg, p_str, TEXT("test")/*g_p_cur_supper_sdti->sz_type_str*/, dw_id);
}
else
{
return MessageBox(g_hwnd_dlg, p_str, p_str2, dw_id);
}
}
/*
CTwainMutex g_sys_mutex;
BOOL g_not_user_sineng_dev = true;
BOOL g_InitSysMutexRun()
{
//return g_sys_mutex.InitRunMutexId(COMPANY_NAME PRODUCT_NAME);
return true;
//return g_sys_mutex.CreatTwainMutex(SCANNERNAME);
}
BOOL g_InitSysMutexScanRun(DWORD dwPid, DWORD dwUid)
{
//return g_sys_mutex.InitScanRunMutexId(COMPANY_NAME PRODUCT_NAME, dwPid, dwUid);
return true;
}
BOOL g_CloseSysMutexRun()
{
//return g_sys_mutex.CloseAllScnDocA3Mutex();
return g_sys_mutex.CloseTwainMutex();
}
BOOL g_CloseOneSysMutexRun()
{
//return g_sys_mutex.CloseScnDocA3Mutex((SCN_MUTEX_TYPE)smt);
return true;
//return g_sys_mutex.CloseTwainMutex();
}
BOOL g_CheckSysMutex()
{
//return g_sys_mutex.CheckScnDocA3Mutex((SCN_MUTEX_TYPE)smt);
return true;
return g_sys_mutex.CheckExistTwainMutex(SCANNERNAME);
}
BOOL g_CreateSysMutex()
{
//return g_sys_mutex.CreateScnDocA3Mutex((SCN_MUTEX_TYPE)smt);
//return true;
return g_sys_mutex.CreatTwainMutex(SCANNERNAME);
}
RGBQUAD g_default_map[256] = {0};
BOOL ReadDefaultMap()
{
int i = 0;
for ( i = 0; i < 256; i++ )
{
g_default_map[i].rgbBlue = g_default_map[i].rgbGreen = g_default_map[i].rgbRed = i;
}
TCHAR sz_path[MAX_PATH] = {0};
bool nRet = GetModuleFileName(AfxGetApp()->m_hInstance, sz_path, sizeof(sz_path));
if (nRet > 0)
{
TCHAR *p = _tcsrchr(sz_path, TEXT('\\'));
if ( p != NULL )
{
*(p+1) = TEXT('\0');
}
else
{
return TRUE;
}
}
_tcscat(sz_path, TEXT("default.map"));
HANDLE hfile = CreateFile(sz_path, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, NULL, NULL);
if ( hfile != INVALID_HANDLE_VALUE )
{
DWORD dw_write = 0;
ReadFile(hfile, g_default_map, sizeof(g_default_map), &dw_write, NULL);
if ( dw_write != sizeof(g_default_map) )
{
nRet = false;
}
CloseHandle(hfile);
}
return nRet;
}
float GetContrast(int level)
{
float ret=0.0;
switch (level)
{
case -3:
ret=-1000.0;
break;
case -2:
ret=-666.0;
break;
case -1:
ret=-333.0;
break;
case 1:
ret=333.0;
break;
case 2:
ret=666.0;
break;
case 3:
ret=1000.0;
break;
}
return ret;
}
*/
VOID XdPrint(_TCHAR* format, ...)
{
va_list args;
va_start(args, format);
_TCHAR buf[256];
_vstprintf(buf, format, args);
OutputDebugString(buf);
va_end(args);
}

324
HuaGoCorrect/PublicFunc.h Normal file
View File

@ -0,0 +1,324 @@
#ifndef PUBLICFUNC_H_
#define PUBLICFUNC_H_
#include "stdafx.h"
#include <string>
//#include "UI_INI.h"
//#include "DirectshowCaptureVideo.h"
//#include "DirectshowCaptureVideoUvc.h"
using namespace std;
#define PIXTYPE "iPixType"
#define PAPARSIZE "iPaparSize"
#define RESOLUTION "iResolution"
#define DUPLEX "iDuplex"
#define TABINDEX "iTabIndex"
#define OBJVALUE1 "fObjValue1"
#define OBJVALUE2 "fObjValue2"
#define OBJVALUE3 "fObjValue3"
#define OBJVALUE4 "fObjValue4"
#define OBJVALUE5 "fObjValue5"
#define OBJVALUE6 "fObjValue6"
#define LIMITOFFSET1 "iLimitOffset1"
#define LIMITOFFSET2 "iLimitOffset2"
#define LIMITOFFSET3 "iLimitOffset3"
#define LIMITOFFSET4 "iLimitOffset4"
#define LIMITOFFSET5 "iLimitOffset5"
#define LIMITOFFSET6 "iLimitOffset6"
#define LOADNUM "iLoadNum"
#define XPOINT "iXPonit"
#define YPOINT "iYPoint"
#define PWIGHT "iWight"
#define PHEIGHT "iHeight"
#define MATCHPATH "MacthPath"
/************************************
**json格式保存参数名称**
*************************************/
/*
#define PIXTYPE "iPixType"
#define PAPARSIZE "iPaparSize"
#define AUTOCROP "bAuotCrop"
#define RESOLUTION "iResolution"
#define DUPLEX "iDuplex"
#define DISCARBLANK "bDiscardBlank"
#define DISCARBLANKVINCE "bDiscardBlankVince"
#define FLOD "bFlod"
#define BRIGHTNESS "iBrightness"
#define AUTOCONTRAST "bAutoContrast"
#define CONTRAST "iContrast"
#define GAMMA "dGamma"
#define FILTERTYPE "iFilter"
#define FILLBLACK "bFillBlcak"
#define AUTODESCREW "bAutoDescrew"
#define ULTRADETECT "bUltrasonicDetect"
#define BINDINGDETECT "bBindingDetect"
#define SCANCOUNT "ScanCount"
#define DOCORIENTATION "bOrientation"
#define BACKROTATE180 "iBackRotate180"
#define SCREWDETECT "bScrewDetect"
#define SCREWLEVEL "iScrewLevel"
#define ITEMCAPTION "Caption"
#define SAVEPATH "SavePath"
#define MULTIOUTPUT "iMultiOutPut"
#define OUTHOLE "bOutHole"
#define OUTHOLERATIO "iOutHoleRatio"
*/
/******************
****
*******************/
struct tagMATCHPARAMS
{
/*主界面参数*/
INT LoadNum;
INT XPoint;
INT YPoint;
INT PWight;
INT PHeight;
std::string MatchPath;
};
typedef tagMATCHPARAMS MATCHPARAMS, *PMATCHPARAMS;
struct tagCONFIGPARAMS_1
{
/*基本选项卡参数*/
INT Pixtype;
INT PaperSize;
BOOL EnAutoCrop;
INT Resolution;
INT Duplex;
BOOL EnDiscardBlank;
BOOL EnDiscardBlankVince;
BOOL EnFlod;
/*亮度对比度选项卡参数*/
INT Brightness;
BOOL EnAutoContrast;
INT Contrast;
INT Gamma;
/*图像处理选项卡参数*/
INT Filter;
BOOL EnFillBlack;
BOOL EnAutoDescrew;
//BOOL EnMulti
BOOL EnOutHole;
INT OutHoleRatio;
BOOL EnMultiOutPutR;
/*送纸部分选项卡参数*/
BOOL EnUltrasonicDetect;
BOOL EnBindingDetect;
INT ScanCount;
INT Orentation;
BOOL EnBackRotate180;
BOOL EnScrewDetect;
INT ScrewDetectLevel;
/*保存信息*/
std::string Caption;
std::string SavePath;
};
struct tagCONFIGINFO
{
std::string Caption;
std::string SavePath;
};
typedef struct tagCONFIGINFO CONFIGINFO,*PCONFIGINFO;
struct tagCONFIGPARAMS
{
/*主界面参数*/
INT Pixtype;
INT PaperSize;
INT Resolution;
INT Duplex;
INT TabIndex;
};
typedef tagCONFIGPARAMS CONFIGPARAMS, *PCONFIGPARAMS;
/*除穿孔*/
/*
struct tagOutHole
{
BOOL EnOutHole;
INT OutHoleRatio;
};
typedef tagOutHole OutHole,*pOutHole;
#define CAPTION_LEN 256
#define TWAIN_IMAGE_FILE_LIST_NAME TEXT(".dat")
#ifndef malloc_my
#define malloc_my malloc
#endif
*/
//#define TWSS_A4R 60
//enum TwSS
//{
// None = 0,
// A4Letter = 1,
// A4 = 1,
// B5Letter = 2,
// JISB5 = 2,
// B5 = 2,
// USLetter = 3,
// USLegal = 4,
// A5 = 5,
// B4 = 6,
// ISOB4 = 6,
// B6 = 7,
// ISOB6 = 7,
// USLedger = 9,
// USExecutive = 10,
// A3 = 11,
// B3 = 12,
// ISOB3 = 12,
// A6 = 13,
// C4 = 14,
// C5 = 15,
// C6 = 16,
// _4A0 = 17,
// _2A0 = 18,
// A0 = 19,
// A1 = 20,
// A2 = 21,
// A7 = 22,
// A8 = 23,
// A9 = 24,
// A10 = 25,
// ISOB0 = 26,
// ISOB1 = 27,
// ISOB2 = 28,
// ISOB5 = 29,
// ISOB7 = 30,
// ISOB8 = 31,
// ISOB9 = 32,
// ISOB10 = 33,
// JISB0 = 34,
// JISB1 = 35,
// JISB2 = 36,
// JISB3 = 37,
// JISB4 = 38,
// JISB6 = 39,
// JISB7 = 40,
// JISB8 = 41,
// JISB9 = 42,
// JISB10 = 43,
// C0 = 44,
// C1 = 45,
// C2 = 46,
// C3 = 47,
// C7 = 48,
// C8 = 49,
// C9 = 50,
// C10 = 51,
// USStatement = 52,
// BusinessCard = 53,
// A4R = 60,
// A5R = 61,
// A6R = 62,
// B5R = 70,
// B6R = 71,
// USLetterR = 80,
// DOUBLELetter = 81,
// AUTO = 90
//};
typedef struct tagTWAIN_IMAGE_FILE_LIST
{
INT n_item;//
TCHAR sz_path[MAX_PATH];
DWORD dw_color_bit;
DWORD dw_width;
DWORD dw_height;
DWORD dw_dpi;
DWORD dw_image_size;
BOOL b_del_flg;//文件时是否删除, 传送一个删除一个
}TWAIN_IMAGE_FILE_LIST,FAR*PTWAIN_IMAGE_FILE_LIST;
typedef struct tagTWAIN_IMAGE_DATA_INFO
{
BOOL b_lock_flg;//是否在使用中
//BOOL b_flg;
TCHAR sz_path_dir[MAX_PATH];//文件目录
//IMAGE_BMP_INFO st_bmp_info;//图像信息
PTWAIN_IMAGE_FILE_LIST p_wifl;
INT n_wifl_count;//内存大小
INT n_wifl_cur_count;//当前使用内存个数
INT n_wifl_cur_pos;//当前传送内存位置
}TWAIN_IMAGE_DATA_INFO, FAR*PTWAIN_IMAGE_DATA_INFO;
//void initialDictionary();
//CSize getSize(TwSS paperType, float dpi);
DWORD ReadTwianImageData(TCHAR *p_file_path);
BOOL WriteTwianImageData(TCHAR *p_file_path, PBYTE p_data, DWORD dw_size);
BOOL MallocTwainFileListMem();
VOID FreeTwainFileListMem();
//取得用户自定义目录,参数 窗口句柄,当前目录, 显示在浏览对话框上的字符串
TCHAR* GetUserCustomFilePath(HWND hWin, LPSTR lpFilePath, TCHAR *lp_head_text = NULL);
//取得当前模块的文件路径, 参数,模块实列举并, 文件路径, 字符串的长度
TCHAR* GetCurExeFilePath(HINSTANCE hInstance, TCHAR* lpPath, DWORD dwSize);
//取得路径中已经存在的路径,并返回
TCHAR* GetExistFileDir(TCHAR* p_file_path);
//回调函数,取得用户自定义的文件路径
DWORD CALLBACK BrowserCallbackProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ;
std::string UtfToString(std::string strValue);
std::string StringToUtf(std::string strValue);
//检查,创建文件夹, 参数 文件路径, = 真,创建p_file_path不寻在文件路径
BOOL CheckAndCreateFileDir(TCHAR* p_file_path, BOOL flg);
BOOL CheckDiskFreeBitM(HWND hWin, TCHAR *p_disk_name, DWORD dw_min_bit_m);
HBITMAP SetButtonStaticBkBmp(HINSTANCE hInst, HWND hWin, UINT id, UINT iamge_id);
DWORD MyMessageBox(TCHAR *p_str, TCHAR *p_str2, DWORD dw_id);
extern TWAIN_IMAGE_DATA_INFO g_st_twain_bmp_info;
//extern CDirectshowCaptureVideo g_dc_video;
extern BOOL g_b_show_ui_flg;
//extern WATER_PRO g_st_water_pro;
extern BOOL g_add_water_flg;
extern DWORD g_dw_white_bright_count;
//extern CDirectshowCaptureVideoUvc g_dc_uvc_video;
extern BOOL g_b_use_uvc_dev ;
extern BOOL g_b_brigth_show_flg;
extern HWND g_hwnd_dlg;
//extern CSysMutex g_sys_mutex;
typedef enum tagSYS_MUTEX_TYPE
{
SYSMUTEX_APP_RUN_TYPE,// ok
SYSMUTEX_TWAIN_RUN_TYPE,
SYSMUTEX_APP_SCANNER_RUN_TYPE,
SYSMUTEX_TWAIN_SCANNER_RUN_TYPE
}SYS_MUTEX_TYPE, FAR* PSYS_MUTEX_TYPE;
BOOL g_InitSysMutexRun();
BOOL g_InitSysMutexScanRun(DWORD dwPid, DWORD dwUid);
BOOL g_CloseSysMutexRun();
BOOL g_CloseOneSysMutexRun();
BOOL g_CreateSysMutex();
BOOL g_CheckSysMutex();
float GetContrast(int level);
VOID XdPrint(_TCHAR* format, ...);
extern BOOL g_not_user_sineng_dev;
extern RGBQUAD g_default_map[256];
BOOL ReadDefaultMap();
#endif

74
HuaGoCorrect/ReadMe.txt Normal file
View File

@ -0,0 +1,74 @@
================================================================================
MICROSOFT 基础类库: HuaGoCorrect 项目概述
===============================================================================
应用程序向导已为您创建了这个 HuaGoCorrect 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。
本文件概要介绍组成 HuaGoCorrect 应用程序的每个文件的内容。
HuaGoCorrect.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件。
它包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
HuaGoCorrect.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。
它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
HuaGoCorrect.h
这是应用程序的主要头文件。它包括其他项目特定的头文件(包括 Resource.h),并声明 CHuaGoCorrectApp 应用程序类。
HuaGoCorrect.cpp
这是包含应用程序类 CHuaGoCorrectApp 的主要应用程序源文件。
HuaGoCorrect.rc
这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源位于 2052 中。
res\HuaGoCorrect.ico
这是用作应用程序图标的图标文件。此图标包括在主要资源文件 HuaGoCorrect.rc 中。
res\HuaGoCorrect.rc2
此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。
/////////////////////////////////////////////////////////////////////////////
应用程序向导创建一个对话框类:
HuaGoCorrectDlg.hHuaGoCorrectDlg.cpp - 对话框
这些文件包含 CHuaGoCorrectDlg 类。该类定义应用程序主对话框的行为。该对话框的模板位于 HuaGoCorrect.rc 中,该文件可以在 Microsoft Visual C++ 中进行编辑。
/////////////////////////////////////////////////////////////////////////////
其他功能:
ActiveX 控件
应用程序包括对使用 ActiveX 控件的支持。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.hStdAfx.cpp
这些文件用于生成名为 HuaGoCorrect.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
Resource.h
这是标准头文件,它定义新的资源 ID。
Microsoft Visual C++ 读取并更新此文件。
HuaGoCorrect.manifest
应用程序清单文件供 Windows XP 用来描述应用程序
对特定版本并行程序集的依赖性。加载程序使用此
信息从程序集缓存加载适当的程序集或
从应用程序加载私有信息。应用程序清单可能为了重新分发而作为
与应用程序可执行文件安装在相同文件夹中的外部 .manifest 文件包括,
也可能以资源的形式包括在该可执行文件中。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”指示应添加或自定义的源代码部分。
如果应用程序在共享的 DLL 中使用 MFC则需要重新发布这些 MFC DLL如果应用程序所用的语言与操作系统的当前区域设置不同则还需要重新发布对应的本地化资源 MFC100XXX.DLL。有关这两个主题的更多信息请参见 MSDN 文档中有关 Redistributing Visual C++ applications (重新发布 Visual C++ 应用程序)的章节。
/////////////////////////////////////////////////////////////////////////////

BIN
HuaGoCorrect/Resource.h Normal file

Binary file not shown.

335
HuaGoCorrect/UsbScanEx.cpp Normal file
View File

@ -0,0 +1,335 @@
#include "stdafx.h"
#include "UsbScanEx.h"
#include <tchar.h>
#include <winioctl.h>
UsbScanEx::UsbScanEx(int index)
{
m_h_dev = INVALID_HANDLE_VALUE;
timeout = 100;
m_h_index = index;
memset(ov, 0, sizeof(ov));
CTRL_IN_OUT = 3;
for (int i = 0; i < (sizeof(ov) / sizeof(ov[0])); i++)
ov[i].hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
}
UsbScanEx::~UsbScanEx()
{
if (m_h_dev != INVALID_HANDLE_VALUE)
close();
for (int i = 0; i < (sizeof(ov) / sizeof(ov[0])); i++)
CloseHandle(ov[i].hEvent);
}
bool UsbScanEx::open()
{
BOOL b_ret = FALSE;
TCHAR szDevPath[MAX_PATH] = { 0 };
DWORD cbRet = 0;
USBSCAN_TIMEOUT ut;
ut.TimeoutEvent = 1;
ut.TimeoutRead = 1;
ut.TimeoutWrite = 1;
_stprintf(szDevPath, TEXT("\\\\.\\Usbscan%d"), m_h_index);
m_h_dev = CreateFile(szDevPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (m_h_dev != INVALID_HANDLE_VALUE) {
m_b_is_connected = TRUE;
b_ret = DeviceIoControl(m_h_dev, (DWORD)IOCTL_GET_PIPE_CONFIGURATION,
NULL, 0, &m_usbscan_config, sizeof(USBSCAN_PIPE_CONFIGURATION),
&cbRet, NULL);
if (b_ret && m_usbscan_config.NumberOfPipes > 0) {
for (int by_i = 0x00; (ULONG)by_i < m_usbscan_config.NumberOfPipes; by_i++) {
TCHAR szPipePath[MAX_PATH] = { 0 };
_stprintf(szPipePath, TEXT("\\\\.\\Usbscan%d\\%d"), m_h_index, by_i);
m_usb_pipes[by_i].pipe_info = m_usbscan_config.PipeInfo[by_i];
m_usb_pipes[by_i].h_pipe = CreateFile(szPipePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (m_usbscan_config.PipeInfo[by_i].PipeType == USBSCAN_PIPE_INTERRUPT) {
INT_IN = by_i;
}
else {
if (m_usbscan_config.PipeInfo[by_i].EndpointAddress & 0x80) {
BULK_IN = by_i;
}
else {
BULK_OUT = by_i;
}
}
b_ret = DeviceIoControl(m_usb_pipes[by_i].h_pipe, IOCTL_SET_TIMEOUT, &ut, sizeof(ut), NULL, 0, &cbRet, NULL);
}
}
}
else {
CloseHandle(m_h_dev);
m_h_dev = INVALID_HANDLE_VALUE;
}
return m_h_dev;
}
bool UsbScanEx::close()
{
BOOL b_ret = FALSE;
BYTE by_i = 0x00;
if (m_h_dev != INVALID_HANDLE_VALUE) {
BOOL bState = FALSE;
DWORD cbRet = 0;
OVERLAPPED overlapped;
PIPE_TYPE pipeType = ALL_PIPE;
memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.hEvent =
CreateEvent(NULL, // pointer to security attributes
FALSE, // automatic reset
FALSE, // initialize to nosignaled
NULL); // pointer to the event-object name
bState =
DeviceIoControl(m_h_dev,
(DWORD)IOCTL_CANCEL_IO,
(LPVOID)&pipeType,
sizeof(PIPE_TYPE),
NULL,
0,
&cbRet,
&overlapped);
WaitForSingleObject(overlapped.hEvent, 1000);
CloseHandle(overlapped.hEvent);
for (by_i = 0x00; by_i < m_usbscan_config.NumberOfPipes; by_i++) {
CancelIo(m_usb_pipes[by_i].h_pipe);
CloseHandle(m_usb_pipes[by_i].h_pipe);
m_usb_pipes[by_i].h_pipe = INVALID_HANDLE_VALUE;
}
CancelIo(m_h_dev);
b_ret = CloseHandle(m_h_dev);
if (b_ret) {
m_h_dev = INVALID_HANDLE_VALUE;
b_ret = TRUE;
}
}
m_b_is_connected = FALSE;
return b_ret;
}
void UsbScanEx::set_timeout(int timeout)
{
this->timeout = timeout;
}
int UsbScanEx::read_bulk(void* data, int len)
{
BOOL b_ret = FALSE;
HANDLE h_pipe = m_usb_pipes[BULK_IN].h_pipe;
unsigned long pdw_ret = len;
LPOVERLAPPED lp_overlap = ov+BULK_IN;
lp_overlap->Internal = 0;
lp_overlap->InternalHigh = 0;
lp_overlap->Offset = 0;
lp_overlap->OffsetHigh = 0;
lp_overlap->Pointer = 0;
if (m_h_dev != NULL) {
b_ret = ReadFile(h_pipe, data, len, &pdw_ret, lp_overlap);
if (b_ret) {
return pdw_ret;
}
else {
switch (GetLastError())
{
case ERROR_IO_PENDING:
GetOverlappedResult(h_pipe, lp_overlap, &pdw_ret, TRUE);
return pdw_ret;
case ERROR_FILE_NOT_FOUND:
m_b_is_connected = false;
break;
default:
int a = 0;
break;
}
}
}
return 0;
}
int UsbScanEx::write_bulk(void* data, int len)
{
BOOL b_ret = FALSE;
HANDLE h_pipe = m_usb_pipes[BULK_OUT].h_pipe;
void* p_data = data;
unsigned long dw_size = len;
LPOVERLAPPED lp_overlap = ov + BULK_OUT;
if (m_h_dev == INVALID_HANDLE_VALUE)
return TRUE;
b_ret = WriteFile(h_pipe, p_data, dw_size, &dw_size, lp_overlap);
if (b_ret) {
return dw_size;
}
else {
switch (GetLastError())
{
case ERROR_IO_PENDING:
GetOverlappedResult(h_pipe, lp_overlap, &dw_size, TRUE);
return dw_size;
case ERROR_FILE_NOT_FOUND:
m_b_is_connected = false;
break;
default:
int a = 0;
break;
}
}
return 0;
}
int UsbScanEx::control_msg(int rtype, int req, int value, int index, int len, void* data)
{
BOOL b_ret = FALSE;
_IO_BLOCK_EX irp;
DWORD dw_ret;
if (m_h_dev == INVALID_HANDLE_VALUE)
return TRUE;
irp.uOffset = value;
irp.uLength = len;
irp.uIndex = index;
irp.pbyData = (LPBYTE)data;
irp.fTransferDirectionIn = (rtype >> 7);
irp.bRequest = req;
irp.bmRequestType = (rtype >> 5) & 0x03;
LPOVERLAPPED lp_overlap = ov + CTRL_IN_OUT;
b_ret = DeviceIoControl(m_h_dev, IOCTL_SEND_USB_REQUEST, &irp, sizeof(irp), data, len, &dw_ret, lp_overlap);
if (!b_ret)
b_ret = WaitForSingleObject(lp_overlap->hEvent, timeout) == WAIT_OBJECT_0;
return b_ret;
}
bool UsbScanEx::is_open()
{
return m_h_dev != INVALID_HANDLE_VALUE;
}
bool UsbScanEx::is_connected()
{
return is_open();//m_b_is_connected;
}
int UsbScanEx::read_int(void* data, int len)
{
BOOL b_ret = FALSE;
DWORD dw_ret = 0L;
HANDLE h_pipe = m_usb_pipes[INT_IN].h_pipe;
LPOVERLAPPED lp_overlap = ov + INT_IN;
if (m_h_dev == INVALID_HANDLE_VALUE)
return FALSE;
b_ret = DeviceIoControl(h_pipe, (DWORD)IOCTL_WAIT_ON_DEVICE_EVENT, NULL, 0,
data, len, &dw_ret, lp_overlap);
if (b_ret) {
return dw_ret;
}
else {
switch (GetLastError())
{
case ERROR_IO_PENDING:
GetOverlappedResult(h_pipe, lp_overlap, &dw_ret, TRUE);
return dw_ret;
case ERROR_FILE_NOT_FOUND:
m_b_is_connected = false;
break;
default:
break;
}
}
return 0;
}
UsbScan_List::~UsbScan_List()
{
}
std::list<std::shared_ptr<IUsb>> UsbScan_List::find_all()
{
auto devs = find_all_usb();
std::list<std::shared_ptr<IUsb>> usbs;
for (auto inter = devs.begin(); inter != devs.end(); inter++) {
usbs.push_back(std::shared_ptr<IUsb>(new UsbScanEx(inter->index)));
}
return usbs;
}
std::list<std::shared_ptr<IUsb>> UsbScan_List::find_vid_pid(int vid, int pid)
{
auto devs = find_all_usb();
std::list<std::shared_ptr<IUsb>> usbs;
for (auto inter = devs.begin(); inter != devs.end(); inter++) {
if (inter->vid == vid && inter->pid == pid)
usbs.push_back(std::shared_ptr<IUsb>(new UsbScanEx(inter->index)));
}
return usbs;
}
std::list<usb_scan_dev_info> UsbScan_List::find_all_usb()
{
BOOL b_ret = FALSE;
DWORD cbRet = 0;
TCHAR szDevPath[MAX_PATH] = { 0 };
DEVICE_DESCRIPTOR dev_desc;
HANDLE h_dev;
std::list<usb_scan_dev_info> usbs;
usb_scan_dev_info dev_info;
for (int i = 0; i < 1024; i++) {
_stprintf(szDevPath, TEXT("\\\\.\\Usbscan%d"), i);
h_dev = CreateFile(szDevPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (h_dev != INVALID_HANDLE_VALUE) {
b_ret = DeviceIoControl(h_dev, (DWORD)IOCTL_GET_DEVICE_DESCRIPTOR,
&dev_desc, sizeof(dev_desc), &dev_desc, sizeof(dev_desc),
&cbRet, NULL);
if (b_ret != 0) {
dev_info.index = i;
dev_info.vid = dev_desc.usVendorId;
dev_info.pid = dev_desc.usProductId;
usbs.push_back(dev_info);
}
CloseHandle(h_dev);
}
}
return usbs;
}

76
HuaGoCorrect/UsbScanEx.h Normal file
View File

@ -0,0 +1,76 @@
#pragma once
#include <Windows.h>
#include <usbscan.h>
#include <memory>
#include <list>
#include "IUsb.h"
#pragma pack(1)
struct tag_usb_pipe
{
HANDLE h_pipe;
USBSCAN_PIPE_INFORMATION pipe_info;
OVERLAPPED overlap;
};
typedef struct tag_usb_pipe usb_pipe_t, * pusb_pipe_t;
#pragma pack()
typedef struct tag_usb_scan_dev_info
{
WORD vid;
WORD pid;
WORD index;
}usb_scan_dev_info, * pusb_scan_dev_info;
typedef struct tag_usb_scan_dev
{
USHORT _NumberOfDevs;
tag_usb_scan_dev_info dev_infos[1024];
}usb_scan_dev, * pusb_scan_dev;
class UsbScanEx : public IUsb
{
public:
UsbScanEx(int index);
virtual ~UsbScanEx();
// ͨ¹ý IUsb ¼Ì³Ð
virtual bool open() override;
virtual bool close() override;
virtual void set_timeout(int timeout) override;
virtual int read_bulk(void *data, int len) override;
virtual int write_bulk(void *data, int len) override;
virtual int control_msg(int rtype, int req, int value, int index, int len, void* data) override;
virtual bool is_open() override;
virtual bool is_connected() override;
virtual int read_int(void* data, int len) override;
private:
int BULK_OUT;
int BULK_IN;
int INT_IN;
int CTRL_IN_OUT;
USBSCAN_PIPE_CONFIGURATION m_usbscan_config;
usb_pipe_t m_usb_pipes[MAX_NUM_PIPES];
HANDLE m_h_dev;
bool m_b_is_connected;
int m_h_index;
int timeout;
OVERLAPPED ov[4];
};
class UsbScan_List
{
public:
~UsbScan_List();
static std::list<std::shared_ptr<IUsb>> find_all();
static std::list<std::shared_ptr<IUsb>> find_vid_pid(int vid, int pid);
private:
static std::list<usb_scan_dev_info> find_all_usb();
UsbScan_List();
UsbScan_List(unsigned short vendor_id, unsigned short product_id);
};

66
HuaGoCorrect/filetools.h Normal file
View File

@ -0,0 +1,66 @@
#pragma once
#include <vector>
#include <Windows.h>
#include <io.h>
#include <fstream>
class FileTools
{
public:
static std::vector<std::string> getFiles(std::string path)
{
std::vector<std::string> files;
getFiles(path, files);
return files;
}
static void write_log(std::string filepath, std::string log)
{
std::ofstream ofs(filepath, std::ios::app);
ofs << log << std::endl;
}
private:
static void getFiles(std::string path, std::vector<std::string>& files)
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
std::string p;
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo))!=-1)
{
do
{
//如果是目录,迭代之
//如果不是,加入列表
if ((fileinfo.attrib & _A_SUBDIR))
{
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
getFiles(p.assign(path).append("\\").append(fileinfo.name), files);
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
};
class StopWatch
{
public:
StopWatch() { valEnd = valStart = clock(); }
void start() { valStart = clock(); }
void stop() { valEnd =clock(); }
double time_run() { return (double)(valEnd - valStart)/CLOCKS_PER_SEC; }
private:
clock_t valStart;
clock_t valEnd;
};

894
HuaGoCorrect/gscn_drv.cpp Normal file
View File

@ -0,0 +1,894 @@
#include "stdafx.h"
#include "gscn_drv.h"
#include "stdio.h"
#include "turbojpeg.h"
#include <map>
#include "jpeglib.h"
#include "HuaGoCorrect.h"
#include "HuaGoCorrectDlg.h"
#include <Windows.h>
#include "twain.h"
#include "filetools.h"
//extern CHuaGoCorrectDlg theApp;
//#define BYTE unsigned char
GScn_Drv::GScn_Drv()
: canUseDiscardBlank(false),selectDeviceIndex(-1),m_scannerType(-1)
, device_id(0)
{
XdPrint("Init GScn_Drv() \n");
devState = DEV_STOP;
isDuplex=TRUE;
InitMSGMap();
InitScannerDiviceMap();
}
GScn_Drv::~GScn_Drv()
{
if (m_threadUsb.joinable())
{
devState = DEV_STOP;
m_threadUsb.join();
XdPrint("m_threadUsb Released True 22222222222222222222222 \n");
}
XdPrint("~ GScn_Drv() \n");
}
void GScn_Drv::save_config(bool saveOrigin, bool saveFixedOrigin)
{
m_pImages.UpdateSaveConfig(saveOrigin, saveFixedOrigin);
}
void GScn_Drv::InitMSGMap()
{
if (ntcMsg.size()>0)
ntcMsg.clear();
ntcMsg[COUNT_MODE]="计数模式,请先退出计数模式!";
ntcMsg[NO_FEED]="无纸,请放置纸张!";
ntcMsg[OPEN_COVER]="扫描仪开盖!";
ntcMsg[FEED_IN_ERROR]="拾纸错误!";
ntcMsg[PAPER_JAM]="卡纸!";
ntcMsg[DETECT_DOUBLE_FEED]="双张!";
ntcMsg[DETECT_STAPLE]="订书针!";
ntcMsg[PAPER_SKEW]="纸张歪斜!";
ntcMsg[HARDWARE_ERROR]="硬件错误!";
ntcMsg[PC_SCAN_BUSY_or_ERROR]="PC错误";
}
void GScn_Drv::InitScannerDiviceMap()
{
if (devType.size()>0)
{
devType.clear();
}
devType["G100"]=G100;
devType["G200"]=G200;
devType["G300"]=G300;
devType["G400"]=G400;
devType["G500"]=G500;
}
static int iNum = 0;
void GScn_Drv::open(int vid, int pid,int index)
{
usb_scan_dev devs = Devices(vid, pid);
if (devs._NumberOfDevs != 0)
{
device_id = devs._CURNUMBER;
m_usb.open(devs.dev_infos[index].index);//同时存在多个同种扫描设备时默认选取第一个vid pid匹配的设备
selectDeviceIndex=index;
m_scannerType=G200;
}
}
void GScn_Drv::open(int vid)
{
usb_scan_dev devs = Devices(vid);
if (devs._NumberOfDevs != 0)
{
device_id = devs._CURNUMBER;
m_usb.open(devs.dev_infos[0].index);//同时存在多个同种扫描设备时默认选取第一个vid pid匹配的设备
selectDeviceIndex = 0;
m_scannerType = G200;
}
}
void GScn_Drv::close()
{
if (m_usb.is_connected())
{
m_usb.close();
}
}
static void DoEvents()
{
MSG msg;
if (PeekMessage(&msg
, NULL, 0, 0, PM_REMOVE))
{
DispatchMessage(&msg);
TranslateMessage(&msg);
}
}
cv::Mat GScn_Drv::popMat(int num)
{
cv::Mat image = m_pImages.popMat(num);
return image;
}
int GScn_Drv::aquire_image(cv::Mat& image,int num)
{
while (true)
{
if (Get_IsImageQueueEmpty())
{
DoEvents();
if (!is_scan())
break;
}
else
{
if (m_pImages.valid())
{
image = popMat(num);
return 0;
}
}
this_thread::sleep_for(std::chrono::milliseconds(2));
}
return -1;
}
int GScn_Drv::aquire_image(cv::Mat & image)
{
while (true)
{
if (Get_IsImageQueueEmpty())
{
DoEvents();
if (!is_scan())
break;
}
else
{
if (m_pImages.valid())
{
image = m_pImages.popMat();
return 0;
}
}
this_thread::sleep_for(std::chrono::milliseconds(2));
}
return -1;
}
int GScn_Drv::getMatSum()
{
int iSum = 0;
iSum = m_pImages.getMatSum();
return iSum;
}
void GScn_Drv::reset()
{
while (!m_pImages.empty())
{
m_pImages.clear();
}
}
void GScn_Drv::pushMat(JpegBuffer& data)
{
m_pImages.pushMat(data);
}
BOOL GScn_Drv::IsConnected()
{
//XdPrint("Check for Connected!\n");
return m_usb.is_connected();
}
cv::Mat GScn_Drv::Get_Img_Data(int bufferSize)
{
std::lock_guard<std::mutex> lck(m_Locker);
cv::Mat iData(1, bufferSize,CV_8UC1);
USBCB usbcb = { GET_IMAGE,0,bufferSize };
DWORD transfer;
//XdPrint("Get_Img_Data bulk_out GET_IMAGE CV_8UC1 \n.....................");
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
StopWatch sw;
sw.start();
//XdPrint("Get_Img_Data Read_Data bufferSize begin \n.....................");
m_usb.Read_Data(iData.data, bufferSize, 2000, &transfer);
sw.stop();
//XdPrint("GetDate Consume time %lf \n.....................................",sw.time_run());
return iData;
}
void GScn_Drv::run()
{
if (m_threadUsb.joinable())
{
devState = DEV_STOP;
m_threadUsb.join();
}
devState = DEV_ISRUNNING;
m_threadUsb = std::thread(&GScn_Drv::usbmain, this);
}
INT GScn_Drv::get_decompress_pix_type()
{
return pixType;
}
void GScn_Drv::set_decompress_pix_type(int pixtype)
{
if (pixtype==TWPT_RGB)//TWPT_RGB=2
{
pixType=TJPF_BGR;
XdPrint("TurboJpeg ————————————————————TJPF_BGR\n");
}
else
{
pixType=TJPF_GRAY;
XdPrint("TurboJpeg ————————————————————TJPF_GRAY\n");
}
}
void GScn_Drv::enableDiscardBlank(bool bVal)
{
canUseDiscardBlank=bVal;
}
void GScn_Drv::SetIsDuplex(BOOL value)
{
isDuplex=value;
m_pImages.setduplexflag(value);
}
void GScn_Drv::SetRotate(int rotateType)
{
m_rotate=rotateType;
}
void GScn_Drv::SetBackRotate(bool enBackRoate)
{
backRotate=enBackRoate;
}
std::vector<std::string> GScn_Drv::GetSerials(int vid,int pid)
{
usb_scan_dev devs=Devices(vid,pid);
for (int i=0;i<devs._NumberOfDevs;i++)
{
cscn_usb usb;
usb.open(devs.dev_infos[i].index);
if(!usb.is_connected())
{
return vcSerials;
}
string serial=" ";
DWORD nTransfer;
USBCB usbcb={GET_SERIAL,12,0};
usb.bulk_out(0x00,&usbcb,sizeof(USBCB),&nTransfer);
CString cslog;
cslog.Format("GetSerials Read_Data %d",usbcb.u32_Data);
//WriteLog(cslog);
usb.Read_Data(&serial[0],12,200,&nTransfer);
if (serial.length()>0)
{
vcSerials.push_back(serial);
}
usb.close();
}
return vcSerials;
}
void GScn_Drv::ActiveteUSB()
{
if (IsConnected())
{
DWORD transfer;
USBCB usbcb = { 1024,0 ,0 };
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
}
}
DWORD GScn_Drv::usbmain()
{
try
{
while (devState == DEV_ISRUNNING)
{
if (!IsConnected())
{
Sleep(200);
continue;
}
USBCB usbcb = Get_Scanner_Status();
//XdPrint("u32_CMD is %d, u32_Data is %d, u32_Count is %d \n", usbcb.u32_CMD, usbcb.u32_Data, usbcb.u32_Count);
switch (usbcb.u32_Data)
{
case HAVE_IMAGE:
{
int totalNum = usbcb.u32_Count;
DWORD transferCount = 0;
iNum++;
cv::Mat imgData = Get_Img_Data(totalNum);
switch(m_scannerType)
{
case G100:
case G200:
{
cv::Mat bufferF = imgData.clone();
cv::Mat bufferB = imgData.clone();
int j = 0;
int k = 0;
for (int i = 0; i < totalNum / 1024; i++)
{
if (imgData.data[1023 + i * 1024] == 0)
{
j++;
memcpy(&(bufferB.data[(j - 1) * 1023]), &(imgData.data[(j + k - 1) * 1024]), 1023);
}
else if (imgData.data[1023 + i * 1024] == 255)
{
k++;
memcpy(&(bufferF.data[(k - 1) * 1023]), &(imgData.data[(j + k - 1) * 1024]), 1023);
}
}
pushMat(JpegBuffer(bufferB,pixType,0,0));
pushMat(JpegBuffer(bufferF,pixType,1,0));
Pop_Image();
break;
}
case G300:
case G400:
case G500:
pushMat(JpegBuffer(imgData,pixType,0,0));
break;
default:
break;
}
break;
}
case STOP_SCAN:
{
devState = DEV_STOP;
//::PostMessage(HWND_BROADCAST,WM_MYMESSAGE,200,NULL);
break;
}
case COUNT_MODE:
case NO_FEED:
case OPEN_COVER:
case FEED_IN_ERROR:
//case PAPER_JAM:
case DETECT_DOUBLE_FEED:
case DETECT_STAPLE:
case PAPER_SKEW:
case HARDWARE_ERROR:
case PC_SCAN_BUSY_or_ERROR:
devState = DEV_WRONG;
break;
case NORMAL:
break;
default:
break;
}
this_thread::sleep_for(std::chrono::milliseconds(10));
}
return 0;
}
catch (CMemoryException* e)
{
XdPrint("CMemoryException");
}
catch (CFileException* e)
{
XdPrint("CFileException");
}
catch (CException* e)
{
XdPrint("CException");
}
}
///////////////////////////////////////////////////////////////////////////
void GScn_Drv::Config_Scanner(PUSBCB pUSBCB)
{
if (m_usb.is_connected())
{
std::lock_guard<std::mutex> lck(m_imgLocker);
DWORD transfer;
m_usb.bulk_out(0x00, pUSBCB, sizeof(USBCB), &transfer);
}
}
//void GScn_Drv::setlist(std::vector<std::shared_ptr<CImageApply> >list)
//{
// m_pImages.setlist(list);
//}
///////////////////////////////////////////////////////////////////////////
void GScn_Drv::Scanner_StartScan(UINT16 count)
{
//count = 0;
//XdPrint("Scanner_StartScan.............\n");
if (m_usb.is_connected())
{
//XdPrint("Scanner Isconnected.............\n");
std::lock_guard<std::mutex> lck(m_imgLocker);
DWORD transfer;
USBCB usbcb = { START_COMMAND,AUTO_SCAN_MODE ,0 };
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
iNum = 0;
m_pImages.pixType=pixType;
m_pImages.SetDevModel(m_scannerType);
m_pImages.SetFilePath(csPath);
m_pImages.run();
run();
}
}
void GScn_Drv::Set_Scanner_Correct_Ratio(float hrz, float vtc)
{
if (m_usb.is_connected()) {
lock_guard<mutex> lck(m_imgLocker);
UINT32 hv = *(UINT32*)(&hrz);
USBCB usbcbH = { SET_JUST_COF_H,hv,0 };
DWORD transfer;
m_usb.bulk_out(0x00,&usbcbH,sizeof(usbcbH), &transfer);
this_thread::sleep_for(std::chrono::milliseconds(200));
UINT32 vv = *(UINT32*)(&vtc);
USBCB usbcbV = { SET_JUST_COF_V,vv,0 };
m_usb.bulk_out(00,&usbcbV, sizeof(usbcbV),&transfer);
}
}
void GScn_Drv::Get_Scanner_Correct_Ratio(float& hrz, float& vtc)
{
if (m_usb.is_connected()) {
lock_guard<mutex> lck(m_imgLocker);
USBCB usbcb = { GET_JUST_COF_H ,0,0 };
DWORD transfer;
m_usb.bulk_out(00,&usbcb, sizeof(usbcb),&transfer);
m_usb.bulk_in(00,&usbcb, sizeof(usbcb),200, &transfer);
float hratio = *((float*)(&usbcb.u32_Data));
hrz = hratio;
usbcb = { GET_JUST_COF_V ,0,0 };
m_usb.bulk_out(00, &usbcb, sizeof(usbcb), &transfer);
m_usb.bulk_in(00, &usbcb, sizeof(usbcb),200, &transfer);
float vratio = *((float*)(&usbcb.u32_Data));
vtc = vratio;
}
}
///////////////////////////////////////////////////////////////////////////
std::string GScn_Drv::GetFWVersion()
{
if (m_usb.is_connected())
{
std::lock_guard<std::mutex> lck(m_imgLocker);
std::string pFWVersion = " ";
USBCB usbcb = { GET_FW_VERSION,8,0 };
DWORD transfer;
XdPrint("Get GetFWVersion");
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
CString cslog;
cslog.Format("GetFWVersion Read_Data %d",usbcb.u32_Data);
//WriteLog(cslog);
m_usb.Read_Data(&pFWVersion[0], 8, 200, &transfer);
return pFWVersion;
}
return "";
}
void GScn_Drv::SetSerialNum(byte *pvalue)
{
if (m_usb.is_connected())
{
std::lock_guard<std::mutex> lck(m_imgLocker);
for (UINT i = 0; i < 12; i = i + 4)
{
USBCB usbcb;
usbcb.u32_CMD = SEND_SERIAL;
usbcb.u32_Data = (UINT)pvalue[i] + ((UINT)pvalue[i + 1] << 8) + ((UINT)pvalue[i + 2] << 16) + ((UINT)pvalue[i + 3] << 24);
usbcb.u32_Count = i;
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//m_usb.bulk_out(0x00, &pvalue, 12, &transfer);
Sleep(1000);
}
}
return;
}
int GScn_Drv::GetScanNum()
{
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { GET_SCANN_NUM,0,4 };
DWORD transfer;
XdPrint("Get GetScanNum");
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
CString cslog;
cslog.Format("GetScanNum Read_Data %d",usbcb.u32_Data);
//WriteLog(cslog);
m_usb.Read_Data(&usbcb, sizeof(usbcb), 200, &transfer);
return usbcb.u32_Data;
}
void GScn_Drv::ClrRollerNum()
{
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { CLR_ROLLER_NUM,0,4 };
DWORD transfer;
XdPrint("Get ClrRollerNum");
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
return;
}
void GScn_Drv::ClrScanNum()
{
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { CLR_SCAN_NUM,0,4 };
DWORD transfer;
XdPrint("Get ClrScanNum");
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
return;
}
void GScn_Drv::SendColorCorrentFlat(byte buffer[],int size)
{
DWORD transfer;
byte temp[524] = {0};
for(int i = 0; i<524;i++)
{
temp[i] = buffer[i];
}
m_usb.bulk_out(0x00, &temp, size, &transfer);
return;
}
void GScn_Drv::SendColorFlat(byte buffer[],int size)
{
DWORD transfer;
byte temp[524] = {0};
for(int i = 0; i<524;i++)
{
temp[i] = buffer[i];
}
m_usb.bulk_out(0x00, &temp, size, &transfer);
return;
}
void GScn_Drv::SendGrayCorrectFlat(byte buffer[],int size)
{
DWORD transfer;
byte temp[524] = {0};
for(int i = 0; i<524;i++)
{
temp[i] = buffer[i];
}
m_usb.bulk_out(0x00, &temp, size, &transfer);
return;
}
void GScn_Drv::SendGrayFlat(byte buffer[],int size)
{
DWORD transfer;
byte temp[524] = {0};
for(int i = 0; i<524;i++)
{
temp[i] = buffer[i];
}
m_usb.bulk_out(0x00, &temp, size, &transfer);
return;
}
byte* GScn_Drv::GetFlatData()
{
byte buffer[512] = {0};
USBCB usbcb = { GET_FLAT_DATA,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
CString cslog;
cslog.Format("GetFlatData Read_Data %d",usbcb.u32_Data);
//WriteLog(cslog);
m_usb.Read_Data(&buffer, 512, 200, &transfer);
return buffer;
}
byte* GScn_Drv::GetCisPara()
{
byte buffer[16] = {0};
USBCB usbcb = { GET_CIS_PARA,0,16 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
CString cslog;
cslog.Format("GetCisPara Read_Data %d",usbcb.u32_Data);
//WriteLog(cslog);
m_usb.Read_Data(&buffer, 16, 200, &transfer);
return buffer;
}
bool GScn_Drv::FlatA4()
{
if (!m_usb.is_connected())
{
return false;
}
//XdPrint("下发START_FLAT \n.....................");
USBCB usbcb = { START_FLAT,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//XdPrint("下发START_FLAT完成 \n.....................");
//Sleep(1500);
if(devState != DEV_ISRUNNING)
{
//XdPrint("DEV_ISRUNNING \n.....................");
devState = DEV_ISRUNNING;
}
//iNum = 0;
m_pImages.pixType=pixType;
m_pImages.SetDevModel(m_scannerType);
m_pImages.SetFilePath(csPath);
m_pImages.run();
return true;
}
bool GScn_Drv::FlatA4Conrrect()
{
char cTime[32];
CTime currTime = CTime::GetCurrentTime();
_snprintf(cTime, 30, "[%04d-%02d-%02d %02d:%02d:%02d]",
currTime.GetYear(), currTime.GetMonth(), currTime.GetDay(),
currTime.GetHour(), currTime.GetMinute(), currTime.GetSecond());
if (!m_usb.is_connected())
{
XdPrint("%s m_usb 未连接 \n...................", cTime);
return false;
}
//XdPrint("%s 下发START_FLAT \n.....................", cTime);
USBCB usbcb = { START_FLAT,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//XdPrint("%s 下发START_FLAT完成 \n.................", cTime);
//Sleep(1500);
if(devState != DEV_ISRUNNING)
{
//XdPrint("%s DEV_ISRUNNING \n.....................", cTime);
devState = DEV_ISRUNNING;
}
return true;
}
bool GScn_Drv::FlatA3(UINT para)
{
if (!m_usb.is_connected())
{
return false;
}
USBCB usbcb = { START_FLAT,para,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
Sleep(1500);
devState = DEV_ISRUNNING;
m_pImages.pixType=pixType;
m_pImages.SetDevModel(m_scannerType);
m_pImages.SetFilePath(csPath);
m_pImages.run();
return true;
}
void GScn_Drv::DevStateChange()
{
devState = DEV_STOP;
}
bool GScn_Drv::SendrAdPara(UINT para)
{
if (!m_usb.is_connected())
{
return false;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { ADI_PARA,para,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//Sleep(500);
return true;
}
bool GScn_Drv::SendrRgbAdPara(UINT para)
{
if (!m_usb.is_connected())
{
return false;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { RGB_ADI_PARA,para,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//Sleep(500);
return true;
}
bool GScn_Drv::SenGRPara(UINT para)
{
if (!m_usb.is_connected())
{
return false;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { SEND_COMPONENTS_GR,para,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
Sleep(500);
return true;
}
bool GScn_Drv::SenGBPara(UINT para)
{
if (!m_usb.is_connected())
{
return false;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { SEND_COMPONENTS_GB,para,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
Sleep(500);
return true;
}
///////////////////////////////////////////////////////////////////////////
byte* GScn_Drv::GetSerialNum()
{
if (!m_usb.is_connected())
{
return false;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
byte buffer[16] = {0};
USBCB usbcb = { GET_SERIAL,0,12 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
XdPrint("GetSerialNum Read_Data %d",usbcb.u32_Data);
m_usb.Read_Data(&buffer, 16, 50, &transfer);
return buffer;
}
///////////////////////////////////////////////////////////////////////////
USBCB GScn_Drv::Get_Scanner_Status()
{
std::lock_guard<std::mutex> lck(m_imgLocker);
if (!m_usb.is_connected())
{
//XdPrint("Get_Scanner_Status Error\n");
USBCB errorType = { NO_COMMAND ,PC_SCAN_BUSY_or_ERROR ,0 };
return errorType;
}
//XdPrint("Get_Scanner_Status GET_DSP_STATUS bulk_out\n");
USBCB usbcb = { GET_DSP_STATUS ,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
//XdPrint("Get_Scanner_Status Read_Data %d \n",usbcb.u32_Data);
m_usb.Read_Data(&usbcb, sizeof(usbcb), 200, &transfer);
//XdPrint("Get_Scanner_Status return usbcb \n",usbcb.u32_Data);
return usbcb;
}
///////////////////////////////////////////////////////////////////////////
bool GScn_Drv::is_scan()
{
return devState == DEV_ISRUNNING;
}
///////////////////////////////////////////////////////////////////////////
BOOL GScn_Drv::Get_Scanner_PaperOn()
{
if (!m_usb.is_connected())
{
return FALSE;
}
USBCB usbcb = { GET_PAPER_STATUS ,0,0 };
DWORD transfer;
std::lock_guard<std::mutex> lck(m_imgLocker);
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
m_usb.bulk_in(0x00, &usbcb, sizeof(usbcb), 200, &transfer);
return usbcb.u32_Data != 0;
}
///////////////////////////////////////////////////////////////////////////
void GScn_Drv::Pop_Image()
{
if (!m_usb.is_connected())
{
return;
}
USBCB usbcb = { POP_IMAGE ,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
}
///////////////////////////////////////////////////////////////////////////
void GScn_Drv::Stop_scan()
{
if (!m_usb.is_connected())
{
return;
}
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { STOP ,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
}
void GScn_Drv::ResetScanner()
{
if (!m_usb.is_connected())
return;
std::lock_guard<std::mutex> lck(m_imgLocker);
USBCB usbcb = { INIT_HARDWARE_SYS ,0,0 };
DWORD transfer;
m_usb.bulk_out(0x00, &usbcb, sizeof(usbcb), &transfer);
}
///////////////////////////////////////////////////////////////////////////
bool GScn_Drv::Get_IsImageQueueEmpty()
{
bool bIsEmpty = m_pImages.empty();
return bIsEmpty;
}

375
HuaGoCorrect/gscn_drv.h Normal file
View File

@ -0,0 +1,375 @@
#pragma once
#include "scn_usb.h"
#include <memory>
#include <vector>
#include <string>
#include <queue>
#include <Windows.h>
#include "MutexEx.h"
#include "opencv2/core/core.hpp"
#include <opencv2\highgui\highgui.hpp>
#include "jpeglib.h"
#include <time.h>
#include <thread>
#include <mutex>
#include "ImageMatQueue.h"
#include <map>
#include "PublicFunc.h"
#include "HuaGoCorrect.h"
using namespace cv;
typedef struct tag_USBCB {
UINT32 u32_CMD;
UINT32 u32_Data;
UINT32 u32_Count;
}USBCB, *PUSBCB;
typedef struct tag_USBCBA4
{
UINT u32_Command; /* command to execute */
UINT u32_Data; /* generic data field */
UINT u32_Count; /* number of bytes to transfer */
byte buffer[512]; //=new byte[1024];
}USBCBA4, *PUSBCBA4;
//u32_CMD
enum tagUsbKeyWords :UINT32
{
//无命令
NO_COMMAND = 0,
//获取dsp 状态
GET_DSP_STATUS = 1,
//取图
GET_IMAGE = 2,
//销毁DSP中驻存的图
POP_IMAGE = 3,
//开始扫描命令
START_COMMAND = 4,
//停止扫描命令
STOP = 5,
//获取扫描仪扫描模式
GET_SCAN_MODE = 6,
//获取固件版本号
GET_FW_VERSION = 7,
//返回PC端的状态
SEND_STATUS_PC = 8,
//下发扫描配置参数
CONFIGURED_DATA = 9,
//下发固件信息
SEND_FW = 10,
//获取扫描参数
GET_CONFIG_DATA = 11,
//获取扫描总张数
GET_SCANN_NUM = 12,
//获取有无纸的状态
GET_PAPERFEEDER_STATUS = 13,
//DSP初始化
INIT_HARDWARE_SYS = 14,
//获取有无纸的状态
GET_PAPER_STATUS = 0x0d,
//下发元器件配置参数灰度LED R曝光时间
SEND_COMPONENTS_GR = 15,
//下发元器件配置参数LED G/B曝光时间
SEND_COMPONENTS_GB = 16,
//下发扫描模式
SEND_SCAN_MODE = 17,
//开始进行平场矫正
START_FLAT = 18,
//停止平场矫正
STOP_FLAT = 19,
//下发200dpi彩色平场矫正参数
SEND_200_COLOR_FLAT_DATA = 20,
//下发300dpi彩色平场矫正参数
SEND_300_COLOR_FLAT_DATA = 21,
//获取200dpi彩色平场矫正参数
GET_200_COLOR_FLAT_DATA = 22,
//获取300dpi彩色平场矫正参数
GET_300_COLOR_FLAT_DATA = 23,
//下发200dpi灰度平场校正参数
SEND_200_GRAY_FLAT_DATA = 24,
//下发300dpi灰度平场校正参数
SEND_300_GRAY_FLAT_DATA = 25,
//获取200DPI灰度平场校正参数
GET_200_GRAY_FLAT_DATA = 26,
//获取300DPI灰度平场校正参数
GET_300_GRAY_FLAT_DATA = 27,
//下发序列号命令
SEND_SERIAL = 28,
//获取序列号命令
GET_SERIAL = 29,
//获取滚轮张数
GET_ROLLER_NUM = 30,
//清零滚轮张数
CLR_ROLLER_NUM = 31,
//清零扫描总张数
CLR_SCAN_NUM = 32,
PRE_UPGRADE =33,
START_UPGRADE = 34,
RGB_ADI_PARA =35,
ADI_PARA =36,
GET_CIS_PARA =37,
SEND_COLOR_FLAT = 41,
SEND_COLORCORRECT_FLAT=42,
SEND_GRAY_FLAT=43,
SEND_GRAYCORRECT_FLAT=44,
GET_FLAT_DATA=45,
//设置横向畸变系数
SET_JUST_COF_H = 0x38,
//读取横向畸变系数
GET_JUST_COF_H = 0x39,
//设置纵向畸变系数
SET_JUST_COF_V = 0x41,
//读取纵向畸变系数
GET_JUST_COF_V
};
typedef enum tagUsbKeyWords UsbKeyWords, *PUsbKeyWords;
//u32_Data
enum tagUsbSupported
{
//停止扫描
SCAN_STOP = -2,
//异常
HAVE_ERROR = -1,
//正常状态
NORMAL = 0,
//开盖
OPEN_COVER = 1,
// 无纸
NO_FEED = 2,
// 搓纸失败
FEED_IN_ERROR = 4,
// 卡纸
PAPER_JAM = 8,
// 检测到双张
DETECT_DOUBLE_FEED = 16,
// 检测到订书钉
DETECT_STAPLE = 32,
// 纸张倾斜
PAPER_SKEW = 64,
// 自动模式
AUTO_SCAN_MODE = 65,
// 手动模式
MANAUL_SCAN_MODE = 66,
// 计数模式
COUNT_MODE = 67,
// 硬件错误
HARDWARE_ERROR = 68,
// FPGA崩溃
FPGA_ERROR = 68,
// 开始
START_SCAN = 69,
//停止
STOP_SCAN = 70,
//有图
HAVE_IMAGE = 71,
// 更新扫描参数
UPDATE_SCAN_PARAMETER = 72,
// PC繁忙或出错
PC_SCAN_BUSY_or_ERROR = 73
};
typedef enum tagUsbSupported UsbSupported, *PUsbSupported;
enum tagDevState
{
DEV_STOP = -1,
DEV_ISRUNNING,
DEV_WRONG
};
typedef enum tagDevState DevState, PDevState;
enum tagEventIndex
{
EVENT_IMAGE,
EVENT_NUM
};
enum tagDEVMODEL
{
G100=0,
G200,
G300,
G400,
G500
};
class twainImage
{
public:
twainImage(){}
~twainImage()
{
release();
}
twainImage(cv::Mat image,int side=-1)
{
this->m_image=image;
this->m_side=side;
this->m_width=image.cols;
this->m_height=image.rows;
}
bool empty()
{
return m_image.empty();
}
int GetWidth()
{
return m_image.cols;
}
int GetHeight()
{
return m_image.rows;
}
void release()
{
if (!m_image.empty())
{
m_image.release();
}
}
public:
cv::Mat m_image;
int m_side;
private:
int m_height;
int m_width;
};
class GScn_Drv
{
public:
GScn_Drv();
~GScn_Drv();
void save_config(bool saveOrigin, bool saveFixedOrigin);
void open(int vid, int pid,int index);
void open(int vid);
void close();
int aquire_image(cv::Mat& image,int num);
int aquire_image(cv::Mat& image);
BOOL IsConnected();
void Get_Scanner_Correct_Ratio(float & hrz, float & vtc);
std::string GetFWVersion();
byte* GetSerialNum();
bool is_scan();
USBCB Get_Scanner_Status();
BOOL Get_Scanner_PaperOn();
void Config_Scanner(PUSBCB pUSBCB);
//void setlist(std::vector<std::shared_ptr<CImageApply>> list);
void Scanner_StartScan(UINT16 count);
void Set_Scanner_Correct_Ratio(float hrz, float vtc);
void Stop_scan();
void ResetScanner();
bool Get_IsImageQueueEmpty();
void reset();
INT get_decompress_pix_type();
void set_decompress_pix_type(int pixtype);
void enableDiscardBlank(bool bVal);
void SetIsDuplex(BOOL value);
void SetRotate(int rotateType);
void SetBackRotate(bool enBackRoate);
std::vector<string> GetSerials(int vid,int pid);
void ActiveteUSB();
void SetSerialNum(byte *pvalue);
int GetScanNum();
void ClrRollerNum();
void ClrScanNum();
bool SendrAdPara(UINT para);
bool SendrRgbAdPara(UINT para);
bool SenGRPara(UINT para);
bool SenGBPara(UINT para);
void SendColorCorrentFlat(byte buffer[],int size);
void SendColorFlat(byte buffer[],int size);
void SendGrayCorrectFlat(byte buffer[],int size);
void SendGrayFlat(byte buffer[],int size);
byte* GetFlatData();
byte* GetCisPara();
bool FlatA4();
bool FlatA3(UINT para);
void DevStateChange();
int getMatSum();
void SetPath(CString csFilePath)
{
csPath = csFilePath;
}
CString GetPath()
{
return csPath;
}
void setlist(std::vector<std::shared_ptr<CImageApply> >list)
{
m_pImages.setlist(list);
}
bool FlatA4Conrrect();
ImageMatQueue m_pImages;
//HWND h;
int device_id;
bool isusbopened() { return m_usb.is_connected(); }
private:
cscn_usb m_usb;
volatile int devState;
volatile BOOL isDuplex;
std::mutex m_Locker;
std::mutex m_imgLocker;
int pixType;
int m_rotate;
bool backRotate;
BOOL canUseDiscardBlank;
std::thread m_threadUsb;
std::map<int,string> ntcMsg;
std::map<string,int> devType;
std::vector<string> vcSerials;
int selectDeviceIndex;
int m_scannerType;
CString csPath;
private:
void run();
cv::Mat popMat(int num);
void pushMat(JpegBuffer& data);
void InitMSGMap();
void InitScannerDiviceMap();
cv::Mat Get_Img_Data(int buffersize);
DWORD usbmain();
void Pop_Image();
};

View File

@ -0,0 +1,41 @@
#include "stdafx.h"
#include "imageprocess.h"
vector<uchar> histogram_bit8(uchar* data, int rows, int cols)
{
vector<int> hist_sum(static_cast<uint>(cols));
vector<uchar> hist(static_cast<uint>(cols));
for (int x = 0; x < cols; ++x)
{
for (int y = 0; y < rows; ++y)
{
hist_sum[static_cast<uint>(x)] += data[static_cast<uint>(y * cols + x)];
}
hist[static_cast<uint>(x)] = static_cast<uchar>(hist_sum[static_cast<uint>(x)] / rows);
}
return hist;
}
void histogram_bit32(uchar* data, int rows, int cols, vector<uchar>& r, vector<uchar>& g, vector<uchar>& b)
{
uint total = static_cast<uint>(rows * cols);
uchar* buffer_r = new uchar[total];
uchar* buffer_g = new uchar[total];
uchar* buffer_b = new uchar[total];
for (uint i = 0; i < total; ++i)
{
buffer_r[i] = data[i * 3 + 0];
buffer_g[i] = data[i * 3 + 1];
buffer_b[i] = data[i * 3 + 2];
}
r = histogram_bit8(buffer_r, rows, cols);
g = histogram_bit8(buffer_g, rows, cols);
b = histogram_bit8(buffer_b, rows, cols);
delete[] buffer_r;
delete[] buffer_g;
delete[] buffer_b;
}

View File

@ -0,0 +1,15 @@
#ifndef IMAGEPROCESS_H
#define IMAGEPROCESS_H
#include <vector>
using namespace std;
typedef unsigned char uchar;
typedef unsigned int uint;
vector<uchar> histogram_bit8(uchar* data, int rows, int cols = 3456);
void histogram_bit32(uchar* data, int rows, int cols, vector<uchar>& r, vector<uchar>& g, vector<uchar>& b);
#endif // IMAGEPROCESS_H

View File

@ -0,0 +1,8 @@
#pragma once
//#include <qglobal.h>
#if defined(GIMGPROC_LIBRARY)
#define GIMGPROC_SHARED_EXPORT Q_DECL_EXPORT
#else
#define GIMGPROC_SHARED_EXPORT Q_DECL_IMPORT
#endif

72
HuaGoCorrect/jpeglib.cpp Normal file
View File

@ -0,0 +1,72 @@
#include "stdafx.h"
#include "jpeglib.h"
#include "PublicFunc.h"
JpegLib::JpegLib()
:img_buffer(NULL), sizeBuffer(0)
{
handle = std::shared_ptr<void> (tjInitDecompress(),tjDestroy);
}
JpegLib::~JpegLib()
{
clear();
}
void JpegLib::clear()
{
img_buffer.reset();
sizeBuffer = 0;
}
cv::Mat JpegLib::decode(cv::Mat& buf, int pixelFormat)
{
if(buf.rows != 1)
return cv::Mat();
//XdPrint("==============decode cols is :%d ============\n",buf.cols);
decode(buf.data, buf.cols, pixelFormat);
return cv::Mat(getHeight(), getWidth() , pixelFormat == TJPF_BGR ? CV_8UC3 : CV_8UC1, getData());
}
void JpegLib::decode(unsigned char* buff, unsigned long buff_size, int pixelFormat)
{
tjDecompressHeader(handle.get(), buff, buff_size, &width, &height);
//XdPrint("==============tjDecompressHeader width is :%d height is : %d ============\n",width , height);
int size = width * height *tjPixelSize[pixelFormat];
if (sizeBuffer != size)
{
clear();
img_buffer = std::shared_ptr<unsigned char>(tjAlloc(size), tjFree);
sizeBuffer = size;
}
if (img_buffer)
{
//XdPrint("==============img_buffer buff_size is :%d ============\n",buff_size);
tjDecompress2(handle.get(), buff, buff_size, img_buffer.get(), width, 0, height, pixelFormat, 0);
//XdPrint("============== tjDecompress2 finish ============\n",buff_size);
}
}
int JpegLib::getWidth()
{
return width;
}
int JpegLib::getHeight()
{
return height;
}
int JpegLib::getBufferSize()
{
return sizeBuffer;
}
unsigned char* JpegLib::getData()
{
return img_buffer.get();
}

26
HuaGoCorrect/jpeglib.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
#include "turbojpeg.h"
#include <memory>
#include <opencv2\opencv.hpp>
class JpegLib
{
public:
JpegLib();
~JpegLib();
void clear();
cv::Mat decode(cv::Mat& buf, int pixelFormat);
void decode(unsigned char* buff, unsigned long buff_size, int pixelFormat);
int getWidth();
int getHeight();
int getBufferSize();
unsigned char* getData();
private:
std::shared_ptr<void> handle;
std::shared_ptr<unsigned char> img_buffer;
int sizeBuffer;
int width;
int height;
};

10
HuaGoCorrect/json.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef JSON_JSON_H_INCLUDED
# define JSON_JSON_H_INCLUDED
# include "autolink.h"
# include "value.h"
# include "reader.h"
# include "writer.h"
# include "features.h"
#endif // JSON_JSON_H_INCLUDED

11
HuaGoCorrect/localTime.h Normal file
View File

@ -0,0 +1,11 @@
#define YEAR0 1900
#define EPOCH_YR 1970
#define SECS_DAY (24L * 60L * 60L)
#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400)))
#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
#define FIRSTSUNDAY(timp) (((timp)->tm_yday - (timp)->tm_wday + 420) % 7)
#define FIRSTDAYOF(timp) (((timp)->tm_wday - (timp)->tm_yday + 420) % 7)
#define TIME_MAX ULONG_MAX
#define ABB_LEN 3
const int _ytab[2][12]= {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};

553
HuaGoCorrect/m_Dis.cpp Normal file
View File

@ -0,0 +1,553 @@
// m_Dis.cpp: 实现文件
//
#include "stdafx.h"
#include "HuaGoCorrect.h"
#include "m_Dis.h"
#include "afxdialogex.h"
#include "filetools.h"
#include "Config.h"
// m_Dis 对话框
IMPLEMENT_DYNAMIC(m_Dis, CDialog)
m_Dis::m_Dis(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_DIS_DIALOG1, pParent),
d_canget(false),
d_run(false),
m_iQA(0)
{
d_run = true;
d_thred = std::thread(&m_Dis::distortion, this);
}
m_Dis::~m_Dis()
{
if (d_thred.joinable())
{
d_run = false;
d_thred.join();
}
}
void m_Dis::SetEnableGetImage(bool enable)
{
d_canget = enable;
}
int iPic = 0;
int m_QA_num = 0;
void m_Dis::distortion()
{
while (d_run)
{
if (d_canget)
{
if (d_drv)
{
if (!d_drv->Get_IsImageQueueEmpty())
{
cv::Mat mat;
d_drv->aquire_image(mat);
if (!mat.empty())
{
iPic++;
curve(mat, iPic, d_distortonoaram);
}
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
void m_Dis::setgcn_drv(GScn_Drv * drv)
{
if ( d_drv!= drv)
d_drv = drv;
}
void m_Dis::updatadistorionparam()
{
CString str_edit[6], str_text[6];
GetDlgItem(IDC_EDIT2)->GetWindowText(str_edit[0]);
GetDlgItem(IDC_EDIT5)->GetWindowText(str_edit[1]);
GetDlgItem(IDC_EDIT8)->GetWindowText(str_edit[2]);
GetDlgItem(IDC_EDIT11)->GetWindowText(str_edit[3]);
GetDlgItem(IDC_EDIT14)->GetWindowText(str_edit[4]);
GetDlgItem(IDC_EDIT17)->GetWindowText(str_edit[5]);
GetDlgItem(IDC_EDIT3)->GetWindowText(str_text[0]);
GetDlgItem(IDC_EDIT6)->GetWindowText(str_text[1]);
GetDlgItem(IDC_EDIT9)->GetWindowText(str_text[2]);
GetDlgItem(IDC_EDIT12)->GetWindowText(str_text[3]);
GetDlgItem(IDC_EDIT15)->GetWindowText(str_text[4]);
GetDlgItem(IDC_EDIT18)->GetWindowText(str_text[5]);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_x1"), _T(str_edit[0]), INI_FILE_NAME);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_y1"), _T(str_edit[1]), INI_FILE_NAME);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_x2"), _T(str_edit[2]), INI_FILE_NAME);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_y2"), _T(str_edit[3]), INI_FILE_NAME);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_x3"), _T(str_edit[4]), INI_FILE_NAME);
::WritePrivateProfileString(_T("ObjValue"), _T("objvalue_y3"), _T(str_edit[5]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_x1"), _T(str_text[0]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_y1"), _T(str_text[1]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_x2"), _T(str_text[2]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_y2"), _T(str_text[3]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_x3"), _T(str_text[4]), INI_FILE_NAME);
::WritePrivateProfileString(_T("LimitOffset"), _T("limitoffset_y3"), _T(str_text[5]), INI_FILE_NAME);
for (int j = 0; j < 6; j++)
{
str_edit[j].ReleaseBuffer();
str_text[j].ReleaseBuffer();
}
d_distortonoaram = getdistorionparam();
}
DISTORTIONPARAMS m_Dis::getdistorionparam()
{
DISTORTIONPARAMS dis_config ;
CString str;
dis_config.LimitOffset[0] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_x1"), 0, INI_FILE_NAME);
dis_config.LimitOffset[1] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_y1"), 0, INI_FILE_NAME);
dis_config.LimitOffset[2] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_x2"), 0, INI_FILE_NAME);
dis_config.LimitOffset[3] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_y2"), 0, INI_FILE_NAME);
dis_config.LimitOffset[4] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_x3"), 0, INI_FILE_NAME);
dis_config.LimitOffset[5] = ::GetPrivateProfileInt(_T("LimitOffset"), _T("limitoffset_y3"), 0, INI_FILE_NAME);
dis_config.ObjValues[0] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_x1"), 0, INI_FILE_NAME);
dis_config.ObjValues[1] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_y1"), 0, INI_FILE_NAME);
dis_config.ObjValues[2] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_x2"), 0, INI_FILE_NAME);
dis_config.ObjValues[3] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_y2"), 0, INI_FILE_NAME);
dis_config.ObjValues[4] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_x3"), 0, INI_FILE_NAME);
dis_config.ObjValues[5] = ::GetPrivateProfileInt(_T("ObjValue"), _T("objvalue_y3"), 0, INI_FILE_NAME);
char text[20];
sprintf(text, "%d", dis_config.ObjValues[0]);
GetDlgItem(IDC_EDIT2)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.ObjValues[1]);
GetDlgItem(IDC_EDIT5)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.ObjValues[2]);
GetDlgItem(IDC_EDIT8)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.ObjValues[3]);
GetDlgItem(IDC_EDIT11)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.ObjValues[4]);
GetDlgItem(IDC_EDIT14)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.ObjValues[5]);
GetDlgItem(IDC_EDIT17)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[0]);
GetDlgItem(IDC_EDIT3)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[1]);
GetDlgItem(IDC_EDIT6)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[2]);
GetDlgItem(IDC_EDIT9)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[3]);
GetDlgItem(IDC_EDIT12)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[4]);
GetDlgItem(IDC_EDIT15)->SetWindowTextA(text);
sprintf(text, "%d", dis_config.LimitOffset[5]);
GetDlgItem(IDC_EDIT18)->SetWindowTextA(text);
return dis_config;
}
void m_Dis::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, d_edit_log);
DDX_Control(pDX, IDC_STATIC_1, d_result);
DDX_Control(pDX, IDC_STATIC_4, d_QArate);
DDX_Control(pDX, IDC_STATIC_3, d_sum);
DDX_Control(pDX, IDC_STATIC_2, d_qa_sum);
DDX_Control(pDX, IDC_EDIT2, d_x1_value);
}
BOOL m_Dis::OnInitDialog()
{
CDialog::OnInitDialog();
d_distortonoaram=getdistorionparam();
UpdateData(TRUE);
d_qa_sum.SetWindowTextA(_T(""));
d_QArate.SetWindowTextA(_T(""));
d_result.SetWindowTextA(_T(""));
d_sum.SetWindowTextA(_T(""));
UpdateData(FALSE);
return TRUE;
}
void m_Dis::MatToCImage(Mat& mat, CImage& cimage)
{
if (0 == mat.total())
{
return;
}
int nChannels = mat.channels();
if ((1 != nChannels) && (3 != nChannels))
{
return;
}
int nWidth = mat.cols;
int nHeight = mat.rows;
//重建cimage
cimage.Destroy();
cimage.Create(nWidth, nHeight, 8 * nChannels);
//拷贝数据
uchar* pucRow;//指向数据区的行指针
uchar* pucImage = (uchar*)cimage.GetBits();//指向数据区的指针
int nStep = cimage.GetPitch();//每行的字节数,注意这个返回值有正有负
if (1 == nChannels)//对于单通道的图像需要初始化调色板
{
RGBQUAD* rgbquadColorTable;
int nMaxColors = 256;
rgbquadColorTable = new RGBQUAD[nMaxColors];
cimage.GetColorTable(0, nMaxColors, rgbquadColorTable);
for (int nColor = 0; nColor < nMaxColors; nColor++)
{
rgbquadColorTable[nColor].rgbBlue = (uchar)nColor;
rgbquadColorTable[nColor].rgbGreen = (uchar)nColor;
rgbquadColorTable[nColor].rgbRed = (uchar)nColor;
}
cimage.SetColorTable(0, nMaxColors, rgbquadColorTable);
delete[]rgbquadColorTable;
}
for (int nRow = 0; nRow < nHeight; nRow++)
{
pucRow = (mat.ptr<uchar>(nRow));
for (int nCol = 0; nCol < nWidth; nCol++)
{
if (1 == nChannels)
{
*(pucImage + nRow * nStep + nCol) = pucRow[nCol];
}
else if (3 == nChannels)
{
for (int nCha = 0; nCha < 3; nCha++)
{
*(pucImage + nRow * nStep + nCol * 3 + nCha) = pucRow[nCol * 3 + nCha];
}
}
}
}
}
void m_Dis::curve(Mat src, int num, DISTORTIONPARAMS distor)
{
d_edit_log.Clear();
m_iQA = 0;
if (src.empty())
return;
Mat dst;
Mat temp_src = src.clone();
if (temp_src.channels() == 3)
cvtColor(src, src, cv::COLOR_BGR2GRAY);
cv::threshold(src, dst, 125, 255, cv::THRESH_OTSU);
std::vector<std::vector<cv::Point>> contours_temp;
std::vector<cv::Vec4i> hierarchy;
findContours(dst, contours_temp, hierarchy, cv::RETR_LIST);
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Point> centers;
CImage img;
MatToCImage(src, img);
int xt = src.cols;
int yt = src.rows;
CRect rectf;
int cx = img.GetWidth();
int cy = img.GetHeight();
CWnd *pWnd = GetDlgItem(IDC_STATIC_PIC);
if (pWnd == NULL)
return;
pWnd->GetClientRect(&rectf);
CDC *pDC = pWnd->GetDC();
SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
int max = (cx >= cy) ? cx : cy;
float scale = (float)((float)max /460.0f);
int nw = (int)(cx / scale);
int nh = (int)(cy / scale);
CPoint pos = rectf.TopLeft();
rectf = CRect(pos, CSize(nw, nh));
img.Draw(pDC->m_hDC, rectf);
ReleaseDC(pDC);
for (int j = 0, count = contours_temp.size(); j < count; j++)
{
cv::Rect rect = cv::boundingRect(contours_temp[j]);
double area = cv::contourArea(contours_temp[j]);
if (area < 40000) continue;
double v = static_cast<double>(cv::pow((double)(rect.width + rect.height) / 4, 2) * 3.1415926535898 / area);
if (v > 0.9 && v < 1.1)
{
cv::Point center(rect.x + rect.width / 2, rect.y + rect.height / 2);
bool enable = true;
if (!centers.empty())
for (int i = 0; i < centers.size(); i++)
if (cv::pow((double)(centers[i].x - center.x), 2) + cv::pow((double)(centers[i].y - center.y), 2) < 200)
{
enable = false;
break;
}
if (enable)
{
contours.push_back(contours_temp[j]);
centers.push_back(center);
}
}
}
CString strX1, strX2, strX3, strY1, strY2, strY3, strInfo, strSum, strQA, strQArate;
CString strX1Dev, strX2Dev, strX3Dev, strY1Dev, strY2Dev, strY3Dev;
int m_itemp = cv::min(3, static_cast<int>(contours.size()));
if (m_itemp < 3)
{
m_iQA++;
}
for (int j = 0, count = m_itemp; j < count; j++)
{
cv::Rect rect = cv::boundingRect(contours[j]);
if (j == 0)
{
strX1.Format("%d", rect.width);
strY1.Format("%d", rect.height);
strX1Dev.Format("%d", rect.width - distor.ObjValues[0]);
strY1Dev.Format("%d", rect.height - distor.ObjValues[1]);
if (rect.width > (distor.ObjValues[0] + distor.LimitOffset[0]) || rect.width < (distor.ObjValues[0] - distor.LimitOffset[0]))
{
m_iQA++;
}
if (rect.height > (distor.ObjValues[1] + distor.LimitOffset[1]) || rect.height < (distor.ObjValues[1] - distor.LimitOffset[1]))
{
m_iQA++;
}
}
else if (j == 1)
{
strX2.Format("%d", rect.width);
strY2.Format("%d", rect.height);
strX2Dev.Format("%d", rect.width - distor.ObjValues[2]);
strY2Dev.Format("%d", rect.height - distor.ObjValues[3]);
if (rect.width > (distor.ObjValues[2] + distor.LimitOffset[2]) || rect.width < (distor.ObjValues[2] - distor.LimitOffset[2]))
{
m_iQA++;
}
if (rect.height > (distor.ObjValues[3] + distor.LimitOffset[3]) || rect.height < (distor.ObjValues[3] - distor.LimitOffset[3]))
{
m_iQA++;
}
}
else
{
strX3.Format("%d", rect.width);
strY3.Format("%d", rect.height);
strX3Dev.Format("%d", rect.width - distor.ObjValues[4]);
strY3Dev.Format("%d", rect.height - distor.ObjValues[5]);
if (rect.width > (distor.ObjValues[4] + distor.LimitOffset[4]) || rect.width < (distor.ObjValues[4] - distor.LimitOffset[4]))
{
m_iQA++;
}
if (rect.height > (distor.ObjValues[5] + distor.LimitOffset[5]) || rect.height < (distor.ObjValues[5] - distor.LimitOffset[5]))
{
m_iQA++;
}
}
}
if (m_iQA == 0)
{
//GetDlgItem(IDC_RESULT)->SetWindowTextA("Succeed");
m_QA_num++;
}
//else
//{
// //GetDlgItem(IDC_RESULT)->SetWindowTextA("Failed");
// CString csImage;
// csImage.Format("d:\\error\\%d.jpg", (num));
// IplImage qqImg;
// qqImg = IplImage(temp_src);
// cvSaveImage(csImage, &qqImg);
// csImage.ReleaseBuffer();
//}
strSum.Format("%d", num);
strQA.Format("%d", m_QA_num);
strQArate.Format("%0.2f", (float)m_QA_num * 100 / num);
d_sum.SetWindowTextA(strSum);
d_qa_sum.SetWindowTextA(strQA);
d_QArate.SetWindowTextA(strQArate);
d_result.SetWindowTextA(m_iQA == 0 ? "PASS" : "FAIL");
GetDlgItem(IDC_EDIT4)->SetWindowTextA(strX1Dev);
GetDlgItem(IDC_EDIT7)->SetWindowTextA(strY1Dev);
GetDlgItem(IDC_EDIT10)->SetWindowTextA(strX2Dev);
GetDlgItem(IDC_EDIT13)->SetWindowTextA(strY2Dev);
GetDlgItem(IDC_EDIT16)->SetWindowTextA(strX3Dev);
GetDlgItem(IDC_EDIT19)->SetWindowTextA(strY3Dev);
strInfo.Format("第%d张 ", num);
if (m_iQA == 0)
{
strInfo += "1-X:" + strX1+"\r\n" + " 1-Y:" + strY1+"\r\n" + " 2-X:" + strX2 + "\r\n" + " 2-Y:" + strY2 + "\r\n" + " 3-X:" + strX3 + "\r\n" + " 3-Y:" + strY3 + " Succeed";
}
else
{
strInfo += "1-X:" + strX1 + "\r\n" + " 1-Y:" + strY1 + "\r\n" + " 2-X:" + strX2 + "\r\n" + " 2-Y:" + strY2 + "\r\n" + " 3-X:" + strX3 + "\r\n" + " 3-Y:" + strY3 + " Failed";
}
string strTest;
strTest = CT2A(strInfo.GetString());
FileTools::write_log("D:\\Distor.txt", strTest);
CString ss;
if (m_iQA == 0)
{
ss.Format("%d、\r\n 1-X:\t%s\r\n 1-Y:\t%s\r\n 2-X:\t%s\r\n 2-Y:\t%s\r\n 3-X:\t%s\r\n 3-Y:\t%s\r\n Succeed", num, strX1, strY1, strX2, strY2, strX3, strY3);
}
else
{
ss.Format("%d、\r\n 1-X:\t%s\r\n 1-Y:\t%s\r\n 2-X:\t%s\r\n 2-Y:\t%s\r\n 3-X:\t%s\r\n 3-Y:\t%s\r\n Failed", num, strX1, strY1, strX2, strY2, strX3, strY3);
}
strTip = "";
strTip += ss;
strTip += "\r\n";
d_edit_log.SetWindowText(strTip);
d_edit_log.LineScroll(d_edit_log.GetLineCount());
int size = sizeof(strTip);
if (size > 1024)
strTip.Empty();
strX1.ReleaseBuffer();
strX2.ReleaseBuffer();
strX3.ReleaseBuffer();
strY1.ReleaseBuffer();
strY2.ReleaseBuffer();
strY3.ReleaseBuffer();
strInfo.ReleaseBuffer();
ss.ReleaseBuffer();
}
void m_Dis::findContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy,int retr, int method , cv::Point offset )
{
CvMat c_image = src;
cv::MemStorage storage(cvCreateMemStorage());
CvSeq* _ccontours = nullptr;
cvFindContours(&c_image, storage, &_ccontours, sizeof(CvContour), retr, method, CvPoint(offset));
if (!_ccontours)
{
contours.clear();
return;
}
cv::Seq<CvSeq*> all_contours(cvTreeToNodeSeq(_ccontours, sizeof(CvSeq), storage));
size_t total = all_contours.size();
contours.resize(total);
cv::SeqIterator<CvSeq*> it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
reinterpret_cast<CvContour*>(c)->color = static_cast<int>(i);
int count = c->total;
int* data = new int[static_cast<size_t>(count * 2)];
cvCvtSeqToArray(c, data);
for (int j = 0; j < count; j++)
{
contours[i].push_back(cv::Point(data[j * 2], data[j * 2 + 1]));
}
delete[] data;
}
hierarchy.resize(total);
it = all_contours.begin();
for (size_t i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
int h_next = c->h_next ? reinterpret_cast<CvContour*>(c->h_next)->color : -1;
int h_prev = c->h_prev ? reinterpret_cast<CvContour*>(c->h_prev)->color : -1;
int v_next = c->v_next ? reinterpret_cast<CvContour*>(c->v_next)->color : -1;
int v_prev = c->v_prev ? reinterpret_cast<CvContour*>(c->v_prev)->color : -1;
hierarchy[i] = cv::Vec4i(h_next, h_prev, v_next, v_prev);
}
storage.release();
}
BEGIN_MESSAGE_MAP(m_Dis, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &m_Dis::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON4, &m_Dis::OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON6, &m_Dis::OnBnClickedButton6)
ON_BN_CLICKED(IDC_BUTTON7, &m_Dis::OnBnClickedButton7)
END_MESSAGE_MAP()
// m_Dis 消息处理程序
void m_Dis::OnBnClickedButton1()
{
//TODO: 在此添加控件通知处理程序代码
if (!d_drv->IsConnected())
{
MessageBox("扫描仪未连接!");
return;
}
CString hvs;
GetDlgItemText(IDC_EDIT20, hvs);
CString vvs;
GetDlgItemText(IDC_EDIT23, vvs);
float hv = _ttof(hvs.Trim().GetBuffer());
float vv = _ttof(vvs.Trim().GetBuffer());
d_drv->Set_Scanner_Correct_Ratio(hv, vv);
}
void m_Dis::OnBnClickedButton4()
{
//TODO: 在此添加控件通知处理程序代码
if (!d_drv->IsConnected())
{
MessageBox("扫描仪未连接!");
return;
}
std::string fwv;
fwv=d_drv->GetFWVersion();
std::string text = "当前版本为:" + fwv + "!\n版本过低,不支持读取!";
if (atoi(fwv.substr(fwv.length() - 3, fwv.length() - 1).c_str()) < 14)
{
MessageBox(text.c_str());
return;
}
float hv, vv;
d_drv->Get_Scanner_Correct_Ratio(hv, vv);
CString hvs;
hvs.Format(_T("% .4f"), hv);
SetDlgItemText(IDC_EDIT22, hvs);
CString vvs;
vvs.Format(_T("% .4f"), vv);
SetDlgItemText(IDC_EDIT21, vvs);
}
void m_Dis::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
getdistorionparam();
}
void m_Dis::OnBnClickedButton7()
{
// TODO: 在此添加控件通知处理程序代码
updatadistorionparam();
}

61
HuaGoCorrect/m_Dis.h Normal file
View File

@ -0,0 +1,61 @@
#pragma once
#include "DefHSStructure.h"
#include "afxwin.h"
#include "gscn_drv.h"
#include "JsonConfig.h"
#include <thread>
// m_Dis 对话框
class m_Dis : public CDialog
{
DECLARE_DYNAMIC(m_Dis)
public:
m_Dis(CWnd* pParent = nullptr); // 标准构造函数
virtual ~m_Dis();
DISTORTIONPARAMS d_distortonoaram;
GScn_Drv* d_drv;
std::thread d_thred;
int m_iQA;
CString strTip;
void SetEnableGetImage(bool enable);
void distortion();
void setgcn_drv(GScn_Drv* drv);
void updatadistorionparam();
DISTORTIONPARAMS getdistorionparam();
private:
volatile bool d_run;
volatile bool d_canget;
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIS_DIALOG1 };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
BOOL OnInitDialog();
void MatToCImage(Mat & mat, CImage & cimage);
void curve(Mat src, int num, DISTORTIONPARAMS distor);
void findContours(const cv::Mat & src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy, int retr = cv::RETR_LIST, int method = cv::CHAIN_APPROX_SIMPLE, cv::Point offset = cv::Point(0, 0));
DECLARE_MESSAGE_MAP()
public:
CComboBox d_range_combox;
CComboBox d_color_combox;
CComboBox d_dpi_combox;
CComboBox d_page_combox;
CEdit d_edit_log;
CButton d_result;
CStatic d_QArate;
CStatic d_sum;
CStatic d_qa_sum;
CEdit d_x1_value;
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton4();
afx_msg void OnBnClickedButton6();
afx_msg void OnBnClickedButton7();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

2229
HuaGoCorrect/pub/ddk/1394.h Normal file

File diff suppressed because it is too large Load Diff

1101
HuaGoCorrect/pub/ddk/61883.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,170 @@
#ifndef EXDISPID_H_
//+-------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
// File: exdispid.h
//
//--------------------------------------------------------------------------
//
// Dispatch IDS for IExplorer Dispatch Events.
//
#define DISPID_BEFORENAVIGATE 100 // this is sent before navigation to give a chance to abort
#define DISPID_NAVIGATECOMPLETE 101 // in async, this is sent when we have enough to show
#define DISPID_STATUSTEXTCHANGE 102
#define DISPID_QUIT 103
#define DISPID_DOWNLOADCOMPLETE 104
#define DISPID_COMMANDSTATECHANGE 105
#define DISPID_DOWNLOADBEGIN 106
#define DISPID_NEWWINDOW 107 // sent when a new window should be created
#define DISPID_PROGRESSCHANGE 108 // sent when download progress is updated
#define DISPID_WINDOWMOVE 109 // sent when main window has been moved
#define DISPID_WINDOWRESIZE 110 // sent when main window has been sized
#define DISPID_WINDOWACTIVATE 111 // sent when main window has been activated
#define DISPID_PROPERTYCHANGE 112 // sent when the PutProperty method is called
#define DISPID_TITLECHANGE 113 // sent when the document title changes
#define DISPID_TITLEICONCHANGE 114 // sent when the top level window icon may have changed.
#define DISPID_FRAMEBEFORENAVIGATE 200
#define DISPID_FRAMENAVIGATECOMPLETE 201
#define DISPID_FRAMENEWWINDOW 204
#define DISPID_BEFORENAVIGATE2 250 // hyperlink clicked on
#define DISPID_NEWWINDOW2 251
#define DISPID_NAVIGATECOMPLETE2 252 // UIActivate new document
#define DISPID_ONQUIT 253
#define DISPID_ONVISIBLE 254 // sent when the window goes visible/hidden
#define DISPID_ONTOOLBAR 255 // sent when the toolbar should be shown/hidden
#define DISPID_ONMENUBAR 256 // sent when the menubar should be shown/hidden
#define DISPID_ONSTATUSBAR 257 // sent when the statusbar should be shown/hidden
#define DISPID_ONFULLSCREEN 258 // sent when kiosk mode should be on/off
#define DISPID_DOCUMENTCOMPLETE 259 // new document goes ReadyState_Complete
#define DISPID_ONTHEATERMODE 260 // sent when theater mode should be on/off
#define DISPID_ONADDRESSBAR 261 // sent when the address bar should be shown/hidden
#define DISPID_WINDOWSETRESIZABLE 262 // sent to set the style of the host window frame
#define DISPID_WINDOWCLOSING 263 // sent before script window.close closes the window
#define DISPID_WINDOWSETLEFT 264 // sent when the put_left method is called on the WebOC
#define DISPID_WINDOWSETTOP 265 // sent when the put_top method is called on the WebOC
#define DISPID_WINDOWSETWIDTH 266 // sent when the put_width method is called on the WebOC
#define DISPID_WINDOWSETHEIGHT 267 // sent when the put_height method is called on the WebOC
#define DISPID_CLIENTTOHOSTWINDOW 268 // sent during window.open to request conversion of dimensions
#define DISPID_SETSECURELOCKICON 269 // sent to suggest the appropriate security icon to show
#define DISPID_FILEDOWNLOAD 270 // Fired to indicate the File Download dialog is opening
#define DISPID_NAVIGATEERROR 271 // Fired to indicate the a binding error has occured
#define DISPID_PRIVACYIMPACTEDSTATECHANGE 272 // Fired when the user's browsing experience is impacted
#define DISPID_NEWWINDOW3 273
#define DISPID_VIEWUPDATE 281 // Fired when the contents of a shell browser window change
#define DISPID_SETPHISHINGFILTERSTATUS 282 // Fired by the Phishing Filter API to signal what state the analysis is in
#define DISPID_WINDOWSTATECHANGED 283 // Fired to indicate that the browser window's visibility or enabled state has changed
#define DISPID_NEWPROCESS 284 // Fired when a navigation must be redirected due to Protected Mode
#define DISPID_THIRDPARTYURLBLOCKED 285 // Fired when a third-party url is blocked due to Privacy Advisor
#define DISPID_REDIRECTXDOMAINBLOCKED 286 // Fired when a x-domain redirect is blocked due to browser nav constant
// Printing events
#define DISPID_PRINTTEMPLATEINSTANTIATION 225 // Fired to indicate that a print template is instantiated
#define DISPID_PRINTTEMPLATETEARDOWN 226 // Fired to indicate that a print templete is completely gone
#define DISPID_UPDATEPAGESTATUS 227 // Fired to indicate that the spooling status has changed
// define the events for the shell window list
#define DISPID_WINDOWREGISTERED 200 // Window registered
#define DISPID_WINDOWREVOKED 201 // Window Revoked
#define DISPID_RESETFIRSTBOOTMODE 1
#define DISPID_RESETSAFEMODE 2
#define DISPID_REFRESHOFFLINEDESKTOP 3
#define DISPID_ADDFAVORITE 4
#define DISPID_ADDCHANNEL 5
#define DISPID_ADDDESKTOPCOMPONENT 6
#define DISPID_ISSUBSCRIBED 7
#define DISPID_NAVIGATEANDFIND 8
#define DISPID_IMPORTEXPORTFAVORITES 9
#define DISPID_AUTOCOMPLETESAVEFORM 10
#define DISPID_AUTOSCAN 11
#define DISPID_AUTOCOMPLETEATTACH 12
#define DISPID_SHOWBROWSERUI 13
#define DISPID_ADDSEARCHPROVIDER 14
#define DISPID_RUNONCESHOWN 15
#define DISPID_SKIPRUNONCE 16
#define DISPID_CUSTOMIZESETTINGS 17
#define DISPID_SQMENABLED 18
#define DISPID_PHISHINGENABLED 19
#define DISPID_BRANDIMAGEURI 20
#define DISPID_SKIPTABSWELCOME 21
#define DISPID_DIAGNOSECONNECTION 22
#define DISPID_CUSTOMIZECLEARTYPE 23
#define DISPID_ISSEARCHPROVIDERINSTALLED 24
#define DISPID_ISSEARCHMIGRATED 25
#define DISPID_DEFAULTSEARCHPROVIDER 26
#define DISPID_RUNONCEREQUIREDSETTINGSCOMPLETE 27
#define DISPID_RUNONCEHASSHOWN 28
#define DISPID_SEARCHGUIDEURL 29
#define DISPID_ADDSERVICE 30
#define DISPID_ISSERVICEINSTALLED 31
#define DISPID_ADDTOFAVORITESBAR 32
#define DISPID_BUILDNEWTABPAGE 33
#define DISPID_SETRECENTLYCLOSEDVISIBLE 34
#define DISPID_SETACTIVITIESVISIBLE 35
#define DISPID_CONTENTDISCOVERYRESET 36
#define DISPID_INPRIVATEFILTERINGENABLED 37
#define DISPID_SUGGESTEDSITESENABLED 38
#define DISPID_ENABLESUGGESTEDSITES 39
#define DISPID_NAVIGATETOSUGGESTEDSITES 40
#define DISPID_SHOWTABSHELP 41
#define DISPID_SHOWINPRIVATEHELP 42
#define DISPID_SHELLUIHELPERLAST 43
#define DISPID_ADVANCEERROR 10
#define DISPID_RETREATERROR 11
#define DISPID_CANADVANCEERROR 12
#define DISPID_CANRETREATERROR 13
#define DISPID_GETERRORLINE 14
#define DISPID_GETERRORCHAR 15
#define DISPID_GETERRORCODE 16
#define DISPID_GETERRORMSG 17
#define DISPID_GETERRORURL 18
#define DISPID_GETDETAILSSTATE 19
#define DISPID_SETDETAILSSTATE 20
#define DISPID_GETPERERRSTATE 21
#define DISPID_SETPERERRSTATE 22
#define DISPID_GETALWAYSSHOWLOCKSTATE 23
// Dispatch IDS for ShellFavoritesNameSpace Dispatch Events.
//
#define DISPID_FAVSELECTIONCHANGE 1
#define DISPID_SELECTIONCHANGE 2
#define DISPID_DOUBLECLICK 3
#define DISPID_INITIALIZED 4
#define DISPID_MOVESELECTIONUP 1
#define DISPID_MOVESELECTIONDOWN 2
#define DISPID_RESETSORT 3
#define DISPID_NEWFOLDER 4
#define DISPID_SYNCHRONIZE 5
#define DISPID_IMPORT 6
#define DISPID_EXPORT 7
#define DISPID_INVOKECONTEXTMENU 8
#define DISPID_MOVESELECTIONTO 9
#define DISPID_SUBSCRIPTIONSENABLED 10
#define DISPID_CREATESUBSCRIPTION 11
#define DISPID_DELETESUBSCRIPTION 12
#define DISPID_SETROOT 13
#define DISPID_ENUMOPTIONS 14
#define DISPID_SELECTEDITEM 15
#define DISPID_ROOT 16
#define DISPID_DEPTH 17
#define DISPID_MODE 18
#define DISPID_FLAGS 19
#define DISPID_TVFLAGS 20
#define DISPID_NSCOLUMNS 21
#define DISPID_COUNTVIEWTYPES 22
#define DISPID_SETVIEWTYPE 23
#define DISPID_SELECTEDITEMS 24
#define DISPID_EXPAND 25
#define DISPID_UNSELECTALL 26
#define EXDISPID_H_
#endif // EXDISPID_H_

View File

@ -0,0 +1,655 @@
/*
scarderr.mc
Error message codes from the Smart Card Resource Manager
These messages must be reconciled with winerror.w
They exist here to provide error messages on pre-Win2K systems.
*/
#ifndef SCARD_S_SUCCESS
//
// =============================
// Facility SCARD Error Messages
// =============================
//
#define SCARD_S_SUCCESS NO_ERROR
//
// Values are 32 bit values laid out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
// Define the facility codes
//
#define FACILITY_SYSTEM 0x0
#define FACILITY_SCARD 0x10
//
// Define the severity codes
//
#define STATUS_SEVERITY_WARNING 0x2
#define STATUS_SEVERITY_INFORMATIONAL 0x1
#define STATUS_SEVERITY_ERROR 0x3
//
// MessageId: SCARD_F_INTERNAL_ERROR
//
// MessageText:
//
// An internal consistency check failed.
//
#define SCARD_F_INTERNAL_ERROR ((DWORD)0x80100001L)
//
// MessageId: SCARD_E_CANCELLED
//
// MessageText:
//
// The action was cancelled by an SCardCancel request.
//
#define SCARD_E_CANCELLED ((DWORD)0x80100002L)
//
// MessageId: SCARD_E_INVALID_HANDLE
//
// MessageText:
//
// The supplied handle was invalid.
//
#define SCARD_E_INVALID_HANDLE ((DWORD)0x80100003L)
//
// MessageId: SCARD_E_INVALID_PARAMETER
//
// MessageText:
//
// One or more of the supplied parameters could not be properly interpreted.
//
#define SCARD_E_INVALID_PARAMETER ((DWORD)0x80100004L)
//
// MessageId: SCARD_E_INVALID_TARGET
//
// MessageText:
//
// Registry startup information is missing or invalid.
//
#define SCARD_E_INVALID_TARGET ((DWORD)0x80100005L)
//
// MessageId: SCARD_E_NO_MEMORY
//
// MessageText:
//
// Not enough memory available to complete this command.
//
#define SCARD_E_NO_MEMORY ((DWORD)0x80100006L)
//
// MessageId: SCARD_F_WAITED_TOO_LONG
//
// MessageText:
//
// An internal consistency timer has expired.
//
#define SCARD_F_WAITED_TOO_LONG ((DWORD)0x80100007L)
//
// MessageId: SCARD_E_INSUFFICIENT_BUFFER
//
// MessageText:
//
// The data buffer to receive returned data is too small for the returned data.
//
#define SCARD_E_INSUFFICIENT_BUFFER ((DWORD)0x80100008L)
//
// MessageId: SCARD_E_UNKNOWN_READER
//
// MessageText:
//
// The specified reader name is not recognized.
//
#define SCARD_E_UNKNOWN_READER ((DWORD)0x80100009L)
//
// MessageId: SCARD_E_TIMEOUT
//
// MessageText:
//
// The user-specified timeout value has expired.
//
#define SCARD_E_TIMEOUT ((DWORD)0x8010000AL)
//
// MessageId: SCARD_E_SHARING_VIOLATION
//
// MessageText:
//
// The smart card cannot be accessed because of other connections outstanding.
//
#define SCARD_E_SHARING_VIOLATION ((DWORD)0x8010000BL)
//
// MessageId: SCARD_E_NO_SMARTCARD
//
// MessageText:
//
// The operation requires a Smart Card, but no Smart Card is currently in the device.
//
#define SCARD_E_NO_SMARTCARD ((DWORD)0x8010000CL)
//
// MessageId: SCARD_E_UNKNOWN_CARD
//
// MessageText:
//
// The specified smart card name is not recognized.
//
#define SCARD_E_UNKNOWN_CARD ((DWORD)0x8010000DL)
//
// MessageId: SCARD_E_CANT_DISPOSE
//
// MessageText:
//
// The system could not dispose of the media in the requested manner.
//
#define SCARD_E_CANT_DISPOSE ((DWORD)0x8010000EL)
//
// MessageId: SCARD_E_PROTO_MISMATCH
//
// MessageText:
//
// The requested protocols are incompatible with the protocol currently in use with the smart card.
//
#define SCARD_E_PROTO_MISMATCH ((DWORD)0x8010000FL)
//
// MessageId: SCARD_E_NOT_READY
//
// MessageText:
//
// The reader or smart card is not ready to accept commands.
//
#define SCARD_E_NOT_READY ((DWORD)0x80100010L)
//
// MessageId: SCARD_E_INVALID_VALUE
//
// MessageText:
//
// One or more of the supplied parameters values could not be properly interpreted.
//
#define SCARD_E_INVALID_VALUE ((DWORD)0x80100011L)
//
// MessageId: SCARD_E_SYSTEM_CANCELLED
//
// MessageText:
//
// The action was cancelled by the system, presumably to log off or shut down.
//
#define SCARD_E_SYSTEM_CANCELLED ((DWORD)0x80100012L)
//
// MessageId: SCARD_F_COMM_ERROR
//
// MessageText:
//
// An internal communications error has been detected.
//
#define SCARD_F_COMM_ERROR ((DWORD)0x80100013L)
//
// MessageId: SCARD_F_UNKNOWN_ERROR
//
// MessageText:
//
// An internal error has been detected, but the source is unknown.
//
#define SCARD_F_UNKNOWN_ERROR ((DWORD)0x80100014L)
//
// MessageId: SCARD_E_INVALID_ATR
//
// MessageText:
//
// An ATR obtained from the registry is not a valid ATR string.
//
#define SCARD_E_INVALID_ATR ((DWORD)0x80100015L)
//
// MessageId: SCARD_E_NOT_TRANSACTED
//
// MessageText:
//
// An attempt was made to end a non-existent transaction.
//
#define SCARD_E_NOT_TRANSACTED ((DWORD)0x80100016L)
//
// MessageId: SCARD_E_READER_UNAVAILABLE
//
// MessageText:
//
// The specified reader is not currently available for use.
//
#define SCARD_E_READER_UNAVAILABLE ((DWORD)0x80100017L)
//
// MessageId: SCARD_P_SHUTDOWN
//
// MessageText:
//
// The operation has been aborted to allow the server application to exit.
//
#define SCARD_P_SHUTDOWN ((DWORD)0x80100018L)
//
// MessageId: SCARD_E_PCI_TOO_SMALL
//
// MessageText:
//
// The PCI Receive buffer was too small.
//
#define SCARD_E_PCI_TOO_SMALL ((DWORD)0x80100019L)
//
// MessageId: SCARD_E_READER_UNSUPPORTED
//
// MessageText:
//
// The reader driver does not meet minimal requirements for support.
//
#define SCARD_E_READER_UNSUPPORTED ((DWORD)0x8010001AL)
//
// MessageId: SCARD_E_DUPLICATE_READER
//
// MessageText:
//
// The reader driver did not produce a unique reader name.
//
#define SCARD_E_DUPLICATE_READER ((DWORD)0x8010001BL)
//
// MessageId: SCARD_E_CARD_UNSUPPORTED
//
// MessageText:
//
// The smart card does not meet minimal requirements for support.
//
#define SCARD_E_CARD_UNSUPPORTED ((DWORD)0x8010001CL)
//
// MessageId: SCARD_E_NO_SERVICE
//
// MessageText:
//
// The Smart card resource manager is not running.
//
#define SCARD_E_NO_SERVICE ((DWORD)0x8010001DL)
//
// MessageId: SCARD_E_SERVICE_STOPPED
//
// MessageText:
//
// The Smart card resource manager has shut down.
//
#define SCARD_E_SERVICE_STOPPED ((DWORD)0x8010001EL)
//
// MessageId: SCARD_E_UNEXPECTED
//
// MessageText:
//
// An unexpected card error has occurred.
//
#define SCARD_E_UNEXPECTED ((DWORD)0x8010001FL)
//
// MessageId: SCARD_E_ICC_INSTALLATION
//
// MessageText:
//
// No Primary Provider can be found for the smart card.
//
#define SCARD_E_ICC_INSTALLATION ((DWORD)0x80100020L)
//
// MessageId: SCARD_E_ICC_CREATEORDER
//
// MessageText:
//
// The requested order of object creation is not supported.
//
#define SCARD_E_ICC_CREATEORDER ((DWORD)0x80100021L)
//
// MessageId: SCARD_E_UNSUPPORTED_FEATURE
//
// MessageText:
//
// This smart card does not support the requested feature.
//
#define SCARD_E_UNSUPPORTED_FEATURE ((DWORD)0x80100022L)
//
// MessageId: SCARD_E_DIR_NOT_FOUND
//
// MessageText:
//
// The identified directory does not exist in the smart card.
//
#define SCARD_E_DIR_NOT_FOUND ((DWORD)0x80100023L)
//
// MessageId: SCARD_E_FILE_NOT_FOUND
//
// MessageText:
//
// The identified file does not exist in the smart card.
//
#define SCARD_E_FILE_NOT_FOUND ((DWORD)0x80100024L)
//
// MessageId: SCARD_E_NO_DIR
//
// MessageText:
//
// The supplied path does not represent a smart card directory.
//
#define SCARD_E_NO_DIR ((DWORD)0x80100025L)
//
// MessageId: SCARD_E_NO_FILE
//
// MessageText:
//
// The supplied path does not represent a smart card file.
//
#define SCARD_E_NO_FILE ((DWORD)0x80100026L)
//
// MessageId: SCARD_E_NO_ACCESS
//
// MessageText:
//
// Access is denied to this file.
//
#define SCARD_E_NO_ACCESS ((DWORD)0x80100027L)
//
// MessageId: SCARD_E_WRITE_TOO_MANY
//
// MessageText:
//
// The smartcard does not have enough memory to store the information.
//
#define SCARD_E_WRITE_TOO_MANY ((DWORD)0x80100028L)
//
// MessageId: SCARD_E_BAD_SEEK
//
// MessageText:
//
// There was an error trying to set the smart card file object pointer.
//
#define SCARD_E_BAD_SEEK ((DWORD)0x80100029L)
//
// MessageId: SCARD_E_INVALID_CHV
//
// MessageText:
//
// The supplied PIN is incorrect.
//
#define SCARD_E_INVALID_CHV ((DWORD)0x8010002AL)
//
// MessageId: SCARD_E_UNKNOWN_RES_MNG
//
// MessageText:
//
// An unrecognized error code was returned from a layered component.
//
#define SCARD_E_UNKNOWN_RES_MNG ((DWORD)0x8010002BL)
//
// MessageId: SCARD_E_NO_SUCH_CERTIFICATE
//
// MessageText:
//
// The requested certificate does not exist.
//
#define SCARD_E_NO_SUCH_CERTIFICATE ((DWORD)0x8010002CL)
//
// MessageId: SCARD_E_CERTIFICATE_UNAVAILABLE
//
// MessageText:
//
// The requested certificate could not be obtained.
//
#define SCARD_E_CERTIFICATE_UNAVAILABLE ((DWORD)0x8010002DL)
//
// MessageId: SCARD_E_NO_READERS_AVAILABLE
//
// MessageText:
//
// Cannot find a smart card reader.
//
#define SCARD_E_NO_READERS_AVAILABLE ((DWORD)0x8010002EL)
//
// MessageId: SCARD_E_COMM_DATA_LOST
//
// MessageText:
//
// A communications error with the smart card has been detected. Retry the operation.
//
#define SCARD_E_COMM_DATA_LOST ((DWORD)0x8010002FL)
//
// MessageId: SCARD_E_NO_KEY_CONTAINER
//
// MessageText:
//
// The requested key container does not exist on the smart card.
//
#define SCARD_E_NO_KEY_CONTAINER ((DWORD)0x80100030L)
//
// MessageId: SCARD_E_SERVER_TOO_BUSY
//
// MessageText:
//
// The Smart card resource manager is too busy to complete this operation.
//
#define SCARD_E_SERVER_TOO_BUSY ((DWORD)0x80100031L)
//
// MessageId: SCARD_E_PIN_CACHE_EXPIRED
//
// MessageText:
//
// The smart card PIN cache has expired.
//
#define SCARD_E_PIN_CACHE_EXPIRED ((DWORD)0x80100032L)
//
// MessageId: SCARD_E_NO_PIN_CACHE
//
// MessageText:
//
// The smart card PIN cannot be cached.
//
#define SCARD_E_NO_PIN_CACHE ((DWORD)0x80100033L)
//
// MessageId: SCARD_E_READ_ONLY_CARD
//
// MessageText:
//
// The smart card is read only and cannot be written to.
//
#define SCARD_E_READ_ONLY_CARD ((DWORD)0x80100034L)
//
// These are warning codes.
//
//
// MessageId: SCARD_W_UNSUPPORTED_CARD
//
// MessageText:
//
// The reader cannot communicate with the smart card, due to ATR configuration conflicts.
//
#define SCARD_W_UNSUPPORTED_CARD ((DWORD)0x80100065L)
//
// MessageId: SCARD_W_UNRESPONSIVE_CARD
//
// MessageText:
//
// The smart card is not responding to a reset.
//
#define SCARD_W_UNRESPONSIVE_CARD ((DWORD)0x80100066L)
//
// MessageId: SCARD_W_UNPOWERED_CARD
//
// MessageText:
//
// Power has been removed from the smart card, so that further communication is not possible.
//
#define SCARD_W_UNPOWERED_CARD ((DWORD)0x80100067L)
//
// MessageId: SCARD_W_RESET_CARD
//
// MessageText:
//
// The smart card has been reset, so any shared state information is invalid.
//
#define SCARD_W_RESET_CARD ((DWORD)0x80100068L)
//
// MessageId: SCARD_W_REMOVED_CARD
//
// MessageText:
//
// The smart card has been removed, so that further communication is not possible.
//
#define SCARD_W_REMOVED_CARD ((DWORD)0x80100069L)
//
// MessageId: SCARD_W_SECURITY_VIOLATION
//
// MessageText:
//
// Access was denied because of a security violation.
//
#define SCARD_W_SECURITY_VIOLATION ((DWORD)0x8010006AL)
//
// MessageId: SCARD_W_WRONG_CHV
//
// MessageText:
//
// The card cannot be accessed because the wrong PIN was presented.
//
#define SCARD_W_WRONG_CHV ((DWORD)0x8010006BL)
//
// MessageId: SCARD_W_CHV_BLOCKED
//
// MessageText:
//
// The card cannot be accessed because the maximum number of PIN entry attempts has been reached.
//
#define SCARD_W_CHV_BLOCKED ((DWORD)0x8010006CL)
//
// MessageId: SCARD_W_EOF
//
// MessageText:
//
// The end of the smart card file has been reached.
//
#define SCARD_W_EOF ((DWORD)0x8010006DL)
//
// MessageId: SCARD_W_CANCELLED_BY_USER
//
// MessageText:
//
// The action was cancelled by the user.
//
#define SCARD_W_CANCELLED_BY_USER ((DWORD)0x8010006EL)
//
// MessageId: SCARD_W_CARD_NOT_AUTHENTICATED
//
// MessageText:
//
// No PIN was presented to the smart card.
//
#define SCARD_W_CARD_NOT_AUTHENTICATED ((DWORD)0x8010006FL)
//
// MessageId: SCARD_W_CACHE_ITEM_NOT_FOUND
//
// MessageText:
//
// The requested item could not be found in the cache.
//
#define SCARD_W_CACHE_ITEM_NOT_FOUND ((DWORD)0x80100070L)
//
// MessageId: SCARD_W_CACHE_ITEM_STALE
//
// MessageText:
//
// The requested cache item is too old and was deleted from the cache.
//
#define SCARD_W_CACHE_ITEM_STALE ((DWORD)0x80100071L)
//
// MessageId: SCARD_W_CACHE_ITEM_TOO_BIG
//
// MessageText:
//
// The new cache item exceeds the maximum per-item size defined for the cache.
//
#define SCARD_W_CACHE_ITEM_TOO_BIG ((DWORD)0x80100072L)
#endif // SCARD_S_SUCCESS

View File

@ -0,0 +1,886 @@
/*++
Copyright (c) 2005 Microsoft Corporation
Module Name:
USBProtocolDefs.h
Abstract:
USB protocol definitions
Author:
--*/
#ifndef _USBPROTOCOLDEFS_H_
#define _USBPROTOCOLDEFS_H_
#include <PSHPACK1.h>
// Initial address for an unconnected wired device.
#define USB_UnConnected_Device_Address 0
#define USB_UNCONNECTED_ADDRESS(address) ( USB_UnConnected_Device_Address == (address))
#define USB_CONNECTED_ADDRESS(address) ( USB_UnConnected_Device_Address != (address) )
//PID definition taken from
//USB Spec 2.0 chapter 8.3.1
// Token
#define PID_OUT 1
#define PID_IN 9
#define PID_SOF 5
#define PID_SETUP 13
// Data
#define PID_DATA0 3
#define PID_DATA1 11
#define PID_DATA2 7
#define PID_MDATA 15
// Handshake
#define USB_ACK 2
#define USB_NAK 10
#define USB_STALL 14
#define USB_NYET 6
// Special
#define USB_PRE 12
#define USB_ERR 12
#define USB_SPLIT 8
#define USB_PING 4
#define USB_TIMEOUT 0
/////////////////////////////////////////////////////////////////////
// Spec release
#define USB_SPEC 0x0200
#define HID_SPEC 0x0101
/////////////////////////////////////////////////////////////////////
// USB Device specification
#define USB_20_SPEC 0x0200
#define USB_11_SPEC 0x0110
#define USB_10_SPEC 0x0100
/////////////////////////////////////////////////////////////////////
// Default values:
// Device Descriptor
#define HID_MAX_PACKET_SIZE0 0x08
#define MICROSOFT_VENDOR_ID 0x045E
#define HID_DEVICE_RELEASE 0x0100
// Endpoint Descriptor
#define HID_MAX_PACKET_SIZE 0x0008
#define HID_POLLING_INTERVAL 0x0A
#define MAX_POLLING_INTERVAL 0xFF
// Product IDs
#define USB_DEFAULT_KEYBOARD_PRODUCT_ID 0x000B // Microsoft USB Natural Keyboard from keyboard.inf
#define USB_DEFAULT_MOUSE_PRODUCT_ID 0x0040 // Microsoft USB Wheel Mouse Optical from msmouse.inf
/////////////////////////////////////////////////////////////////////
// Descriptor type Table 9.5 usb2.0 spec
#define DEVICE_DESCRIPTOR 0x01
#define CONFIGURATION_DESCRIPTOR 0x02
#define STRING_DESCRIPTOR 0x03
#define INTERFACE_DESCRIPTOR 0x04
#define ENDPOINT_DESCRIPTOR 0x05
#define QUALIFIER_DESCRIPTOR 0x06
#define OTHER_SPEED_DESCRIPTOR 0x07
#define INTERFACE_POWER_DESCRIPTOR 0x08
// Class-specific descriptor types
#define HID_DESCRIPTOR 0x21
#define REPORT_DESCRIPTOR 0x22
#define PHYSICAL_DESCRIPTOR 0x23
#define HUB_DESCRIPTOR 0x29
// USBDESCRIPTORTYPE defines the high byte of wValue for a
// GET_DESCRIPTOR request
typedef union _USBDESCRIPTORTYPE
{
BYTE Byte;
#if !defined(MIDL_PASS)
struct Bits
{
BYTE Descriptor:5; // bits 0-4 descriptor type as qualified by the Type field
BYTE Type:2; // bits 5-6
BYTE Reserved:1; // bit 7
} Bits;
#endif
} USBDESCRIPTORTYPE;
// These are the possible values for USBDESCRIPTORTYPE.Bits.Type
#define USB_DESCRIPTOR_TYPE_STD 0
#define USB_DESCRIPTOR_TYPE_CLASS 1
#define USB_DESCRIPTOR_TYPE_VENDOR 2
#define USB_DESCRIPTOR_TYPE_RESERVED 3
/////////////////////////////////////////////////////////////////////
// REQUEST TYPES
// Taken from USB 2.0 spec. Table 9-2
// Data transfer direction. D7
#define DIR_HOST_TO_DEVICE 0
#define DIR_DEVICE_TO_HOST 1
// Type. D6..5
#define TYPE_STANDARD 0
#define TYPE_CLASS 1
#define TYPE_VENDOR 2
#define TYPE_RESERVED 3
// Recipient D4..0
#define RCPT_DEVICE 0
#define RCPT_INTERFACE 1
#define RCPT_ENDPOINT 2
#define RCPT_OTHER 3
#define RCPT_PORT 4
#define RCPT_RPIPE 5
#if !defined(MIDL_PASS)
#define USB_MAKE_REQUEST_TYPE(direction, type, recipient) (BYTE)( ((BYTE)direction << 7) | ((BYTE)type << 5) | ((BYTE)recipient & 0x07) )
#endif
/////////////////////////////////////////////////////////////////////
// STANDARD REQUESTS
#define GET_STATUS 0
#define CLEAR_FEATURE 1
#define SET_FEATURE 3
#define SET_ADDRESS 5
#define GET_DESCRIPTOR 6
#define SET_DESCRIPTOR 7
#define GET_CONFIGURATION 8
#define SET_CONFIGURATION 9
#define GET_INTERFACE 10
#define SET_INTERFACE 11
#define SYNCH_FRAME 12
/////////////////////////////////////////////////////////////////////
// BULK-ONLY MASS STORAGE CLASS REQUESTS
#define USB_BULK_ONLY_MASS_STG_RESET 0xFF
#define USB_BULK_ONLY_MASS_STG_GET_MAX_LUN 0xFE
/////////////////////////////////////////////////////////////////////
// HID CLASS REQUESTS
#define GET_REPORT 0x01
#define GET_IDLE 0x02
#define GET_PROTOCOL 0x03
#define SET_REPORT 0x09
#define SET_IDLE 0x0A
#define SET_PROTOCOL 0x0B
///////////////////////////////////////////////////////////////////
// HWA Device class requests
#define ADD_MMC_IE 20
#define REMOVE_MMC_IE 21
#define SET_NUM_DNTS 22
#define SET_CLUSTER_ID 23
#define SET_DEVICE_INFO 24
#define GET_TIME 25
#define SET_STREAM_INDEX 26
#define SET_WUSB_MAS 27
#define WUSB_CH_STOP 28
//RC Class requests
#define EXEC_RC_CMD 40
////////////////////////////////////////////////////////////////////
// WUSB Channel Time Type
#define TIME_ADJ 0x01
#define TIME_BPST 0x02
#define TIME_WUSB 0x03
/////////////////////////////////////////////////////////////////////
// HID REPORT TYPES
#define HID_REPORT_TYPE_INPUT 0x01
#define HID_REPORT_TYPE_OUTPUT 0x02
#define HID_REPORT_TYPE_FEATURE 0x03
/////////////////////////////////////////////////////////////////////
// HID protocol types for GET/SET_PROTOCOL requests
#define HID_PROTOCOL_TYPE_BOOT 0x00
#define HID_PROTOCOL_TYPE_REPORT 0x01
///////////////////////////////////////////////////////////////////
// HUB protocol definitions
#define HUB_DEVICE_PROTOCOL_1X 0
#define HUB_DEVICE_PROTOCOL_SINGLE_TT 1
#define HUB_DEVICE_PROTOCOL_MULTI_TT 2
#define HUB_INTERFACE_PROTOCOL_1X 0
#define HUB_INTERFACE_PROTOCOL_SINGLE_TT 0
#define HUB_INTERFACE_PROTOCOL_MULTI_TT_IN_SINGLE_TT_MODE 1
#define HUB_INTERFACE_PROTOCOL_MULTI_TT_IN_MULTI_TT_MODE 2
///////////////////////////////////////////////////////////////////
//HUB Class Request code
#define CLEAR_TT_BUFFER 8
#define RESET_TT 9
#define GET_TT_STATE 10
#define STOP_TT 11
///////////////////////////////////////////////////////////////////
//HUB And PORT Feature selector
#define C_HUB_LOCAL_POWER 0
#define C_HUB_OVER_CURRENT 1
#define PORT_CONNECTION 0
#define PORT_ENABLE 1
#define PORT_SUSPEND 2
#define PORT_OVER_CURRENT 3
#define PORT_RESET 4
#define PORT_POWER 8
#define PORT_LOW_SPEED 9
#define C_PORT_CONNECTION 16
#define C_PORT_ENABLE 17
#define C_PORT_SUSPEND 18
#define C_PORT_OVER_CURRENT 19
#define C_PORT_RESET 20
#define PORT_TEST 21
#define PORT_INDICATOR 22
/////////////////////////////////////////////////////////////////////
// SETUP Constants
#define USBSETUPSIZE 8
#define USBINREQUEST 128
/////////////////////////////////////////////////////////////////////
// BM_REQUESTES
#define BM_GET_DEVICE 128
#define BM_GET_INTERFACE 129
#define BM_GET_ENDPOINT 130
#define BM_SET_DEVICE 0
#define BM_SET_INTERFACE 1
#define BM_SET_ENDPOINT 2
#define HALT_ENDPOINT 0
#define REMOTE_WAKEUP 1
#define TEST_MODE 2
/////////////////////////////////////////////////////////////////////
// Descriptor requests
#define DEVICE_DESCRIPTION_TYPE 0x100
#define QUALIFIER_DESCRIPTION_TYPE 0x600
#define OTHER_SPEED_DESCRIPTION_TYPE 0x700
#define CONFIG_DESCRIPTION_TYPE 0x200
#define STRING_DESCRIPTION_TYPE 0x300
#define MSOS_DESCRIPTION_TYPE 0x3EE
/////////////////////////////////////////////////////////////////////
// Configuration Descriptor values
// bmAttribute bits in Configuration Descriptor
// - USB 2.0 9.6.3 (bmAttributes in Table 9-10): Bit 7 is reserved, and always set to one
#define CONFIG_BUS_POWERED 0x80
#define CONFIG_SELF_POWERED 0x40
// Not to be confused with Device Remote Wakeup feature selector!
#define CONFIG_REMOTE_WAKEUP 0x20
//HWA definitions
#define USB_WA_MULTIFUNCTION 0x02
#define USB_WA_PROTOCOL 0x01
#define USB_RADIO_CONTROL 0x2
typedef union _USBCONFIGATTRIBS
{
BYTE Byte;
#if !defined(MIDL_PASS)
struct Bits
{
BYTE bReserved0_4:5; // bits 0-4
BYTE bRemoteWakeup:1; // bit 5
BYTE bSelfPowered:1; // bit 6
BYTE bReserved7:1; // bit 7
} Bits;
#endif
} USBCONFIGATTRIBS;
/////////////////////////////////////////////////////////////////////
// Interface Descriptor values
// bInterfaceClass values
#define USB_HID_CLASS_CODE 0x03
#define USB_MASS_STORAGE_CLASS_CODE 0x08
#define USB_HUB_CLASS_CODE 0x09
#define USB_MISCELLANEOUS 0xEF
#define USB_WIRELESS_WA 0xE0
// bInterfaceSubClass value
#define BOOT_INTERFACE_SUBCLASS 0x01
#define COMMON_CLASS 0x02
#define USB_RF_CONTROL 0x01
// bInterfaceProtocol values for HID
#define PROTOCOL_NONE 0x00
#define PROTOCOL_KEYBOARD 0x01
#define PROTOCOL_MOUSE 0x02
/////////////////////////////////////////////////////////////////////
// Endpoint Descriptor values
// Macros for generating bEndpointAddress value
// - USB HID 1.11 Appendix E.5
#define EP_OUT 0
#define EP_IN 1
// Bit 0..3 The end point number
// Bit 4..6 Reserved, reset to zero
// Bit 7 Direction, ignored for control endpoints
#define MAKE_ENDPOINT_ADDRESS(num, dir) ( ((BYTE)(dir) << 7) | ((BYTE)(num) & 0x0F) )
// bmAttributes values
// ENDPOINT TYPES
#define ENDPOINT_TYPE 0x03
#define CONTROL_ENDPOINT 0
#define ISOCHRONOUS_ENDPOINT 1
#define BULK_ENDPOINT 2
#define INTERRUPT_ENDPOINT 3
//Define standard USB structures which are used to transfer data from the
//host to the endpoints
typedef union _USBREQUESTTYPE
{
BYTE Byte;
#if !defined(MIDL_PASS)
struct Bits
{
BYTE Recipient:5; // bits 0-4
BYTE Type:2; // bits 5-6
BYTE Direction:1; // bit 7
} Bits;
#endif
} USBREQUESTTYPE;
#if !defined(MIDL_PASS)
C_ASSERT((sizeof(USBREQUESTTYPE) == sizeof(BYTE)));
#endif
typedef struct _USBSETUPREQUEST
{
USBREQUESTTYPE bmRequestType; // Setup request type
BYTE bRequest; // Setup Request
SHORT sSetupValue; // Value for the setup request
SHORT sSetupIndex; // Index for the setup request
SHORT sSetupLength; // Data Length for the device
} USBSETUPREQUEST;
#if !defined(MIDL_PASS)
typedef struct _USBDEVICEDESC
{
BYTE bLength;
BYTE bDescriptorType;
USHORT usUSB;
BYTE bDeviceClass;
BYTE bDeviceSubClass;
BYTE bProtocol;
BYTE bMaxPacket0;
USHORT usVendor;
USHORT usProduct;
USHORT usDeviceNumber;
BYTE bManufacturer;
BYTE bProductDesc;
BYTE bSerialNumber;
BYTE bNumConfigs;
} USBDEVICEDESC;
typedef struct _USBCONFIGDESC
{
BYTE bLength;
BYTE bDescriptorType;
USHORT usTotalLength;
BYTE bNumInterfaces;
BYTE bConfigValue;
BYTE bConfig;
BYTE bAttributes;
BYTE bMaxPower;
} USBCONFIGDESC;
typedef struct _USBINTERFACEDESC
{
BYTE bLength;
BYTE bDescriptorType;
BYTE bInterfaceNumber;
BYTE bAlternateSetting;
BYTE bNumEndpoints;
BYTE bClass;
BYTE bSubClass;
BYTE bProtocol;
BYTE bDescription;
} USBINTERFACEDESC;
#define ENDPOINT_DIRECTION_OUT 0
#define ENDPOINT_DIRECTION_IN 1
typedef union _USBENDPOINTADDRESS
{
BYTE Byte;
struct Bits
{
BYTE Number:4; // bits 0-3
BYTE Reserved:3; // bits 4-6
BYTE Direction:1; // bit 7
} Bits;
} USBENDPOINTADDRESS;
C_ASSERT((sizeof(USBENDPOINTADDRESS) == sizeof(BYTE)));
#define USB_TRANSFER_TYPE_CONTROL 0
#define USB_TRANSFER_TYPE_ISOCH 1
#define USB_TRANSFER_TYPE_BULK 2
#define USB_TRANSFER_TYPE_INTERRUPT 3
#define USB_SYNC_TYPE_NONE 0
#define USB_SYNC_TYPE_ASYNC 1
#define USB_SYNC_TYPE_ADAPTIVE 2
#define USB_SYNC_TYPE_SYNC 3
#define USB_USAGE_TYPE_DATA 0
#define USB_USAGE_TYPE_FEEDBACK 1
#define USB_USAGE_TYPE_IMPLICIT 2
#define USB_USAGE_TYPE_RESERVED 3
typedef union _USBENDPOINTATTRIBS
{
BYTE Byte;
struct Bits
{
BYTE TransferType:2; // bits 0-1
BYTE SyncType:2; // bits 3-4
BYTE UsageType:2; // bits 5-6
BYTE Reserved:2; // bits 7-8
} Bits;
} USBENDPOINTATTRIBS;
C_ASSERT((sizeof(USBENDPOINTATTRIBS) == sizeof(BYTE)));
typedef union _USBMAXPACKET
{
WORD Word;
struct Bits
{
WORD Size:11; // bits 0-10
WORD AdditionalXactions:2; // bits 11-12
WORD Reserved:3; // bits 13-15
} Bits;
} USBMAXPACKET;
C_ASSERT((sizeof(USBMAXPACKET) == sizeof(WORD)));
typedef struct _USBENDPOINTDESC
{
BYTE bLength;
BYTE bDescriptorType;
USBENDPOINTADDRESS Address;
USBENDPOINTATTRIBS Attributes;
USBMAXPACKET MaxPacket;
BYTE bInterval;
} USBENDPOINTDESC;
typedef struct _USBQUALIFIERDESC
{
BYTE bLength;
BYTE bDescriptorType;
USHORT usUSB;
BYTE bDeviceClass;
BYTE bDeviceSubClass;
BYTE bProtocol;
BYTE bMaxPacket;
BYTE bNumConfigs;
BYTE bReserved;
} USBQUALIFIERDESC;
typedef struct _USBSTRINGDESC
{
BYTE bLength;
BYTE bDescriptorType;
WCHAR wchData[1];
} USBSTRINGDESC;
typedef struct _USBSTRINGLANGIDS
{
BYTE bLength;
BYTE bDescriptorType;
WORD wLANGIDs[1];
} USBSTRINGLANGIDS;
typedef struct _USBHIDSTANDARDDESC
{
BYTE bLength;
BYTE bDescriptorType;
USHORT bcdHID;
BYTE bCountryCode;
BYTE bNumDescriptors;
} USBHIDSTANDARDDESC;
typedef struct _USBHIDOPTIONALDESC
{
BYTE bClassDescriptorType;
USHORT usDescriptorLength;
} USBHIDOPTIONALDESC;
typedef struct _USBPHYSICALDESCSET0
{
BYTE bNumber;
BYTE bLength;
} USBPHYSICALDESCSET0;
typedef union _USBPHYSICALDESCSET
{
BYTE bPhysicalInfo;
struct Bits
{
BYTE bPreference : 5;
BYTE bBias : 3;
} Bits;
} USBPHYSICALDESCSET;
typedef struct _USBPHYSICALDESCITEM
{
BYTE bDesignator;
union Flags
{
BYTE bFlags;
struct Bits
{
BYTE bEffort : 5;
BYTE bQualifier : 3;
} Bits;
} Flags;
} USBPHYSICALDESCITEM;
typedef union _USBHUBCHARACTERISTICS
{
WORD wHubCharacteristics;
struct Bits
{
BYTE bLogicalPowerSwitchingMode : 2;
BYTE fCompoundDevice : 1;
BYTE bOverCurrentMode : 2;
BYTE bTTThinkTime : 2;
BYTE fPortIndicatorSupport : 1;
BYTE bReserved : 8;
} Bits;
} USBHUBCHARACTERISTICS;
#if !defined(MIDL_PASS)
C_ASSERT((sizeof(USBHUBCHARACTERISTICS) == sizeof(WORD)));
#endif
typedef struct _USBHUBDESC
{
BYTE bLength;
BYTE bDescriptorType;
BYTE bNumberOfPorts;
USBHUBCHARACTERISTICS Characteristics;
BYTE bPwrOn2PwrGood;
BYTE bHubContrCurrent;
BYTE bDeviceRemovable[32]; // Defined as its maximum possible size for 255 ports
BYTE bPortPwrCtrlMask[32]; // Defined as its maximum possible size for 255 ports
} USBHUBDESC;
#if !defined(MIDL_PASS)
C_ASSERT((sizeof(USBHUBDESC) == 71));
#endif
typedef union _USBHUBPORTSTATUS
{
WORD wPortStatus;
struct Bits
{
BYTE fCurrentConnectionStatus : 1;
BYTE fEnabled : 1;
BYTE fSuspend : 1;
BYTE fOverCurrent : 1;
BYTE fReset : 1;
BYTE bReserved1 : 3;
BYTE fPortPower : 1;
BYTE fLowSpeedDevice : 1;
BYTE fHighSpeedDevice : 1;
BYTE fTestMode : 1;
BYTE fPortIndicatorControl : 1;
BYTE bReserved2 : 3;
} Bits;
} USBHUBPORTSTATUS;
#if !defined(MIDL_PASS)
C_ASSERT((sizeof(USBHUBPORTSTATUS) == sizeof(WORD)));
#endif
typedef union _USBHUBPORTSTATUSCHANGE
{
WORD wPortStatusChange;
struct Bits
{
BYTE fConnectionStatusChange : 1;
BYTE fEnabledChange : 1;
BYTE fSuspendChange : 1;
BYTE fOverCurrentChange : 1;
BYTE fResetChange : 1;
BYTE bReserved1 : 3;
BYTE bReserved2 : 8;
} Bits;
} USBHUBPORTSTATUSCHANGE;
#if !defined(MIDL_PASS)
C_ASSERT((sizeof(USBHUBPORTSTATUSCHANGE) == sizeof(WORD)));
#endif
typedef struct _USBHUBPORTDATA
{
USBHUBPORTSTATUS PortStatus;
USBHUBPORTSTATUSCHANGE PortStatusChange;
} USBHUBPORTDATA;
// USB Language Identifiers
//
// These are taken directly from http://www.usb.org/developers/docs/USB_LANGIDs.pdf
// USB_MAKE_LANGID(lang, sublang)
//
// Use this macro to create a language ID. For example, for US English
// use:
//
// USB_MAKE_LANGID(USB_LANG_ENGLISH, USB_SUBLANG_ENGLISH_US)
#define USB_MAKE_LANGID(lang, sublang) ((((USHORT)(sublang)) << 10) | (USHORT)(lang))
#define USB_LANG_RESERVED 0x00
#define USB_LANG_ARABIC 0x01
#define USB_LANG_BULGARIAN 0x02
#define USB_LANG_CATALAN 0x03
#define USB_LANG_CHINESE 0x04
#define USB_LANG_CZECH 0x05
#define USB_LANG_DANISH 0x06
#define USB_LANG_GERMAN 0x07
#define USB_LANG_GREEK 0x08
#define USB_LANG_ENGLISH 0x09
#define USB_LANG_SPANISH 0x0a
#define USB_LANG_FINNISH 0x0b
#define USB_LANG_FRENCH 0x0c
#define USB_LANG_HEBREW 0x0d
#define USB_LANG_HUNGARIAN 0x0e
#define USB_LANG_ICELANDIC 0x0f
#define USB_LANG_ITALIAN 0x10
#define USB_LANG_JAPANESE 0x11
#define USB_LANG_KOREAN 0x12
#define USB_LANG_DUTCH 0x13
#define USB_LANG_NORWEGIAN 0x14
#define USB_LANG_POLISH 0x15
#define USB_LANG_PORTUGUESE 0x16
#define USB_LANG_ROMANIAN 0x18
#define USB_LANG_RUSSIAN 0x19
#define USB_LANG_CROATIAN 0x1a
#define USB_LANG_SERBIAN 0x1a
#define USB_LANG_SLOVAK 0x1b
#define USB_LANG_ALBANIAN 0x1c
#define USB_LANG_SWEDISH 0x1d
#define USB_LANG_THAI 0x1e
#define USB_LANG_TURKISH 0x1f
#define USB_LANG_URDU 0x20
#define USB_LANG_INDONESIAN 0x21
#define USB_LANG_UKRANIAN 0x22
#define USB_LANG_BELARUSIAN 0x23
#define USB_LANG_SLOVENIAN 0x24
#define USB_LANG_ESTONIAN 0x25
#define USB_LANG_LATVIAN 0x26
#define USB_LANG_LITHUANIAN 0x27
#define USB_LANG_FARSI 0x29
#define USB_LANG_VIETNAMESE 0x2a
#define USB_LANG_ARMENIAN 0x2b
#define USB_LANG_AZERI 0x2c
#define USB_LANG_BASQUE 0x2d
#define USB_LANG_MACEDONIAN 0x2f // This is actually Macedonian (FYROM)
#define USB_LANG_AFRIKAANS 0x36
#define USB_LANG_GEORGIAN 0x37
#define USB_LANG_FAEROESE 0x38
#define USB_LANG_HINDI 0x39
#define USB_LANG_MALAY 0x3e
#define USB_LANG_KAZAK 0x3f
#define USB_LANG_SWAHILI 0x41
#define USB_LANG_UZBEK 0x43
#define USB_LANG_TATAR 0x44
#define USB_LANG_BENGALI 0x45
#define USB_LANG_PUNJABI 0x46
#define USB_LANG_GUJARATI 0x47
#define USB_LANG_ORIYA 0x48
#define USB_LANG_TAMIL 0x49
#define USB_LANG_TELUGU 0x4a
#define USB_LANG_KANNADA 0x4b
#define USB_LANG_MALAYALAM 0x4c
#define USB_LANG_ASSAMESE 0x4d
#define USB_LANG_MARATHI 0x4e
#define USB_LANG_SANSKRIT 0x4f
#define USB_LANG_KONKANI 0x57
#define USB_LANG_MANIPURI 0x58
#define USB_LANG_SINDHI 0x59
#define USB_LANG_KASHMIRI 0x60
#define USB_LANG_NEPALI 0x61
#define USB_LANG_HID 0xff
#define USB_SUBLANG_ARABIC_SAUDI_ARABIA 0x01
#define USB_SUBLANG_ARABIC_SAUDI_ARABIA 0x01
#define USB_SUBLANG_ARABIC_IRAQ 0x02
#define USB_SUBLANG_ARABIC_EGYPT 0x03
#define USB_SUBLANG_ARABIC_LIBYA 0x04
#define USB_SUBLANG_ARABIC_ALGERIA 0x05
#define USB_SUBLANG_ARABIC_MOROCCO 0x06
#define USB_SUBLANG_ARABIC_TUNISIA 0x07
#define USB_SUBLANG_ARABIC_OMAN 0x08
#define USB_SUBLANG_ARABIC_YEMEN 0x09
#define USB_SUBLANG_ARABIC_SYRIA 0x10
#define USB_SUBLANG_ARABIC_JORDAN 0x11
#define USB_SUBLANG_ARABIC_LEBANON 0x12
#define USB_SUBLANG_ARABIC_KUWAIT 0x13
#define USB_SUBLANG_ARABIC_UAE 0x14
#define USB_SUBLANG_ARABIC_BAHRAIN 0x15
#define USB_SUBLANG_ARABIC_QATAR 0x16
#define USB_SUBLANG_AZERI_CYRILLIC 0x01
#define USB_SUBLANG_AZERI_LATIN 0x02
#define USB_SUBLANG_CHINESE_TRADITIONAL 0x01
#define USB_SUBLANG_CHINESE_SIMPLIFIED 0x02
#define USB_SUBLANG_CHINESE_HONGKONG 0x03
#define USB_SUBLANG_CHINESE_SINGAPORE 0x04
#define USB_SUBLANG_CHINESE_MACAU 0x05
#define USB_SUBLANG_DUTCH 0x01
#define USB_SUBLANG_DUTCH_BELGIAN 0x02
#define USB_SUBLANG_ENGLISH_US 0x01
#define USB_SUBLANG_ENGLISH_UK 0x02
#define USB_SUBLANG_ENGLISH_AUS 0x03
#define USB_SUBLANG_ENGLISH_CAN 0x04
#define USB_SUBLANG_ENGLISH_NZ 0x05
#define USB_SUBLANG_ENGLISH_EIRE 0x06
#define USB_SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
#define USB_SUBLANG_ENGLISH_JAMAICA 0x08
#define USB_SUBLANG_ENGLISH_CARIBBEAN 0x09
#define USB_SUBLANG_ENGLISH_BELIZE 0x0a
#define USB_SUBLANG_ENGLISH_TRINIDAD 0x0b
#define USB_SUBLANG_ENGLISH_PHILIPPINES 0x0c
#define USB_SUBLANG_ENGLISH_ZIMBABWE 0x0d
#define USB_SUBLANG_FRENCH 0x01
#define USB_SUBLANG_FRENCH_BELGIAN 0x02
#define USB_SUBLANG_FRENCH_CANADIAN 0x03
#define USB_SUBLANG_FRENCH_SWISS 0x04
#define USB_SUBLANG_FRENCH_LUXEMBOURG 0x05
#define USB_SUBLANG_FRENCH_MONACO 0x06
#define USB_SUBLANG_GERMAN 0x01
#define USB_SUBLANG_GERMAN_SWISS 0x02
#define USB_SUBLANG_GERMAN_AUSTRIAN 0x03
#define USB_SUBLANG_GERMAN_LUXEMBOURG 0x04
#define USB_SUBLANG_GERMAN_LIECHTENSTEIN 0x05
#define USB_SUBLANG_ITALIAN 0x01
#define USB_SUBLANG_ITALIAN_SWISS 0x02
#define USB_SUBLANG_KASHMIRI_INDIA 0x02
#define USB_SUBLANG_KOREAN 0x01
#define USB_SUBLANG_LITHUANIAN 0x01
#define USB_SUBLANG_MALAY_MALAYSIA 0x01
#define USB_SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
#define USB_SUBLANG_NEPALI_INDIA 0x02
#define USB_SUBLANG_NORWEGIAN_BOKMAL 0x01
#define USB_SUBLANG_NORWEGIAN_NYNORSK 0x02
#define USB_SUBLANG_PORTUGUESE 0x01
#define USB_SUBLANG_PORTUGUESE_BRAZILIAN 0x02
#define USB_SUBLANG_SERBIAN_LATIN 0x02
#define USB_SUBLANG_SERBIAN_CYRILLIC 0x03
#define USB_SUBLANG_SPANISH 0x01
#define USB_SUBLANG_SPANISH_MEXICAN 0x02
#define USB_SUBLANG_SPANISH_MODERN 0x03
#define USB_SUBLANG_SPANISH_GUATEMALA 0x04
#define USB_SUBLANG_SPANISH_COSTA_RICA 0x05
#define USB_SUBLANG_SPANISH_PANAMA 0x06
#define USB_SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
#define USB_SUBLANG_SPANISH_VENEZUELA 0x08
#define USB_SUBLANG_SPANISH_COLOMBIA 0x09
#define USB_SUBLANG_SPANISH_PERU 0x0a
#define USB_SUBLANG_SPANISH_ARGENTINA 0x0b
#define USB_SUBLANG_SPANISH_ECUADOR 0x0c
#define USB_SUBLANG_SPANISH_CHILE 0x0d
#define USB_SUBLANG_SPANISH_URUGUAY 0x0e
#define USB_SUBLANG_SPANISH_PARAGUAY 0x0f
#define USB_SUBLANG_SPANISH_BOLIVIA 0x10
#define USB_SUBLANG_SPANISH_EL_SALVADOR 0x11
#define USB_SUBLANG_SPANISH_HONDURAS 0x12
#define USB_SUBLANG_SPANISH_NICARAGUA 0x13
#define USB_SUBLANG_SPANISH_PUERTO_RICO 0x14
#define USB_SUBLANG_SWEDISH 0x01
#define USB_SUBLANG_SWEDISH_FINLAND 0x02
#define USB_SUBLANG_URDU_PAKISTAN 0x01
#define USB_SUBLANG_URDU_INDIA 0x02
#define USB_SUBLANG_UZBEK_LATIN 0x01
#define USB_SUBLANG_UZBEK_CYRILLIC 0x02
#define USB_SUBLANG_HID_USAGE_DATA_DESCRIPTOR 0x01
#define USB_SUBLANG_HID_VENDOR_DEFINED_1 0x3c
#define USB_SUBLANG_HID_VENDOR_DEFINED_2 0x3d
#define USB_SUBLANG_HID_VENDOR_DEFINED_3 0x3e
#define USB_SUBLANG_HID_VENDOR_DEFINED_4 0x3f
#endif // !defined(MIDL_PASS)
#include <POPPACK.h>
#endif //_USBPROTOCOLDEFS_H_

View File

@ -0,0 +1,802 @@
/*+-------------------------------------------------------------------
Microsoft Windows
Copyright (C) Microsoft Corporation, 1993-1998.
File: accctrl.h
Contents: common includes for new style Win32 Access Control
APIs
--------------------------------------------------------------------*/
#ifndef __ACCESS_CONTROL__
#define __ACCESS_CONTROL__
#ifndef __midl
#include <wtypes.h>
#endif
#if (_MSC_VER >= 800)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif
#pragma warning(disable:4001) /* nonstandard extension : single line comment */
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define AccFree LocalFree
//
// Definition:
// This enumerated type defines the objects supported by the get/set API within
// this document. See section 3.1, Object Types for a detailed definition of the
// supported object types, and their name formats.
//
typedef enum _SE_OBJECT_TYPE
{
SE_UNKNOWN_OBJECT_TYPE = 0,
SE_FILE_OBJECT,
SE_SERVICE,
SE_PRINTER,
SE_REGISTRY_KEY,
SE_LMSHARE,
SE_KERNEL_OBJECT,
SE_WINDOW_OBJECT,
SE_DS_OBJECT,
SE_DS_OBJECT_ALL,
SE_PROVIDER_DEFINED_OBJECT,
SE_WMIGUID_OBJECT,
SE_REGISTRY_WOW64_32KEY,
} SE_OBJECT_TYPE;
//
// Definition: TRUSTEE_TYPE
// This enumerated type specifies the type of trustee account for the trustee
// returned by the API described in this document.
// TRUSTEE_IS_UNKNOWN - The trustee is an unknown, but not necessarily invalid
// type. This field is not validated on input to the APIs
// that take Trustees.
// TRUSTEE_IS_USER The trustee account is a user account.
// TRUSTEE_IS_GROUP The trustee account is a group account.
//
typedef enum _TRUSTEE_TYPE
{
TRUSTEE_IS_UNKNOWN,
TRUSTEE_IS_USER,
TRUSTEE_IS_GROUP,
TRUSTEE_IS_DOMAIN,
TRUSTEE_IS_ALIAS,
TRUSTEE_IS_WELL_KNOWN_GROUP,
TRUSTEE_IS_DELETED,
TRUSTEE_IS_INVALID,
TRUSTEE_IS_COMPUTER
} TRUSTEE_TYPE;
//
// Definition: TRUSTEE_FORM
// This enumerated type specifies the form the trustee identifier is in for a
// particular trustee.
// TRUSTEE_IS_SID The trustee is identified with a SID rather than with a name.
// TRUSTEE_IS_NAME The trustee is identified with a name.
//
typedef enum _TRUSTEE_FORM
{
TRUSTEE_IS_SID,
TRUSTEE_IS_NAME,
TRUSTEE_BAD_FORM,
TRUSTEE_IS_OBJECTS_AND_SID,
TRUSTEE_IS_OBJECTS_AND_NAME
} TRUSTEE_FORM;
//
// Definition: MULTIPLE_TRUSTEE_OPERATION
// If the trustee is a multiple trustee, this enumerated type specifies the type.
// TRUSTEE_IS_IMPERSONATE The trustee is an impersonate trustee and the multiple
// trustee field in the trustee points to another trustee
// that is a trustee for the server that will be doing the
// impersonation.
//
typedef enum _MULTIPLE_TRUSTEE_OPERATION
{
NO_MULTIPLE_TRUSTEE,
TRUSTEE_IS_IMPERSONATE,
} MULTIPLE_TRUSTEE_OPERATION;
typedef struct _OBJECTS_AND_SID
{
DWORD ObjectsPresent;
GUID ObjectTypeGuid;
GUID InheritedObjectTypeGuid;
SID * pSid;
} OBJECTS_AND_SID, *POBJECTS_AND_SID;
typedef struct _OBJECTS_AND_NAME_A
{
DWORD ObjectsPresent;
SE_OBJECT_TYPE ObjectType;
LPSTR ObjectTypeName;
LPSTR InheritedObjectTypeName;
LPSTR ptstrName;
} OBJECTS_AND_NAME_A, *POBJECTS_AND_NAME_A;
typedef struct _OBJECTS_AND_NAME_W
{
DWORD ObjectsPresent;
SE_OBJECT_TYPE ObjectType;
LPWSTR ObjectTypeName;
LPWSTR InheritedObjectTypeName;
LPWSTR ptstrName;
} OBJECTS_AND_NAME_W, *POBJECTS_AND_NAME_W;
#ifdef UNICODE
typedef OBJECTS_AND_NAME_W OBJECTS_AND_NAME_;
typedef POBJECTS_AND_NAME_W POBJECTS_AND_NAME_;
#else
typedef OBJECTS_AND_NAME_A OBJECTS_AND_NAME_;
typedef POBJECTS_AND_NAME_A POBJECTS_AND_NAME_;
#endif // UNICODE
//
// Definition: TRUSTEE
// This structure is used to pass account information into and out of the system
// using the API defined in this document.
// PMultipleTrustee - if NON-NULL, points to another trustee structure, as
// defined by the multiple trustee operation field.
// MultipleTrusteeOperation - Defines the multiple trustee operation/type.
// TrusteeForm - defines if the trustee is defined by name or SID.
// TrusteeType - defines if the trustee type is unknown, a user or a group.
// PwcsName - points to the trustee name or the trustee SID.
//
typedef struct _TRUSTEE_A
{
struct _TRUSTEE_A *pMultipleTrustee;
MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
TRUSTEE_FORM TrusteeForm;
TRUSTEE_TYPE TrusteeType;
#ifdef __midl
[switch_is(TrusteeForm)]
union
{
[case(TRUSTEE_IS_NAME)]
LPSTR ptstrName;
[case(TRUSTEE_IS_SID)]
SID *pSid;
[case(TRUSTEE_IS_OBJECTS_AND_SID)]
OBJECTS_AND_SID *pObjectsAndSid;
[case(TRUSTEE_IS_OBJECTS_AND_NAME)]
OBJECTS_AND_NAME_A *pObjectsAndName;
};
#else
LPSTR ptstrName;
#endif
} TRUSTEE_A, *PTRUSTEE_A, TRUSTEEA, *PTRUSTEEA;
typedef struct _TRUSTEE_W
{
struct _TRUSTEE_W *pMultipleTrustee;
MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
TRUSTEE_FORM TrusteeForm;
TRUSTEE_TYPE TrusteeType;
#ifdef __midl
[switch_is(TrusteeForm)]
union
{
[case(TRUSTEE_IS_NAME)]
LPWSTR ptstrName;
[case(TRUSTEE_IS_SID)]
SID *pSid;
[case(TRUSTEE_IS_OBJECTS_AND_SID)]
OBJECTS_AND_SID *pObjectsAndSid;
[case(TRUSTEE_IS_OBJECTS_AND_NAME)]
OBJECTS_AND_NAME_W *pObjectsAndName;
};
#else
LPWSTR ptstrName;
#endif
} TRUSTEE_W, *PTRUSTEE_W, TRUSTEEW, *PTRUSTEEW;
#ifdef UNICODE
typedef TRUSTEE_W TRUSTEE_;
typedef PTRUSTEE_W PTRUSTEE_;
typedef TRUSTEEW TRUSTEE;
typedef PTRUSTEEW PTRUSTEE;
#else
typedef TRUSTEE_A TRUSTEE_;
typedef PTRUSTEE_A PTRUSTEE_;
typedef TRUSTEEA TRUSTEE;
typedef PTRUSTEEA PTRUSTEE;
#endif // UNICODE
//
// Definition: ACCESS_MODE
// This enumerated type specifies how permissions are (requested)/to be applied
// for the trustee by the access control entry. On input this field can by any
// of the values, although it is not meaningful to mix access control and audit
// control entries. On output this field will be either SET_ACCESS, DENY_ACCESS,
// SET_AUDIT_SUCCESS, SET_AUDIT_FAILURE.
// The following descriptions define how this type effects an explicit access
// request to apply access permissions to an object.
// GRANT_ACCESS - The trustee will have at least the requested permissions upon
// successful completion of the command. (If the trustee has
// additional permissions they will not be removed).
// SET_ACCESS - The trustee will have exactly the requested permissions upon
// successful completion of the command.
// DENY_ACCESS - The trustee will be denied the specified permissions.
// REVOKE_ACCESS - Any explicit access rights the trustee has will be revoked.
// SET_AUDIT_SUCCESS - The trustee will be audited for successful opens of the
// object using the requested permissions.
// SET_AUDIT_FAILURE - The trustee will be audited for failed opens of the object
// using the requested permissions.
//
typedef enum _ACCESS_MODE
{
NOT_USED_ACCESS = 0,
GRANT_ACCESS,
SET_ACCESS,
DENY_ACCESS,
REVOKE_ACCESS,
SET_AUDIT_SUCCESS,
SET_AUDIT_FAILURE
} ACCESS_MODE;
//
// Definition: Inheritance flags
// These bit masks are provided to allow simple application of inheritance in
// explicit access requests on containers.
// NO_INHERITANCE The specific access permissions will only be applied to
// the container, and will not be inherited by objects created
// within the container.
// SUB_CONTAINERS_ONLY_INHERIT The specific access permissions will be inherited
// and applied to sub containers created within the
// container, and will be applied to the container
// itself.
// SUB_OBJECTS_ONLY_INHERIT The specific access permissions will only be inherited
// by objects created within the specific container.
// The access permissions will not be applied to the
// container itself.
// SUB_CONTAINERS_AND_OBJECTS_INHERIT The specific access permissions will be
// inherited by containers created within the
// specific container, will be applied to
// objects created within the container, but
// will not be applied to the container itself.
//
#define NO_INHERITANCE 0x0
#define SUB_OBJECTS_ONLY_INHERIT 0x1
#define SUB_CONTAINERS_ONLY_INHERIT 0x2
#define SUB_CONTAINERS_AND_OBJECTS_INHERIT 0x3
#define INHERIT_NO_PROPAGATE 0x4
#define INHERIT_ONLY 0x8
//
// Informational bit that is returned
//
#define INHERITED_ACCESS_ENTRY 0x10
//
// Informational bit that tells where a node was inherited from. Valid only
// for NT 5 APIs
//
#define INHERITED_PARENT 0x10000000
#define INHERITED_GRANDPARENT 0x20000000
//
// Definition: EXPLICIT_ACCESS
// This structure is used to pass access control entry information into and out
// of the system using the API defined in this document.
// grfAccessPermissions - This contains the access permissions to assign for the
// trustee. It is in the form of an NT access mask.
// grfAccessMode - This field defines how the permissions are to be applied for
// the trustee.
// grfInheritance - For containers, this field defines how the access control
// entry is/(is requested) to be inherited on
// objects/sub-containers created within the container.
// Trustee - This field contains the definition of the trustee account the
// explicit access applies to.
//
typedef struct _EXPLICIT_ACCESS_A
{
DWORD grfAccessPermissions;
ACCESS_MODE grfAccessMode;
DWORD grfInheritance;
TRUSTEE_A Trustee;
} EXPLICIT_ACCESS_A, *PEXPLICIT_ACCESS_A, EXPLICIT_ACCESSA, *PEXPLICIT_ACCESSA;
typedef struct _EXPLICIT_ACCESS_W
{
DWORD grfAccessPermissions;
ACCESS_MODE grfAccessMode;
DWORD grfInheritance;
TRUSTEE_W Trustee;
} EXPLICIT_ACCESS_W, *PEXPLICIT_ACCESS_W, EXPLICIT_ACCESSW, *PEXPLICIT_ACCESSW;
#ifdef UNICODE
typedef EXPLICIT_ACCESS_W EXPLICIT_ACCESS_;
typedef PEXPLICIT_ACCESS_W PEXPLICIT_ACCESS_;
typedef EXPLICIT_ACCESSW EXPLICIT_ACCESS;
typedef PEXPLICIT_ACCESSW PEXPLICIT_ACCESS;
#else
typedef EXPLICIT_ACCESS_A EXPLICIT_ACCESS_;
typedef PEXPLICIT_ACCESS_A PEXPLICIT_ACCESS_;
typedef EXPLICIT_ACCESSA EXPLICIT_ACCESS;
typedef PEXPLICIT_ACCESSA PEXPLICIT_ACCESS;
#endif // UNICODE
//----------------------------------------------------------------------------
//
// NT5 APIs
//
//----------------------------------------------------------------------------
//
// Default provider
//
#define ACCCTRL_DEFAULT_PROVIDERA "Windows NT Access Provider"
#define ACCCTRL_DEFAULT_PROVIDERW L"Windows NT Access Provider"
#ifdef UNICODE
#define ACCCTRL_DEFAULT_PROVIDER ACCCTRL_DEFAULT_PROVIDERW
#else
#define ACCCTRL_DEFAULT_PROVIDER ACCCTRL_DEFAULT_PROVIDERA
#endif
//
/// Access rights
//
typedef ULONG ACCESS_RIGHTS, *PACCESS_RIGHTS;
//
// Inheritance flags
//
typedef ULONG INHERIT_FLAGS, *PINHERIT_FLAGS;
//
// Access / Audit structures
//
typedef struct _ACTRL_ACCESS_ENTRYA
{
TRUSTEE_A Trustee;
ULONG fAccessFlags;
ACCESS_RIGHTS Access;
ACCESS_RIGHTS ProvSpecificAccess;
INHERIT_FLAGS Inheritance;
LPSTR lpInheritProperty;
} ACTRL_ACCESS_ENTRYA, *PACTRL_ACCESS_ENTRYA;
//
// Access / Audit structures
//
typedef struct _ACTRL_ACCESS_ENTRYW
{
TRUSTEE_W Trustee;
ULONG fAccessFlags;
ACCESS_RIGHTS Access;
ACCESS_RIGHTS ProvSpecificAccess;
INHERIT_FLAGS Inheritance;
LPWSTR lpInheritProperty;
} ACTRL_ACCESS_ENTRYW, *PACTRL_ACCESS_ENTRYW;
#ifdef UNICODE
typedef ACTRL_ACCESS_ENTRYW ACTRL_ACCESS_ENTRY;
typedef PACTRL_ACCESS_ENTRYW PACTRL_ACCESS_ENTRY;
#else
typedef ACTRL_ACCESS_ENTRYA ACTRL_ACCESS_ENTRY;
typedef PACTRL_ACCESS_ENTRYA PACTRL_ACCESS_ENTRY;
#endif // UNICODE
typedef struct _ACTRL_ACCESS_ENTRY_LISTA
{
ULONG cEntries;
#ifdef __midl
[size_is(cEntries)]
#endif
ACTRL_ACCESS_ENTRYA *pAccessList;
} ACTRL_ACCESS_ENTRY_LISTA, *PACTRL_ACCESS_ENTRY_LISTA;
typedef struct _ACTRL_ACCESS_ENTRY_LISTW
{
ULONG cEntries;
#ifdef __midl
[size_is(cEntries)]
#endif
ACTRL_ACCESS_ENTRYW *pAccessList;
} ACTRL_ACCESS_ENTRY_LISTW, *PACTRL_ACCESS_ENTRY_LISTW;
#ifdef UNICODE
typedef ACTRL_ACCESS_ENTRY_LISTW ACTRL_ACCESS_ENTRY_LIST;
typedef PACTRL_ACCESS_ENTRY_LISTW PACTRL_ACCESS_ENTRY_LIST;
#else
typedef ACTRL_ACCESS_ENTRY_LISTA ACTRL_ACCESS_ENTRY_LIST;
typedef PACTRL_ACCESS_ENTRY_LISTA PACTRL_ACCESS_ENTRY_LIST;
#endif // UNICODE
typedef struct _ACTRL_PROPERTY_ENTRYA
{
LPSTR lpProperty;
PACTRL_ACCESS_ENTRY_LISTA pAccessEntryList;
ULONG fListFlags;
} ACTRL_PROPERTY_ENTRYA, *PACTRL_PROPERTY_ENTRYA;
typedef struct _ACTRL_PROPERTY_ENTRYW
{
LPWSTR lpProperty;
PACTRL_ACCESS_ENTRY_LISTW pAccessEntryList;
ULONG fListFlags;
} ACTRL_PROPERTY_ENTRYW, *PACTRL_PROPERTY_ENTRYW;
#ifdef UNICODE
typedef ACTRL_PROPERTY_ENTRYW ACTRL_PROPERTY_ENTRY;
typedef PACTRL_PROPERTY_ENTRYW PACTRL_PROPERTY_ENTRY;
#else
typedef ACTRL_PROPERTY_ENTRYA ACTRL_PROPERTY_ENTRY;
typedef PACTRL_PROPERTY_ENTRYA PACTRL_PROPERTY_ENTRY;
#endif // UNICODE
typedef struct _ACTRL_ALISTA
{
ULONG cEntries;
#ifdef __midl
[size_is(cEntries)]
#endif
PACTRL_PROPERTY_ENTRYA pPropertyAccessList;
} ACTRL_ACCESSA, *PACTRL_ACCESSA, ACTRL_AUDITA, *PACTRL_AUDITA;
typedef struct _ACTRL_ALISTW
{
ULONG cEntries;
#ifdef __midl
[size_is(cEntries)]
#endif
PACTRL_PROPERTY_ENTRYW pPropertyAccessList;
} ACTRL_ACCESSW, *PACTRL_ACCESSW, ACTRL_AUDITW, *PACTRL_AUDITW;
#ifdef UNICODE
typedef ACTRL_ACCESSW ACTRL_ACCESS;
typedef PACTRL_ACCESSW PACTRL_ACCESS;
typedef ACTRL_AUDITW ACTRL_AUDIT;
typedef PACTRL_AUDITW PACTRL_AUDIT;
#else
typedef ACTRL_ACCESSA ACTRL_ACCESS;
typedef PACTRL_ACCESSA PACTRL_ACCESS;
typedef ACTRL_AUDITA ACTRL_AUDIT;
typedef PACTRL_AUDITA PACTRL_AUDIT;
#endif // UNICODE
//
// TRUSTEE_ACCESS flags
//
#define TRUSTEE_ACCESS_ALLOWED 0x00000001L
#define TRUSTEE_ACCESS_READ 0x00000002L
#define TRUSTEE_ACCESS_WRITE 0x00000004L
#define TRUSTEE_ACCESS_EXPLICIT 0x00000001L
#define TRUSTEE_ACCESS_READ_WRITE (TRUSTEE_ACCESS_READ | \
TRUSTEE_ACCESS_WRITE)
#define TRUSTEE_ACCESS_ALL 0xFFFFFFFFL
typedef struct _TRUSTEE_ACCESSA
{
LPSTR lpProperty;
ACCESS_RIGHTS Access;
ULONG fAccessFlags;
ULONG fReturnedAccess;
} TRUSTEE_ACCESSA, *PTRUSTEE_ACCESSA;
typedef struct _TRUSTEE_ACCESSW
{
LPWSTR lpProperty;
ACCESS_RIGHTS Access;
ULONG fAccessFlags;
ULONG fReturnedAccess;
} TRUSTEE_ACCESSW, *PTRUSTEE_ACCESSW;
#ifdef UNICODE
typedef TRUSTEE_ACCESSW TRUSTEE_ACCESS;
typedef PTRUSTEE_ACCESSW PTRUSTEE_ACCESS;
#else
typedef TRUSTEE_ACCESSA TRUSTEE_ACCESS;
typedef PTRUSTEE_ACCESSA PTRUSTEE_ACCESS;
#endif // UNICODE
//
// Generic permission values
//
#define ACTRL_RESERVED 0x00000000
#define ACTRL_PERM_1 0x00000001
#define ACTRL_PERM_2 0x00000002
#define ACTRL_PERM_3 0x00000004
#define ACTRL_PERM_4 0x00000008
#define ACTRL_PERM_5 0x00000010
#define ACTRL_PERM_6 0x00000020
#define ACTRL_PERM_7 0x00000040
#define ACTRL_PERM_8 0x00000080
#define ACTRL_PERM_9 0x00000100
#define ACTRL_PERM_10 0x00000200
#define ACTRL_PERM_11 0x00000400
#define ACTRL_PERM_12 0x00000800
#define ACTRL_PERM_13 0x00001000
#define ACTRL_PERM_14 0x00002000
#define ACTRL_PERM_15 0x00004000
#define ACTRL_PERM_16 0x00008000
#define ACTRL_PERM_17 0x00010000
#define ACTRL_PERM_18 0x00020000
#define ACTRL_PERM_19 0x00040000
#define ACTRL_PERM_20 0x00080000
//
// Access permissions
//
#define ACTRL_ACCESS_ALLOWED 0x00000001
#define ACTRL_ACCESS_DENIED 0x00000002
#define ACTRL_AUDIT_SUCCESS 0x00000004
#define ACTRL_AUDIT_FAILURE 0x00000008
//
// Property list flags
//
#define ACTRL_ACCESS_PROTECTED 0x00000001
//
// Standard and object rights
//
#define ACTRL_SYSTEM_ACCESS 0x04000000
#define ACTRL_DELETE 0x08000000
#define ACTRL_READ_CONTROL 0x10000000
#define ACTRL_CHANGE_ACCESS 0x20000000
#define ACTRL_CHANGE_OWNER 0x40000000
#define ACTRL_SYNCHRONIZE 0x80000000
#define ACTRL_STD_RIGHTS_ALL 0xf8000000
#define ACTRL_STD_RIGHT_REQUIRED ( ACTRL_STD_RIGHTS_ALL & ~ACTRL_SYNCHRONIZE )
#ifndef _DS_CONTROL_BITS_DEFINED_
#define _DS_CONTROL_BITS_DEFINED_
#define ACTRL_DS_OPEN ACTRL_RESERVED
#define ACTRL_DS_CREATE_CHILD ACTRL_PERM_1
#define ACTRL_DS_DELETE_CHILD ACTRL_PERM_2
#define ACTRL_DS_LIST ACTRL_PERM_3
#define ACTRL_DS_SELF ACTRL_PERM_4
#define ACTRL_DS_READ_PROP ACTRL_PERM_5
#define ACTRL_DS_WRITE_PROP ACTRL_PERM_6
#define ACTRL_DS_DELETE_TREE ACTRL_PERM_7
#define ACTRL_DS_LIST_OBJECT ACTRL_PERM_8
#define ACTRL_DS_CONTROL_ACCESS ACTRL_PERM_9
#endif
#define ACTRL_FILE_READ ACTRL_PERM_1
#define ACTRL_FILE_WRITE ACTRL_PERM_2
#define ACTRL_FILE_APPEND ACTRL_PERM_3
#define ACTRL_FILE_READ_PROP ACTRL_PERM_4
#define ACTRL_FILE_WRITE_PROP ACTRL_PERM_5
#define ACTRL_FILE_EXECUTE ACTRL_PERM_6
#define ACTRL_FILE_READ_ATTRIB ACTRL_PERM_8
#define ACTRL_FILE_WRITE_ATTRIB ACTRL_PERM_9
#define ACTRL_FILE_CREATE_PIPE ACTRL_PERM_10
#define ACTRL_DIR_LIST ACTRL_PERM_1
#define ACTRL_DIR_CREATE_OBJECT ACTRL_PERM_2
#define ACTRL_DIR_CREATE_CHILD ACTRL_PERM_3
#define ACTRL_DIR_DELETE_CHILD ACTRL_PERM_7
#define ACTRL_DIR_TRAVERSE ACTRL_PERM_6
#define ACTRL_KERNEL_TERMINATE ACTRL_PERM_1
#define ACTRL_KERNEL_THREAD ACTRL_PERM_2
#define ACTRL_KERNEL_VM ACTRL_PERM_3
#define ACTRL_KERNEL_VM_READ ACTRL_PERM_4
#define ACTRL_KERNEL_VM_WRITE ACTRL_PERM_5
#define ACTRL_KERNEL_DUP_HANDLE ACTRL_PERM_6
#define ACTRL_KERNEL_PROCESS ACTRL_PERM_7
#define ACTRL_KERNEL_SET_INFO ACTRL_PERM_8
#define ACTRL_KERNEL_GET_INFO ACTRL_PERM_9
#define ACTRL_KERNEL_CONTROL ACTRL_PERM_10
#define ACTRL_KERNEL_ALERT ACTRL_PERM_11
#define ACTRL_KERNEL_GET_CONTEXT ACTRL_PERM_12
#define ACTRL_KERNEL_SET_CONTEXT ACTRL_PERM_13
#define ACTRL_KERNEL_TOKEN ACTRL_PERM_14
#define ACTRL_KERNEL_IMPERSONATE ACTRL_PERM_15
#define ACTRL_KERNEL_DIMPERSONATE ACTRL_PERM_16
#define ACTRL_PRINT_SADMIN ACTRL_PERM_1
#define ACTRL_PRINT_SLIST ACTRL_PERM_2
#define ACTRL_PRINT_PADMIN ACTRL_PERM_3
#define ACTRL_PRINT_PUSE ACTRL_PERM_4
#define ACTRL_PRINT_JADMIN ACTRL_PERM_5
#define ACTRL_SVC_GET_INFO ACTRL_PERM_1
#define ACTRL_SVC_SET_INFO ACTRL_PERM_2
#define ACTRL_SVC_STATUS ACTRL_PERM_3
#define ACTRL_SVC_LIST ACTRL_PERM_4
#define ACTRL_SVC_START ACTRL_PERM_5
#define ACTRL_SVC_STOP ACTRL_PERM_6
#define ACTRL_SVC_PAUSE ACTRL_PERM_7
#define ACTRL_SVC_INTERROGATE ACTRL_PERM_8
#define ACTRL_SVC_UCONTROL ACTRL_PERM_9
#define ACTRL_REG_QUERY ACTRL_PERM_1
#define ACTRL_REG_SET ACTRL_PERM_2
#define ACTRL_REG_CREATE_CHILD ACTRL_PERM_3
#define ACTRL_REG_LIST ACTRL_PERM_4
#define ACTRL_REG_NOTIFY ACTRL_PERM_5
#define ACTRL_REG_LINK ACTRL_PERM_6
#define ACTRL_WIN_CLIPBRD ACTRL_PERM_1
#define ACTRL_WIN_GLOBAL_ATOMS ACTRL_PERM_2
#define ACTRL_WIN_CREATE ACTRL_PERM_3
#define ACTRL_WIN_LIST_DESK ACTRL_PERM_4
#define ACTRL_WIN_LIST ACTRL_PERM_5
#define ACTRL_WIN_READ_ATTRIBS ACTRL_PERM_6
#define ACTRL_WIN_WRITE_ATTRIBS ACTRL_PERM_7
#define ACTRL_WIN_SCREEN ACTRL_PERM_8
#define ACTRL_WIN_EXIT ACTRL_PERM_9
#pragma warning (push)
#pragma warning (disable: 4201)
typedef struct _ACTRL_OVERLAPPED
{
union {
PVOID Provider;
ULONG Reserved1;
} DUMMYUNIONNAME;
ULONG Reserved2;
HANDLE hEvent;
} ACTRL_OVERLAPPED, *PACTRL_OVERLAPPED;
#pragma warning(pop)
typedef struct _ACTRL_ACCESS_INFOA
{
ULONG fAccessPermission;
LPSTR lpAccessPermissionName;
} ACTRL_ACCESS_INFOA, *PACTRL_ACCESS_INFOA;
typedef struct _ACTRL_ACCESS_INFOW
{
ULONG fAccessPermission;
LPWSTR lpAccessPermissionName;
} ACTRL_ACCESS_INFOW, *PACTRL_ACCESS_INFOW;
#ifdef UNICODE
typedef ACTRL_ACCESS_INFOW ACTRL_ACCESS_INFO;
typedef PACTRL_ACCESS_INFOW PACTRL_ACCESS_INFO;
#else
typedef ACTRL_ACCESS_INFOA ACTRL_ACCESS_INFO;
typedef PACTRL_ACCESS_INFOA PACTRL_ACCESS_INFO;
#endif // UNICODE
typedef struct _ACTRL_CONTROL_INFOA
{
LPSTR lpControlId;
LPSTR lpControlName;
} ACTRL_CONTROL_INFOA, *PACTRL_CONTROL_INFOA;
typedef struct _ACTRL_CONTROL_INFOW
{
LPWSTR lpControlId;
LPWSTR lpControlName;
} ACTRL_CONTROL_INFOW, *PACTRL_CONTROL_INFOW;
#ifdef UNICODE
typedef ACTRL_CONTROL_INFOW ACTRL_CONTROL_INFO;
typedef PACTRL_CONTROL_INFOW PACTRL_CONTROL_INFO;
#else
typedef ACTRL_CONTROL_INFOA ACTRL_CONTROL_INFO;
typedef PACTRL_CONTROL_INFOA PACTRL_CONTROL_INFO;
#endif // UNICODE
#define ACTRL_ACCESS_NO_OPTIONS 0x00000000
#define ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES 0x00000001
#if (NTDDI_VERSION >= NTDDI_VISTA)
#define TREE_SEC_INFO_SET 0x00000001
#define TREE_SEC_INFO_RESET 0x00000002
#define TREE_SEC_INFO_RESET_KEEP_EXPLICIT 0x00000003
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
typedef enum _PROGRESS_INVOKE_SETTING {
ProgressInvokeNever = 1, // Never invoke the progress function
ProgressInvokeEveryObject, // Invoke for each object
ProgressInvokeOnError, // Invoke only for each error case
ProgressCancelOperation, // Stop propagation and return
ProgressRetryOperation, // Retry operation on subtree
#if (NTDDI_VERSION >= NTDDI_VISTA)
ProgressInvokePrePostError, // Invoke Pre, Post, Error
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
} PROG_INVOKE_SETTING, *PPROG_INVOKE_SETTING;
//
// Progress Function:
// Caller of tree operation implements this Progress function, then
// passes its function pointer to tree operation.
// Tree operation invokes Progress function to provide progress and error
// information to the caller during the potentially long execution
// of the tree operation. Tree operation provides the name of the object
// last processed and the error status of the operation on that object.
// Tree operation also passes the current InvokeSetting value.
// Caller may change the InvokeSetting value, for example, from "Always"
// to "Only On Error."
//
/*
typedef VOID (*FN_PROGRESS) (
IN LPWSTR pObjectName, // name of object just processed
IN DWORD Status, // status of operation on object
IN OUT PPROG_INVOKE_SETTING pInvokeSetting, // Never, always,
IN PVOID Args, // Caller specific data
IN BOOL SecuritySet // Whether security was set
);
*/
//
// New Object Type function pointers. TBD.
// To support additional object resource managers generically, the
// resource manager must provide it's own functions for operations
// like:
// GetAncestorAcl(IN ObjName, IN GenerationGap, IN DaclOrSacl?, ...)
// GetAncestorName(...)
// FreeNameStructure(...)
//
typedef struct _FN_OBJECT_MGR_FUNCTIONS
{
ULONG Placeholder;
} FN_OBJECT_MGR_FUNCTS, *PFN_OBJECT_MGR_FUNCTS;
//
// Name of ancestor and number of generations between
// ancestor and inheriting object.
//
// GenerationGap:
// Name of ancestor from which ACE was inherited.
// NULL for explicit ACE.
//
// AncestorName:
// Number of levels (or generations) between the object and the ancestor.
// Parent, gap=1.
// Grandparent, gap=2.
// Set to 0 for explicit ACE on object.
//
typedef struct _INHERITED_FROMA
{
LONG GenerationGap;
LPSTR AncestorName;
} INHERITED_FROMA, *PINHERITED_FROMA;
typedef struct _INHERITED_FROMW
{
LONG GenerationGap;
LPWSTR AncestorName;
} INHERITED_FROMW, *PINHERITED_FROMW;
#ifdef UNICODE
typedef INHERITED_FROMW INHERITED_FROM;
typedef PINHERITED_FROMW PINHERITED_FROM;
#else
typedef INHERITED_FROMA INHERITED_FROM;
typedef PINHERITED_FROMA PINHERITED_FROM;
#endif // UNICODE
#ifdef __cplusplus
}
#endif
#if (_MSC_VER >= 800)
#if (_MSC_VER >= 1200)
#pragma warning(pop)
#else
#pragma warning(default:4001)
#endif
#endif
#endif /* __ACCESS_CONTROL__ */

View File

@ -0,0 +1,253 @@
/*++
Copyright (c) 1997 Microsoft Corporation
Module Name:
acpiioct.h
Abstract:
This module handles all of the INTERNAL_DEVICE_CONTROLS requested to
the ACPI driver
Author:
Environment:
NT Kernel Model Driver only
--*/
#ifndef _ACPIIOCT_H_
#define _ACPIIOCT_H_
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#pragma warning(push)
#endif
#pragma warning(disable:4201) // named type definition in parentheses
//
// IRP_MJ_INTERNAL_DEVICE_CONTROL CODES
//
#define IOCTL_ACPI_ASYNC_EVAL_METHOD CTL_CODE(FILE_DEVICE_ACPI, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_ACPI_EVAL_METHOD CTL_CODE(FILE_DEVICE_ACPI, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK CTL_CODE(FILE_DEVICE_ACPI, 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_ACPI_RELEASE_GLOBAL_LOCK CTL_CODE(FILE_DEVICE_ACPI, 5, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#if (NTDDI_VERSION >= NTDDI_VISTA)
#define IOCTL_ACPI_EVAL_METHOD_EX CTL_CODE(FILE_DEVICE_ACPI, 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_ACPI_ASYNC_EVAL_METHOD_EX CTL_CODE(FILE_DEVICE_ACPI, 7, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_ACPI_ENUM_CHILDREN CTL_CODE(FILE_DEVICE_ACPI, 8, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#endif
//
// Data structures used for IOCTL_ACPI_ASYNC_EVAL_METHOD and
// IOCTL_ACPI_EVAL_METHOD
//
//
// Possible Input buffer
//
typedef struct _ACPI_EVAL_INPUT_BUFFER {
ULONG Signature;
union {
UCHAR MethodName[4];
ULONG MethodNameAsUlong;
} DUMMYUNIONNAME;
} ACPI_EVAL_INPUT_BUFFER, *PACPI_EVAL_INPUT_BUFFER;
typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER {
ULONG Signature;
union {
UCHAR MethodName[4];
ULONG MethodNameAsUlong;
} DUMMYUNIONNAME;
ULONG IntegerArgument;
} ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER, *PACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER;
typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING {
ULONG Signature;
union {
UCHAR MethodName[4];
ULONG MethodNameAsUlong;
} DUMMYUNIONNAME;
ULONG StringLength;
UCHAR String[ANYSIZE_ARRAY];
} ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING, *PACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING;
typedef struct _ACPI_METHOD_ARGUMENT {
USHORT Type;
USHORT DataLength;
union {
ULONG Argument;
UCHAR Data[ANYSIZE_ARRAY];
} DUMMYUNIONNAME;
} ACPI_METHOD_ARGUMENT;
typedef ACPI_METHOD_ARGUMENT UNALIGNED *PACPI_METHOD_ARGUMENT;
#define ACPI_METHOD_ARGUMENT_LENGTH( DataLength ) \
(FIELD_OFFSET(ACPI_METHOD_ARGUMENT, Data) + max(sizeof(ULONG), DataLength))
#define ACPI_METHOD_ARGUMENT_LENGTH_FROM_ARGUMENT( Argument ) \
(ACPI_METHOD_ARGUMENT_LENGTH(((PACPI_METHOD_ARGUMENT)Argument)->DataLength))
#define ACPI_METHOD_NEXT_ARGUMENT( Argument ) \
(PACPI_METHOD_ARGUMENT) ( (PUCHAR) Argument + \
ACPI_METHOD_ARGUMENT_LENGTH_FROM_ARGUMENT( Argument ) )
#define ACPI_METHOD_SET_ARGUMENT_INTEGER( MethodArgument, IntData ) \
{ MethodArgument->Type = ACPI_METHOD_ARGUMENT_INTEGER; \
MethodArgument->DataLength = sizeof(ULONG); \
MethodArgument->Argument = IntData; }
#define ACPI_METHOD_SET_ARGUMENT_STRING( Argument, StrData ) \
{ Argument->Type = ACPI_METHOD_ARGUMENT_STRING; \
Argument->DataLength = strlen((PUCHAR)StrData) + sizeof(UCHAR); \
RtlCopyMemory(&Argument->Data[0],(PUCHAR)StrData,Argument->DataLength); }
#define ACPI_METHOD_SET_ARGUMENT_BUFFER( Argument, BuffData, BuffLength ) \
{ Argument->Type = ACPI_METHOD_ARGUMENT_BUFFER; \
Argument->DataLength = BuffLength; \
RtlCopyMemory(&Argument->Data[0],(PUCHAR)BuffData,Argument->DataLength); }
typedef struct _ACPI_EVAL_INPUT_BUFFER_COMPLEX {
ULONG Signature;
union {
UCHAR MethodName[4];
ULONG MethodNameAsUlong;
} DUMMYUNIONNAME;
ULONG Size;
ULONG ArgumentCount;
ACPI_METHOD_ARGUMENT Argument[ANYSIZE_ARRAY];
} ACPI_EVAL_INPUT_BUFFER_COMPLEX, *PACPI_EVAL_INPUT_BUFFER_COMPLEX;
typedef struct _ACPI_EVAL_OUTPUT_BUFFER {
ULONG Signature;
ULONG Length;
ULONG Count;
ACPI_METHOD_ARGUMENT Argument[ANYSIZE_ARRAY];
} ACPI_EVAL_OUTPUT_BUFFER;
typedef ACPI_EVAL_OUTPUT_BUFFER UNALIGNED *PACPI_EVAL_OUTPUT_BUFFER;
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE 'BieA'
#define ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_SIGNATURE 'IieA'
#define ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING_SIGNATURE 'SieA'
#define ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE 'CieA'
#define ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE 'BoeA'
#if (NTDDI_VERSION >= NTDDI_VISTA)
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE_EX 'AieA'
#define ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_SIGNATURE_EX 'DieA'
#define ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING_SIGNATURE_EX 'EieA'
#define ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE_EX 'FieA'
#define ACPI_ENUM_CHILDREN_OUTPUT_BUFFER_SIGNATURE 'GieA'
#define ACPI_ENUM_CHILDREN_INPUT_BUFFER_SIGNATURE 'HieA'
#endif
#define ACPI_METHOD_ARGUMENT_INTEGER 0x0
#define ACPI_METHOD_ARGUMENT_STRING 0x1
#define ACPI_METHOD_ARGUMENT_BUFFER 0x2
#define ACPI_METHOD_ARGUMENT_PACKAGE 0x3
#define ACPI_METHOD_ARGUMENT_PACKAGE_EX 0x4
//
// Data structures used for IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK
// IOCTL_ACPI_RELEASE_GLOBAL_LOCK
//
typedef struct _ACPI_MANIPULATE_GLOBAL_LOCK_BUFFER {
ULONG Signature;
PVOID LockObject;
} ACPI_MANIPULATE_GLOBAL_LOCK_BUFFER, *PACPI_MANIPULATE_GLOBAL_LOCK_BUFFER;
#define ACPI_ACQUIRE_GLOBAL_LOCK_SIGNATURE 'LgaA'
#define ACPI_RELEASE_GLOBAL_LOCK_SIGNATURE 'LgrA'
//
// Data structure used for IOCTL_ACPI_ASYNC_EVAL_METHOD_EX,
// IOCTL_ACPI_EVAL_METHOD_EX and
// IOCTL_ACPI_ENUM_CHILDREN
//
typedef struct _ACPI_EVAL_INPUT_BUFFER_EX {
ULONG Signature;
CHAR MethodName[256]; //NULL terminated name string
} ACPI_EVAL_INPUT_BUFFER_EX, *PACPI_EVAL_INPUT_BUFFER_EX;
typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_EX {
ULONG Signature;
CHAR MethodName[256];//NULL terminated name string
ULONG64 IntegerArgument;
} ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_EX, *PACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_EX;
typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING_EX {
ULONG Signature;
CHAR MethodName[256];//NULL terminated name string
ULONG StringLength;
UCHAR String[ANYSIZE_ARRAY];
} ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING_EX, *PACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING_EX;
typedef struct _ACPI_EVAL_INPUT_BUFFER_COMPLEX_EX {
ULONG Signature;
CHAR MethodName[256];//NULL terminated name string
ULONG Size;
ULONG ArgumentCount;
ACPI_METHOD_ARGUMENT Argument[ANYSIZE_ARRAY];
} ACPI_EVAL_INPUT_BUFFER_COMPLEX_EX, *PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX;
typedef struct _ACPI_ENUM_CHILDREN_INPUT_BUFFER {
ULONG Signature;
ULONG Flags;
ULONG NameLength;
CHAR Name[ANYSIZE_ARRAY];
} ACPI_ENUM_CHILDREN_INPUT_BUFFER, *PACPI_ENUM_CHILDREN_INPUT_BUFFER;
typedef struct _ACPI_ENUM_CHILD {
ULONG Flags;
ULONG NameLength; // length including null terminator
CHAR Name[ANYSIZE_ARRAY];
} ACPI_ENUM_CHILD;
typedef ACPI_ENUM_CHILD UNALIGNED *PACPI_ENUM_CHILD;
typedef struct _ACPI_ENUM_CHILDREN_OUTPUT_BUFFER {
ULONG Signature;
ULONG NumberOfChildren;
ACPI_ENUM_CHILD Children[ANYSIZE_ARRAY];
} ACPI_ENUM_CHILDREN_OUTPUT_BUFFER;
typedef ACPI_ENUM_CHILDREN_OUTPUT_BUFFER UNALIGNED *PACPI_ENUM_CHILDREN_OUTPUT_BUFFER;
#define ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child ) \
( (2* sizeof (ULONG)) + Child->NameLength )
#define ACPI_ENUM_CHILD_NEXT( Child ) \
(PACPI_ENUM_CHILD) ( (PUCHAR) Child + \
ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child ) )
//
// valid flags for ACPI_ENUM_CHILDREN_INPUT_BUFFER.Flags
//
#define ENUM_CHILDREN_IMMEDIATE_ONLY 0x1
#define ENUM_CHILDREN_MULTILEVEL 0x2
#define ENUM_CHILDREN_NAME_IS_FILTER 0x4
//
// valid flags for ACPI_ENUM_CHILD
//
#define ACPI_OBJECT_HAS_CHILDREN 0x1
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
#pragma warning(pop)
#endif
#endif

View File

@ -0,0 +1,68 @@
//==========================================================================;
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//--------------------------------------------------------------------------;
//
//
// We want to use this list for generating strings for debugging too
// so we redefine OUR_GUID_ENTRY depending on what we want to do
//
// It is imperative that all entries in this file are declared using
// OUR_GUID_ENTRY as that macro might have been defined in advance of
// including this file. See wxdebug.cpp in sdk\classes\base.
//
#ifndef OUR_GUID_ENTRY
#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8);
#endif
// -------------------------------------------------------------------------
// TVTuner GUIDS
// -------------------------------------------------------------------------
// {266EEE40-6C63-11cf-8A03-00AA006ECB65}
OUR_GUID_ENTRY(CLSID_CTVTunerFilter,
0x266eee40, 0x6c63, 0x11cf, 0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65);
// {266EEE41-6C63-11cf-8A03-00AA006ECB65}
OUR_GUID_ENTRY(CLSID_CTVTunerFilterPropertyPage,
0x266eee41, 0x6c63, 0x11cf, 0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65);
// {266EEE44-6C63-11cf-8A03-00AA006ECB65}
OUR_GUID_ENTRY(IID_AnalogVideoStandard,
0x266eee44, 0x6c63, 0x11cf, 0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65);
// {266EEE46-6C63-11cf-8A03-00AA006ECB65}
OUR_GUID_ENTRY(IID_TunerInputType,
0x266eee46, 0x6c63, 0x11cf, 0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65);
// -------------------------------------------------------------------------
// Crossbar (XBar) GUIDS
// -------------------------------------------------------------------------
// {71F96460-78F3-11d0-A18C-00A0C9118956}
OUR_GUID_ENTRY(CLSID_CrossbarFilter,
0x71f96460, 0x78f3, 0x11d0, 0xa1, 0x8c, 0x0, 0xa0, 0xc9, 0x11, 0x89, 0x56);
// {71F96461-78F3-11d0-A18C-00A0C9118956}
OUR_GUID_ENTRY(CLSID_CrossbarFilterPropertyPage,
0x71f96461, 0x78f3, 0x11d0, 0xa1, 0x8c, 0x0, 0xa0, 0xc9, 0x11, 0x89, 0x56);
// {71F96462-78F3-11d0-A18C-00A0C9118956}
OUR_GUID_ENTRY(CLSID_TVAudioFilter,
0x71f96462, 0x78f3, 0x11d0, 0xa1, 0x8c, 0x0, 0xa0, 0xc9, 0x11, 0x89, 0x56);
// {71F96463-78F3-11d0-A18C-00A0C9118956}
OUR_GUID_ENTRY(CLSID_TVAudioFilterPropertyPage,
0x71f96463, 0x78f3, 0x11d0, 0xa1, 0x8c, 0x0, 0xa0, 0xc9, 0x11, 0x89, 0x56);

View File

@ -0,0 +1,316 @@
/*
* AnchorSyncDeviceService.h
*
* Contains definitions for the Anchor Sync Device Service
*
* Copyright (c) Microsoft Corporation, All Rights Reserved.
*
*/
#ifndef _ANCHORSYNCSERVICE_H_
#define _ANCHORSYNCSERVICE_H_
#include <DeviceServices.h>
#include <SyncDeviceService.h>
/*****************************************************************************/
/* Anchor Sync Service Info */
/*****************************************************************************/
DEFINE_DEVSVCGUID(SERVICE_AnchorSync,
0x056d8b9e, 0xad7a, 0x44fc, 0x94, 0x6f, 0x1d, 0x63, 0xa2, 0x5c, 0xda, 0x9a);
#define NAME_AnchorSyncSvc L"AnchorSync"
#define TYPE_AnchorSyncSvc DEVSVCTYPE_ABSTRACT
/*****************************************************************************/
/* Anchor Sync Service Properties */
/*****************************************************************************/
DEFINE_DEVSVCGUID(NAMESPACE_AnchorSyncSvc,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa);
/* PKEY_AnchorSyncSvc_VersionProps
*
* Provides information about change units and version properties. The
* format for the dataset is
*
* UINT32 Number of change units
* UINT128 Namespace GUID for first change unit property key
* UINT32 Namespace ID for the first change unit property key
* UINT32 Number of properties associated with this change unit
* UINT128 Namespace GUID for first property key in change unit
* UINT32 Namespace ID for first property key in change unit
* ... Repeat for number of property keys
* ... Repeat for number of change units
*
* NOTE: If all change units use the same property key specify a namespace
* GUID of GUID_NULL (all 0's) and a namespace ID of 0.
*
* Type: AUInt8
* Form: None
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_VersionProps,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
2);
#define NAME_AnchorSyncSvc_VersionProps L"AnchorVersionProps"
/* PKEY_AnchorSyncSvc_ReplicaID
*
* Contains the GUID representing this replica in the sync community.
*
* Type: UInt128
* Form: None
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_ReplicaID,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
3);
#define NAME_AnchorSyncSvc_ReplicaID L"AnchorReplicaID"
/* PKEY_AnchorSyncSvc_KnowledgeObjectID
*
* Object ID to be used for the knowledge object
*
* Type: UInt32
* Form: Object ID
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_KnowledgeObjectID,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
4);
#define NAME_AnchorSyncSvc_KnowledgeObjectID L"AnchorKnowledgeObjectID"
/* PKEY_AnchorSyncSvc_LastSyncProxyID
*
* Contains a GUID indicating the last sync proxy to perform a sync operation
*
* Type: UInt128
* Form: None
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_LastSyncProxyID,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
5);
#define NAME_AnchorSyncSvc_LastSyncProxyID L"AnchorLastSyncProxyID"
/* PKEY_AnchorSyncSvc_CurrentAnchor
*
* Contains a blob of data representing the current anchor for the device.
* As the anchor may be transient depending on the current state of the sync
* the value of PKEY_AnchorSyncSvc_CurrentAnchor may not reflect the current
* state of the database unless the current session holds a lock (via the
* BeginSync method) on the service.
*
* Type: AUInt8
* Form: BinaryArray
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_CurrentAnchor,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
6);
#define NAME_AnchorSyncSvc_CurrentAnchor L"AnchorCurrentAnchor"
/* PKEY_AnchorSyncSvc_ProviderVersion
*
* Contains a device defined value giving the version of the provider
* currently in use on the device. This version must be incremented whenever
* new properties are added to the device implementation so that they will
* be recognized and managed as part of synchronization. 0 is reserved.
*
* Type: UInt16
* Form: None
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorSyncSvc_ProviderVersion,
0xe65b8fb7, 0x8fc7, 0x4278, 0xb9, 0xa3, 0xba, 0x14, 0xc2, 0xdb, 0x40, 0xfa,
7);
#define NAME_AnchorSyncSvc_ProviderVersion L"AnchorProviderVersion"
/* PKEY_AnchorSyncSvc_SyncFormat
*
* Indicates the format GUID for the object format that is to be used in the
* sync operation.
*
* Type: UInt128
* Form: None
*/
#define PKEY_AnchorSyncSvc_SyncFormat PKEY_SyncSvc_SyncFormat
#define NAME_AnchorSyncSvc_SyncFormat NAME_SyncSvc_SyncFormat
/* PKEY_AnchorSyncSvc_LocalOnlyDelete
*
* Boolean flag indicating whether deletes of objects on the service host
* should be treated as "local only" and not propogated to other sync
* participants. The alternative is "true sync" in which deletes on the
* service host are propogated to all other sync participants.
*
* Type: UInt8
* Form: None
*/
#define PKEY_AnchorSyncSvc_LocalOnlyDelete PKEY_SyncSvc_LocalOnlyDelete
#define NAME_AnchorSyncSvc_LocalOnlyDelete NAME_SyncSvc_LocalOnlyDelete
/* PKEY_AnchorSyncSvc_FilterType
*
* Boolean flag indicating whether the default filter is being applied to
* this endpoint. Note that the meaning of the default filter is determined
* by the content type service.
*
* Type: UInt8
* Form: None
*/
#define PKEY_AnchorSyncSvc_FilterType PKEY_SyncSvc_FilterType
#define NAME_AnchorSyncSvc_FilterType NAME_SyncSvc_FilterType
/*****************************************************************************/
/* Anchor Sync Service Object Formats */
/*****************************************************************************/
/* FORMAT_AnchorSyncKnowledge
*/
DEFINE_DEVSVCGUID(FORMAT_AnchorSyncKnowledge,
0x37c550bc, 0xf231, 0x4727, 0xbb, 0xbc, 0x4c, 0xb3, 0x3a, 0x3f, 0x3e, 0xcd);
#define NAME_AnchorSyncKnowledge L"AnchorSyncKnowledge"
/* FORMAT_AnchorSyncSvc_AnchorResults
*
* GetChangesSinceAnchor results format
*/
DEFINE_DEVSVCGUID(FORMAT_AnchorSyncSvc_AnchorResults,
0xf35527c1, 0xce4a, 0x487a, 0x9d, 0x29, 0x93, 0x83, 0x35, 0x69, 0x32, 0x1e);
#define NAME_AnchorResults L"AnchorResults"
/*****************************************************************************/
/* Anchor Sync Service Object Property Keys */
/*****************************************************************************/
DEFINE_DEVSVCGUID(NAMESPACE_AnchorResults,
0x516b5dce, 0x8d45, 0x430f, 0x80, 0x5c, 0x25, 0xe5, 0x10, 0x6d, 0x8b, 0x1f);
/* PKEY_AnchorResults_AnchorState
*
* Output parameter from GetChangesSinceAnchor method. Contains the state
* of the current anchor result:
*
* Type: UInt32
* Form: Enum
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorResults_AnchorState,
0x516b5dce, 0x8d45, 0x430f, 0x80, 0x5c, 0x25, 0xe5, 0x10, 0x6d, 0x8b, 0x1f,
2);
#define NAME_AnchorResults_AnchorState L"AnchorState"
#define ENUM_AnchorResults_AnchorStateNormal 0x00000000
#define ENUM_AnchorResults_AnchorStateInvalid 0x00000001
#define ENUM_AnchorResults_AnchorStateOld 0x00000002
/* PKEY_AnchorResults_Anchor
*
* Input parameter for GetChangesSinceAnchor method. Contains the anchor for
* which data is being requested.
*
* Type: AUInt8
* Form: None
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorResults_Anchor,
0x516b5dce, 0x8d45, 0x430f, 0x80, 0x5c, 0x25, 0xe5, 0x10, 0x6d, 0x8b, 0x1f,
3);
#define NAME_AnchorResults_Anchor L"Anchor"
/* PKEY_AnchorResults_ResultObjectID
*
* Output parameter from GetChangesSinceAnchor method. Contains the object
* ID of the AnchorResults object that has the results of the
* GetChangesSinceAnchor operation.
*
* Type: UInt32
* Form: Object ID
*/
DEFINE_DEVSVCPROPKEY(PKEY_AnchorResults_ResultObjectID,
0x516b5dce, 0x8d45, 0x430f, 0x80, 0x5c, 0x25, 0xe5, 0x10, 0x6d, 0x8b, 0x1f,
4);
#define NAME_AnchorResults_ResultObjectID L"ResultObjectID"
/*****************************************************************************/
/* Anchor Sync Service Methods */
/*****************************************************************************/
/* METHOD_AnchorSyncSvc_GetChangesSinceAnchor
*/
DEFINE_DEVSVCGUID(METHOD_AnchorSyncSvc_GetChangesSinceAnchor,
0x37c550bc, 0xf231, 0x4727, 0xbb, 0xbc, 0x4c, 0xb3, 0x3a, 0x3f, 0x3e, 0xcd);
#define NAME_AnchorSyncSvc_GetChangesSinceAnchor L"GetChangesSinceAnchor"
/* Inherited methods
*/
#define METHOD_AnchorSyncSvc_BeginSync METHOD_SyncSvc_BeginSync
#define NAME_AnchorSyncSvc_BeginSync NAME_SyncSvc_BeginSync
#define METHOD_AnchorSyncSvc_EndSync METHOD_SyncSvc_EndSync
#define NAME_AnchorSyncSvc_EndSync NAME_SyncSvc_EndSync
/*****************************************************************************/
/* Anchor Sync Service Additional Defines */
/*****************************************************************************/
/* ENUM_AnchorResults_ItemState*
*
* This enum is used when encoding the Anchor results stream. It defines the
* current state of an object. If a device is capable of distinguishing
* between item update and create operations the *_ItemStateCreated and
* *_ItemStateUpdated enumerations should be used. If the device cannot
* distinuish between a create and an up updated the *_ItemStateChanged result
* should be used.
*
* Type: UInt32
* Form: Enum
*/
#define ENUM_AnchorResults_ItemStateInvalid 0x00000000
#define ENUM_AnchorResults_ItemStateDeleted 0x00000001
#define ENUM_AnchorResults_ItemStateCreated 0x00000002
#define ENUM_AnchorResults_ItemStateUpdated 0x00000003
#define ENUM_AnchorResults_ItemStateChanged 0x00000004
#endif /* _ANCHORSYNCSERVICE_H_ */

695
HuaGoCorrect/pub/ddk/ata.h Normal file
View File

@ -0,0 +1,695 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
ata.h
Abstract:
Defines the structures used by ATA port and the miniport drivers.
Authors:
Revision History:
--*/
#ifndef _NTATA_
#define _NTATA_
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4214) // bit field types other than int
//
// IDENTIFY device data (response to 0xEC)
//
#pragma pack(push, id_device_data, 1)
typedef struct _IDENTIFY_DEVICE_DATA {
struct {
USHORT Reserved1 : 1;
USHORT Retired3 : 1;
USHORT ResponseIncomplete : 1;
USHORT Retired2 : 3;
USHORT FixedDevice : 1;
USHORT RemovableMedia : 1;
USHORT Retired1 : 7;
USHORT DeviceType : 1;
} GeneralConfiguration; // word 0
USHORT NumCylinders; // word 1
USHORT ReservedWord2;
USHORT NumHeads; // word 3
USHORT Retired1[2];
USHORT NumSectorsPerTrack; // word 6
USHORT VendorUnique1[3];
UCHAR SerialNumber[20]; // word 10-19
USHORT Retired2[2];
USHORT Obsolete1;
UCHAR FirmwareRevision[8]; // word 23-26
UCHAR ModelNumber[40]; // word 27-46
UCHAR MaximumBlockTransfer; // word 47
UCHAR VendorUnique2;
USHORT ReservedWord48;
struct {
UCHAR ReservedByte49;
UCHAR DmaSupported : 1;
UCHAR LbaSupported : 1;
UCHAR IordyDisable : 1;
UCHAR IordySupported : 1;
UCHAR Reserved1 : 1;
UCHAR StandybyTimerSupport : 1;
UCHAR Reserved2 : 2;
USHORT ReservedWord50;
}Capabilities; // word 49-50
USHORT ObsoleteWords51[2];
USHORT TranslationFieldsValid:3; // word 53
USHORT Reserved3:13;
USHORT NumberOfCurrentCylinders; // word 54
USHORT NumberOfCurrentHeads; // word 55
USHORT CurrentSectorsPerTrack; // word 56
ULONG CurrentSectorCapacity; // word 57
UCHAR CurrentMultiSectorSetting; // word 58
UCHAR MultiSectorSettingValid : 1;
UCHAR ReservedByte59 : 7;
ULONG UserAddressableSectors; // word 60-61
USHORT ObsoleteWord62;
USHORT MultiWordDMASupport : 8; // word 63
USHORT MultiWordDMAActive : 8;
USHORT AdvancedPIOModes : 8;
USHORT ReservedByte64 : 8;
USHORT MinimumMWXferCycleTime;
USHORT RecommendedMWXferCycleTime;
USHORT MinimumPIOCycleTime;
USHORT MinimumPIOCycleTimeIORDY;
USHORT ReservedWords69[6];
USHORT QueueDepth : 5;
USHORT ReservedWord75 : 11;
USHORT ReservedWords76[4];
USHORT MajorRevision;
USHORT MinorRevision;
struct {
//
// Word 82
//
USHORT SmartCommands : 1;
USHORT SecurityMode : 1;
USHORT RemovableMediaFeature : 1;
USHORT PowerManagement : 1;
USHORT Reserved1 : 1;
USHORT WriteCache : 1;
USHORT LookAhead : 1;
USHORT ReleaseInterrupt : 1;
USHORT ServiceInterrupt : 1;
USHORT DeviceReset : 1;
USHORT HostProtectedArea : 1;
USHORT Obsolete1 : 1;
USHORT WriteBuffer : 1;
USHORT ReadBuffer : 1;
USHORT Nop : 1;
USHORT Obsolete2 : 1;
//
// Word 83
//
USHORT DownloadMicrocode : 1;
USHORT DmaQueued : 1;
USHORT Cfa : 1;
USHORT AdvancedPm : 1;
USHORT Msn : 1;
USHORT PowerUpInStandby : 1;
USHORT ManualPowerUp : 1;
USHORT Reserved2 : 1;
USHORT SetMax : 1;
USHORT Acoustics : 1;
USHORT BigLba : 1;
USHORT DeviceConfigOverlay : 1;
USHORT FlushCache : 1;
USHORT FlushCacheExt : 1;
USHORT Resrved3 : 2;
//
// Word 84
//
USHORT SmartErrorLog : 1;
USHORT SmartSelfTest : 1;
USHORT MediaSerialNumber : 1;
USHORT MediaCardPassThrough : 1;
USHORT StreamingFeature : 1;
USHORT GpLogging : 1;
USHORT WriteFua : 1;
USHORT WriteQueuedFua : 1;
USHORT WWN64Bit : 1;
USHORT URGReadStream : 1;
USHORT URGWriteStream : 1;
USHORT ReservedForTechReport : 2;
USHORT IdleWithUnloadFeature : 1;
USHORT Reserved4 : 2;
}CommandSetSupport;
struct {
//
// Word 85
//
USHORT SmartCommands : 1;
USHORT SecurityMode : 1;
USHORT RemovableMediaFeature : 1;
USHORT PowerManagement : 1;
USHORT Reserved1 : 1;
USHORT WriteCache : 1;
USHORT LookAhead : 1;
USHORT ReleaseInterrupt : 1;
USHORT ServiceInterrupt : 1;
USHORT DeviceReset : 1;
USHORT HostProtectedArea : 1;
USHORT Obsolete1 : 1;
USHORT WriteBuffer : 1;
USHORT ReadBuffer : 1;
USHORT Nop : 1;
USHORT Obsolete2 : 1;
//
// Word 86
//
USHORT DownloadMicrocode : 1;
USHORT DmaQueued : 1;
USHORT Cfa : 1;
USHORT AdvancedPm : 1;
USHORT Msn : 1;
USHORT PowerUpInStandby : 1;
USHORT ManualPowerUp : 1;
USHORT Reserved2 : 1;
USHORT SetMax : 1;
USHORT Acoustics : 1;
USHORT BigLba : 1;
USHORT DeviceConfigOverlay : 1;
USHORT FlushCache : 1;
USHORT FlushCacheExt : 1;
USHORT Resrved3 : 2;
//
// Word 87
//
USHORT SmartErrorLog : 1;
USHORT SmartSelfTest : 1;
USHORT MediaSerialNumber : 1;
USHORT MediaCardPassThrough : 1;
USHORT StreamingFeature : 1;
USHORT GpLogging : 1;
USHORT WriteFua : 1;
USHORT WriteQueuedFua : 1;
USHORT WWN64Bit : 1;
USHORT URGReadStream : 1;
USHORT URGWriteStream : 1;
USHORT ReservedForTechReport : 2;
USHORT IdleWithUnloadFeature : 1;
USHORT Reserved4 : 2;
}CommandSetActive;
USHORT UltraDMASupport : 8; // word 88
USHORT UltraDMAActive : 8;
USHORT ReservedWord89[4];
USHORT HardwareResetResult;
USHORT CurrentAcousticValue : 8;
USHORT RecommendedAcousticValue : 8;
USHORT ReservedWord95[5];
ULONG Max48BitLBA[2]; // word 100-103
USHORT StreamingTransferTime;
USHORT ReservedWord105;
struct {
USHORT LogicalSectorsPerPhysicalSector : 4;
USHORT Reserved0 : 8;
USHORT LogicalSectorLongerThan256Words : 1;
USHORT MultipleLogicalSectorsPerPhysicalSector : 1;
USHORT Reserved1 : 2;
} PhysicalLogicalSectorSize; // word 106
USHORT InterSeekDelay; //word 107
USHORT WorldWideName[4]; //words 108-111
USHORT ReservedForWorldWideName128[4]; //words 112-115
USHORT ReservedForTlcTechnicalReport; //word 116
USHORT WordsPerLogicalSector[2]; //words 117-118
struct {
USHORT ReservedForDrqTechnicalReport : 1;
USHORT WriteReadVerifySupported : 1;
USHORT Reserved0 : 11;
USHORT Reserved1 : 2;
}CommandSetSupportExt; //word 119
struct {
USHORT ReservedForDrqTechnicalReport : 1;
USHORT WriteReadVerifyEnabled : 1;
USHORT Reserved0 : 11;
USHORT Reserved1 : 2;
}CommandSetActiveExt; //word 120
USHORT ReservedForExpandedSupportandActive[6];
USHORT MsnSupport : 2; //word 127
USHORT ReservedWord127 : 14;
struct { //word 128
USHORT SecuritySupported : 1;
USHORT SecurityEnabled : 1;
USHORT SecurityLocked : 1;
USHORT SecurityFrozen : 1;
USHORT SecurityCountExpired : 1;
USHORT EnhancedSecurityEraseSupported : 1;
USHORT Reserved0 : 2;
USHORT SecurityLevel : 1;
USHORT Reserved1 : 7;
} SecurityStatus;
USHORT ReservedWord129[31];
struct { //word 160
USHORT MaximumCurrentInMA : 12;
USHORT CfaPowerMode1Disabled : 1;
USHORT CfaPowerMode1Required : 1;
USHORT Reserved0 : 1;
USHORT Word160Supported : 1;
} CfaPowerMode1;
USHORT ReservedForCfaWord161[8]; //Words 161-168
struct { //Word 169
USHORT SupportsTrim : 1;
USHORT Reserved0 : 15;
} DataSetManagementFeature;
USHORT ReservedForCfaWord170[6]; //Words 170-175
USHORT CurrentMediaSerialNumber[30]; //Words 176-205
USHORT ReservedWord206; //Word 206
USHORT ReservedWord207[2]; //Words 207-208
struct { //Word 209
USHORT AlignmentOfLogicalWithinPhysical: 14;
USHORT Word209Supported: 1;
USHORT Reserved0: 1;
} BlockAlignment;
USHORT WriteReadVerifySectorCountMode3Only[2]; //Words 210-211
USHORT WriteReadVerifySectorCountMode2Only[2]; //Words 212-213
struct {
USHORT NVCachePowerModeEnabled: 1;
USHORT Reserved0: 3;
USHORT NVCacheFeatureSetEnabled: 1;
USHORT Reserved1: 3;
USHORT NVCachePowerModeVersion: 4;
USHORT NVCacheFeatureSetVersion: 4;
} NVCacheCapabilities; //Word 214
USHORT NVCacheSizeLSW; //Word 215
USHORT NVCacheSizeMSW; //Word 216
USHORT NominalMediaRotationRate; //Word 217; value 0001h means non-rotating media.
USHORT ReservedWord218; //Word 218
struct {
UCHAR NVCacheEstimatedTimeToSpinUpInSeconds;
UCHAR Reserved;
} NVCacheOptions; //Word 219
USHORT ReservedWord220[35]; //Words 220-254
USHORT Signature : 8; //Word 255
USHORT CheckSum : 8;
} IDENTIFY_DEVICE_DATA, *PIDENTIFY_DEVICE_DATA;
#pragma pack (pop, id_device_data)
//
// identify packet data (response to 0xA1)
//
#pragma pack (push, id_packet_data, 1)
typedef struct _IDENTIFY_PACKET_DATA {
struct {
USHORT PacketType : 2;
USHORT Reserved1 : 3;
USHORT DrqDelay : 2;
USHORT RemovableMedia : 1;
USHORT CommandPacketType : 5;
USHORT Reserved2 : 1;
USHORT DeviceType : 2;
}GeneralConfiguration;
USHORT ResevedWord1;
USHORT UniqueConfiguration;
USHORT ReservedWords3[7];
USHORT SerialNumber[10];
USHORT ReservedWords20[3];
USHORT FirmwareRevision[4];
USHORT ModelNumber[20];
USHORT ReservedWords47[2];
struct {
USHORT VendorSpecific : 8;
USHORT DmaSupported : 1;
USHORT LbaSupported : 1;
USHORT IordyDisabled : 1;
USHORT IordySupported : 1;
USHORT Obsolete : 1;
USHORT OverlapSupported : 1;
USHORT QueuedCommandsSupported : 1;
USHORT InterleavedDmaSupported : 1;
} Capabilities;
USHORT ReservedWord50;
USHORT ObsoleteWords51[2];
USHORT TranslationFieldsValid:3;
USHORT Reserved3:13;
USHORT ReservedWords54[9];
USHORT MultiWordDMASupport : 8; // word 63
USHORT MultiWordDMAActive : 8;
USHORT AdvancedPIOModes : 8;
USHORT ReservedByte64 : 8;
USHORT MinimumMWXferCycleTime;
USHORT RecommendedMWXferCycleTime;
USHORT MinimumPIOCycleTime;
USHORT MinimumPIOCycleTimeIORDY;
USHORT ReservedWords69[2];
USHORT BusReleaseDelay;
USHORT ServiceCommandDelay;
USHORT ReservedWords73[2];
USHORT QueueDepth : 5;
USHORT ReservedWord75 : 11;
USHORT ReservedWords76[4];
USHORT MajorRevision;
USHORT MinorRevision;
struct {
USHORT SmartCommands : 1;
USHORT SecurityMode : 1;
USHORT RemovableMedia : 1;
USHORT PowerManagement : 1;
USHORT PacketCommands : 1;
USHORT WriteCache : 1;
USHORT LookAhead : 1;
USHORT ReleaseInterrupt : 1;
USHORT ServiceInterrupt : 1;
USHORT DeviceReset : 1;
USHORT HostProtectedArea : 1;
USHORT Obsolete1 : 1;
USHORT WriteBuffer : 1;
USHORT ReadBuffer : 1;
USHORT Nop : 1;
USHORT Obsolete2 : 1;
USHORT DownloadMicrocode : 1;
USHORT Reserved1 : 3;
USHORT Msn : 1;
USHORT PowerUpInStandby : 1;
USHORT ManualPowerUp : 1;
USHORT Reserved2 : 1;
USHORT SetMax : 1;
USHORT Reserved3 : 7;
} CommandSetSupport;
USHORT ReservedWord84;
struct {
USHORT SmartCommands : 1;
USHORT SecurityMode : 1;
USHORT RemovableMedia : 1;
USHORT PowerManagement : 1;
USHORT PacketCommands : 1;
USHORT WriteCache : 1;
USHORT LookAhead : 1;
USHORT ReleaseInterrupt : 1;
USHORT ServiceInterrupt : 1;
USHORT DeviceReset : 1;
USHORT HostProtectedArea : 1;
USHORT Obsolete1 : 1;
USHORT WriteBuffer : 1;
USHORT ReadBuffer : 1;
USHORT Nop : 1;
USHORT Obsolete2 : 1;
USHORT DownloadMicrocode : 1;
USHORT Reserved1 : 3;
USHORT Msn : 1;
USHORT PowerUpInStandby : 1;
USHORT ManualPowerUp : 1;
USHORT Reserved2 : 1;
USHORT SetMax : 1;
USHORT Reserved : 7;
} CommandSetActive;
USHORT ReservedWord87;
USHORT UltraDMASupport : 8; // word 88
USHORT UltraDMAActive : 8;
USHORT ReservedWords89[4];
USHORT HardwareResetResult;
USHORT ReservedWords94[32];
USHORT AtapiZeroByteCount;
USHORT MsnSupport : 2;
USHORT ReservedWord127 : 14;
USHORT SecurityStatus;
USHORT ReservedWord129[126];
USHORT Signature : 8;
USHORT CheckSum : 8;
} IDENTIFY_PACKET_DATA, *PIDENTIFY_PACKET_DATA;
#pragma pack (pop, id_packet_data)
//
// Register FIS
//
#pragma pack (push, regfis, 1)
typedef struct _REGISTER_FIS {
//
// dword 0
//
UCHAR FisType;
UCHAR Reserved0 : 7;
UCHAR CmdReg : 1;
UCHAR Command;
UCHAR Features;
//
// dword 1
//
UCHAR SectorNumber;
UCHAR CylinderLow;
UCHAR CylinderHigh;
UCHAR DeviceHead;
//
// dword 2
//
UCHAR SectorNumberExp;
UCHAR CylinderLowExp;
UCHAR CylinderHighExp;
UCHAR FeaturesExp;
//
// dword 3
//
UCHAR SectorCount;
UCHAR SectorCountExp;
UCHAR Reserved2;
UCHAR Control;
//
// dword 4
//
ULONG Reserved3;
}REGISTER_FIS, *PREGISTER_FIS;
#pragma pack (pop, regfis)
//
// ATAPI specific scsiops
//
#define ATAPI_MODE_SENSE 0x5A
#define ATAPI_MODE_SELECT 0x55
#define ATAPI_LS120_FORMAT_UNIT 0x24
//
// IDE driveSelect register bit for LBA mode
//
#define IDE_LBA_MODE (1 << 6)
//
// IDE drive control definitions
//
#define IDE_DC_DISABLE_INTERRUPTS 0x02
#define IDE_DC_RESET_CONTROLLER 0x04
#define IDE_DC_REENABLE_CONTROLLER 0x00
//
// IDE status definitions
//
#define IDE_STATUS_ERROR 0x01
#define IDE_STATUS_INDEX 0x02
#define IDE_STATUS_CORRECTED_ERROR 0x04
#define IDE_STATUS_DRQ 0x08
#define IDE_STATUS_DSC 0x10
#define IDE_STATUS_DRDY 0x40
#define IDE_STATUS_IDLE 0x50
#define IDE_STATUS_BUSY 0x80
//
// IDE error definitions
//
#define IDE_ERROR_BAD_BLOCK 0x80
#define IDE_ERROR_CRC_ERROR IDE_ERROR_BAD_BLOCK
#define IDE_ERROR_DATA_ERROR 0x40
#define IDE_ERROR_MEDIA_CHANGE 0x20
#define IDE_ERROR_ID_NOT_FOUND 0x10
#define IDE_ERROR_MEDIA_CHANGE_REQ 0x08
#define IDE_ERROR_COMMAND_ABORTED 0x04
#define IDE_ERROR_END_OF_MEDIA 0x02
#define IDE_ERROR_ILLEGAL_LENGTH 0x01
#define IDE_ERROR_ADDRESS_NOT_FOUND IDE_ERROR_ILLEGAL_LENGTH
//
// IDE command definitions
//
#define IDE_COMMAND_NOP 0x00
#define IDE_COMMAND_DATA_SET_MANAGEMENT 0x06
#define IDE_COMMAND_ATAPI_RESET 0x08
#define IDE_COMMAND_READ 0x20
#define IDE_COMMAND_READ_EXT 0x24
#define IDE_COMMAND_READ_DMA_EXT 0x25
#define IDE_COMMAND_READ_DMA_QUEUED_EXT 0x26
#define IDE_COMMAND_READ_MULTIPLE_EXT 0x29
#define IDE_COMMAND_WRITE 0x30
#define IDE_COMMAND_WRITE_EXT 0x34
#define IDE_COMMAND_WRITE_DMA_EXT 0x35
#define IDE_COMMAND_WRITE_DMA_QUEUED_EXT 0x36
#define IDE_COMMAND_WRITE_MULTIPLE_EXT 0x39
#define IDE_COMMAND_WRITE_DMA_FUA_EXT 0x3D
#define IDE_COMMAND_WRITE_DMA_QUEUED_FUA_EXT 0x3E
#define IDE_COMMAND_VERIFY 0x40
#define IDE_COMMAND_VERIFY_EXT 0x42
#define IDE_COMMAND_EXECUTE_DEVICE_DIAGNOSTIC 0x90
#define IDE_COMMAND_SET_DRIVE_PARAMETERS 0x91
#define IDE_COMMAND_ATAPI_PACKET 0xA0
#define IDE_COMMAND_ATAPI_IDENTIFY 0xA1
#define IDE_COMMAND_SMART 0xB0
#define IDE_COMMAND_READ_MULTIPLE 0xC4
#define IDE_COMMAND_WRITE_MULTIPLE 0xC5
#define IDE_COMMAND_SET_MULTIPLE 0xC6
#define IDE_COMMAND_READ_DMA 0xC8
#define IDE_COMMAND_WRITE_DMA 0xCA
#define IDE_COMMAND_WRITE_DMA_QUEUED 0xCC
#define IDE_COMMAND_WRITE_MULTIPLE_FUA_EXT 0xCE
#define IDE_COMMAND_GET_MEDIA_STATUS 0xDA
#define IDE_COMMAND_DOOR_LOCK 0xDE
#define IDE_COMMAND_DOOR_UNLOCK 0xDF
#define IDE_COMMAND_STANDBY_IMMEDIATE 0xE0
#define IDE_COMMAND_IDLE_IMMEDIATE 0xE1
#define IDE_COMMAND_CHECK_POWER 0xE5
#define IDE_COMMAND_SLEEP 0xE6
#define IDE_COMMAND_FLUSH_CACHE 0xE7
#define IDE_COMMAND_FLUSH_CACHE_EXT 0xEA
#define IDE_COMMAND_IDENTIFY 0xEC
#define IDE_COMMAND_MEDIA_EJECT 0xED
#define IDE_COMMAND_SET_FEATURE 0xEF
#define IDE_COMMAND_SECURITY_FREEZE_LOCK 0xF5
#define IDE_COMMAND_NOT_VALID 0xFF
//
// IDE Set Transfer Mode
//
#define IDE_SET_DEFAULT_PIO_MODE(mode) ((UCHAR) 1) // disable I/O Ready
#define IDE_SET_ADVANCE_PIO_MODE(mode) ((UCHAR) ((1 << 3) | (mode)))
#define IDE_SET_SWDMA_MODE(mode) ((UCHAR) ((1 << 4) | (mode)))
#define IDE_SET_MWDMA_MODE(mode) ((UCHAR) ((1 << 5) | (mode)))
#define IDE_SET_UDMA_MODE(mode) ((UCHAR) ((1 << 6) | (mode)))
//
// Set features parameter list
//
#define IDE_FEATURE_ENABLE_WRITE_CACHE 0x2
#define IDE_FEATURE_SET_TRANSFER_MODE 0x3
#define IDE_FEATURE_ENABLE_SATA_FEATURE 0x10
#define IDE_FEATURE_DISABLE_MSN 0x31
#define IDE_FEATURE_DISABLE_REVERT_TO_POWER_ON 0x66
#define IDE_FEATURE_DISABLE_WRITE_CACHE 0x82
#define IDE_FEATURE_DISABLE_SATA_FEATURE 0x90
#define IDE_FEATURE_ENABLE_MSN 0x95
//
// SATA Features Sector Count parameter list
//
#define IDE_SATA_FEATURE_NON_ZERO_DMA_BUFFER_OFFSET 0x1
#define IDE_SATA_FEATURE_DMA_SETUP_FIS_AUTO_ACTIVATE 0x2
#define IDE_SATA_FEATURE_DEVICE_INITIATED_POWER_MANAGEMENT 0x3
#define IDE_SATA_FEATURE_GUARANTEED_IN_ORDER_DELIVERY 0x4
#define IDE_SATA_FEATURE_ASYNCHRONOUS_NOTIFICATION 0x5
#define IDE_SATA_FEATURE_SOFTWARE_SETTINGS_PRESERVATION 0x6
//
// SMART sub command list
//
#define IDE_SMART_READ_ATTRIBUTES 0xD0
#define IDE_SMART_READ_THRESHOLDS 0xD1
#define IDE_SMART_ENABLE_DISABLE_AUTOSAVE 0xD2
#define IDE_SMART_SAVE_ATTRIBUTE_VALUES 0xD3
#define IDE_SMART_EXECUTE_OFFLINE_DIAGS 0xD4
#define IDE_SMART_READ_LOG 0xD5
#define IDE_SMART_WRITE_LOG 0xD6
#define IDE_SMART_ENABLE 0xD8
#define IDE_SMART_DISABLE 0xD9
#define IDE_SMART_RETURN_STATUS 0xDA
#define IDE_SMART_ENABLE_DISABLE_AUTO_OFFLINE 0xDB
//
// Features for IDE_COMMAND_DATA_SET_MANAGEMENT
//
#define IDE_DSM_FEATURE_TRIM 0x0001 //bit 0 of WORD
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(default:4214)
#endif
#endif

785
HuaGoCorrect/pub/ddk/atm.h Normal file
View File

@ -0,0 +1,785 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
atm.h
Abstract:
This module defines the structures, macros, and manifests available
to ATM aware components.
Author:
NDIS/ATM Development Team
Revision History:
Initial Version - March 1996
--*/
#ifndef _ATM_H_
#define _ATM_H_
#pragma once
//
// Address type
//
typedef ULONG ATM_ADDRESSTYPE;
#define ATM_NSAP 0
#define ATM_E164 1
//
// ATM Address
//
#define ATM_MAC_ADDRESS_LENGTH 6 // Same as 802.x
#define ATM_ADDRESS_LENGTH 20
//
// Special characters in ATM address string used in textual representations
//
#define ATM_ADDR_BLANK_CHAR L' '
#define ATM_ADDR_PUNCTUATION_CHAR L'.'
#define ATM_ADDR_E164_START_CHAR L'+'
typedef struct _ATM_ADDRESS
{
ATM_ADDRESSTYPE AddressType;
ULONG NumberOfDigits;
UCHAR Address[ATM_ADDRESS_LENGTH];
} ATM_ADDRESS, *PATM_ADDRESS;
//
// AAL types that the miniport supports
//
#define AAL_TYPE_AAL0 1
#define AAL_TYPE_AAL1 2
#define AAL_TYPE_AAL34 4
#define AAL_TYPE_AAL5 8
typedef ULONG ATM_AAL_TYPE, *PATM_AAL_TYPE;
//
// Types of Information Elements
//
typedef enum
{
IE_AALParameters,
IE_TrafficDescriptor,
IE_BroadbandBearerCapability,
IE_BHLI,
IE_BLLI,
IE_CalledPartyNumber,
IE_CalledPartySubaddress,
IE_CallingPartyNumber,
IE_CallingPartySubaddress,
IE_Cause,
IE_QOSClass,
IE_TransitNetworkSelection,
IE_BroadbandSendingComplete,
IE_LIJCallId,
IE_Raw
} Q2931_IE_TYPE;
//
// Common header for each Information Element
//
typedef struct _Q2931_IE
{
Q2931_IE_TYPE IEType;
ULONG IELength; // Bytes, including IEType and IELength fields
UCHAR IE[1];
} Q2931_IE, *PQ2931_IE;
//
// Definitions for SapType in CO_SAP
//
#define SAP_TYPE_NSAP 0x00000001
#define SAP_TYPE_E164 0x00000002
//
// Values used for the Mode field in AAL5_PARAMETERS
//
#define AAL5_MODE_MESSAGE 0x01
#define AAL5_MODE_STREAMING 0x02
//
// Values used for the SSCSType field in AAL5_PARAMETERS
//
#define AAL5_SSCS_NULL 0x00
#define AAL5_SSCS_SSCOP_ASSURED 0x01
#define AAL5_SSCS_SSCOP_NON_ASSURED 0x02
#define AAL5_SSCS_FRAME_RELAY 0x04
//
// AAL Parameters
//
typedef struct _AAL1_PARAMETERS
{
UCHAR Subtype;
UCHAR CBRRate;
USHORT Multiplier;
UCHAR SourceClockRecoveryMethod;
UCHAR ErrorCorrectionMethod;
USHORT StructuredDataTransferBlocksize;
UCHAR PartiallyFilledCellsMethod;
} AAL1_PARAMETERS, *PAAL1_PARAMETERS;
typedef struct _AAL34_PARAMETERS
{
USHORT ForwardMaxCPCSSDUSize;
USHORT BackwardMaxCPCSSDUSize;
USHORT LowestMID;
USHORT HighestMID;
UCHAR SSCSType;
} AAL34_PARAMETERS, *PAAL34_PARAMETERS;
typedef struct _AAL5_PARAMETERS
{
ULONG ForwardMaxCPCSSDUSize;
ULONG BackwardMaxCPCSSDUSize;
UCHAR Mode;
UCHAR SSCSType;
} AAL5_PARAMETERS, *PAAL5_PARAMETERS;
typedef struct _AALUSER_PARAMETERS
{
ULONG UserDefined;
} AALUSER_PARAMETERS, *PAALUSER_PARAMETERS;
typedef struct _AAL_PARAMETERS_IE
{
ATM_AAL_TYPE AALType;
union
{
AAL1_PARAMETERS AAL1Parameters;
AAL34_PARAMETERS AAL34Parameters;
AAL5_PARAMETERS AAL5Parameters;
AALUSER_PARAMETERS AALUserParameters;
} AALSpecificParameters;
} AAL_PARAMETERS_IE, *PAAL_PARAMETERS_IE;
//
// ATM Traffic Descriptor
//
typedef struct _ATM_TRAFFIC_DESCRIPTOR // For one direction
{
ULONG PeakCellRateCLP0;
ULONG PeakCellRateCLP01;
ULONG SustainableCellRateCLP0;
ULONG SustainableCellRateCLP01;
ULONG MaximumBurstSizeCLP0;
ULONG MaximumBurstSizeCLP01;
BOOLEAN Tagging;
} ATM_TRAFFIC_DESCRIPTOR, *PATM_TRAFFIC_DESCRIPTOR;
typedef struct _ATM_TRAFFIC_DESCRIPTOR_IE
{
ATM_TRAFFIC_DESCRIPTOR ForwardTD;
ATM_TRAFFIC_DESCRIPTOR BackwardTD;
BOOLEAN BestEffort;
} ATM_TRAFFIC_DESCRIPTOR_IE, *PATM_TRAFFIC_DESCRIPTOR_IE;
//
// values used for the BearerClass field in the Broadband Bearer Capability IE
//
#define BCOB_A 0x00 // Bearer class A
#define BCOB_C 0x01 // Bearer class C
#define BCOB_X 0x02 // Bearer class X
//
// values used for the TrafficType field in the Broadband Bearer Capability IE
//
#define TT_NOIND 0x00 // No indication of traffic type
#define TT_CBR 0x04 // Constant bit rate
#define TT_VBR 0x08 // Variable bit rate
//
// values used for the TimingRequirements field in the Broadband Bearer Capability IE
//
#define TR_NOIND 0x00 // No timing requirement indication
#define TR_END_TO_END 0x01 // End-to-end timing required
#define TR_NO_END_TO_END 0x02 // End-to-end timing not required
//
// values used for the ClippingSusceptability field in the Broadband Bearer Capability IE
//
#define CLIP_NOT 0x00 // Not susceptible to clipping
#define CLIP_SUS 0x20 // Susceptible to clipping
//
// values used for the UserPlaneConnectionConfig field in
// the Broadband Bearer Capability IE
//
#define UP_P2P 0x00 // Point-to-point connection
#define UP_P2MP 0x01 // Point-to-multipoint connection
//
// Broadband Bearer Capability
//
typedef struct _ATM_BROADBAND_BEARER_CAPABILITY_IE
{
UCHAR BearerClass;
UCHAR TrafficType;
UCHAR TimingRequirements;
UCHAR ClippingSusceptability;
UCHAR UserPlaneConnectionConfig;
} ATM_BROADBAND_BEARER_CAPABILITY_IE, *PATM_BROADBAND_BEARER_CAPABILITY_IE;
//
// values used for the HighLayerInfoType field in ATM_BHLI
//
#define BHLI_ISO 0x00 // ISO
#define BHLI_UserSpecific 0x01 // User Specific
#define BHLI_HighLayerProfile 0x02 // High layer profile (only in UNI3.0)
#define BHLI_VendorSpecificAppId 0x03 // Vendor-Specific Application ID
//
// Broadband High layer Information
//
typedef struct _ATM_BHLI_IE
{
ULONG HighLayerInfoType; // High Layer Information Type
ULONG HighLayerInfoLength; // number of bytes in HighLayerInfo
UCHAR HighLayerInfo[8]; // The value dependent on the
// HighLayerInfoType field
} ATM_BHLI_IE, *PATM_BHLI_IE;
//
// values used for Layer2Protocol in B-LLI
//
#define BLLI_L2_ISO_1745 0x01 // Basic mode ISO 1745
#define BLLI_L2_Q921 0x02 // CCITT Rec. Q.921
#define BLLI_L2_X25L 0x06 // CCITT Rec. X.25, link layer
#define BLLI_L2_X25M 0x07 // CCITT Rec. X.25, multilink
#define BLLI_L2_ELAPB 0x08 // Extended LAPB; for half duplex operation
#define BLLI_L2_HDLC_ARM 0x09 // HDLC ARM (ISO 4335)
#define BLLI_L2_HDLC_NRM 0x0A // HDLC NRM (ISO 4335)
#define BLLI_L2_HDLC_ABM 0x0B // HDLC ABM (ISO 4335)
#define BLLI_L2_LLC 0x0C // LAN logical link control (ISO 8802/2)
#define BLLI_L2_X75 0x0D // CCITT Rec. X.75, single link procedure
#define BLLI_L2_Q922 0x0E // CCITT Rec. Q.922
#define BLLI_L2_USER_SPECIFIED 0x10 // User Specified
#define BLLI_L2_ISO_7776 0x11 // ISO 7776 DTE-DTE operation
//
// values used for Layer3Protocol in B-LLI
//
#define BLLI_L3_X25 0x06 // CCITT Rec. X.25, packet layer
#define BLLI_L3_ISO_8208 0x07 // ISO/IEC 8208 (X.25 packet layer for DTE
#define BLLI_L3_X223 0x08 // X.223/ISO 8878
#define BLLI_L3_SIO_8473 0x09 // ISO/IEC 8473 (OSI connectionless)
#define BLLI_L3_T70 0x0A // CCITT Rec. T.70 min. network layer
#define BLLI_L3_ISO_TR9577 0x0B // ISO/IEC TR 9577 Network Layer Protocol ID
#define BLLI_L3_USER_SPECIFIED 0x10 // User Specified
//
// values used for Layer3IPI in struct B-LLI
//
#define BLLI_L3_IPI_SNAP 0x80 // IEEE 802.1 SNAP identifier
#define BLLI_L3_IPI_IP 0xCC // Internet Protocol (IP) identifier
//
// Broadband Lower Layer Information
//
typedef struct _ATM_BLLI_IE
{
ULONG Layer2Protocol;
UCHAR Layer2Mode;
UCHAR Layer2WindowSize;
ULONG Layer2UserSpecifiedProtocol;
ULONG Layer3Protocol;
UCHAR Layer3Mode;
UCHAR Layer3DefaultPacketSize;
UCHAR Layer3PacketWindowSize;
ULONG Layer3UserSpecifiedProtocol;
ULONG Layer3IPI;
UCHAR SnapId[5];
} ATM_BLLI_IE, *PATM_BLLI_IE;
//
// Called Party Number
//
// If present, this IE overrides the Called Address specified in
// the main parameter block.
//
typedef ATM_ADDRESS ATM_CALLED_PARTY_NUMBER_IE;
//
// Called Party Subaddress
//
typedef ATM_ADDRESS ATM_CALLED_PARTY_SUBADDRESS_IE;
//
// Calling Party Number
//
typedef struct _ATM_CALLING_PARTY_NUMBER_IE
{
ATM_ADDRESS Number;
UCHAR PresentationIndication;
UCHAR ScreeningIndicator;
} ATM_CALLING_PARTY_NUMBER_IE, *PATM_CALLING_PARTY_NUMBER_IE;
//
// Calling Party Subaddress
//
typedef ATM_ADDRESS ATM_CALLING_PARTY_SUBADDRESS_IE;
//
// Values used for the QOSClassForward and QOSClassBackward
// fields in ATM_QOS_CLASS_IE
//
#define QOS_CLASS0 0x00
#define QOS_CLASS1 0x01
#define QOS_CLASS2 0x02
#define QOS_CLASS3 0x03
#define QOS_CLASS4 0x04
//
// QOS Class
//
typedef struct _ATM_QOS_CLASS_IE
{
UCHAR QOSClassForward;
UCHAR QOSClassBackward;
} ATM_QOS_CLASS_IE, *PATM_QOS_CLASS_IE;
//
// Broadband Sending Complete
//
typedef struct _ATM_BROADBAND_SENDING_COMPLETE_IE
{
UCHAR SendingComplete;
} ATM_BROADBAND_SENDING_COMPLETE_IE, *PATM_BROADBAND_SENDING_COMPLETE_IE;
//
// Values used for the TypeOfNetworkId field in ATM_TRANSIT_NETWORK_SELECTION_IE
//
#define TNS_TYPE_NATIONAL 0x40
//
// Values used for the NetworkIdPlan field in ATM_TRANSIT_NETWORK_SELECTION_IE
//
#define TNS_PLAN_CARRIER_ID_CODE 0x01
//
// Transit Network Selection
//
typedef struct _ATM_TRANSIT_NETWORK_SELECTION_IE
{
UCHAR TypeOfNetworkId;
UCHAR NetworkIdPlan;
UCHAR NetworkIdLength;
UCHAR NetworkId[1];
} ATM_TRANSIT_NETWORK_SELECTION_IE, *PATM_TRANSIT_NETWORK_SELECTION_IE;
//
// Values used for the Location field in struct ATM_CAUSE_IE
//
#define ATM_CAUSE_LOC_USER 0x00
#define ATM_CAUSE_LOC_PRIVATE_LOCAL 0x01
#define ATM_CAUSE_LOC_PUBLIC_LOCAL 0x02
#define ATM_CAUSE_LOC_TRANSIT_NETWORK 0x03
#define ATM_CAUSE_LOC_PUBLIC_REMOTE 0x04
#define ATM_CAUSE_LOC_PRIVATE_REMOTE 0x05
#define ATM_CAUSE_LOC_INTERNATIONAL_NETWORK 0x07
#define ATM_CAUSE_LOC_BEYOND_INTERWORKING 0x0A
//
// Values used for the Cause field in struct ATM_CAUSE_IE
//
#define ATM_CAUSE_UNALLOCATED_NUMBER 0x01
#define ATM_CAUSE_NO_ROUTE_TO_TRANSIT_NETWORK 0x02
#define ATM_CAUSE_NO_ROUTE_TO_DESTINATION 0x03
#define ATM_CAUSE_VPI_VCI_UNACCEPTABLE 0x0A
#define ATM_CAUSE_NORMAL_CALL_CLEARING 0x10
#define ATM_CAUSE_USER_BUSY 0x11
#define ATM_CAUSE_NO_USER_RESPONDING 0x12
#define ATM_CAUSE_CALL_REJECTED 0x15
#define ATM_CAUSE_NUMBER_CHANGED 0x16
#define ATM_CAUSE_USER_REJECTS_CLIR 0x17
#define ATM_CAUSE_DESTINATION_OUT_OF_ORDER 0x1B
#define ATM_CAUSE_INVALID_NUMBER_FORMAT 0x1C
#define ATM_CAUSE_STATUS_ENQUIRY_RESPONSE 0x1E
#define ATM_CAUSE_NORMAL_UNSPECIFIED 0x1F
#define ATM_CAUSE_VPI_VCI_UNAVAILABLE 0x23
#define ATM_CAUSE_NETWORK_OUT_OF_ORDER 0x26
#define ATM_CAUSE_TEMPORARY_FAILURE 0x29
#define ATM_CAUSE_ACCESS_INFORMAION_DISCARDED 0x2B
#define ATM_CAUSE_NO_VPI_VCI_AVAILABLE 0x2D
#define ATM_CAUSE_RESOURCE_UNAVAILABLE 0x2F
#define ATM_CAUSE_QOS_UNAVAILABLE 0x31
#define ATM_CAUSE_USER_CELL_RATE_UNAVAILABLE 0x33
#define ATM_CAUSE_BEARER_CAPABILITY_UNAUTHORIZED 0x39
#define ATM_CAUSE_BEARER_CAPABILITY_UNAVAILABLE 0x3A
#define ATM_CAUSE_OPTION_UNAVAILABLE 0x3F
#define ATM_CAUSE_BEARER_CAPABILITY_UNIMPLEMENTED 0x41
#define ATM_CAUSE_UNSUPPORTED_TRAFFIC_PARAMETERS 0x49
#define ATM_CAUSE_INVALID_CALL_REFERENCE 0x51
#define ATM_CAUSE_CHANNEL_NONEXISTENT 0x52
#define ATM_CAUSE_INCOMPATIBLE_DESTINATION 0x58
#define ATM_CAUSE_INVALID_ENDPOINT_REFERENCE 0x59
#define ATM_CAUSE_INVALID_TRANSIT_NETWORK_SELECTION 0x5B
#define ATM_CAUSE_TOO_MANY_PENDING_ADD_PARTY 0x5C
#define ATM_CAUSE_AAL_PARAMETERS_UNSUPPORTED 0x5D
#define ATM_CAUSE_MANDATORY_IE_MISSING 0x60
#define ATM_CAUSE_UNIMPLEMENTED_MESSAGE_TYPE 0x61
#define ATM_CAUSE_UNIMPLEMENTED_IE 0x63
#define ATM_CAUSE_INVALID_IE_CONTENTS 0x64
#define ATM_CAUSE_INVALID_STATE_FOR_MESSAGE 0x65
#define ATM_CAUSE_RECOVERY_ON_TIMEOUT 0x66
#define ATM_CAUSE_INCORRECT_MESSAGE_LENGTH 0x68
#define ATM_CAUSE_PROTOCOL_ERROR 0x6F
//
// Values used for the Condition portion of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
//
#define ATM_CAUSE_COND_UNKNOWN 0x00
#define ATM_CAUSE_COND_PERMANENT 0x01
#define ATM_CAUSE_COND_TRANSIENT 0x02
//
// Values used for the Rejection Reason portion of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
//
#define ATM_CAUSE_REASON_USER 0x00
#define ATM_CAUSE_REASON_IE_MISSING 0x04
#define ATM_CAUSE_REASON_IE_INSUFFICIENT 0x08
//
// Values used for the P-U flag of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
//
#define ATM_CAUSE_PU_PROVIDER 0x00
#define ATM_CAUSE_PU_USER 0x08
//
// Values used for the N-A flag of the Diagnostics field
// in struct ATM_CAUSE_IE, for certain Cause values
//
#define ATM_CAUSE_NA_NORMAL 0x00
#define ATM_CAUSE_NA_ABNORMAL 0x04
//
// Cause
//
typedef struct _ATM_CAUSE_IE
{
UCHAR Location;
UCHAR Cause;
UCHAR DiagnosticsLength;
UCHAR Diagnostics[4];
} ATM_CAUSE_IE, *PATM_CAUSE_IE;
//
// Leaf Initiated Join (LIJ) Identifier
//
typedef struct _ATM_LIJ_CALLID_IE
{
ULONG Identifier;
} ATM_LIJ_CALLID_IE, *PATM_LIJ_CALLID_IE;
//
// Raw Information Element - the user can fill in whatever he wants
//
typedef struct _ATM_RAW_IE
{
ULONG RawIELength;
ULONG RawIEType;
UCHAR RawIEValue[1];
} ATM_RAW_IE, *PATM_RAW_IE;
//
// This is the value of the ParamType field in the CO_SPECIFIC_PARAMETERS structure
// when the Parameters[] field contains ATM media specific values in the structure
// ATM_MEDIA_PARAMETERS.
//
#define ATM_MEDIA_SPECIFIC 0x00000001
//
// The Q2931 Call Manager Specific parameters that goes into the
// CallMgrParameters->CallMgrSpecific.Parameters
//
typedef struct _Q2931_CALLMGR_PARAMETERS
{
ATM_ADDRESS CalledParty;
ATM_ADDRESS CallingParty;
ULONG InfoElementCount;
UCHAR InfoElements[1]; // one or more info elements
} Q2931_CALLMGR_PARAMETERS, *PQ2931_CALLMGR_PARAMETERS;
//
// This is the specific portion of either the Media parameters or the CallMgr
// Parameters. The following two defines are used in the ParamType field
// depending on the signaling type.
//
#define CALLMGR_SPECIFIC_Q2931 0x00000001
typedef struct _ATM_VPIVCI
{
ULONG Vpi;
ULONG Vci;
} ATM_VPIVCI, *PATM_VPIVCI;
//
// ATM Service Category
//
#define ATM_SERVICE_CATEGORY_CBR 1 // Constant Bit Rate
#define ATM_SERVICE_CATEGORY_VBR 2 // Variable Bit Rate
#define ATM_SERVICE_CATEGORY_UBR 4 // Unspecified Bit Rate
#define ATM_SERVICE_CATEGORY_ABR 8 // Available Bit Rate
typedef ULONG ATM_SERVICE_CATEGORY, *PATM_SERVICE_CATEGORY;
//
// ATM flow parameters for use in specifying Media parameters
//
typedef struct _ATM_FLOW_PARAMETERS
{
ATM_SERVICE_CATEGORY ServiceCategory;
ULONG AverageCellRate; // in cells/sec
ULONG PeakCellRate; // in cells/sec
ULONG MinimumCellRate; // in cells/sec (ABR MCR)
ULONG InitialCellRate; // in cells/sec (ABR ICR)
ULONG BurstLengthCells; // in cells
ULONG MaxSduSize; // MTU in bytes
ULONG TransientBufferExposure; // in cells (ABR TBE)
ULONG CumulativeRMFixedRTT; // in microseconds (ABR FRTT)
UCHAR RateIncreaseFactor; // UNI 4.0 coding (ABR RIF)
UCHAR RateDecreaseFactor; // UNI 4.0 coding (ABR RDF)
USHORT ACRDecreaseTimeFactor; // UNI 4.0 coding (ABR ADTF)
UCHAR MaximumCellsPerForwardRMCell; // UNI 4.0 coding (ABR Nrm)
UCHAR MaximumForwardRMCellInterval; // UNI 4.0 coding (ABR Trm)
UCHAR CutoffDecreaseFactor; // UNI 4.0 coding (ABR CDF)
UCHAR Reserved1; // padding
ULONG MissingRMCellCount; // (ABR CRM)
ULONG Reserved2;
ULONG Reserved3;
} ATM_FLOW_PARAMETERS, *PATM_FLOW_PARAMETERS;
//
// ATM Specific Media parameters - this is the Media specific structure for ATM
// that goes into MediaParameters->MediaSpecific.Parameters.
//
typedef struct _ATM_MEDIA_PARAMETERS
{
ATM_VPIVCI ConnectionId;
ATM_AAL_TYPE AALType;
ULONG CellDelayVariationCLP0;
ULONG CellDelayVariationCLP1;
ULONG CellLossRatioCLP0;
ULONG CellLossRatioCLP1;
ULONG CellTransferDelayCLP0;
ULONG CellTransferDelayCLP1;
ULONG DefaultCLP;
ATM_FLOW_PARAMETERS Transmit;
ATM_FLOW_PARAMETERS Receive;
} ATM_MEDIA_PARAMETERS, *PATM_MEDIA_PARAMETERS;
// Bit 0 in Reserved1 in ATM_FLOW_PARAMETERS is reserved.
#define ATM_FLOW_PARAMS_RSVD1_MPP 0x01
#ifndef SAP_FIELD_ABSENT
#define SAP_FIELD_ABSENT ((ULONG)0xfffffffe)
#endif
#ifndef SAP_FIELD_ANY
#define SAP_FIELD_ANY ((ULONG)0xffffffff)
#endif
#define SAP_FIELD_ANY_AESA_SEL ((ULONG)0xfffffffa) // SEL is wild-carded
#define SAP_FIELD_ANY_AESA_REST ((ULONG)0xfffffffb) // All of the address
// except SEL, is wild-carded
//
// The ATM Specific SAP definition
//
typedef struct _ATM_SAP
{
ATM_BLLI_IE Blli;
ATM_BHLI_IE Bhli;
ULONG NumberOfAddresses;
UCHAR Addresses[1]; // each of type ATM_ADDRESS
} ATM_SAP, *PATM_SAP;
//
// The ATM Specific SAP definition when adding PVCs
//
typedef struct _ATM_PVC_SAP
{
ATM_BLLI_IE Blli;
ATM_BHLI_IE Bhli;
} ATM_PVC_SAP, *PATM_PVC_SAP;
//
// The structure passed in the Parameters field of the CO_SPECIFIC_PARAMETERS
// structure passed in an ADD PVC request for Q.2931
//
typedef struct _Q2931_ADD_PVC
{
ATM_ADDRESS CalledParty;
ATM_ADDRESS CallingParty;
ATM_VPIVCI ConnectionId;
ATM_AAL_TYPE AALType;
ATM_FLOW_PARAMETERS ForwardFP;
ATM_FLOW_PARAMETERS BackwardFP;
ULONG Flags;
ATM_PVC_SAP LocalSap;
ATM_PVC_SAP DestinationSap;
BOOLEAN LIJIdPresent;
ATM_LIJ_CALLID_IE LIJId;
} Q2931_ADD_PVC, *PQ2931_ADD_PVC;
//
// These flags are defined to be used with Q2931_ADD_PVC above
//
// this VC should be used by the CallMgr as the signaling VC now
#define CO_FLAG_SIGNALING_VC 0x00000001
//
// Use this flag for a PVC that cannot be used for a MakeCall - incoming call only
// the call mgr can then be optimized not to search these PVCs during make call
// processing.
#define CO_FLAG_NO_DEST_SAP 0x00000002
//
// Use this flag for a PVC that cannot be used to indicate an incoming call.
//
#define CO_FLAG_NO_LOCAL_SAP 0x00000004
//
// the structure passed in the Parameters field of the CO_SPECIFIC_PARAMETERS
// structure passed in an NDIS_CO_PVC request for Q2931
//
typedef struct _Q2931_DELETE_PVC
{
ATM_VPIVCI ConnectionId;
} Q2931_DELETE_PVC, *PQ2931_DELETE_PVC;
typedef struct _CO_GET_CALL_INFORMATION
{
ULONG CallInfoType;
ULONG CallInfoLength;
PVOID CallInfoBuffer;
} CO_GET_CALL_INFORMATION, *PCO_GET_CALL_INFORMATION;
//
// the structure for returning the supported VC rates from the miniport,
// returned in response to OID_ATM_SUPPORTED_VC_RATES
//
typedef struct _ATM_VC_RATES_SUPPORTED
{
ULONG MinCellRate;
ULONG MaxCellRate;
} ATM_VC_RATES_SUPPORTED, *PATM_VC_RATES_SUPPORTED;
//
// NDIS_PACKET out of band information for ATM.
//
typedef struct _ATM_AAL_OOB_INFO
{
ATM_AAL_TYPE AalType;
union
{
struct _ATM_AAL5_INFO
{
BOOLEAN CellLossPriority;
UCHAR UserToUserIndication;
UCHAR CommonPartIndicator;
} ATM_AAL5_INFO;
struct _ATM_AAL0_INFO
{
BOOLEAN CellLossPriority;
UCHAR PayLoadTypeIdentifier;
} ATM_AAL0_INFO;
};
} ATM_AAL_OOB_INFO, *PATM_AAL_OOB_INFO;
//
// Physical Line Speeds in bits/sec.
//
#define ATM_PHYS_RATE_SONET_STS3C 155520000
#define ATM_PHYS_RATE_IBM_25 25600000
//
// ATM cell layer transfer capacities in bits/sec. This is the throughput
// available for ATM cells, after allowing for physical framing overhead.
//
#define ATM_CELL_TRANSFER_CAPACITY_SONET_STS3C 149760000
#define ATM_CELL_TRANSFER_CAPACITY_IBM_25 25125926
//
// User data rate in units of 100 bits/sec. This is returned in response to
// the OID_GEN_CO_LINK_SPEED query. This is the effective rate of
// transfer of data available to the ATM layer user, after allowing for
// the ATM cell header.
//
#define ATM_USER_DATA_RATE_SONET_155 1356317
#define ATM_USER_DATA_RATE_IBM_25 227556
//
// The ATM Service Registry MIB Table is used to locate ATM network
// services. OID_ATM_GET_SERVICE_ADDRESS is used by clients to access
// this table.
//
typedef ULONG ATM_SERVICE_REGISTRY_TYPE;
#define ATM_SERVICE_REGISTRY_LECS 1 // LAN Emulation Configuration Server
#define ATM_SERVICE_REGISTRY_ANS 2 // ATM Name Server
//
// Structure passed to OID_ATM_GET_SERVICE_ADDRESS.
//
typedef struct _ATM_SERVICE_ADDRESS_LIST
{
ATM_SERVICE_REGISTRY_TYPE ServiceRegistryType;
ULONG NumberOfAddressesAvailable;
ULONG NumberOfAddressesReturned;
ATM_ADDRESS Address[1];
} ATM_SERVICE_ADDRESS_LIST, *PATM_SERVICE_ADDRESS_LIST;
#endif // _ATM_H_

View File

@ -0,0 +1,104 @@
/*++
Copyright (c) 2004 Microsoft Corporation
Module Name:
aux_klib.h
Abstract:
Kernel mode shim to access system functionality that is not properly exposed
to applications in currently shipping operating systems.
--*/
#ifndef _AUX_KLIB_H
#define _AUX_KLIB_H
#ifndef PIMAGE_EXPORT_DIRECTORY
#include <ntimage.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if (NTDDI_VERSION >= NTDDI_WIN2K)
#define AUX_KLIB_MODULE_PATH_LEN 256
typedef struct _AUX_MODULE_BASIC_INFO {
PVOID ImageBase;
} AUX_MODULE_BASIC_INFO, *PAUX_MODULE_BASIC_INFO;
typedef struct _AUX_MODULE_EXTENDED_INFO {
AUX_MODULE_BASIC_INFO BasicInfo;
ULONG ImageSize;
USHORT FileNameOffset;
UCHAR FullPathName [AUX_KLIB_MODULE_PATH_LEN];
} AUX_MODULE_EXTENDED_INFO, *PAUX_MODULE_EXTENDED_INFO;
typedef struct _KBUGCHECK_DATA {
ULONG BugCheckDataSize;
ULONG BugCheckCode;
ULONG_PTR Parameter1;
ULONG_PTR Parameter2;
ULONG_PTR Parameter3;
ULONG_PTR Parameter4;
} KBUGCHECK_DATA, *PKBUGCHECK_DATA;
#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
#if (NTDDI_VERSION >= NTDDI_WIN2K)
NTSTATUS
__stdcall
AuxKlibInitialize (
VOID
);
#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
#if (NTDDI_VERSION >= NTDDI_WIN2K)
NTSTATUS
__stdcall
AuxKlibQueryModuleInformation (
IN OUT PULONG BufferSize,
IN ULONG ElementSize,
OUT PVOID QueryInfo OPTIONAL
);
#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
#if (NTDDI_VERSION >= NTDDI_WIN2K)
NTSTATUS
AuxKlibGetBugCheckData(
OUT PKBUGCHECK_DATA BugCheckData
);
#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
#if (NTDDI_VERSION >= NTDDI_WIN2K)
PIMAGE_EXPORT_DIRECTORY
AuxKlibGetImageExportDirectory(
IN PVOID ImageBase
);
#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
#ifdef __cplusplus
}
#endif
#endif // _AUX_KLIB_H

397
HuaGoCorrect/pub/ddk/avc.h Normal file
View File

@ -0,0 +1,397 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
avc.h
Abstract
MS AVC Driver
Author:
PB 9/24/99
Revision History:
Date Who What
-------- --------- ------------------------------------------------------------
9/24/99 PB created
10/13/99 DG added avc protocol support
--*/
#if (NTDDI_VERSION >= NTDDI_WINXP)
#ifndef _AVC_H_
#define _AVC_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CTL_CODE
#pragma message ("CTL_CODE undefined. Include winioctl.h or wdm.h")
#endif
// ctype values from AVC Digital Interface General Specification, Rev 3.0, Section 5.3.1
typedef enum _tagAvcCommandType {
AVC_CTYPE_CONTROL = 0x00,
AVC_CTYPE_STATUS = 0x01,
AVC_CTYPE_SPEC_INQ = 0x02,
AVC_CTYPE_NOTIFY = 0x03,
AVC_CTYPE_GEN_INQ = 0x04
} AvcCommandType;
// response values from AVC Digital Interface General Specification, Rev 3.0, Section 5.3.2
typedef enum _tagAvcResponseCode {
AVC_RESPONSE_NOTIMPL = 0x08,
AVC_RESPONSE_ACCEPTED = 0x09,
AVC_RESPONSE_REJECTED = 0x0a,
AVC_RESPONSE_IN_TRANSITION = 0x0b,
AVC_RESPONSE_STABLE = 0x0c,
AVC_RESPONSE_IMPLEMENTED = 0x0c,
AVC_RESPONSE_CHANGED = 0x0d,
AVC_RESPONSE_INTERIM = 0x0f
} AvcResponseCode;
// subunit type values from Enhancements to AV/C General Specification 3.0, Version 1.1, Section 7.
typedef enum _tagAvcSubunitType {
AVC_SUBUNITTYPE_VIDEO_MONITOR = 0x00,
AVC_SUBUNITTYPE_AUDIO = 0x01,
AVC_SUBUNITTYPE_PRINTER = 0x02,
AVC_SUBUNITTYPE_DISC_PLAYER = 0x03,
AVC_SUBUNITTYPE_TAPE_PLAYER = 0x04,
AVC_SUBUNITTYPE_TUNER = 0x05,
AVC_SUBUNITTYPE_CA = 0x06,
AVC_SUBUNITTYPE_VIDEO_CAMERA = 0x07,
AVC_SUBUNITTYPE_PANEL = 0x09,
AVC_SUBUNITTYPE_BULLETINBOARD = 0x0A,
AVC_SUBUNITTYPE_CAMERASTORAGE = 0x0B,
AVC_SUBUNITTYPE_VENDOR_UNIQUE = 0x1c,
AVC_SUBUNITTYPE_EXTENDED = 0x1e,
AVC_SUBUNITTYPE_EXTENDED_FULL = 0xff, // This is used only in extension bytes
AVC_SUBUNITTYPE_UNIT = 0x1f
} AvcSubunitType;
#ifdef _NTDDK_
#define STATIC_KSMEDIUMSETID_1394SerialBus\
0x9D46279FL, 0x3432, 0x48F3, 0x88, 0x8A, 0xEE, 0xFF, 0x1B, 0x7E, 0xEE, 0x71
DEFINE_GUIDSTRUCT("9D46279F-3432-48F3-888A-EEFF1B7EEE71", KSMEDIUMSETID_1394SerialBus);
#define KSMEDIUMSETID_1394SerialBus DEFINE_GUIDNAMED(KSMEDIUMSETID_1394SerialBus)
#define DEFAULT_AVC_TIMEOUT (1000000L) // 100ms in 100 nanosecond units
#define DEFAULT_AVC_RETRIES 9 // 10 tries altogether
// Max pages available via the SUBUNIT INFO command
#define MAX_AVC_SUBUNITINFO_PAGES 8
// Max number of bytes of subunit address information per page
#define MAX_AVC_SUBUNITINFO_BYTES 4
// Combined subunit address byte count for all pages
#define AVC_SUBUNITINFO_BYTES (MAX_AVC_SUBUNITINFO_PAGES * MAX_AVC_SUBUNITINFO_BYTES)
//
// IOCTL definitions
//
#define IOCTL_AVC_CLASS CTL_CODE( \
FILE_DEVICE_UNKNOWN, \
0x92, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS \
)
typedef enum _tagAVC_FUNCTION {
AVC_FUNCTION_COMMAND = 0, // struct AVC_COMMAND_IRB
AVC_FUNCTION_GET_PIN_COUNT = 1, // struct AVC_PIN_COUNT
AVC_FUNCTION_GET_PIN_DESCRIPTOR = 2, // struct AVC_PIN_DESCRIPTOR
AVC_FUNCTION_GET_CONNECTINFO = 3, // struct AVC_PRECONNECT_INFO
AVC_FUNCTION_SET_CONNECTINFO = 4, // struct AVC_SETCONNECT_INFO
AVC_FUNCTION_ACQUIRE = 5, // struct AVC_PIN_ID
AVC_FUNCTION_RELEASE = 6, // struct AVC_PIN_ID
AVC_FUNCTION_CLR_CONNECTINFO = 7, // struct AVC_PIN_ID
AVC_FUNCTION_GET_EXT_PLUG_COUNTS = 8, // struct AVC_EXT_PLUG_COUNTS
AVC_FUNCTION_GET_UNIQUE_ID = 9, // struct AVC_UNIQUE_ID
AVC_FUNCTION_GET_REQUEST = 10, // struct AVC_COMMAND_IRB
AVC_FUNCTION_SEND_RESPONSE = 11, // struct AVC_COMMAND_IRB
AVC_FUNCTION_FIND_PEER_DO = 12, // struct AVC_PEER_DO_LOCATOR
AVC_FUNCTION_PEER_DO_LIST = 13, // struct AVC_PEER_DO_LIST
AVC_FUNCTION_GET_SUBUNIT_INFO = 14, // struct AVC_SUBUNIT_INFO_BLOCK
} AVC_FUNCTION;
// Ensure that packing is consistent (/Zp8)
#include <pshpack8.h>
// This structure is to be included at the head of a more specific AVC function structure
typedef struct _AVC_IRB {
AVC_FUNCTION Function;
} AVC_IRB, *PAVC_IRB;
// The maximum number of bytes available for an operand list
#define MAX_AVC_OPERAND_BYTES 509
// AVC_COMMAND_IRB
//
// This structure defines the common components of an AVC command request. It
// holds the opcode and operands of a request, and the opcode and operands
// of a response (upon completion). The size of the operand list is fixed at
// the maximum allowable number of operands given a one-byte Subunit Address.
// If the Subunit Address is extended in any way, the maximum permissible
// number of operand bytes will be reduced accordingly.
// (supported by peer and virtual instances)
typedef struct _AVC_COMMAND_IRB {
// AVC_FUNCTION_COMMAND
#ifdef __cplusplus
AVC_IRB Common;
#else
AVC_IRB;
#endif
UCHAR SubunitAddrFlag : 1; // set to 1 if a SubunitAddr address is specified
UCHAR AlternateOpcodesFlag : 1; // set to 1 if the AlternateOpcodes address is specified
UCHAR TimeoutFlag : 1; // set to 1 if Timeout specified
UCHAR RetryFlag : 1; // set to 1 if Retries specified
// On command request, this struct will use the CommandType
// On command response, this struct will use ResponseCode
union {
UCHAR CommandType;
UCHAR ResponseCode;
};
PUCHAR SubunitAddr; // set according to the target device object if not specified
PUCHAR AlternateOpcodes; // set to the address of an array of alternate opcodes (byte 0
// is the count of alternate opcodes that follow)
LARGE_INTEGER Timeout; // Defaults to DEFAULT_AVC_TIMEOUT if not specified
UCHAR Retries; // Defaults to DEFAULT_AVC_RETRIES if not specified
// The total amount of time a request will wait if the subunit is not responsive is:
// Timeout * (Retries+1)
UCHAR Opcode;
ULONG OperandLength; // set to the actual length of the operand list
UCHAR Operands[MAX_AVC_OPERAND_BYTES];
NODE_ADDRESS NodeAddress; // Used by virtual devices, ignored otherwise
ULONG Generation; // Used by virtual devices, ignored otherwise
} AVC_COMMAND_IRB, *PAVC_COMMAND_IRB;
// For AVC_FUNCTION_GET_PIN_COUNT (supported by peer instance only)
//
typedef struct _AVC_PIN_COUNT {
ULONG PinCount; // The pin count
} AVC_PIN_COUNT, *PAVC_PIN_COUNT;
// Dataformat Intersection handler used in struct AVC_PIN_DESCRIPTOR
typedef
__checkReturn
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
(*PFNAVCINTERSECTHANDLER)(
__in PVOID Context,
__in ULONG PinId,
__in PKSDATARANGE DataRange,
__in PKSDATARANGE MatchingDataRange,
__in ULONG DataBufferSize,
__out_bcount_opt(DataBufferSize) PVOID Data,
__out PULONG DataSize
);
// For AVC_FUNCTION_GET_PIN_DESCRIPTOR (supported by peer instance only)
//
typedef struct _AVC_PIN_DESCRIPTOR {
ULONG PinId; // The pin number
KSPIN_DESCRIPTOR PinDescriptor;
PFNAVCINTERSECTHANDLER IntersectHandler;
PVOID Context;
} AVC_PIN_DESCRIPTOR, *PAVC_PIN_DESCRIPTOR;
#define AVCCONNECTINFO_MAX_SUBUNITADDR_LEN AVC_SUBUNITINFO_BYTES
typedef enum _KSPIN_FLAG_AVC {
KSPIN_FLAG_AVCMASK = 0x03, // the mask to isolate the AV/C defined bit flags
KSPIN_FLAG_AVC_PERMANENT = 0x01, // part of the AV/C Connect Status bit flag
KSPIN_FLAG_AVC_CONNECTED = 0x02, // part of the AV/C Connect Status bit flag
KSPIN_FLAG_AVC_PCRONLY = 0x04, // no subunit plug control
KSPIN_FLAG_AVC_FIXEDPCR = 0x08, // implies KSPIN_FLAG_AVC_PERMANENT
} KSPIN_FLAG_AVC;
typedef struct _AVCPRECONNECTINFO {
// Unique ID of the target unit
GUID DeviceID;
UCHAR SubunitAddress[AVCCONNECTINFO_MAX_SUBUNITADDR_LEN];
ULONG SubunitPlugNumber;
KSPIN_DATAFLOW DataFlow;
// KSPIN_FLAG_AVC_...
ULONG Flags;
// Undefined if !(Flags & KSPIN_FLAG_AVC_FIXEDPCR)
ULONG UnitPlugNumber;
} AVCPRECONNECTINFO, *PAVCPRECONNECTINFO;
// For AVC_FUNCTION_GET_CONNECTINFO (supported by peer instance only)
//
typedef struct _AVC_PRECONNECT_INFO {
ULONG PinId; // The pin number
AVCPRECONNECTINFO ConnectInfo;
} AVC_PRECONNECT_INFO, *PAVC_PRECONNECT_INFO;
typedef struct _AVCCONNECTINFO {
// Unique ID of the target unit
GUID DeviceID;
UCHAR SubunitAddress[AVCCONNECTINFO_MAX_SUBUNITADDR_LEN];
ULONG SubunitPlugNumber;
KSPIN_DATAFLOW DataFlow;
// NULL if intra-unit connection
HANDLE hPlug;
// Undefined if hPlug == NULL
ULONG UnitPlugNumber;
} AVCCONNECTINFO, *PAVCCONNECTINFO;
// For AVC_FUNCTION_SET_CONNECTINFO (supported by peer instance only)
//
typedef struct _AVC_SETCONNECT_INFO {
ULONG PinId; // The pin number
AVCCONNECTINFO ConnectInfo;
} AVC_SETCONNECT_INFO, *PAVC_SETCONNECT_INFO;
// For AVC_FUNCTION_ACQUIRE or AVC_FUNCTION_RELEASE or AVC_FUNCTION_CLR_CONNECTINFO (supported by peer instance only)
//
typedef struct _AVC_PIN_ID {
ULONG PinId; // The pin ID
} AVC_PIN_ID, *PAVC_PIN_ID;
// For AVC_FUNCTION_GET_EXT_PLUG_COUNTS (supported by peer instance only)
//
typedef struct _AVC_EXT_PLUG_COUNTS {
ULONG ExtInputs;
ULONG ExtOutputs;
} AVC_EXT_PLUG_COUNTS, *PAVC_EXT_PLUG_COUNTS;
// For AVC_FUNCTION_GET_UNIQUE_ID (supported by peer instance only)
//
typedef struct _AVC_UNIQUE_ID {
// Unique ID of the target unit
GUID DeviceID;
} AVC_UNIQUE_ID, *PAVC_UNIQUE_ID;
// For AVC_FUNCTION_FIND_PEER_DO
//
typedef struct _AVC_PEER_DO_LOCATOR {
// 1394 NodeAddress identifying target for query
NODE_ADDRESS NodeAddress;
ULONG Generation;
PDEVICE_OBJECT DeviceObject;
} AVC_PEER_DO_LOCATOR, *PAVC_PEER_DO_LOCATOR;
// For AVC_FUNCTION_PEER_DO_LIST
//
typedef struct _AVC_PEER_DO_LIST {
// Counted array of referenced device objects (allocated by target)
ULONG Count;
__field_ecount(Count)
PDEVICE_OBJECT *Objects;
} AVC_PEER_DO_LIST, *PAVC_PEER_DO_LIST;
// For AVC_FUNCTION_GET_SUBUNIT_INFO
//
typedef struct _AVC_SUBUNIT_INFO_BLOCK {
// Array of bytes to hold subunit info (see AV/C SUBUNIT_INFO unit command for format)
UCHAR Info[AVC_SUBUNITINFO_BYTES];
} AVC_SUBUNIT_INFO_BLOCK, *PAVC_SUBUNIT_INFO_BLOCK;
typedef struct _AVC_MULTIFUNC_IRB {
#ifdef __cplusplus
AVC_IRB Common;
#else
AVC_IRB;
#endif
union {
AVC_PIN_COUNT PinCount; // AVC_FUNCTION_GET_PIN_COUNT
AVC_PIN_DESCRIPTOR PinDescriptor; // AVC_FUNCTION_GET_PIN_DESCRIPTOR
AVC_PRECONNECT_INFO PreConnectInfo; // AVC_FUNCTION_GET_CONNECTINFO
AVC_SETCONNECT_INFO SetConnectInfo; // AVC_FUNCTION_SET_CONNECTINFO
AVC_PIN_ID PinId; // AVC_FUNCTION_ACQUIRE or
// AVC_FUNCTION_RELEASE or
// AVC_FUNCTION_CLR_CONNECTINFO
AVC_EXT_PLUG_COUNTS ExtPlugCounts; // AVC_FUNCTION_GET_EXT_PLUG_COUNTS
AVC_UNIQUE_ID UniqueID; // AVC_FUNCTION_GET_UNIQUE_ID
AVC_PEER_DO_LOCATOR PeerLocator; // AVC_FUNCTION_FIND_PEER_DO
AVC_PEER_DO_LIST PeerList; // AVC_FUNCTION_PEER_DO_LIST
AVC_SUBUNIT_INFO_BLOCK Subunits; // AVC_FUNCTION_GET_SUBUNIT_INFO
};
} AVC_MULTIFUNC_IRB, *PAVC_MULTIFUNC_IRB;
#include <poppack.h>
#endif // _NTDDK_
//
// IOCTL definitions for Virtual Unit control (from user mode)
//
#define IOCTL_AVC_UPDATE_VIRTUAL_SUBUNIT_INFO CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x000, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_AVC_REMOVE_VIRTUAL_SUBUNIT_INFO CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x001, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_AVC_BUS_RESET CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x002, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Ensure that packing is consistent (/Zp8)
#include <pshpack8.h>
typedef struct _AVC_SUBUNIT_ADDR_SPEC {
ULONG Flags;
UCHAR SubunitAddress[1];
} AVC_SUBUNIT_ADDR_SPEC, *PAVC_SUBUNIT_ADDR_SPEC;
// Flags, when used with IOCTL_AVC_UPDATE_VIRTUAL_SUBUNIT_INFO
// and IOCTL_AVC_REMOVE_VIRTUAL_SUBUNIT_INFO
#define AVC_SUBUNIT_ADDR_PERSISTENT 0x00000001
#define AVC_SUBUNIT_ADDR_TRIGGERBUSRESET 0x00000002
#include <poppack.h>
#ifdef __cplusplus
}
#endif
#endif // _AVC_H_
#ifndef AVC_GUIDS_DEFINED
#define AVC_GUIDS_DEFINED
// {616EF4D0-23CE-446d-A568-C31EB01913D0}
DEFINE_GUID(GUID_VIRTUAL_AVC_CLASS, 0x616ef4d0, 0x23ce, 0x446d, 0xa5, 0x68, 0xc3, 0x1e, 0xb0, 0x19, 0x13, 0xd0);
// {095780C3-48A1-4570-BD95-46707F78C2DC}
DEFINE_GUID(GUID_AVC_CLASS, 0x095780c3, 0x48a1, 0x4570, 0xbd, 0x95, 0x46, 0x70, 0x7f, 0x78, 0xc2, 0xdc);
#endif
#endif

View File

@ -0,0 +1,551 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
avcstrm.h
Abstract
MS AVC Connection and Streaming
--*/
#if (NTDDI_VERSION >= NTDDI_WINXP)
#ifndef __AVCSTRM_H__
#define __AVCSTRM_H__
#define MASK_AUX_50_60_BIT 0x00200000 // the NTSC/PAL bit of DV{A|V}AuxSrc
// DVINFO
typedef struct _DVINFO {
//for 1st track
DWORD dwDVAAuxSrc;
DWORD dwDVAAuxCtl;
// for 2nd track
DWORD dwDVAAuxSrc1;
DWORD dwDVAAuxCtl1;
//for video information
DWORD dwDVVAuxSrc;
DWORD dwDVVAuxCtl;
DWORD dwDVReserved[2];
} DVINFO, *PDVINFO;
// Static definitions for DVINFO initialization
// MEDIATYPE_Interleaved equivalent
#define STATIC_KSDATAFORMAT_TYPE_INTERLEAVED\
0x73766169L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("73766169-0000-0010-8000-00aa00389b71", KSDATAFORMAT_TYPE_INTERLEAVED);
#define KSDATAFORMAT_TYPE_INTERLEAVED DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_INTERLEAVED)
// MEDIASUBTYPE_dvsd equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_DVSD\
0x64737664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("64737664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVSD);
#define KSDATAFORMAT_SUBTYPE_DVSD DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVSD)
// MEDIASUBTYPE_dvsl equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_DVSL\
0x6C737664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("6C737664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVSL);
#define KSDATAFORMAT_SUBTYPE_DVSL DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVSL)
// MEDIASUBTYPE_dvhd equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_DVHD\
0x64687664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("64687664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVHD);
#define KSDATAFORMAT_SUBTYPE_DVHD DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVHD)
#if ( (NTDDI_VERSION >= NTDDI_WINXPSP2) && (NTDDI_VERSION < NTDDI_WS03) ) || (NTDDI_VERSION >= NTDDI_WS03SP1)
// MEDIASUBTYPE_dv25 equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_dv25\
0x35327664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("35327664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_dv25);
#define KSDATAFORMAT_SUBTYPE_dv25 DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_dv25)
// MEDIASUBTYPE_dv50 equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_dv50\
0x30357664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("30357664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_dv50);
#define KSDATAFORMAT_SUBTYPE_dv50 DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_dv50)
// MEDIASUBTYPE_dvh1 equivalent
#define STATIC_KSDATAFORMAT_SUBTYPE_dvh1\
0x31687664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
DEFINE_GUIDSTRUCT("31687664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_dvh1);
#define KSDATAFORMAT_SUBTYPE_dvh1 DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_dvh1)
#endif
// FORMAT_DvInfo equivalent
#define STATIC_KSDATAFORMAT_SPECIFIER_DVINFO\
0x05589f84L, 0xc356, 0x11ce, 0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a
DEFINE_GUIDSTRUCT("05589f84-c356-11ce-bf01-00aa0055595a", KSDATAFORMAT_SPECIFIER_DVINFO);
#define KSDATAFORMAT_SPECIFIER_DVINFO DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_DVINFO)
#define STATIC_KSDATAFORMAT_SPECIFIER_DV_AVC\
0xddcff71aL, 0xfc9f, 0x4bd9, 0xb9, 0xb, 0x19, 0x7b, 0xd, 0x44, 0xad, 0x94
DEFINE_GUIDSTRUCT("ddcff71a-fc9f-4bd9-b90b-197b0d44ad94", KSDATAFORMAT_SPECIFIER_DV_AVC);
#define KSDATAFORMAT_SPECIFIER_DV_AVC DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_DV_AVC)
#define STATIC_KSDATAFORMAT_SPECIFIER_AVC\
0xf09dc377L, 0x6e51, 0x4ec5, 0xa0, 0xc4, 0xcd, 0x7f, 0x39, 0x62, 0x98, 0x80
DEFINE_GUIDSTRUCT("f09dc377-6e51-4ec5-a0c4-cd7f39629880", KSDATAFORMAT_SPECIFIER_AVC);
#define KSDATAFORMAT_SPECIFIER_AVC DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_AVC)
// Media subtype for MPEG2TS with STRIDE
#define STATIC_KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE\
0x138aa9a4L, 0x1ee2, 0x4c5b, 0x98, 0x8e, 0x19, 0xab, 0xfd, 0xbc, 0x8a, 0x11
DEFINE_GUIDSTRUCT("138aa9a4-1ee2-4c5b-988e-19abfdbc8a11", KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE);
#define KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE)
// Specifier for MPEG2TS with STRIDE
#define STATIC_KSDATAFORMAT_SPECIFIER_61883_4\
0x97e218b1L, 0x1e5a, 0x498e, 0xa9, 0x54, 0xf9, 0x62, 0xcf, 0xd9, 0x8c, 0xde
DEFINE_GUIDSTRUCT("97e218b1-1e5a-498e-a954-f962cfd98cde", KSDATAFORMAT_SPECIFIER_61883_4);
#define KSDATAFORMAT_SPECIFIER_61883_4 DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_61883_4)
// Associated with KSDATAFORMAT_SPECIFIER_DVINFO
typedef struct tagKS_DATARANGE_DVVIDEO {
KSDATARANGE DataRange;
DVINFO DVVideoInfo;
} KS_DATARANGE_DVVIDEO, *PKS_DATARANGE_DVVIDEO;
// Associated with KSDATAFORMAT_SPECIFIER_DV_AVC
typedef struct tagKS_DATARANGE_DV_AVC {
KSDATARANGE DataRange;
DVINFO DVVideoInfo;
AVCPRECONNECTINFO ConnectInfo;
} KS_DATARANGE_DV_AVC, *PKS_DATARANGE_DV_AVC;
typedef struct tagKS_DATAFORMAT_DV_AVC {
KSDATAFORMAT DataFormat;
DVINFO DVVideoInfo;
AVCCONNECTINFO ConnectInfo;
} KS_DATAFORMAT_DV_AVC, *PKS_DATAFORMAT_DV_AVC;
// Associated with KSDATAFORMAT_SPECIFIER_AVC
typedef struct tagKS_DATARANGE_MPEG2TS_AVC {
KSDATARANGE DataRange;
AVCPRECONNECTINFO ConnectInfo;
} KS_DATARANGE_MPEG2TS_AVC, *PKS_DATARANGE_MPEG2TS_AVC;
typedef struct tagKS_DATAFORMAT_MPEG2TS_AVC {
KSDATAFORMAT DataFormat;
AVCCONNECTINFO ConnectInfo;
} KS_DATAFORMAT_MPEG2TS_AVC, *PKS_DATAFORMAT_MPEG2TS_AVC;
/**********************
// 1394
***********************/
#define SPEED_100_INDEX 0
#define SPEED_200_INDEX 1
#define SPEED_400_INDEX 2
/**********************
// 61883
***********************/
#define BLOCK_PERIOD_2997 133466800 // nano-sec
#define BLOCK_PERIOD_25 133333333 // nano-sec
/************************
// CIP header definition:
*************************/
// FMT: "Blue book" Part 1, page 25, Table 3; DVCR:000000
#define CIP_HDR_FMT_MASK 0x3f
#define CIP_HDR_FMT_DVCR 0x80 // 10:FMT(00:0000)
#define CIP_HDR_FMT_MPEG 0xa0 // 10:FMT(10:0000)
// FDF
#define CIP_HDR_FDF0_50_60_MASK 0x80
#define CIP_HDR_FDF0_50_60_PAL 0x80
#define CIP_HDR_FDF0_50_60_NTSC 0x00
#define CIP_HDR_FDF0_STYPE_MASK 0x7c
#define CIP_HDR_FDF0_STYPE_SD_DVCR 0x00 // STYPE: 000:00
#define CIP_HDR_FDF0_STYPE_SDL_DVCR 0x04 // STYPE: 000:01
#define CIP_HDR_FDF0_STYPE_HD_DVCR 0x08 // STYPE: 000:10
#define CIP_HDR_FDF0_STYPE_SD_DVCPRO 0x78 // STYPE: 111:10
#define CIP_SPH_DV 0 // No source packet header
#define CIP_SPH_MPEG 1 // Has a source packet header
#define CIP_FN_DV 0 // Data blocks in a source pacaket of SD DVCR; BlueBook Part 2
#define CIP_FN_MPEG 0x3 // Data blocks in a source pacaket of SD DVCR; BlueBook Part 2
#define CIP_QPC_DV 0 // No padding
#define CIP_QPC_MPEG 0 // No padding
#define CIP_SPH_DV 0 // No header
#define CIP_SPH_MPEG 1 // Has a header (time stamp)
#define CIP_DBS_SDDV 120 // quadlets in a data block of the SD DVCR; BlueBook Part 2
#define CIP_DBS_HDDV 240 // quadlets in a data block of the HD DVCR; BlueBook Part 3
#define CIP_DBS_SDLDV 60 // quadlets in a data block of the SDL DVCR; BlueBook Part 5
#define CIP_DBS_MPEG 6 // quadlets in a data block of the MPEG TS; BlueBook Part 4
#define CIP_FMT_DV 0x0 // 00 0000
#define CIP_FMT_MPEG 0x20 // 10 0000
#define CIP_60_FIELDS 0 // 60 fields (NTSC)
#define CIP_50_FIELDS 1 // 50 fields (PAL)
#define CIP_TSF_ON 1 // TimeShift is ON
#define CIP_TSF_OFF 0 // TimeShift is OFF
#define CIP_STYPE_DV 0x0 // 00000
#define CIP_STYPE_DVCPRO 0x1e // 11100
//
// Some derive values
//
#define SRC_PACKETS_PER_NTSC_FRAME 250 // Fixed and same for SDDV, HDDV and SDLDV
#define SRC_PACKETS_PER_PAL_FRAME 300 // Fixed and same for SDDV, HDDV and SDLDV
// Note: Frame size of MPEG2 will depends on number of source packets per frame, and
// the is application dependent..
#define FRAME_TIME_NTSC 333667 // "about" 29.97
#define FRAME_TIME_PAL 400000 // exactly 25
#define SRC_PACKET_SIZE_SDDV ((CIP_DBS_SDDV << 2) * (1 << CIP_FN_DV))
#define SRC_PACKET_SIZE_HDDV ((CIP_DBS_HDDV << 2) * (1 << CIP_FN_DV))
#define SRC_PACKET_SIZE_SDLDV ((CIP_DBS_SDLDV << 2) * (1 << CIP_FN_DV))
#define SRC_PACKET_SIZE_MPEG2TS ((CIP_DBS_MPEG << 2) * (1 << CIP_FN_MPEG)) // Contain a sourcr packet header
#define FRAME_SIZE_SDDV_NTSC (SRC_PACKET_SIZE_SDDV * SRC_PACKETS_PER_NTSC_FRAME)
#define FRAME_SIZE_SDDV_PAL (SRC_PACKET_SIZE_SDDV * SRC_PACKETS_PER_PAL_FRAME)
#define FRAME_SIZE_HDDV_NTSC (SRC_PACKET_SIZE_HDDV * SRC_PACKETS_PER_NTSC_FRAME)
#define FRAME_SIZE_HDDV_PAL (SRC_PACKET_SIZE_HDDV * SRC_PACKETS_PER_PAL_FRAME)
#define FRAME_SIZE_SDLDV_NTSC (SRC_PACKET_SIZE_SDLDV * SRC_PACKETS_PER_NTSC_FRAME)
#define FRAME_SIZE_SDLDV_PAL (SRC_PACKET_SIZE_SDLDV * SRC_PACKETS_PER_PAL_FRAME)
// Generic 1st quadlet of a CIP header
typedef struct _CIP_HDR1 {
ULONG DBC: 8; // Continuity counter of data blocks
ULONG Rsv00: 2;
ULONG SPH: 1; // Sourcre packet header; 1: source packet contain a source packet header
ULONG QPC: 3; // Quadlet padding count (0..7 quadlets)
ULONG FN: 2; // Fraction number
ULONG DBS: 8; // Data block size in quadlets
ULONG SID: 6; // Source node ID (ID of transmitter)
ULONG Bit00: 2; // Always 0:0
} CIP_HDR1, *PCIP_HDR1;
// Generic 2nd quadlet of a CIP header with SYT field
typedef struct _CIP_HDR2_SYT {
ULONG SYT: 16; // lower 16bits of IEEE CYCLE_TIME
ULONG RSV: 2; //
ULONG STYPE: 5; // Signal type of video signal
ULONG F5060_OR_TSF: 1; // 0:(60 field system; NTSC); 1:(50 field system; PAL); or 1/0 for TimeShiftFlag
// e.g. 000000:DV, 100000 :MPEGTS;
// if 111111 (no data), DBS, FN, QPC, SPH and DBC arfe ignored.
ULONG FMT: 6; // Format ID
ULONG Bit10: 2; // Always 1:0
} CIP_HDR2_SYT, *PCIP_HDR2_SYT;
// Generic 2nd quadlet of a CIP header with FDF field
typedef struct _CIP_HDR2_FDF {
ULONG FDF: 24;
ULONG FMT: 6; // e.g. 000000:DV, 100000 :MPEGTS
ULONG Bit10: 2; // Always 1:0
} CIP_HDR2_FDF, *PCIP_HDR2_FDF;
// 2nd quadlet of a CIP header of a MPEGTS data
typedef struct _CIP_HDR2_MPEGTS {
ULONG TSF: 1;
ULONG RSV23bit: 23;
ULONG FMT: 6; // e.g. 000000:DV, 100000 :MPEGTS
ULONG Bit10: 2; // Always 1:0
} CIP_HDR2_MPEGTS, *PCIP_HDR2_MPEGTS;
//
// AV/C command response data definition
//
#define AVC_DEVICE_TAPE_REC 0x20 // 00100:000
#define AVC_DEVICE_CAMERA 0x38 // 00111:000
#define AVC_DEVICE_TUNER 0x28 // 00101:000
//
// 61883 data format
//
typedef enum _AVCSTRM_FORMAT {
AVCSTRM_FORMAT_SDDV_NTSC = 0, // 61883-2
AVCSTRM_FORMAT_SDDV_PAL, // 61883-2
AVCSTRM_FORMAT_MPEG2TS, // 61883-4
AVCSTRM_FORMAT_HDDV_NTSC, // 61883-3
AVCSTRM_FORMAT_HDDV_PAL, // 61883-3
AVCSTRM_FORMAT_SDLDV_NTSC, // 61883-5
AVCSTRM_FORMAT_SDLDV_PAL, // 61883-5
// others..
} AVCSTRM_FORMAT;
//
// This structure is create and initialize by the subunit.parameters
// The streaming DLL will streaming based on these parameters.
// Not all parameters apply to every format.
//
#define AVCSTRM_FORMAT_OPTION_STRIP_SPH 0x00000001
typedef struct _AVCSTRM_FORMAT_INFO {
ULONG SizeOfThisBlock; // sizeof of this structure
/**************************
* 61883-x format defintion
**************************/
AVCSTRM_FORMAT AVCStrmFormat; // Format, such as DV or MPEG2TS
//
// Two quadlet of a CIP header
//
CIP_HDR1 cipHdr1;
CIP_HDR2_SYT cipHdr2;
/*****************
* Buffers related
*****************/
//
// Number of source packet per frame
//
ULONG SrcPacketsPerFrame;
//
// Frame size
//
ULONG FrameSize;
//
// Number of receiving buffers
//
ULONG NumOfRcvBuffers;
//
// Number of transmitting buffers
//
ULONG NumOfXmtBuffers;
//
// Optional flags
//
DWORD OptionFlags;
/********************
* Frame rate related
********************/
//
// Approximate time per frame
//
ULONG AvgTimePerFrame;
//
// BlockPeriod - TX Only
//
ULONG BlockPeriod;
//
// Reserved for future use
//
ULONG Reserved[4];
} AVCSTRM_FORMAT_INFO, * PAVCSTRM_FORMAT_INFO;
//
// IOCTL Definitions
//
#define IOCTL_AVCSTRM_CLASS CTL_CODE( \
FILE_DEVICE_UNKNOWN, \
0x93, \
METHOD_IN_DIRECT, \
FILE_ANY_ACCESS \
)
//
// Current AVCSTRM DDI Version
//
#define CURRENT_AVCSTRM_DDI_VERSION '15TN' // 1.' 8XD' 2.'15TN'
//
// INIT_AVCStrm_HEADER Macro
//
#define INIT_AVCSTRM_HEADER( AVCStrm, Request ) \
(AVCStrm)->SizeOfThisBlock = sizeof(AVC_STREAM_REQUEST_BLOCK); \
(AVCStrm)->Function = Request; \
(AVCStrm)->Version = CURRENT_AVCSTRM_DDI_VERSION;
typedef enum _AVCSTRM_FUNCTION {
// Stream funcrtions
AVCSTRM_READ = 0,
AVCSTRM_WRITE,
AVCSTRM_ABORT_STREAMING, // Cancel all; to cancel each individual IRP, use IoCancelIrp()
AVCSTRM_OPEN = 0x100,
AVCSTRM_CLOSE,
AVCSTRM_GET_STATE,
AVCSTRM_SET_STATE,
// Not enabled
AVCSTRM_GET_PROPERTY,
AVCSTRM_SET_PROPERTY,
} AVCSTRM_FUNCTION;
//
// Structure used to open a stream; a stream extension is returned when success.
//
typedef struct _AVCSTRM_OPEN_STRUCT {
KSPIN_DATAFLOW DataFlow;
PAVCSTRM_FORMAT_INFO AVCFormatInfo;
// return stream exension (a context) if a stream is open successfully
// This context is used for subsequent call after a stream is opened.
PVOID AVCStreamContext;
// Local i/oPCR to be connected to the remote o/iPCR
HANDLE hPlugLocal;
} AVCSTRM_OPEN_STRUCT, * PAVCSTRM_OPEN_STRUCT;
//
// Structure used to read or write a buffer
//
typedef struct _AVCSTRM_BUFFER_STRUCT {
//
// Clock provider
//
BOOL ClockProvider;
HANDLE ClockHandle; // This is used only if !ClockProvider
//
// KS stream header
//
PKSSTREAM_HEADER StreamHeader;
//
// Frame buffer
//
PVOID FrameBuffer;
//
// Notify Context
//
PVOID Context;
} AVCSTRM_BUFFER_STRUCT, * PAVCSTRM_BUFFER_STRUCT;
typedef struct _AVC_STREAM_REQUEST_BLOCK {
ULONG SizeOfThisBlock; // sizeof AVC_STREAM_REQUEST_BLOCK
//
// Version
//
ULONG Version;
//
// AVC Stream function
//
AVCSTRM_FUNCTION Function;
//
// Flags
//
ULONG Flags;
//
// Status of this final AVCStream request.
//
NTSTATUS Status;
//
// This pointer contain the context of a stream and this structure is opaque to client.
//
PVOID AVCStreamContext;
//
// Contexts that the requester needs when this request is completed asychronously
//
PVOID Context1;
PVOID Context2;
PVOID Context3;
PVOID Context4;
ULONG Reserved[4];
//
// the following union passes in the information needed for the various ASRB functions.
//
union _tagCommandData {
// Get or set a stream state
KSSTATE StreamState;
// Struct used to open a stream
AVCSTRM_OPEN_STRUCT OpenStruct;
// Stream buffer structure
AVCSTRM_BUFFER_STRUCT BufferStruct;
} CommandData; // union for function data
} AVC_STREAM_REQUEST_BLOCK, *PAVC_STREAM_REQUEST_BLOCK;
#endif // ifndef __AVCSTRM_H__
#endif

View File

@ -0,0 +1,189 @@
/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
backpack.h
Abstract:
This module contains the package for pseudo polling. When a caller
requests the same operation and gets the same error return the rdr
must prevent flooding the network by backing off requests. Examples
of when this is desirable are receiving 0 bytes on consequtive reads
and consequtive fails on a file lock.
If the caller is flooding the network, the rdr will return the 0 bytes
or lock fail to the user until NextTime. When NextTime is reached
the network will be used.
Author:
Revision History:
--*/
#ifndef _BACKPACK_
#define _BACKPACK_
typedef struct _THROTTLING_STATE {
LARGE_INTEGER NextTime; // Do not access the network until
// CurrentTime >= NextTime
__volatile ULONG CurrentIncrement; // Number of Increments applied to calculate NextTime
ULONG MaximumDelay; // Specifies slowest rate that we will back off to
// NextTime <= CurrentTime + (Interval * MaximumDelay)
LARGE_INTEGER Increment;// {0,10000000} == 1 second
__volatile ULONG NumberOfQueries;
} THROTTLING_STATE, *PTHROTTLING_STATE;
//++
//
// VOID
// RxInitializeThrottlingState(
// IN PTHROTTLING_STATE pBP,
// IN ULONG Increment,
// IN ULONG MaximumDelay
// );
//
// Routine Description:
//
// This routine is called to initialize the back off structure (usually in
// an Icb).
//
// Arguments:
//
// pBP - Supplies back pack data for this request.
// Increment - Supplies the increase in delay in milliseconds, each time a request
// to the network fails.
// MaximumDelay- Supplies the longest delay the backoff package can introduce
// in milliseconds.
//
// Return Value:
//
// None.
//
//--
#define RxInitializeThrottlingState( _pBP, _Increment, _MaximumDelay ) { \
if ((_Increment)>0) { \
(_pBP)->Increment.QuadPart = (_Increment) * 10000; \
(_pBP)->MaximumDelay = (_MaximumDelay) / (_Increment); \
(_pBP)->CurrentIncrement = 0; \
}}
//++
//
// VOID
// RxUninitializeBackPack(
// IN PTHROTTLING_STATE pBP
// )
//
// Routine Description:
//
// Resets the Back Pack specified. Currently no work needed.
//
// Arguments:
//
// pBP - Supplies back pack address.
//
// Return Value:
//
// None.
//
//--
#define RxUninitializeBackPack( pBP ) ()
// RxShouldRequestBeThrottled indicates when the request should not go to the network.
BOOLEAN
RxShouldRequestBeThrottled(
IN PTHROTTLING_STATE pBP
);
// Register the last request as failed.
VOID
RxInitiateOrContinueThrottling (
IN PTHROTTLING_STATE pBP
);
// Register the last request as worked.
//++
//
// VOID
// RxTerminateThrottling(
// IN PTHROTTLING_STATE pBP
// )
//
// Routine Description:
//
// Sets the Delay to zero. This routine is called each time that
// a network request succeeds to avoid the next request backing off.
//
// Arguments:
//
// pBP - Supplies back pack address.
//
// Return Value:
//
// None.
//
//--
#define RxTerminateThrottling( pBP ) ( (pBP)->CurrentIncrement = 0 )
//++
//
// VOID
// RxInitializeBackoffPackage (
// VOID
// )
//
// Routine Description:
//
// This routine initializes the redirector back off package.
//
// Arguments:
//
// None
//
// Return Value:
//
// None.
//
//--
#define RxInitializeBackoffPackage( )
//++
//
// VOID
// RxUninitializeBackoffPackage (
// VOID
// )
//
// Routine Description:
//
// This routine uninitializes the redirector back off package.
//
// Arguments:
//
// None
//
// Return Value:
//
// None.
//
//--
#define RxUninitializeBackoffPackage( )
#endif /* _BACKPACK_ */

View File

@ -0,0 +1,696 @@
//==========================================================================;
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//==========================================================================;
#if (NTDDI_VERSION >= NTDDI_WINXP)
#if !defined(_BDATYPES_)
#error BDATYPES.H must be included before BDATOPGY.H
#endif // !defined(_BDATYPES_)
#if !defined(_BDATOPGY_)
#define _BDATOPGY_
#if defined(__cplusplus)
extern "C" {
#endif // defined(__cplusplus)
//---------------------------------------------------------------------------
// Common typedefs
//---------------------------------------------------------------------------
#define STDMETHODCALLTYPE __stdcall
typedef GUID * PGUID;
//===========================================================================
//
// BDA KS Topology Structures
//
//===========================================================================
typedef struct _KSM_PIN_PAIR
{
KSMETHOD Method;
ULONG InputPinId;
ULONG OutputPinId;
ULONG Reserved;
} KSM_PIN_PAIR, * PKSM_PIN_PAIR;
typedef struct _KSM_PIN
{
KSMETHOD Method;
union
{
ULONG PinId;
ULONG PinType;
};
ULONG Reserved;
} KSM_PIN, * PKSM_PIN;
typedef ULONG BDA_TOPOLOGY_JOINT, * PBDA_TOPOLOGY_JOINT;
typedef struct _BDA_PIN_PAIRING
{
ULONG ulInputPin;
ULONG ulOutputPin;
ULONG ulcMaxInputsPerOutput;
ULONG ulcMinInputsPerOutput;
ULONG ulcMaxOutputsPerInput;
ULONG ulcMinOutputsPerInput;
ULONG ulcTopologyJoints;
const ULONG * pTopologyJoints;
} BDA_PIN_PAIRING, * PBDA_PIN_PAIRING;
// BDA Topology Template Structures
//
typedef struct _BDA_FILTER_TEMPLATE
{
const KSFILTER_DESCRIPTOR * pFilterDescriptor;
ULONG ulcPinPairs;
const BDA_PIN_PAIRING * pPinPairs;
} BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE;
//===========================================================================
//
// BDA Utility Functions
//
//===========================================================================
/*
** BdaCreateFilterFactory()
**
** Creates a Filter Factory according to pFilterDescriptor. Keeps a
** reference to pBdaFilterTemplate so that Pin Factories can be dynamically
** created on a Filter created from this Filter Factory.
**
** Arguments:
**
**
** Returns:
**
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCreateFilterFactory(
__in PKSDEVICE pKSDevice,
__in const KSFILTER_DESCRIPTOR * pFilterDescriptor,
__in const BDA_FILTER_TEMPLATE * pBdaFilterTemplate
);
/*
** BdaCreateFilterFactoryEx()
**
** Creates a Filter Factory according to pFilterDescriptor. Keeps a
** reference to pBdaFilterTemplate so that Pin Factories can be dynamically
** created on a Filter created from this Filter Factory.
**
** Arguments:
**
**
** Returns:
**
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCreateFilterFactoryEx(
__in PKSDEVICE pKSDevice,
__in const KSFILTER_DESCRIPTOR * pFilterDescriptor,
__in const BDA_FILTER_TEMPLATE * pBdaFilterTemplate,
__out_opt PKSFILTERFACTORY * ppKSFilterFactory
);
/*
** BdaInitFilter()
**
** Initializes a BDA filter context for this KS Filter instance. Creates
** a linkage to the BDA Filter Template associated with the factory from
** which this KS Filter instance was created.
**
** Arguments:
**
**
** Returns:
**
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaInitFilter(
__in PKSFILTER pKSFilter,
__in const BDA_FILTER_TEMPLATE * pBdaFilterTemplate
);
/*
** BdaUninitFilter()
**
** Unitializes and frees resources from the BDA filter context associated
** with this KS filter instance.
**
** Arguments:
**
**
** Returns:
**
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaUninitFilter(
__in PKSFILTER pKSFilter
);
/*
** BdaFilterFactoryUpdateCacheData()
**
** Updates the pin data cache for the given filter factory.
** The function will update the cached information for all pin factories
** exposed by the given filter factory.
**
** If the option filter descriptor is given, the function will update
** the pin data cache for all pins listed in the given filter descriptor
** instead of those in the filter factory.
**
** Drivers will call this to update the pin data cache for all
** pins that may be exposed by the filter factory. The driver will
** provide a filter descriptor listing pins that are not initially exposed
** by the filter factory (this is usually the same as the template filter
** descriptor).
**
** Arguments:
**
**
** Returns:
**
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaFilterFactoryUpdateCacheData(
__in PKSFILTERFACTORY pFilterFactory,
__in const KSFILTER_DESCRIPTOR * pFilterDescriptor OPTIONAL
);
/*
** BdaCreatePin()
**
** Utility function creates a new pin in the given filter instance.
**
**
** Arguments:
**
**
** Returns:
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCreatePin(
__in PKSFILTER pKSFilter,
__in ULONG ulPinType,
__out_opt PULONG pulPinId
);
/*
** BdaDeletePin()
**
** Utility function deletes a pin from the given filter instance.
**
**
** Arguments:
**
**
** Returns:
**
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaDeletePin(
__in PKSFILTER pKSFilter,
__out_opt PULONG pulPinId
);
/*
** BdaCreateTopology()
**
** Utility function creates the topology between two pins.
**
**
** Arguments:
**
**
** Returns:
**
** NULL If no valid pin pairing exists with the
** given input and output pins.
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCreateTopology(
__in PKSFILTER pKSFilter,
__in ULONG InputPinId,
__in ULONG OutputPinId
);
//===========================================================================
//
// BDA Property and Method Functions
//
//===========================================================================
/*
** BdaPropertyNodeTypes ()
**
** Returns a list of ULONGs.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyNodeTypes(
__in PIRP pIrp,
__in PKSPROPERTY pKSProperty,
__out_bcount(OutputBufferLenFromIrp(Irp)) ULONG * pulProperty
);
/*
** BdaPropertyPinTypes ()
**
** Returns a list of GUIDS.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyPinTypes(
__in PIRP pIrp,
__in PKSPROPERTY pKSProperty,
__out_bcount(OutputBufferLenFromIrp(Irp)) ULONG * pulProperty
);
/*
** BdaPropertyTemplateConnections ()
**
** Returns a list of KSTOPOLOGY_CONNECTIONS. The list of connections
** describs how pin types and node types are connected in the template
** topology
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyTemplateConnections(
__in PIRP pIrp,
__in PKSPROPERTY pKSProperty,
__out_opt PKSTOPOLOGY_CONNECTION pConnectionProperty
);
/*
** BdaPropertyNodeProperties ()
**
** Returns a list of GUIDs.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyNodeProperties(
__in PIRP pIrp,
__in PKSP_NODE pKSProperty,
__out_opt GUID * pguidProperty
);
/*
** BdaPropertyNodeMethods ()
**
** Returns a list of GUIDs.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyNodeMethods(
__in PIRP pIrp,
__in PKSP_NODE pKSProperty,
__out_opt GUID * pguidProperty
);
/*
** BdaPropertyNodeEvents ()
**
** Returns a list of GUIDs.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyNodeEvents(
__in PIRP pIrp,
__in PKSP_NODE pKSProperty,
__out_opt GUID * pguidProperty
);
/*
** BdaPropertyNodeDescriptors ()
**
** Returns a list of BDA Node Descriptors.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyNodeDescriptors(
__in PIRP pIrp,
__in PKSPROPERTY pKSProperty,
__out_opt BDANODE_DESCRIPTOR * pNodeDescriptorProperty
);
/*
** BdaPropertyGetControllingPinId ()
**
** Gets the ID of the pin on which to submit node properties, methods
** and events.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyGetControllingPinId(
__in PIRP Irp,
__in PKSP_BDA_NODE_PIN Property,
__out_opt PULONG pulControllingPinId
);
/*
** BdaStartChanges ()
**
** Starts a new set of BDA topology changes. All changes to BDA topology
** that have not been committed are ignored. Changes after this will be
** in effect only after BdaCommitChanges.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaStartChanges(
__in PIRP pIrp
);
/*
** BdaCheckChanges ()
**
** Checks the changes to BDA topology that have occured since the
** last BdaStartChanges. Returns the result that would have occurred if
** CommitChanges had been called.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCheckChanges(
__in PIRP pIrp
);
/*
** BdaCommitChanges ()
**
** Commits the changes to BDA topology that have occured since the
** last BdaStartChanges.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaCommitChanges(
__in PIRP pIrp
);
/*
** BdaGetChangeState ()
**
** Returns the current change state of the BDA topology.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaGetChangeState(
__in PIRP pIrp,
__out_opt PBDA_CHANGE_STATE pChangeState
);
/*
** BdaMethodCreatePin ()
**
** Creates a new pin factory for the given pin type.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaMethodCreatePin(
__in PIRP pIrp,
__in PKSMETHOD pKSMethod,
__out_opt PULONG pulPinFactoryID
);
/*
** BdaMethodDeletePin ()
**
** Deletes the given pin factory
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaMethodDeletePin(
__in PIRP pIrp,
__in PKSMETHOD pKSMethod,
PVOID pvIgnored
);
/*
** BdaMethodCreateTopology ()
**
** Creates the topology between the two given pin factories.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaMethodCreateTopology(
__in PIRP pIrp,
__in PKSMETHOD pKSMethod,
OPTIONAL PVOID pvIgnored
);
/*
** BdaPropertyGetPinControl ()
**
** Returns a the BDA ID or BDA Template Type of the Pin.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaPropertyGetPinControl(
__in PIRP Irp,
__in PKSPROPERTY Property,
__out_opt ULONG * pulProperty
);
/*
** BdaValidateNodeProperty ()
**
** Validates that the node property belongs to the current pin.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
__checkReturn
__drv_requiresIRQL(PASSIVE_LEVEL)
STDMETHODIMP_(NTSTATUS)
BdaValidateNodeProperty(
__in PIRP pIrp,
__in PKSPROPERTY pProperty
);
#if defined(__cplusplus)
}
#endif // defined(__cplusplus)
#endif // !defined(_BDATOPGY_)
#endif // (NTDDI_VERSION >= NTDDI_WINXP)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
#ifndef __BTHGUID_H__
#define __BTHGUID_H__
#if (NTDDI_VERSION >= NTDDI_VISTA)
// 81A7FDF3-86C1-4BE8-A8C8-2A6D188B4177
DEFINE_GUID(GUID_BTHDDI_SDP_NODE_INTERFACE, 0x81a7fdf3, 0x86c1, 0x4be8, 0xa8, 0xc8, 0x2a, 0x6d, 0x18, 0x8b, 0x41, 0x77);
// 4E719439-9CF1-4BAB-AC1D-3279865743D2
DEFINE_GUID(GUID_BTHDDI_SDP_PARSE_INTERFACE, 0x4e719439, 0x9cf1, 0x4bab, 0xac, 0x1d, 0x32, 0x79, 0x86, 0x57, 0x43, 0xd2);
// {94A59AA8-4383-4286-AA4F-34A160F40004}
DEFINE_GUID(GUID_BTHDDI_PROFILE_DRIVER_INTERFACE, 0x94a59aa8, 0x4383, 0x4286, 0xaa, 0x4f, 0x34, 0xa1, 0x60, 0xf4, 0x0, 0x4);
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
#endif // __BTHGUID_H__

View File

@ -0,0 +1,609 @@
/****************************************************************************
Copyright (c) 2000 Microsoft Corporation
Module Name:
bthioctl.h
Abstract:
defines the IOCTL codes for the kernel/user calls
Environment:
Kernel & user mode
Revision History:
4-4-00 : created by Husni Roukbi
2-4-05 : split into public and private header files by SandySp
****************************************************************************/
#ifndef __BTHIOCTL_H__
#define __BTHIOCTL_H__
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4201) // nameless struct/union
#if (NTDDI_VERSION >= NTDDI_VISTA)
#ifndef CTL_CODE
#pragma message("CTL_CODE undefined. Include winioctl.h or wdm.h")
#endif
//
// IOCTL defines.
//
#define BTH_IOCTL_BASE 0
#define BTH_CTL(id) CTL_CODE(FILE_DEVICE_BLUETOOTH, \
(id), \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define BTH_KERNEL_CTL(id) CTL_CODE(FILE_DEVICE_BLUETOOTH, \
(id), \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
//
// kernel-level (internal) IOCTLs
//
#define IOCTL_INTERNAL_BTH_SUBMIT_BRB BTH_KERNEL_CTL(BTH_IOCTL_BASE+0x00)
//
// Input: none
// Output: BTH_ENUMERATOR_INFO
//
#define IOCTL_INTERNAL_BTHENUM_GET_ENUMINFO BTH_KERNEL_CTL(BTH_IOCTL_BASE+0x01)
//
// Input: none
// Output: BTH_DEVICE_INFO
//
#define IOCTL_INTERNAL_BTHENUM_GET_DEVINFO BTH_KERNEL_CTL(BTH_IOCTL_BASE+0x02)
//
// IOCTLs
//
//
// Input: none
// Output: BTH_LOCAL_RADIO_INFO
//
#define IOCTL_BTH_GET_LOCAL_INFO BTH_CTL(BTH_IOCTL_BASE+0x00)
//
// Input: BTH_ADDR
// Output: BTH_RADIO_INFO
//
#define IOCTL_BTH_GET_RADIO_INFO BTH_CTL(BTH_IOCTL_BASE+0x01)
//
// use this ioctl to get a list of cached discovered devices in the port driver.
//
// Input: None
// Output: BTH_DEVICE_INFO_LIST
//
#define IOCTL_BTH_GET_DEVICE_INFO BTH_CTL(BTH_IOCTL_BASE+0x02)
//
// Input: BTH_ADDR
// Output: none
//
#define IOCTL_BTH_DISCONNECT_DEVICE BTH_CTL(BTH_IOCTL_BASE+0x03)
#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
(NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
#ifdef FULL_EIR_SUPPORT // in WUR this funcitonality is disabled
//
// Input: BTH_GET_DEVICE_RSSI
// Output: ULONG
//
#define IOCTL_BTH_GET_DEVICE_RSSI BTH_CTL(BTH_IOCTL_BASE+0x05)
//
// Input: BTH_EIR_GET_RECORDS
// Output: UCHAR array, sequence of length + type + data fields triplets.
//
#define IOCTL_BTH_EIR_GET_RECORDS BTH_CTL(BTH_IOCTL_BASE+0x10)
//
// Input: BTH_EIR_SUBMIT_RECORD
// Output HANDLE
//
#define IOCTL_BTH_EIR_SUBMIT_RECORD BTH_CTL(BTH_IOCTL_BASE+0x11)
//
// Input: BTH_EIR_SUBMIT_RECORD
// Output None
//
#define IOCTL_BTH_EIR_UPDATE_RECORD BTH_CTL(BTH_IOCTL_BASE+0x12)
//
// Input: HANDLE
// Output: None
//
#define IOCTL_BTH_EIR_REMOVE_RECORD BTH_CTL(BTH_IOCTL_BASE+0x13)
#endif // FULL_EIR_SUPPORT
//
// Input: BTH_VENDOR_SPECIFIC_COMMAND
// Output: PVOID
//
#define IOCTL_BTH_HCI_VENDOR_COMMAND BTH_CTL(BTH_IOCTL_BASE+0x14)
#endif // >= SP1+KB942567
//
// Input: BTH_SDP_CONNECT
// Output: BTH_SDP_CONNECT
//
#define IOCTL_BTH_SDP_CONNECT BTH_CTL(BTH_IOCTL_BASE+0x80)
//
// Input: HANDLE_SDP
// Output: none
//
#define IOCTL_BTH_SDP_DISCONNECT BTH_CTL(BTH_IOCTL_BASE+0x81)
//
// Input: BTH_SDP_SERVICE_SEARCH_REQUEST
// Output: ULONG * number of handles wanted
//
#define IOCTL_BTH_SDP_SERVICE_SEARCH BTH_CTL(BTH_IOCTL_BASE+0x82)
//
// Input: BTH_SDP_ATTRIBUTE_SEARCH_REQUEST
// Output: BTH_SDP_STREAM_RESPONSE or bigger
//
#define IOCTL_BTH_SDP_ATTRIBUTE_SEARCH BTH_CTL(BTH_IOCTL_BASE+0x83)
//
// Input: BTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST
// Output: BTH_SDP_STREAM_RESPONSE or bigger
//
#define IOCTL_BTH_SDP_SERVICE_ATTRIBUTE_SEARCH \
BTH_CTL(BTH_IOCTL_BASE+0x84)
//
// Input: raw SDP stream (at least 2 bytes)
// Ouptut: HANDLE_SDP
//
#define IOCTL_BTH_SDP_SUBMIT_RECORD BTH_CTL(BTH_IOCTL_BASE+0x85)
//
// Input: HANDLE_SDP
// Output: none
//
#define IOCTL_BTH_SDP_REMOVE_RECORD BTH_CTL(BTH_IOCTL_BASE+0x86)
//
// Input: BTH_SDP_RECORD + raw SDP record
// Output: HANDLE_SDP
//
#define IOCTL_BTH_SDP_SUBMIT_RECORD_WITH_INFO BTH_CTL(BTH_IOCTL_BASE+0x87)
#include <PSHPACK1.H>
typedef struct _BTH_DEVICE_INFO_LIST {
//
// [IN/OUT] minimum of 1 device required
//
ULONG numOfDevices;
//
// Open ended array of devices;
//
BTH_DEVICE_INFO deviceList[1];
} BTH_DEVICE_INFO_LIST, *PBTH_DEVICE_INFO_LIST;
typedef struct _BTH_RADIO_INFO {
//
// Supported LMP features of the radio. Use LMP_XXX() to extract
// the desired bits.
//
ULONGLONG lmpSupportedFeatures;
//
// Manufacturer ID (possibly BTH_MFG_XXX)
//
USHORT mfg;
//
// LMP subversion
//
USHORT lmpSubversion;
//
// LMP version
//
UCHAR lmpVersion;
} BTH_RADIO_INFO, *PBTH_RADIO_INFO;
typedef struct _BTH_LOCAL_RADIO_INFO {
//
// Local BTH_ADDR, class of defice, and radio name
//
BTH_DEVICE_INFO localInfo;
//
// Combo of LOCAL_RADIO_XXX values
//
ULONG flags;
//
// HCI revision, see core spec
//
USHORT hciRevision;
//
// HCI version, see core spec
//
UCHAR hciVersion;
//
// More information about the local radio (LMP, MFG)
//
BTH_RADIO_INFO radioInfo;
} BTH_LOCAL_RADIO_INFO, *PBTH_LOCAL_RADIO_INFO;
#define SDP_CONNECT_CACHE (0x00000001)
#define SDP_CONNECT_ALLOW_PIN (0x00000002)
#define SDP_REQUEST_TO_DEFAULT (0)
#define SDP_REQUEST_TO_MIN (10)
#define SDP_REQUEST_TO_MAX (45)
#define SERVICE_OPTION_DO_NOT_PUBLISH (0x00000002)
#define SERVICE_OPTION_NO_PUBLIC_BROWSE (0x00000004)
#define SERVICE_OPTION_DO_NOT_PUBLISH_EIR (0x00000008)
#define SERVICE_SECURITY_USE_DEFAULTS (0x00000000)
#define SERVICE_SECURITY_NONE (0x00000001)
#define SERVICE_SECURITY_AUTHORIZE (0x00000002)
#define SERVICE_SECURITY_AUTHENTICATE (0x00000004)
#define SERVICE_SECURITY_ENCRYPT_REQUIRED (0x00000010)
#define SERVICE_SECURITY_ENCRYPT_OPTIONAL (0x00000020)
#define SERVICE_SECURITY_DISABLED (0x10000000)
#define SERVICE_SECURITY_NO_ASK (0x20000000)
//
// Do not attempt to validate that the stream can be parsed
//
#define SDP_SEARCH_NO_PARSE_CHECK (0x00000001)
//
// Do not check the format of the results. This includes suppression of both
// the check for a record patten (SEQ of UINT16 + value) and the validation
// of each universal attribute's accordance to the spec.
//
#define SDP_SEARCH_NO_FORMAT_CHECK (0x00000002)
typedef ULONGLONG HANDLE_SDP, *PHANDLE_SDP;
#define HANDLE_SDP_NULL ((HANDLE_SDP) 0x0)
#define HANDLE_SDP_LOCAL ((HANDLE_SDP) -2)
typedef struct _BTH_SDP_CONNECT {
//
// Address of the remote SDP server. Cannot be the local radio.
//
BTH_ADDR bthAddress;
//
// Combination of SDP_CONNECT_XXX flags
//
ULONG fSdpConnect;
//
// When the connect request returns, this will specify the handle to the
// SDP connection to the remote server
//
HANDLE_SDP hConnection;
//
// Timeout, in seconds, for the requests on ths SDP channel. If the request
// times out, the SDP connection represented by the HANDLE_SDP must be
// closed. The values for this field are bound by SDP_REQUEST_TO_MIN and
// SDP_REQUEST_MAX. If SDP_REQUEST_TO_DEFAULT is specified, the timeout is
// 30 seconds.
//
UCHAR requestTimeout;
} BTH_SDP_CONNECT, *PBTH_SDP_CONNECT;
typedef struct _BTH_SDP_DISCONNECT {
//
// hConnection returned by BTH_SDP_CONNECT
//
HANDLE_SDP hConnection;
} BTH_SDP_DISCONNECT, *PBTH_SDP_DISCONNECT;
typedef struct _BTH_SDP_RECORD {
//
// Combination of SERVICE_SECURITY_XXX flags
//
ULONG fSecurity;
//
// Combination of SERVICE_OPTION_XXX flags
//
ULONG fOptions;
//
// combo of COD_SERVICE_XXX flags
//
ULONG fCodService;
//
// The length of the record array, in bytes.
//
ULONG recordLength;
//
// The SDP record in its raw format
//
UCHAR record[1];
} BTH_SDP_RECORD, *PBTH_SDP_RECORD;
typedef struct _BTH_SDP_SERVICE_SEARCH_REQUEST {
//
// Handle returned by the connect request or HANDLE_SDP_LOCAL
//
HANDLE_SDP hConnection;
//
// Array of UUIDs. Each entry can be either a 2 byte, 4 byte or 16 byte
// UUID. SDP spec mandates that a request can have a maximum of 12 UUIDs.
//
SdpQueryUuid uuids[MAX_UUIDS_IN_QUERY];
} BTH_SDP_SERVICE_SEARCH_REQUEST, *PBTH_SDP_SERVICE_SEARCH_REQUEST;
typedef struct _BTH_SDP_ATTRIBUTE_SEARCH_REQUEST {
//
// Handle returned by the connect request or HANDLE_SDP_LOCAL
//
HANDLE_SDP hConnection;
//
// Combo of SDP_SEARCH_Xxx flags
//
ULONG searchFlags;
//
// Record handle returned by the remote SDP server, most likely from a
// previous BTH_SDP_SERVICE_SEARCH_RESPONSE.
//
ULONG recordHandle;
//
// Array of attributes to query for. Each SdpAttributeRange entry can
// specify either a single attribute or a range. To specify a single
// attribute, minAttribute should be equal to maxAttribute. The array must
// be in sorted order, starting with the smallest attribute. Furthermore,
// if a range is specified, the minAttribute must be <= maxAttribute.
//
SdpAttributeRange range[1];
} BTH_SDP_ATTRIBUTE_SEARCH_REQUEST, *PBTH_SDP_ATTRIBUTE_SEARCH_REQUEST;
typedef struct _BTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST {
//
// Handle returned by the connect request or HANDLE_SDP_LOCAL
//
HANDLE_SDP hConnection;
//
// Combo of SDP_SEARCH_Xxx flags
//
ULONG searchFlags;
//
// See comments in BTH_SDP_SERVICE_SEARCH_REQUEST
//
SdpQueryUuid uuids[MAX_UUIDS_IN_QUERY];
//
// See comments in BTH_SDP_ATTRIBUTE_SEARCH_REQUEST
//
SdpAttributeRange range[1];
} BTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST,
*PBTH_SDP_SERVICE_ATTRIBUTE_SEARCH_REQUEST;
typedef struct _BTH_SDP_STREAM_RESPONSE {
//
// The required buffer size (not including the first 2 ULONG_PTRs of this
// data structure) needed to contain the response.
//
// If the buffer passed was large enough to contain the entire response,
// requiredSize will be equal to responseSize. Otherwise, the caller should
// resubmit the request with a buffer size equal to
// sizeof(BTH_SDP_STREAM_RESPONSE) + requiredSize - 1. (The -1 is because
// the size of this data structure already includes one byte of the
// response.)
//
// A response cannot exceed 4GB in size.
//
ULONG requiredSize;
//
// The number of bytes copied into the response array of this data
// structure. If there is not enough room for the entire response, the
// response will be partially copied into the response array.
//
ULONG responseSize;
//
// The raw SDP response from the serach.
//
UCHAR response[1];
} BTH_SDP_STREAM_RESPONSE, *PBTH_SDP_STREAM_RESPONSE;
#if (NTDDI_VERSION > NTDDI_VISTASP1 || \
(NTDDI_VERSION == NTDDI_VISTASP1 && defined(VISTA_KB942567)))
//
// Vendor specific HCI command header
//
typedef struct _BTH_COMMAND_HEADER {
//
// Opcode for the command
//
USHORT OpCode;
//
// Payload of the command excluding the header.
// TotalParameterLength = TotalCommandLength - sizeof(BTH_COMMAND_HEADER)
//
UCHAR TotalParameterLength;
} BTH_COMMAND_HEADER, * PBTH_COMMAND_HEADER;
//
// Vendor Specific Command structure
//
typedef struct _BTH_VENDOR_SPECIFIC_COMMAND {
//
// Manufacturer ID
//
ULONG ManufacturerId;
//
// LMP version. Command is send to radio only if the radios
// LMP version is greater than this value.
//
UCHAR LmpVersion;
//
// Should all the patterns match or just one. If MatchAnySinglePattern == TRUE
// then if a single pattern matches the command, we decide that we have a match.
//
BOOLEAN MatchAnySinglePattern;
//
// HCI Command Header
//
BTH_COMMAND_HEADER HciHeader;
//
// Data for the above command including patterns
//
UCHAR Data[1];
} BTH_VENDOR_SPECIFIC_COMMAND, * PBTH_VENDOR_SPECIFIC_COMMAND;
//
// Structure of patterns
//
typedef struct _BTH_VENDOR_PATTERN {
//
// Pattern Offset in the event structure excluding EVENT header
//
UCHAR Offset;
//
// Size of the Pattern
//
UCHAR Size;
//
// Pattern
//
UCHAR Pattern[1];
} BTH_VENDOR_PATTERN, * PBTH_VENDOR_PATTERN;
//
//The buffer associated with GUID_BLUETOOTH_HCI_VENDOR_EVENT
//
typedef struct _BTH_VENDOR_EVENT_INFO {
//
//Local radio address with which the event is associated.
//
BTH_ADDR BthAddress;
//
//Size of the event buffer including Event header
//
ULONG EventSize;
//
//Information associated with the event
//
UCHAR EventInfo[1];
} BTH_VENDOR_EVENT_INFO, * PBTH_VENDOR_EVENT_INFO;
//
// Extended Inquiry Response data defines.
//
typedef ULONGLONG HANDLE_EIR, *PHANDLE_EIR;
#define INVALID_HANDLE_EIR_VALUE ((HANDLE_EIR)((LONGLONG)-1))
typedef struct _BTH_EIR_GET_RECORDS {
//
// [IN] Device's Bluetooth address. For local device use BTH_ADDR_NULL.
//
BTH_ADDR BthAddress;
//
// Reseved field (set to zero).
//
ULONG Reserved;
} BTH_EIR_GET_RECORDS, *PBTH_EIR_GET_RECORDS;
typedef struct _BTH_EIR_SUBMIT_RECORD {
//
// [IN/OUT] Record Handle. Set to INVALID_HANDLE_EIR_VALUE for submit.
//
HANDLE_EIR Handle;
//
// Reserved field (set to zero).
//
ULONG Reserved;
//
// [IN] Record size in bytes.
//
ULONG RecordSize;
//
// [IN] The EIR record data array (data-type and data).
//
UCHAR Record[1];
} BTH_EIR_SUBMIT_RECORD, *PBTH_EIR_SUBMIT_RECORD;
#endif // >= SP1+KB942567
#include <POPPACK.H>
#endif // (NTDDI_VERSION >= NTDDI_VISTA)
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(default:4201)
#endif
#endif // __BTHIOCTL_H__

Some files were not shown because too many files have changed in this diff Show More