资源简介
Opencv旧版本的CvvImage类库,新版本已移除。可用于MFC中的picture control控件实现显示图片功能。
代码片段和文件信息
#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) && \
((IplImag
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-10 23:36 CvvImage\
文件 6498 2019-02-03 13:12 CvvImage\CvvImage.cpp
文件 1926 2019-02-03 13:12 CvvImage\CvvImage.h
相关资源
- Draw项目的地址.txt
- 基于opencv的C++人眼识别以及眨眼检测
- 在VS2012上基于opencv的C++人眼识别与眨
- 产生式系统反向推理算法的设计与实
- 基于MFC OpenGL读取obj文件并以双视图显
- MFC 窗口阴影效果
- 基于暗通道和导向滤波的图像去雾算
- 根据原图和二值图得到分割彩图
- qt界面化实现各种滤波函数
- 学生信息管理系统+MFC+VC6+SQLServer
- c#通过dll读取opencv里的mat图片
- vs2017无法使用MFC添加类的问题
- windows后台监听键盘事件vs mfc版
- MFC中实现不同行高的CListCtrl
- 实训项目-基于MFC网络监控源代码可直
- MFC按行读取txt文件,以空格分隔字符
- MFC:Socket编程—TCP服务端和多个客户
- 罗马尼亚度假问题MFC实现
- 语音信号处理- MFCC特征提取
- MFC 2010编写 C++ 求1元4次方程解,含1元
- MFC做的学生成绩管理系统
- MFC sql server的ADO及ODBC连接操作
- MFC控件重绘大全
- vs2013 c++串口助手源码
- linux opencv车牌识别
- MFC BUTTON按钮控件,设置按钮透明,按
- CHTMLDome1
- CPlot - MFC绘制曲线
- 仿QQ聊天 MFC 实现
- PN532-mfoc-mfcuk-GUI_V2.1.rar
评论
共有 条评论