28 # define _CRT_SECURE_NO_WARNINGS
30 #include <Base/Common/BIASpragma.hh>
35 #ifdef BIAS_HAVE_OPENCV
61 BIASDOUT(D_GUI_DESTRUCT,
"GuiCV destructor started");
65 BIASDOUT(D_GUI_DESTRUCT,
"GuiCV destructor finished");
91 cvDestroyWindow(
Title_.c_str());
98 const int key = cvWaitKey(1);
104 int key = cvWaitKey();
109 int& Xpos,
int& Ypos)
122 BIASCDOUT(D_GUI_MOUSE_BUTTON,
"pressed at ("<<Xpos<<
", "<<Ypos<<
")"<<endl);
130 BIASCDOUT(D_GUI_MOUSE_BUTTON,
"released at ("<<Xpos<<
", "<<Ypos<<
")"<<endl);
139 cvNamedWindow(
Title_.c_str(), 0);
150 int newWidth = (image.
GetWidth() / 4) * 4 + 4;
155 for (
unsigned int y = 0; y < image.
GetHeight(); y++)
157 for (
unsigned int x = 0; x < image.
GetWidth(); x++)
159 for (
unsigned short c = 0; c < (
unsigned short)image.
GetChannelCount(); c++)
178 case CV_EVENT_MOUSEMOVE:
182 case CV_EVENT_LBUTTONDOWN:
187 case CV_EVENT_RBUTTONDOWN:
192 case CV_EVENT_MBUTTONDOWN:
197 case CV_EVENT_LBUTTONUP:
202 case CV_EVENT_RBUTTONUP:
207 case CV_EVENT_MBUTTONUP:
216 int flags,
void* param)
224 BIASERR(
"ImageBase ptr p_src is NULL.");
227 BIASASSERT(p_src!=NULL);
232 BIASASSERT(p_dest!=NULL);
236 BIASERR(
"Only interleaved images with modulo 4 with are currently supported, sorry.");
250 BIASERR(
"Image width is not multiple of 4 :"<< p_src->
GetWidth()
255 BIASASSERT( p_src->
GetWidth() % 4 == 0 );
266 depth=IPL_DEPTH_8S;
break;
268 depth=IPL_DEPTH_8U;
break;
270 depth=IPL_DEPTH_32F;
break;
272 depth=IPL_DEPTH_64F;
break;
274 depth=IPL_DEPTH_16S;
break;
276 depth=IPL_DEPTH_16U;
break;
278 depth=IPL_DEPTH_32S;
break;
282 BIASERR(
"you try to wrap a BIAS unsigned int Image with OpenCV. This format may be unsupported by OpenCV! (JW)");
283 depth=IPL_DEPTH_32S|IPL_DEPTH_SIGN;
285 BIASERR(
"unsupported Storagetype in BIAS image for BIAs->ipl image wrapper. GetStorageType="<<p_src->
GetStorageType() );
291 cvInitImageHeader( p_dest,
307 strcpy( p_dest->colorModel,
"RGB");
308 strcpy( p_dest->channelSeq,
"RGB");
312 strcpy( p_dest->colorModel,
"RGB");
313 strcpy( p_dest->channelSeq,
"BGR");
317 strcpy( p_dest->colorModel,
"RGBA");
318 strcpy( p_dest->channelSeq,
"BGRA");
322 strcpy( p_dest->colorModel,
"RGBA");
323 strcpy( p_dest->channelSeq,
"RGBA");
327 strcpy( p_dest->colorModel,
"GREY");
328 strcpy( p_dest->channelSeq,
"GREY");
331 BIASERR(
"unsupported color model for OpenCV wrapping. ChannelSeq may be wrong.");
void Release()
reimplemented from ImageBase
(16bit) unsigned integer image storage type
static pthread_mutex_t MouseButtonMutex_
int CreateIplImageShared(const BIAS::ImageBase *p_src, IplImage *&p_dest)
virtual void SetTitle(std::string const &Title)
static void StaticMouseCallback(int event, int x, int y, int flags, void *param)
bool IsInterleaved() const
Gui is a simple windowing environment...
(8bit) signed char image storage type
virtual int DestroyWindow()
stops the main loop and closes the window
virtual char WaitForKeyEvent()
waits until a key is pressed and returns it tested
Gui based on OpenCV is a simple windowing environment...
GuiCV(bool ShowMousePos=true)
double image storage type
unsigned int GetWidth() const
StorageType PixelValue(const unsigned int x, const unsigned int y, const unsigned short int channel=0) const
Returns value of pixel at specific position, using specific channel as offset.
(16bit) signed integer image storage type
color values, 3 channels, order: blue,green,red
const void * GetImageData() const
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
color values, 3 channels, order: red,green,blue
void MouseCallback(int event, int x, int y, int flags)
unsigned int GetHeight() const
void FillImageWithConstValue(StorageType Value)
fill grey images
void SetPixel(const StorageType &value, const unsigned int &x, const unsigned int &y, const unsigned short int channel=0)
Set the value of a given pixel (x,y) in channel to value.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
RGBA, 4 channels, order: red,green,blue,alpha.
enum EColorModel GetColorModel() const
Image< unsigned char > CurrentImage_
(32bit) signed integer image storage type
virtual int ShowConvertedImage_(Image< unsigned char > &image)
Does the real update of the image shown in window. Must be overloaded.
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
This is the base class for images in BIAS.
virtual char CheckForKeyEvent()
checks if any key is pressed and returns it returns -1 if no key is pressed
BGRA color values, 4 channels, order: blue,green,red,alpha.
(32bit) unsigned integer image storage type
virtual void WaitForMouseButtonEvent(bool &Pressed, int &Button, int &Xpos, int &Ypos)
waits until any mouse button is pressed or released