-
大小: 91.53MB文件类型: .zip金币: 1下载: 0 次发布日期: 2022-04-30
- 语言: C/C++
- 标签:
资源简介
MFC 使用Opencv调用摄像头并显示画面,关闭摄像头显示一张本地图片,MFC 使用Opencv调用摄像头并显示画面,关闭摄像头显示一张本地图片,MFC 使用Opencv调用摄像头并显示画面,关闭摄像头显示一张本地图片
代码片段和文件信息
#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 2018-05-07 13:46 ipch\
目录 0 2018-05-07 13:46 ipch\opencamera-31ca8e88\
文件 147259392 2018-05-07 13:46 ipch\opencamera-31ca8e88\opencamera-6198c061.ipch
文件 92557312 2018-05-07 14:02 OpenCamera.sdf
文件 897 2018-05-04 16:27 OpenCamera.sln
文件 27136 2018-05-07 14:02 OpenCamera.suo
目录 0 2018-05-07 12:28 OpenCamera\
文件 1 2009-08-31 02:32 OpenCamera\ClassDiagram1.cd
文件 6547 2018-05-04 17:05 OpenCamera\CvvImage.cpp
文件 1925 2018-05-04 17:10 OpenCamera\CvvImage.h
目录 0 2018-05-04 16:47 OpenCamera\Debug\
文件 3214 2018-05-04 16:48 OpenCamera\Debug\cl.command.1.tlog
文件 103590 2018-05-04 16:48 OpenCamera\Debug\CL.read.1.tlog
文件 1640 2018-05-04 16:48 OpenCamera\Debug\CL.write.1.tlog
文件 543 2018-05-04 16:47 OpenCamera\Debug\OpenCamera.Build.CppClean.log
文件 68 2018-05-04 16:48 OpenCamera\Debug\OpenCamera.lastbuildstate
文件 1507 2018-05-04 16:48 OpenCamera\Debug\OpenCamera.log
文件 36831232 2018-05-04 16:47 OpenCamera\Debug\OpenCamera.pch
文件 0 2018-05-04 16:48 OpenCamera\Debug\OpenCamera.unsuccessfulbuild
文件 0 2018-05-04 16:47 OpenCamera\Debug\OpenCamera.write.1.tlog
文件 747375 2018-05-04 16:47 OpenCamera\Debug\stdafx.obj
文件 1715200 2018-05-04 16:48 OpenCamera\Debug\vc100.idb
文件 4362240 2018-05-04 16:48 OpenCamera\Debug\vc100.pdb
文件 105980 2018-05-07 11:37 OpenCamera\OpenCamera.aps
文件 2045 2018-05-04 16:27 OpenCamera\OpenCamera.cpp
文件 466 2018-05-04 16:27 OpenCamera\OpenCamera.h
文件 10504 2018-05-07 11:37 OpenCamera\OpenCamera.rc
文件 7155 2018-05-07 12:29 OpenCamera\OpenCamera.vcxproj
文件 2232 2018-05-07 12:29 OpenCamera\OpenCamera.vcxproj.filters
文件 143 2018-05-04 16:27 OpenCamera\OpenCamera.vcxproj.user
文件 5802 2018-05-07 13:59 OpenCamera\OpenCameraDlg.cpp
............此处省略39个文件信息
评论
共有 条评论