cisstStereoVision svlFilterImageWindow - jhu-cisst/cisst GitHub Wiki
svlFilterImageWindow class
The cisstStereoVision library has a built in filter called svlFilterImageWindow to display image data at any given stage of the stream. By default the filter displays one separate window for each input video channel and renders the images into the windows' client area. Optionally, the filter can be configured to hide the window borders. The underlying platform-dependent API that is used to manage windows automatically choses the best possible image display option from the list of supported methods.
Platform
GUI Library
API
Notes
MS Windows
Win32
SetDIBitsToDevice
Linux
X11 or Xv
XPutImage or XvShmPutImage
Xv is a hardware-accelerated imaging library. When ''Xv'' is available, image refresh is synchronized to VSYNC
Mac OS X
X11
XPutImage
Xv is not available on Mac OS X; Carbon is not used due to the lack of 64 bit support
Please note: If you are using a different GUI library in your application then you might need to implement your own image display filter that fits your needs.
svlFilterImageWindow:: public methods
Name
Description
int SetPosition(int x, int y, unsigned int videoch)
Moves the window to the specified position on the screen. x and y are the coordinates of the window's upper left corner.
int GetPosition(int & x, int & y, unsigned int videoch)
Retrieves the screen coordinates of the upper left corner of the window.
Registers a user-specified window event handler object that will receive user (keyboard and mouse) events.
void SetFullScreen(bool & fullscreen)
Call this method to enable/disable borderless window mode.
void GetFullScreen(bool & fullscreen)
Retrieves the status of the borderless window mode.
void SetTitle(std::string & title)
Sets the title of the image window.
void GetTitle(std::string & title)
Retrieves the title of the image window.
Handling keyboard and mouse inputs
In order to handle keyboard and mouse inputs inside the image window, the user may register a event handler object to the filter that will receive callbacks upon user events. The custom event handler class needs to be derived from the base class svlWindowEventHandlerBase declared in <cisstStereoVision/svlFilterImageWindow.h>. User input events are dispatched to the callback method OnUserEvent that needs to be overloaded by the user in order to perform custom event-handling. Additionally, another callback method called OnNewFrame may be overloaded by the user. OnNewFrame is called by the filter once for every video frame before rendering.
The method GetMousePos may be used to get the position of the mouse cursor. The retrieved cursor position is valid only when the mouse cursor is hovering on top of the window's client area or the mouse focus is currently captured. The '''mouse focus''' becomes captured when the user clicks on the image window and keeps the button depressed. As long as the mouse button remains depressed all the mouse input will be dispatched to the event handler, even if the mouse cursor moves off the window area. The mouse cursor loses the focus when the user releases the button.
svlWindowEventHandlerBase:: callback methods
Name
Description
void OnUserEvent(unsigned int winid, bool ascii, unsigned int eventide)
Called by the image window filter upon every user input event. winid specifies the video channel for which the event was generated; the flag ascii is set to true if eventid is an ASCII code; eventid contains either an ASCII code or the code of the user event (see below).
void OnNewFrame(unsigned int frameid)
Called every time a new input image arrives to the filter.
svlWindowEventHandlerBase:: public methods
Name
Description
void GetMousePos(int & x, int & y)
Use this method to retrieve the current position of the mouse cursor on the screen.