OpenCV 2.2.0及以上版本CvvImage的使用

OpenCV 2.2.0移除了CvvImage类,本文提供该类的源代码以便在新版本中使用。通过条件编译宏确保代码兼容性,并探讨了OpenCV移除CvvImage的可能原因。
摘要由CSDN通过智能技术生成

      前几日,OpenCV 2.2.0版本出现了...但是...以前版本的CvvImage类不见了...为了能够继续使用这个类,下面把这个类的源代码贴出来,使用的时候将该代码加入到工程中便可以使用了。为了方便切换OpenCV的版本,这里用到了一些条件编译宏,来保证代码的灵活性。

      不过从OpenCV 2.2.0开始,OpenCV取消了CvvImage这个类,一定是有它的原因的,具体可以在做实验的时候体会这些原因。

      CvvImage头文件

#ifndef CVVIMAGE_CLASS_DEF
#define CVVIMAGE_CLASS_DEF

#ifndef RC_OPENCV_2_1_0

#include <opencv/cv.h>
#include <opencv/highgui.h>

/* 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 */
    virtual void  Show( HDC dc, int x, int y, int width, int height,
       
  • 0
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

理想主义帕鲁

感恩有你,日久弥新。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值