VC++6.0 OPENCV1.0
1.生成MFC框架
MFC exe. Scrollview 其余默认
1.生成MFC框架
MFC exe. Scrollview 其余默认
2.环境配置
vc6.0配置opencv :工程、设置、链接、对象库模块 cv.lib highgui.lib cxcore.lib
工具、选项、目录的设置opencv的路径
includes
C:\PROGRAM FILES\OPENCV\OTHERLIBS\CVCAM\INCLUDE
C:\PROGRAM FILES\OPENCV\CV\INCLUDE
C:\PROGRAM FILES\OPENCV\CVAUX\INCLUDE
C:\PROGRAM FILES\OPENCV\LIB
C:\PROGRAM FILES\OPENCV\CXCORE\INCLUDE
C:\PROGRAM FILES\OPENCV\OTHERLIBS\HIGHGUI
libs
C:\PROGRAM FILES\OPENCV\LIB
C:\PROGRAM FILES\OPENCV\OTHERLIBS\HIGHGUI
C:\PROGRAM FILES\OPENCV\LIB
C:\PROGRAM FILES\OPENCV\OTHERLIBS\HIGHGUI
3变量
DOC类头文件
public:
CvvImage* m_pvImage;
CString m_nFileTitle;
DOC类
构造函数 指针初始化
m_pvImage=NULL;
析构函数,图像结束
if (m_pvImage!=NULL)
{
delete m_pvImage;
}
if (m_pvImage!=NULL)
{
delete m_pvImage;
}
4代码
DOC类 ,用类向导添加Onfileopen函数
DOC类 ,用类向导添加Onfileopen函数
Onfileopen 部分
char szFileFilter[]="All Supported Images|*.bmp;*.dib;*.JPEG;*.JPG;*.png;*.tiff;*.tif||";
char szFileFilter[]="All Supported Images|*.bmp;*.dib;*.JPEG;*.JPG;*.png;*.tiff;*.tif||";
CFileDialog FileDlg(1,0,0,6,szFileFilter);
if (FileDlg.DoModal()==IDOK)
{
if (m_pvImage==NULL)
{
m_pvImage=new CvvImage;
}
m_pvImage->Load(FileDlg.GetPathName());
m_nFileTitle=FileDlg.GetFileTitle();
UpdateAllViews(NULL);
}
if (FileDlg.DoModal()==IDOK)
{
if (m_pvImage==NULL)
{
m_pvImage=new CvvImage;
}
m_pvImage->Load(FileDlg.GetPathName());
m_nFileTitle=FileDlg.GetFileTitle();
UpdateAllViews(NULL);
}
view类ondraw 函数
if (pDoc->m_pvImage)
{
CSize size;
CRect clientRect(0,0,pDoc->m_pvImage->Width(),pDoc->m_pvImage->Height());
size.cx=pDoc->m_pvImage->Width();
size.cy=pDoc->m_pvImage->Height();
SetScrollSizes(MM_TEXT, size);
pDoc->m_pvImage->Show(pDC->GetSafeHdc(),0,0,clientRect.Width(),clientRect.Height());
}
if (pDoc->m_pvImage)
{
CSize size;
CRect clientRect(0,0,pDoc->m_pvImage->Width(),pDoc->m_pvImage->Height());
size.cx=pDoc->m_pvImage->Width();
size.cy=pDoc->m_pvImage->Height();
SetScrollSizes(MM_TEXT, size);
pDoc->m_pvImage->Show(pDC->GetSafeHdc(),0,0,clientRect.Width(),clientRect.Height());
}
view类 OnInitialUpdata()
CScrollView::OnInitialUpdate();
CMy23Doc* pDoc = GetDocument(); //类命需要根据自己的命名修改
ASSERT_VALID(pDoc);
CSize sizeTotal;
// TODO: calculate the total size of this view
if (pDoc->m_pvImage!=NULL)
{
sizeTotal.cx=pDoc->m_pvImage->Width();
sizeTotal.cy=pDoc->m_pvImage->Height();
}
else
sizeTotal.cx=sizeTotal.cy=100;
// TODO: calculate the total size of this view
if (pDoc->m_pvImage!=NULL)
{
sizeTotal.cx=pDoc->m_pvImage->Width();
sizeTotal.cy=pDoc->m_pvImage->Height();
}
else
sizeTotal.cx=sizeTotal.cy=100;
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
SetScrollSizes(MM_TEXT, sizeTotal);
}
5打开opencv文件夹,找到可执行文件bin ,把几个cv.dll移到vc6.0执行文件debug里面去
运行