#include "CameraEwclib2.h" //EWCLIB 2.0 //website: http://www.geocities.jp/in_subaru/ //vector : http://www.vector.co.jp/soft/winnt/prog/se363340.html #include "ewclib.h" CameraEwclib2::CameraEwclib2(int index, int width, int height, double fps, int device, GUID mstype) { _index = index; _width = width; _height = height; _fps = fps; /* http://msdn.microsoft.com/en-us/library/dd407253(VS.85).aspx RGB Formats With No Alpha Channel The following subtypes define uncompressed RGB formats. GUID Description MEDIASUBTYPE_RGB1 RGB, 1 bit per pixel (bpp), palettized MEDIASUBTYPE_RGB4 RGB, 4 bpp, palettized MEDIASUBTYPE_RGB8 RGB, 8 bpp MEDIASUBTYPE_RGB555 RGB 555, 16 bpp MEDIASUBTYPE_RGB565 RGB 565, 16 bpp MEDIASUBTYPE_RGB24 RGB, 24 bpp MEDIASUBTYPE_RGB32 RGB, 32 bpp RGB Formats With Alpha Channel GUID Description MEDIASUBTYPE_ARGB1555 RGB 555 with alpha channel MEDIASUBTYPE_ARGB32 RGB 32 with alpha channel MEDIASUBTYPE_ARGB4444 16-bit RGB with alpha channel; 4 bits per channel MEDIASUBTYPE_A2R10G10B10 32-bit RGB with alpha channel; 10 bits per RGB channel plus 2 bits for alpha. MEDIASUBTYPE_A2B10G10R10 32-bit RGB with alpha channel; 10 bits per RGB channel plus 2 bits for alpha. OpenCV IplImage Support IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F */ int depth = IPL_DEPTH_8U; int channel = 3; if (mstype == MEDIASUBTYPE_RGB24 ) { depth = IPL_DEPTH_8U; channel = 3; } else if (mstype == MEDIASUBTYPE_RGB32 ) { depth = IPL_DEPTH_8U; channel = 4; } else if (mstype == MEDIASUBTYPE_ARGB32 ) { depth = IPL_DEPTH_8U; channel = 4; } else if (mstype == MEDIASUBTYPE_RGB1 ) { } //not supported else if (mstype == MEDIASUBTYPE_RGB4 ) { } //not supported else if (mstype == MEDIASUBTYPE_RGB8 ) { } //not supported else if (mstype == MEDIASUBTYPE_RGB555 ) { } //not supported else if (mstype == MEDIASUBTYPE_RGB565 ) { } //not supported else if (mstype == MEDIASUBTYPE_ARGB1555 ) { } //not supported else if (mstype == MEDIASUBTYPE_ARGB4444 ) { } //not supported else if (mstype == MEDIASUBTYPE_A2R10G10B10) { } //not supported else if (mstype == MEDIASUBTYPE_A2B10G10R10) { } //not supported EWC_Open(_index, _width, _height, _fps, device, mstype); _buffer = new char[EWC_GetBufferSize(_index)]; _image = cvCreateImage(cvSize(_width, _height), depth, channel); }; CameraEwclib2::~CameraEwclib2(void) { EWC_Close(_index); cvReleaseImage(&_image); delete _buffer; }; IplImage* CameraEwclib2::capture(bool mirror) { EWC_GetImage(_index, _buffer); _image->imageData = _buffer; if (mirror) cvFlip(_image, _image, 1); return _image; };