#pragma once
#include "ofxCvConstants.h"
class ofxCvGrayscaleImage;
class ofxCvColorImage;
class ofxCvFloatImage;
class ofxCvShortImage;
class ofxCvBlob;
class ofxCvImage : public ofBaseImage {
public:
int width;
int height;
bool bAllocated;
ofxCvImage();
virtual ~ofxCvImage();
virtual void allocate( int w, int h );
virtual void clear();
virtual float getWidth() const;
virtual float getHeight() const;
virtual void setUseTexture( bool bUse );
virtual bool isUsingTexture() const;
virtual ofTexture& getTexture();
virtual const ofTexture & getTexture() const;
OF_DEPRECATED_MSG("Use getTexture",virtual ofTexture& getTextureReference());
OF_DEPRECATED_MSG("Use getTexture",virtual const ofTexture & getTextureReference() const);
virtual void flagImageChanged();
virtual void setROI( int x, int y, int w, int h );
virtual void setROI( const ofRectangle& rect );
virtual ofRectangle getROI() const;
virtual void resetROI();
virtual ofRectangle getIntersectionROI( const ofRectangle& rec1,
const ofRectangle& rec2 );
virtual void set( float value ) = 0;
virtual void operator -= ( float value );
virtual void operator += ( float value );
virtual void setFromPixels( const unsigned char* _pixels, int w, int h ) = 0;
virtual void setFromPixels( const ofPixels & pixels );
virtual void setRoiFromPixels( const unsigned char* _pixels, int w, int h ) = 0;
virtual void setRoiFromPixels( const ofPixels & pixels );
virtual void operator = ( const ofxCvGrayscaleImage& mom ) = 0;
virtual void operator = ( const ofxCvColorImage& mom ) = 0;
virtual void operator = ( const ofxCvFloatImage& mom ) = 0;
virtual void operator = ( const ofxCvShortImage& mom ) = 0;
virtual void operator = ( const IplImage* mom );
virtual void operator -= ( ofxCvImage& mom );
virtual void operator += ( ofxCvImage& mom );
virtual void operator *= ( ofxCvImage& mom );
virtual void operator &= ( ofxCvImage& mom );
virtual void drawBlobIntoMe( ofxCvBlob& blob, int color );
virtual ofPixels& getPixels();
virtual ofPixels& getRoiPixels();
virtual IplImage* getCvImage() { return cvImage; };
virtual const ofPixels& getPixels() const;
virtual const ofPixels& getRoiPixels() const;
virtual const IplImage* getCvImage() const { return cvImage; };
virtual void updateTexture();
virtual void draw( float x, float y ) const;
virtual void draw( float x, float y, float w, float h ) const;
virtual void draw(const ofPoint & point) const;
virtual void draw(const ofRectangle & rect) const;
virtual void drawROI( float x, float y ) const;
virtual void drawROI( float x, float y, float w, float h ) const;
virtual void setAnchorPercent( float xPct, float yPct );
virtual void setAnchorPoint( float x, float y );
virtual void resetAnchor();
virtual void erode( );
virtual void dilate( );
virtual void blur( int value=3 );
virtual void blurGaussian( int value=3 );
virtual void invert();
virtual void contrastStretch() = 0;
virtual void convertToRange(float min, float max) = 0;
virtual void resize( int w, int h ) = 0;
virtual void scaleIntoMe( ofxCvImage& mom, int interpolationMethod = CV_INTER_NN ) = 0;
virtual void mirror( bool bFlipVertically, bool bFlipHorizontally );
virtual void translate( float x, float y );
virtual void rotate( float angle, float centerX, float centerY );
virtual void scale( float scaleX, float sclaeY );
virtual void transform( float angle, float centerX, float centerY,
float scaleX, float scaleY,
float moveX, float moveY );
virtual void undistort( float radialDistX, float radialDistY,
float tangentDistX, float tangentDistY,
float focalX, float focalY,
float centerX, float centerY );
virtual void remap( IplImage* mapX, IplImage* mapY );
virtual void warpPerspective( const ofPoint& A, const ofPoint& B,
const ofPoint& C, const ofPoint& D );
virtual void warpIntoMe( ofxCvImage& mom,
const ofPoint src[4], const ofPoint dst[4] );
virtual int countNonZeroInRegion( int x, int y, int w, int h );
protected:
virtual void allocateTexture() = 0;
virtual void allocatePixels(int w, int h) = 0;
bool matchingROI( const ofRectangle& rec1, const ofRectangle& rec2 );
virtual void setImageROI( IplImage* img, const ofRectangle& rect );
virtual void resetImageROI( IplImage* img );
virtual void rangeMap( IplImage* img, float min1, float max1, float min2, float max2 );
virtual void rangeMap( IplImage* mom, IplImage* kid, float min1, float max1, float min2, float max2 );
virtual void swapTemp();
virtual IplImage* getCv8BitsImage() { return cvImage; }
virtual IplImage* getCv8BitsRoiImage() { return cvImage; }
IplImage* cvImage;
IplImage* cvImageTemp;
int ipldepth;
int iplchannels;
ofPixels pixels;
ofPixels roiPixels;
bool bPixelsDirty;
bool bRoiPixelsDirty;
mutable ofTexture tex;
mutable bool bTextureDirty;
bool bUseTexture;
ofPoint anchor;
bool bAnchorIsPct;
};
Comments