2014-02-11 00:59:20 -0600 | received badge | ● Editor (source) |
2014-02-11 00:57:50 -0600 | asked a question | how to display 2 camera vidieo screens on mfc dialog? // FlyCapture2_EXDlg.cpp:구현 파일 include"stdafx.h"include"FlyCapture2_EX.h"include"FlyCapture2_EXDlg.h"ifdef _DEBUGdefine new DEBUG_NEWendifclass CAboutDlg:public CDialog{ public: CAboutDlg(); // 대화 상자 데이터입니다. enum{IDD=IDD_ABOUTBOX}; // 구현입니다. protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){ } void CAboutDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg,CDialog) END_MESSAGE_MAP() // CFlyCapture2_EXDlg 대화 상자 CFlyCapture2_EXDlg::CFlyCapture2_EXDlg(CWnd* pParent /=NULL/) :CDialog(CFlyCapture2_EXDlg::IDD,pParent) ,m_ThreadContinue(false){ m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_heventThreadDone=CreateEvent(NULL,FALSE,FALSE,NULL);// 핸들 이벤트 생성 } void CFlyCapture2_EXDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CFlyCapture2_EXDlg,CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_START,&CFlyCapture2_EXDlg::OnBnClickedStart) ON_WM_DESTROY() END_MESSAGE_MAP() // CFlyCapture2_EXDlg 메시지 처리기 BOOL CFlyCapture2_EXDlg::OnInitDialog(){ CDialog::OnInitDialog(); } void CFlyCapture2_EXDlg::OnSysCommand(UINT nID,LPARAM lParam){ if((nID & 0xFFF0)==IDM_ABOUTBOX){ CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID,lParam); } } // 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면 // 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는 // 프레임워크에서 이 작업을 자동으로 수행합니다. void CFlyCapture2_EXDlg::OnPaint(){ if(IsIconic()){ CPaintDC dc(this);// 그리기를 위한 디바이스 컨텍스트 } // 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서 // 이 함수를 호출합니다. HCURSOR CFlyCapture2_EXDlg::OnQueryDragIcon(){ return static_cast<hcursor>(m_hIcon); } UINT CFlyCapture2_EXDlg::threadGrab(LPVOID pParam){ CFlyCapture2_EXDlg* pDlg=((CFlyCapture2_EXDlg*)pParam); UINT Retval=pDlg ->GrabLoop(); SetEvent(pDlg->m_heventThreadDone);// 이벤트를 Set 함 SetEvent(pDlg->n_heventThreadDone); return Retval; } void CFlyCapture2_EXDlg::OnBnClickedStart(){ m_ThreadContinue=true; n_ThreadContinue=true; CWinThread *pThread=::AfxBeginThread(threadGrab,this);// thread 생성 } void CFlyCapture2_EXDlg::OnDestroy(){ CDialog::OnDestroy(); } include <stdio.h>IplImage* image=NULL; IplImage* image2=NULL; IplImage* gray=NULL; IplImage* gray2=NULL; IplImage* binary=NULL; IplImage* binary2=NULL; UINT CFlyCapture2_EXDlg::GrabLoop(void){ m_error=m_BusManager.GetCameraFromIndex(0,&m_Guid);//select cam0 m_error=m_Cam.Connect(&m_Guid); m_error=m_Cam.GetConfiguration(&m_Config); m_Config.grabMode=BUFFER_FRAMES; m_Config.numBuffers=20; m_error=m_Cam.SetConfiguration(&m_Config); m_error=m_Cam.SetVideoModeAndFrameRate(VIDEOMODE_640x480Y8,FRAMERATE_15); m_error=m_Cam.StartCapture(); (more) |