机器视觉(定位源码)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
机器视觉---定位识别源码
(完全基于几何算法的定位, 精度高、速度快、识别能力及抗干扰能力强;
引用地址: 注册会员下载VB,VC实现源码, 其中对图片的处理代码)
// KMDVisionDemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "KMDVisionDemo.h"
#include "KMDVisionDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
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()
/////////////////////////////////////////////////////////////////////////////
// CKMDVisionDemoDlg dialog
CKMDVisionDemoDlg::CKMDVisionDemoDlg(CWnd* pParent /*=NULL*/) : CDialog(CKMDVisionDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CKMDVisionDemoDlg)
m_Score = 0;
m_DownZoom = 1.0f;
m_UpZoom = 1.0f;
m_MaxAngle = 45;
m_MinAngle = -45;
m_PyrLevel = 1;
m_MatchNum = 1;
m_pRawData = NULL;
m_pDispData = NULL;
m_hMVC1000=NULL;
IsMatching=FALSE;
IsCamera=FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CKMDVisionDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKMDVisionDemoDlg)
DDX_Control(pDX, IDC_VIEWWND, m_ViewWnd);
DDX_Control(pDX, IDC_SCROLLBARV, m_VScroBar);
DDX_Control(pDX, IDC_SCROLLBARH, m_HScroBar);
DDX_Text(pDX, IDC_MATCHNUM, m_MatchNum);
DDV_MinMaxInt(pDX, m_MatchNum, 1, 80);
DDX_Text(pDX, IDC_ZOOMBEDIT, m_UpZoom);
DDV_MinMaxFloat(pDX, m_UpZoom, 1.f, 5.f);
DDX_Text(pDX, IDC_ZOOMSEDIT, m_DownZoom);
DDV_MinMaxFloat(pDX, m_DownZoom, 0.1f, 1.f);
DDX_Text(pDX, IDC_SCORE, m_Score);
DDV_MinMaxInt(pDX, m_Score, 20, 100);
DDX_Text(pDX, IDC_PYRLEVEL, m_PyrLevel);
DDV_MinMaxInt(pDX, m_PyrLevel, 1, 4);
DDX_Text(pDX, IDC_MAXANGLEEDIT, m_MaxAngle);
DDV_MinMaxInt(pDX, m_MaxAngle, -180, 180);
DDX_Text(pDX, IDC_MINANGLEEDIT, m_MinAngle);
DDV_MinMaxInt(pDX, m_MinAngle, -180, 180);
//}}AFX_DATA_MAP
}
void CALLBACK RawCallBack(LPVOID lpParam, LPVOID lpUser)
{
BYTE *pDataBuffer = (BYTE*)lpParam;
CKMDVisionDemoDlg *pDemoDlg = (CKMDVisionDemoDlg*)lpUser;
for(int i=0;i<480;i++)
memcpy(pDemoDlg->m_pDispData+i*640,pDataBuffer+(479-i)*640,640);
pDemoDlg->DrawImage();
}
BEGIN_MESSAGE_MAP(CKMDVisionDemoDlg, CDialog)
//{{AFX_MSG_MAP(CKMDVisionDemoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SETMODELAREA, OnSetmodelarea)
ON_BN_CLICKED(IDC_OPENMODELIMAGE, OnOpenmodelimage)
ON_BN_CLICKED(IDC_MAKEMODEL, OnMakemodel)
ON_BN_CLICKED(IDC_OPENSEARCHIMAGE, OnOpensearchimage)
ON_BN_CLICKED(IDC_SETSEARCHAREA, OnSetsearcharea)
ON_BN_CLICKED(IDC_TRYMODEL, OnTrymodel)
ON_WM_HSCROLL()