Salut
j'ai un code c++ ( interface graphique ) qui contient un bouton "open image" et qui affiche cette image dans une nouvelle fenetre nommé "Original image" .
je veux bien que l'affichage soit dans la meme interface dans une zone dédiée à une image .
s'il vous plait , est-ce que vous pouvez m'aider pour refaire le meme travail mais cette fois çi sur un vidéo et non pas sur une image .
merci d'avance
Code C/C++ :
// cvisionDlg.cpp : implementation file
//
#include "stdafx.h"
#include "cvision.h"
#include "cvisionDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CString mesg;
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
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()
// CcvisionDlg dialog
CcvisionDlg::CcvisionDlg(CWnd* pParent /*=NULL*/)
: CDialog(CcvisionDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CcvisionDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//DDX_Control(pDX, IDC_EDITB, m_editB);
}
BEGIN_MESSAGE_MAP(CcvisionDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, &CcvisionDlg::OnOpen)
ON_BN_CLICKED(IDOK, &CcvisionDlg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CcvisionDlg::OnBnClickedCancel)
ON_EN_CHANGE(IDC_EDIT1, &CcvisionDlg::OnEnChangeEdit1)
END_MESSAGE_MAP()
// CcvisionDlg message handlers
BOOL CcvisionDlg::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
cvNamedWindow( "Original Image"); // create the window on which
// the image will be displayed
return TRUE; // return TRUE unless you set the focus to a control
}
void CcvisionDlg::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 CcvisionDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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 function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CcvisionDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CcvisionDlg::OnOpen()
{
CFileDialog dlg(TRUE, _T("*.bmp"), NULL,
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY,
_T("image files (*.bmp; *.jpg) |*.bmp;*.jpg|All Files (*.*)|*.*||"),NULL);
dlg.m_ofn.lpstrTitle= _T("Open Image");
if (dlg.DoModal() == IDOK) {
CString path= dlg.GetPathName(); // contain the selected filename
IplImage *image; // This is image pointer
image= cvLoadImage(path); // load the image
cvShowImage("Original Image", image); // display it
}
}
void CcvisionDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
cvDestroyAllWindows();
OnOK();
}
void CcvisionDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
cvDestroyAllWindows();
OnCancel();
}
void CcvisionDlg::OnEnChangeEdit1()
{
// TODO: S'il s'agit d'un contrôle RICHEDIT, le contrôle
// n'enverra la notification que si vous substituez la fonction CDialog::OnInitDialog()
// et l'appel CRichEditCtrl().SetEventMask()
// avec l'indicateur ENM_CHANGE ajouté au masque grâce à l'opérateur OR.
// TODO: Ajoutez ici le code de votre gestionnaire de notification de contrôle
}
Code C/C++ :
// cvision.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "cvision.h"
#include "cvisionDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CcvisionApp
BEGIN_MESSAGE_MAP(CcvisionApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CcvisionApp construction
CcvisionApp::CcvisionApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CcvisionApp object
CcvisionApp theApp;
// CcvisionApp initialization
BOOL CcvisionApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CcvisionDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
Code C/C++ :
// cvisionDlg.h : header file
//
#pragma once
#include "highgui.h"
// CcvisionDlg dialog
class CcvisionDlg : public CDialog
{
// Construction
public:
CcvisionDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_CVISION_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnOpen();
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
afx_msg void OnEnChangeEdit1();
};
Code C/C++ :
// cvision.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CcvisionApp:
// See cvision.cpp for the implementation of this class
//
class CcvisionApp : public CWinApp
{
public:
CcvisionApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CcvisionApp theApp;
Code C/C++ :
//Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by cvision.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_CVISION_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_BUTTON1 1000
#define IDC_EDIT1 1001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif