// PatternDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Pattern.h"
#include "PatternDlg.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
void RotateModelCenter(MIL_ID Buffer,
double *X,
double *Y,
double Angle);
double CalculateAngleDist(double Angle1, double Angle2);
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPatternDlg dialog
CPatternDlg::CPatternDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPatternDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPatternDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_milApplication = m_milSystem = m_milDisplay = m_milOverlay = M_NULL;
m_milImageSimple = m_milModelSimple = m_milResultSimple = M_NULL;
m_milImageRotate = m_milModelRotate = m_milTargetRotate = m_milResultRotate = M_NULL;
}
CPatternDlg::~CPatternDlg()
{
if (M_NULL != m_milResultRotate)
{
MpatFree(m_milResultRotate);
}
if (M_NULL != m_milModelRotate)
{
MpatFree(m_milModelRotate);
}
if (M_NULL != m_milTargetRotate)
{
MbufFree(m_milTargetRotate);
}
if (M_NULL != m_milImageRotate)
{
MbufFree(m_milImageRotate);
}
if (M_NULL != m_milResultSimple)
{
MpatFree(m_milResultSimple);
}
if (M_NULL != m_milModelSimple)
{
MpatFree(m_milModelSimple);
}
if (M_NULL != m_milImageSimple)
{
MbufFree(m_milImageSimple);
}
if (M_NULL != m_milApplication)
{
MappFreeDefault(m_milApplication, m_milSystem, m_milDisplay, M_NULL, M_NULL);
}
}
void CPatternDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPatternDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPatternDlg, CDialog)
//{{AFX_MSG_MAP(CPatternDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDB_READMODEL_SIMPLE, OnReadmodelSimple)
ON_BN_CLICKED(IDB_SETMODEL_SIMPLE, OnSetmodelSimple)
ON_BN_CLICKED(IDB_SETTARGET_SIMPLE, OnSettargetSimple)
ON_BN_CLICKED(IDB_FIND_SIMPLE, OnFindSimple)
ON_BN_CLICKED(IDB_READMODEL_ROTATE, OnReadmodelRotate)
ON_BN_CLICKED(IDB_SETMODEL_ROTATE, OnSetmodelRotate)
ON_BN_CLICKED(IDB_FIND_ROTATE, OnFindRotate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPatternDlg message handlers
BOOL CPatternDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//分配MIL基础系统
MappAllocDefault(M_SETUP, &m_milApplication, &m_milSystem, &m_milDisplay, M_NULL,M_NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CPatternDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPatternDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPatternDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPatternDlg::OnReadmodelSimple()
{
// TODO: Add your control notification handler code here
if (M_NULL != m_milImageSimple)
{
MbufFree(m_milImageSimple);
m_milImageSimple = M_NULL;
}
//读入图像
CFileDialog fileDialog(TRUE);
fileDialog.m_ofn.lpstrFilter = TEXT("(MIL格式图像)\0*.mim\0\0");
fileDialog.m_ofn.lpstrInitialDir = TEXT(".\\Image");
if (IDOK == fileDialog.DoModal())
{
MbufRestore(fileDialog.GetPathName().GetBuffer(MAX_PATH), m_milSystem, &m_milImageSimple);
MdispZoom(m_milDisplay, 0.9, 0.9);
MdispControl(m_milDisplay, M_CENTER_DISPLAY, M_ENABLE);
MdispControl(m_milDisplay, M_OVERLAY_CLEAR, M_DEFAULT);
MdispSelectWindow(m_milDisplay, m_milImageSimple, GetDlgItem(IDP_DISP_IMAGE)->GetSafeHwnd());
}
}
void CPatternDlg::OnSetmodelSimple()
{
// TODO: Add your control notification handler code here
if (M_NULL != m_milModelSimple)
{
MpatFree(m_milModelSimple);
m_milModelSimple = M_NULL;
}
//分配Model
MpatAllocModel(m_milSystem, m_milImageSimple,
FIND_MODEL_X_POS, FIND_MODEL_Y_POS,
FIND_MODEL_WIDTH, FIND_MODEL_HEIGHT,
M_NORMALIZED,
&m_milModelSimple);
//设置查找精度
MpatSetAccuracy(m_milModelSimple, M_HIGH);
//设置查找速度
MpatSetSpeed(m_milModelSimple, M_HIGH);
//预处理Model
MpatPreprocModel(m_milImageSimple, m_milModelSimple, M_DEFAULT);
//在图中标记处出Model
MdispControl(m_milDisplay, M_OVERLAY, M_ENABLE);
MdispControl(m_milDisplay, M_OVERLAY_CLEAR, M_DEFAULT);
MdispInquire(m_milDisplay, M_OVERLAY_ID, &m_milOverlay);
MgraColor(M_DEFAULT, M_COLOR_BLUE);
MpatDraw(M_DEFAULT, m_milModelSimple, m_milOverlay, M_DRAW_BOX+M_DRAW_POSITION,
M_DEFAULT, M_ORIGINAL);
}
void CPatternDlg::OnSettargetSimple()
{
// TODO: Add your control notification handler code here
//平移原图像作为目标图像
MdispControl(m_milDisplay, M_OVERLAY_CLEAR, M_DEFAULT);
MdispSelectWindow(m_milDisplay, M_NULL, M_NULL);
MimTranslate(m_milImageSimple, m_milImageSimple, FIND_SHIFT_X, FIND_SHIFT_Y, M_DEFAULT);
MdispSelectWindow(m_milDisplay, m_milImageSimple, GetDlgItem(IDP_DISP_IMAGE)->GetSafeHwnd());
}
void CPatternDlg::OnFindSimple()
{
// TODO: Add your con
博客-MIL Pattern灰度匹配模块演示代码
4星 · 超过85%的资源 需积分: 15 87 浏览量
2014-03-31
11:54:22
上传
评论
收藏 204KB ZIP 举报
文大侠666
- 粉丝: 1204
- 资源: 109
最新资源
- 基于Typescript的兔子饭店经营类游戏源码设计免费送cocoscreator
- 基于Java的web快速开发数据权限管理脚手架wonder-server设计源码
- 基于Apache Log4cxx的C++日志库设计源码
- 基于Vue3的likeadmin免费任意商用管理后台设计源码
- 基于JavaScript的Chrome扩展WeNote分享插件设计源码
- 基于C++的中泰EM9108S动态库开发示例源码
- gxlx2-p291-1g.dts和gxlx2-p291-1g.dtb
- STM32WBxx Keil芯片包
- 基于CNN+Bi-LSTM+Attention 的自动对对联系统
- 基于Java的IndexBar Android字母索引栏设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页