OpenCV高版本下使用CvvImage.h

OpenCV2.2版本后取消了CvvImage类,若当前使用的OpenCV版本高于2.2版本,并且想使用CvvImage来显示图片,可以将其CvvImage.h和CvvImage.cpp头文件加入到解决方案中。(注意:最好是生成CvvImage.h和CvvImage.cpp两个文件,并添加到项目文件路径下,引用时只需添加#include "CvvImage.h"

以下是CvvImage.h的源码

//CvvImage.h
 
#pragma once
#ifndef CVVIMAGE_CLASS_DEF
#define CVVIMAGE_CLASS_DEF
#include "opencv.hpp"
/* CvvImage class definition */
class  CvvImage
{
public:
	CvvImage();
	virtual ~CvvImage();
	/* Create image (BGR or grayscale) */
	virtual bool  Create( int width, int height, int bits_per_pixel, int image_origin = 0 );
	/* Load image from specified file */
	virtual bool  Load( const char* filename, int desired_color = 1 );
	/* Load rectangle from the file */
	virtual bool  LoadRect( const char* filename,
		int desired_color, CvRect r );
#if defined WIN32 || defined _WIN32
	virtual bool  LoadRect( const char* filename,
		int desired_color, RECT r )
	{
		return LoadRect( filename, desired_color,
			cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top ));
	}
#endif
	/* Save entire image to specified file. */
	virtual bool  Save( const char* filename );
	/* Get copy of input image ROI */
	virtual void  CopyOf( CvvImage& image, int desired_color = -1 );
	virtual void  CopyOf( IplImage* img, int desired_color = -1 );
	IplImage* GetImage() { return m_img; };
	virtual void  Destroy(void);
	/* width and height of ROI */
	int Width() { return !m_img ? 0 : !m_img->roi ? m_img->width : m_img->roi->width; };
	int Height() { return !m_img ? 0 : !m_img->roi ? m_img->height : m_img->roi->height;};
	int Bpp() { return m_img ? (m_img->depth & 255)*m_img->nChannels : 0; };
	virtual void  Fill( int color );
	/* draw to highgui window */
	virtual void  Show( const char* window );
 
#if defined WIN32 || defined _WIN32
	/* draw part of image to the specified DC */
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值