SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
OpenCV image class with the same interface as the former SLImage class. More...
#include <CVImage.h>
Public Member Functions | |
CVImage () | |
Default constructor. More... | |
CVImage (int width, int height, CVPixelFormatGL format, string name) | |
Constructor for empty image of a certain format and size. More... | |
CVImage (const string &imageFilename, bool flipVertical=true, bool loadGrayscaleIntoAlpha=false) | |
Constructor for image from file. More... | |
CVImage (CVImage &srcImage) | |
Copy constructor from a source image. More... | |
CVImage (const CVVVec3f &colors) | |
Creates a 1D image from a CVVec3f color vector. More... | |
CVImage (const CVVVec4f &colors) | |
~CVImage () | |
void | clearData () |
Deletes all data and resets the image parameters. More... | |
bool | allocate (int width, int height, CVPixelFormatGL pixelFormatGL, bool isContinuous=true) |
Memory allocation function. More... | |
void | load (const string &filename, bool flipVertical=true, bool loadGrayscaleIntoAlpha=false) |
Loads the image with the appropriate image loader. More... | |
bool | load (int inWidth, int inHeight, CVPixelFormatGL srcPixelFormatGL, CVPixelFormatGL dstPixelFormatGL, uchar *data, bool isContinuous, bool isTopLeft) |
loads an image from a memory with format change. More... | |
void | savePNG (const string &filename, int compressionLevel=6, bool flipY=true, bool convertBGR2RGB=true) |
Save as PNG at a certain compression level (0-9) More... | |
void | saveJPG (const string &filename, int compressionLevel=95, bool flipY=true, bool convertBGR2RGB=true) |
Save as JPG at a certain compression level (0-100) More... | |
CVVec4f | getPixeli (int x, int y) |
getPixeli returns the pixel color at the integer pixel coordinate x, y More... | |
CVVec4f | getPixelf (float x, float y) |
void | setPixeli (int x, int y, CVVec4f color) |
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y More... | |
void | setPixeliRGB (int x, int y, CVVec3f color) |
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y More... | |
void | setPixeliRGB (int x, int y, CVVec4f color) |
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y More... | |
void | setPixeliRGBA (int x, int y, CVVec4f color) |
setPixeli sets the RGBA pixel color at the integer pixel coordinate x, y More... | |
void | resize (int width, int height) |
void | convertTo (int cvDataType) |
Converts the data type of the cvMat. More... | |
void | flipX () |
Flip X coordinates used to make JPEGs from top-left to bottom-left images. More... | |
void | flipY () |
Flip Y coordinates used to make JPEGs from top-left to bottom-left images. More... | |
void | fill (uchar r, uchar g, uchar b) |
Fills the image with a certain rgb color. More... | |
void | fill (uchar r, uchar g, uchar b, uchar a) |
Fills the image with a certain rgba color. More... | |
void | crop (float targetWdivH, int &cropW, int &cropH) |
string | name () |
CVMat | cvMat () const |
uchar * | data () |
bool | empty () const |
uint | width () |
uint | height () |
uint | bytesPerPixel () |
uint | bytesPerLine () |
uint | bytesPerImage () |
uint | bytesInFile () |
CVPixelFormatGL | format () |
string | formatString () |
string | path () |
Static Public Member Functions | |
static CVPixelFormatGL | cvType2glPixelFormat (int cvType) |
Converts OpenCV mat type to OpenGL pixel format. More... | |
static int | glPixelFormat2cvType (CVPixelFormatGL pixelFormatGL) |
Converts OpenGL pixel format to OpenCV mat type. More... | |
static string | formatString (CVPixelFormatGL pixelFormatGL) |
Returns the pixel format as string. More... | |
static string | typeString (int cvMatTypeInt) |
Returns the cv::Mat.type()) as string. More... | |
Static Protected Member Functions | |
static uint | bytesPerPixel (CVPixelFormatGL pixelFormat) |
Returns the NO. of bytes per pixel for the passed pixel format. More... | |
static uint | bytesPerLine (uint width, CVPixelFormatGL pixelFormat, bool isContinuous=false) |
Returns the NO. of bytes per image line for the passed pixel format. More... | |
Protected Attributes | |
string | _name |
Image name (e.g. from the filename) More... | |
CVMat | _cvMat |
OpenCV mat matrix image type. More... | |
CVPixelFormatGL | _format |
OpenGL pixel format. More... | |
uint | _bytesPerPixel |
Number of bytes per pixel. More... | |
uint | _bytesPerLine |
Number of bytes per line (stride) More... | |
uint | _bytesPerImage |
Number of bytes per image. More... | |
uint | _bytesInFile |
Number of bytes in file. More... | |
string | _path |
path on the filesystem More... | |
OpenCV image class with the same interface as the former SLImage class.
The core object is the OpenCV matrix _cvMat. Be aware the OpenCV accesses its matrix of type mat often by row and columns. In that order it corresponds to the y and x coordinates and not x and y as we are used to! See the OpenCV docs for more information: http://docs.opencv.org/2.4.10/modules/core/doc/basic_structures.html#mat
CVImage::CVImage | ( | ) |
CVImage::CVImage | ( | int | width, |
int | height, | ||
CVPixelFormatGL | format, | ||
string | name | ||
) |
Constructor for empty image of a certain format and size.
Definition at line 34 of file CVImage.cpp.
|
explicit |
Constructor for image from file.
Definition at line 43 of file CVImage.cpp.
CVImage::CVImage | ( | CVImage & | srcImage | ) |
|
explicit |
Creates a 1D image from a CVVec3f color vector.
Creates a 1D image from a CVVec4f vector.
Definition at line 67 of file CVImage.cpp.
|
explicit |
CVImage::~CVImage | ( | ) |
Definition at line 95 of file CVImage.cpp.
bool CVImage::allocate | ( | int | width, |
int | height, | ||
CVPixelFormatGL | pixelFormatGL, | ||
bool | isContinuous = true |
||
) |
Memory allocation function.
It returns true if width or height or the pixelformat has changed /param width Width of image in pixels /param height Height of image in pixels /param pixelFormatGL OpenGL pixel format enum /param isContinuous True if the memory is continuous and has no stride bytes at the end of the line
Definition at line 119 of file CVImage.cpp.
|
staticprotected |
Returns the NO. of bytes per image line for the passed pixel format.
Definition at line 195 of file CVImage.cpp.
|
staticprotected |
Returns the NO. of bytes per pixel for the passed pixel format.
Definition at line 153 of file CVImage.cpp.
void CVImage::clearData | ( | ) |
void CVImage::convertTo | ( | int | cvDataType | ) |
Converts the data type of the cvMat.
Definition at line 951 of file CVImage.cpp.
void CVImage::crop | ( | float | targetWdivH, |
int & | cropW, | ||
int & | cropH | ||
) |
Definition at line 1014 of file CVImage.cpp.
|
inline |
|
static |
Converts OpenCV mat type to OpenGL pixel format.
Definition at line 522 of file CVImage.cpp.
|
inline |
|
inline |
void CVImage::fill | ( | uchar | r, |
uchar | g, | ||
uchar | b | ||
) |
Fills the image with a certain rgb color.
Definition at line 985 of file CVImage.cpp.
void CVImage::fill | ( | uchar | r, |
uchar | g, | ||
uchar | b, | ||
uchar | a | ||
) |
Fills the image with a certain rgba color.
Definition at line 1000 of file CVImage.cpp.
void CVImage::flipX | ( | ) |
Flip X coordinates used to make JPEGs from top-left to bottom-left images.
Definition at line 963 of file CVImage.cpp.
void CVImage::flipY | ( | ) |
|
inline |
|
static |
CVVec4f CVImage::getPixelf | ( | float | x, |
float | y | ||
) |
getPixelf returns a pixel color with its x & y texture coordinates. If the OpenGL filtering is set to GL_LINEAR a bilinear interpolated color out of four neighbouring pixels is return. Otherwise the nearest pixel is returned.
Definition at line 788 of file CVImage.cpp.
CVVec4f CVImage::getPixeli | ( | int | x, |
int | y | ||
) |
getPixeli returns the pixel color at the integer pixel coordinate x, y
Returns the pixel color at the integer pixel coordinate x, y. The color components range from 0-1 float.
Definition at line 710 of file CVImage.cpp.
|
static |
|
inline |
void CVImage::load | ( | const string & | filename, |
bool | flipVertical = true , |
||
bool | loadGrayscaleIntoAlpha = false |
||
) |
Loads the image with the appropriate image loader.
Definition at line 379 of file CVImage.cpp.
bool CVImage::load | ( | int | width, |
int | height, | ||
CVPixelFormatGL | srcPixelFormatGL, | ||
CVPixelFormatGL | dstPixelFormatGL, | ||
uchar * | data, | ||
bool | isContinuous, | ||
bool | isTopLeft | ||
) |
loads an image from a memory with format change.
It returns true if the width, height or destination format has changed so that the depending texture can be rebuild in OpenGL. If the source and destination pixel format does not match a conversion for certain formats is done. /param width Width of image in pixels /param height Height of image in pixels /param srcPixelFormatGL OpenGL pixel format enum of source image /param dstPixelFormatGL OpenGL pixel format enum of destination image /param data Pointer to the first byte of the image data /param isContinuous True if the memory is continuous and has no stride bytes at the end of the line /param isTopLeft True if image data starts at top left of image (else bottom left)
Definition at line 218 of file CVImage.cpp.
void CVImage::resize | ( | int | width, |
int | height | ||
) |
CVImage::Resize does a scaling with bilinear interpolation.
Definition at line 938 of file CVImage.cpp.
void CVImage::saveJPG | ( | const string & | filename, |
int | compressionLevel = 95 , |
||
bool | flipY = true , |
||
bool | convertBGR2RGB = true |
||
) |
Save as JPG at a certain compression level (0-100)
Save as JPG at a certain compression level (0-100)
filename | filename with path and extension |
compressionLevel | compression level 0-100 (default 95) |
flipY | Flag for vertical mirroring |
convertBGR2RGB | Flag for BGR to RGB conversion |
Definition at line 675 of file CVImage.cpp.
void CVImage::savePNG | ( | const string & | filename, |
int | compressionLevel = 6 , |
||
bool | flipY = true , |
||
bool | convertBGR2RGB = true |
||
) |
Save as PNG at a certain compression level (0-9)
Save as PNG at a certain compression level (0-9)
filename | filename with path and extension |
compressionLevel | compression level 0-9 (default 6) |
flipY | Flag for vertical mirroring |
convertBGR2RGB | Flag for BGR to RGB conversion |
Definition at line 637 of file CVImage.cpp.
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y
Definition at line 834 of file CVImage.cpp.
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y
Definition at line 893 of file CVImage.cpp.
setPixeli sets the RGB pixel color at the integer pixel coordinate x, y
Definition at line 907 of file CVImage.cpp.
setPixeli sets the RGBA pixel color at the integer pixel coordinate x, y
Definition at line 921 of file CVImage.cpp.
|
static |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |