• 大小: 14.91MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-31
  • 语言: C/C++
  • 标签: mfc  opencv  

资源简介

MFC+VS2013+OPENCV3.0打开摄像头拍照 工程压缩了大于60M不让传,我把主要的放了。.sln啥的去掉了。想要真个工程的留个言啥的吧。不过挺简单的,我都写出来,估计大家看看就懂了。--注意:适合初学者。

资源截图

代码片段和文件信息

#include “StdAfx.h“
#include “CvvImage.h“
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CV_INLINE RECT NormalizeRect( RECT r );
CV_INLINE RECT NormalizeRect( RECT r )
{
int t;
if( r.left > r.right )
{
t = r.left;
r.left = r.right;
r.right = t;
}
if( r.top > r.bottom )
{
t = r.top;
r.top = r.bottom;
r.bottom = t;
}

return r;
}
CV_INLINE CvRect RectToCvRect( RECT sr );
CV_INLINE CvRect RectToCvRect( RECT sr )
{
sr = NormalizeRect( sr );
return cvRect( sr.left sr.top sr.right - sr.left sr.bottom - sr.top );
}
CV_INLINE RECT CvRectToRect( CvRect sr );
CV_INLINE RECT CvRectToRect( CvRect sr )
{
RECT dr;
dr.left = sr.x;
dr.top = sr.y;
dr.right = sr.x + sr.width;
dr.bottom = sr.y + sr.height;

return dr;
}
CV_INLINE IplROI RectToROI( RECT r );
CV_INLINE IplROI RectToROI( RECT r )
{
IplROI roi;
r = NormalizeRect( r );
roi.xOffset = r.left;
roi.yOffset = r.top;
roi.width = r.right - r.left;
roi.height = r.bottom - r.top;
roi.coi = 0;

return roi;
}
void  FillBitmapInfo( BITMAPINFO* bmi int width int height int bpp int origin )
{
assert( bmi && width >= 0 && height >= 0 && (bpp == 8 || bpp == 24 || bpp == 32));

BITMAPINFOHEADER* bmih = &(bmi->bmiHeader);

memset( bmih 0 sizeof(*bmih));
bmih->biSize = sizeof(BITMAPINFOHEADER);
bmih->biWidth = width;
bmih->biHeight = origin ? abs(height) : -abs(height);
bmih->biPlanes = 1;
bmih->biBitCount = (unsigned short)bpp;
bmih->biCompression = BI_RGB;
if( bpp == 8 )
{
RGBQUAD* palette = bmi->bmiColors;
int i;
for( i = 0; i < 256; i++ )
{
palette[i].rgbBlue = palette[i].rgbGreen = palette[i].rgbRed = (BYTE)i;
palette[i].rgbReserved = 0;
}
}
}
CvvImage::CvvImage()
{
m_img = 0;
}
void CvvImage::Destroy()
{
cvReleaseImage( &m_img );
}
CvvImage::~CvvImage()
{
Destroy();
}
bool  CvvImage::Create( int w int h int bpp int origin )
{
const unsigned max_img_size = 10000;

if( (bpp != 8 && bpp != 24 && bpp != 32) ||
(unsigned)w >=  max_img_size || (unsigned)h >= max_img_size ||
(origin != IPL_ORIGIN_TL && origin != IPL_ORIGIN_BL))
{
assert(0); // most probably it is a programming error
return false;
}
if( !m_img || Bpp() != bpp || m_img->width != w || m_img->height != h )
{
if( m_img && m_img->nSize == sizeof(IplImage))
Destroy();
/* prepare IPL header */
m_img = cvCreateImage( cvSize( w h ) IPL_DEPTH_8U bpp/8 );
}
if( m_img )
m_img->origin = origin == 0 ? IPL_ORIGIN_TL : IPL_ORIGIN_BL;
return m_img != 0;
}
void  CvvImage::CopyOf( CvvImage& image int desired_color )
{
IplImage* img = image.GetImage();
if( img )
{
CopyOf( img desired_color );
}
}
#define HG_IS_IMAGE(img)\
((img) != 0 && ((const IplImage*)(img))->nSize == sizeof(IplImage) &&\
((IplImage*)img)->imageDat

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-08-21 15:03  Mytimer\
     文件        6547  2015-08-21 15:03  Mytimer\CvvImage.cpp
     文件        2021  2015-08-20 10:51  Mytimer\CvvImage.h
     目录           0  2015-08-21 19:57  Mytimer\Debug\
     文件      218760  2015-08-21 19:57  Mytimer\Debug\CvvImage.obj
     文件        2867  2015-08-21 19:57  Mytimer\Debug\Mytimer.log
     文件       59551  2015-08-21 14:47  Mytimer\Debug\Mytimer.obj
     文件    43188224  2015-08-21 11:22  Mytimer\Debug\Mytimer.pch
     文件       69640  2015-08-21 14:58  Mytimer\Debug\Mytimer.res
     目录           0  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\
     文件        2614  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\cl.command.1.tlog
     文件       83826  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\CL.read.1.tlog
     文件        2192  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\CL.write.1.tlog
     文件        3118  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\link.command.1.tlog
     文件       11766  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\link.read.1.tlog
     文件         610  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\link.write.1.tlog
     文件         147  2015-08-21 19:57  Mytimer\Debug\Mytimer.tlog\Mytimer.lastbuildstate
     文件         542  2015-08-21 14:58  Mytimer\Debug\Mytimer.tlog\rc.command.1.tlog
     文件        2542  2015-08-21 14:58  Mytimer\Debug\Mytimer.tlog\rc.read.1.tlog
     文件         154  2015-08-21 14:58  Mytimer\Debug\Mytimer.tlog\rc.write.1.tlog
     文件      256411  2015-08-21 14:53  Mytimer\Debug\MytimerDlg.obj
     文件      917197  2015-08-21 11:22  Mytimer\Debug\stdafx.obj
     文件     2755584  2015-08-21 19:57  Mytimer\Debug\vc120.idb
     文件     7475200  2015-08-21 19:57  Mytimer\Debug\vc120.pdb
     文件      108408  2015-08-21 14:58  Mytimer\Mytimer.aps
     文件        2387  2015-08-21 11:05  Mytimer\Mytimer.cpp
     文件         449  2015-08-21 11:05  Mytimer\Mytimer.h
     文件       10832  2015-08-21 14:58  Mytimer\Mytimer.rc
     文件        6369  2015-08-21 11:22  Mytimer\Mytimer.vcxproj
     文件        2237  2015-08-21 11:22  Mytimer\Mytimer.vcxproj.filters
     文件        6088  2015-08-21 14:53  Mytimer\MytimerDlg.cpp
............此处省略9个文件信息

评论

共有 条评论