⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agvdlg.cpp

📁 基于视觉的道路识别技术的智能小车导航源代码
💻 CPP
字号:
// AGVDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AGV.h"
#include "AGVDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAGVDlg dialog

CAGVDlg::CAGVDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAGVDlg::IDD, pParent)
	,m_hDIB(NULL)
	,m_hIcon(NULL)
	,m_bStatus(FALSE)

{
    
	//{{AFX_DATA_INIT(CAGVDlg)

	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CAGVDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(CAGVDlg, CDialog)
	//{{AFX_MSG_MAP(CAGVDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_COMMAND(ID__SET_FORMAT, OnSetFormat)
	ON_COMMAND(ID__SET_SOURCE, OnSetSource)
	ON_COMMAND(ID_CAPTURE_FRAME, OnCaptureFrame)
	ON_COMMAND(ID_CAPTURE_SEQUENCE, OnCaptureSequence)
	ON_COMMAND(IDR_CAPTURE_STOP, OnCaptureStop)
	ON_COMMAND(ID_CONTROL_START, OnControlStart)
	ON_COMMAND(ID_CONTROL_END, OnControlEnd)
	ON_COMMAND(ID_RS232_START, OnRs232Start)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAGVDlg message handlers

BOOL CAGVDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	//
	//捕捉窗口
	CWnd*pWnd=(CWnd*)GetDlgItem(IDC_CAPTUREWINDOW);
	if(m_clsCaptureWnd.bofVFW()==FALSE)
	{
		AfxMessageBox("请采用支持VFW的摄像头!");
		return FALSE;
	}
	pWnd->MoveWindow(0,0,768/*IMAGE_WIDTH*/,576/*IMAGE_HEIGHT*/,TRUE);
	m_clsCaptureWnd.CreateCaptureWindow(pWnd->GetSafeHwnd());
		m_clsCaptureWnd.SetPreviewRate(15);//设置预览频率,默认是15
   	return TRUE;  // return TRUE  unless you set the focus to a control
}

// 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 CAGVDlg::OnPaint() 
{
	if (IsIconic())//Nonzero if CWnd is minimized; otherwise 0.


	{
		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();
	     
		//DrawMeasureData(m_aux.StartTimeToShow);
	}
	
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CAGVDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CAGVDlg::OnSetFormat() 
{
    m_clsCaptureWnd.CaptureSetup(0);
//m_clsCaptureWnd.SetVideoFormat(300,400);
Invalidate();
UpdateWindow();
	
}

void CAGVDlg::OnSetSource() 
{
m_clsCaptureWnd.CaptureSetup(2);
	
}

void CAGVDlg::OnCaptureFrame() 
{
    m_pDlgMeasure=new CDlgMeasure(this);
	m_pDlgMeasure->Create();
    
    
    m_pDlgMeasure->ShowWindow(SW_SHOWMAXIMIZED);
	
   m_pDlgMeasure->m_hDIB=(HDIB)m_clsCaptureWnd.GrabFrame(TRUE);
   if(m_pDlgMeasure->m_hDIB==NULL)
   { 
	 AfxMessageBox("Error");
 	 return;
   }
   

 m_pDlgMeasure->InitDIBData();
 //this->ShowWindow(SW_RESTORE);
 m_clsCaptureWnd.Preview(TRUE);
	
}

void CAGVDlg::OnCaptureSequence()//要保存视频文件
{
   m_clsCaptureWnd.StartCapture(TRUE);
	
}


void CAGVDlg::OnCaptureStop() 
{
  m_clsCaptureWnd.StopCapture(TRUE);	// TODO: Add your command handler code here;
	
}



void CAGVDlg::OnControlStart() 
{
	m_bStatus =1-m_bStatus ;
//	m_clsCaptureWnd.SetPreviewRate(0);
	//m_clsCaptureWnd.SetVideoStreamParam(2);//设定每秒抓取2帧
	m_clsCaptureWnd.SetCallbackproc(2,m_bStatus);	
}

void CAGVDlg::OnControlEnd() 
{
  
	
}

BEGIN_EVENTSINK_MAP(CAGVDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CAGVDlg)
//	ON_EVENT(CAGVDlg, IDC_MSCOMM1, 1 /* OnComm */, OnComm, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()



void CAGVDlg::OnRs232Start() 
{
	 m_pCommDialog=new CCommDialog(this);
     m_pCommDialog->Create();
    //CCommDialog dlg;
//	dlg.
    
    m_pCommDialog->ShowWindow(SW_SHOWMAXIMIZED);
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -