Safe Haskell | None |
---|---|
Language | Haskell2010 |
While OpenCV was designed for use in full-scale applications and can be used within functionally rich UI frameworks (such as Qt*, WinForms*, or Cocoa*) or without any UI at all, sometimes there it is required to try functionality quickly and visualize the results. This is what the OpenCV.HighGui module has been designed for.
It provides easy interface to:
- Create and manipulate windows that can display images and “remember” their content (no need to handle repaint events from OS).
- Add trackbars to the windows, handle simple mouse events as well as keyboard commands.
- data Window
- makeWindow :: String -> IO Window
- destroyWindow :: Window -> IO ()
- withWindow :: String -> (Window -> IO a) -> IO a
- resizeWindow :: Window -> Int32 -> Int32 -> IO ()
- waitKey :: Int32 -> IO Int32
- data Event
- data EventFlags
- hasLButton :: EventFlags -> Bool
- hasRButton :: EventFlags -> Bool
- hasMButton :: EventFlags -> Bool
- hasCtrlKey :: EventFlags -> Bool
- hasShiftKey :: EventFlags -> Bool
- hasAltKey :: EventFlags -> Bool
- data EventFlagsRec = EventFlagsRec {
- flagsLButton :: !Bool
- flagsRButton :: !Bool
- flagsMButton :: !Bool
- flagsCtrlKey :: !Bool
- flagsShiftKey :: !Bool
- flagsAltKey :: !Bool
- flagsToRec :: EventFlags -> EventFlagsRec
- type MouseCallback = Event -> Int32 -> Int32 -> EventFlags -> IO ()
- setMouseCallback :: Window -> MouseCallback -> IO ()
- type TrackbarCallback = Int32 -> IO ()
- createTrackbar :: Window -> String -> Int32 -> Int32 -> TrackbarCallback -> IO ()
- imshow :: Window -> Mat (S [height, width]) channels depth -> IO ()
- imshowM :: Window -> Mut (Mat (S [height, width]) channels depth) (PrimState IO) -> IO ()
Window management
makeWindow :: String -> IO Window Source #
Create a window with the specified title.
Make sure to free the window when you're done with it using destroyWindow
or better yet: use withWindow
.
destroyWindow :: Window -> IO () Source #
Close the window and free up all resources associated with the window.
withWindow :: String -> (Window -> IO a) -> IO a Source #
withWindow title act
makes a window with the specified title
and passes
the resulting Window
to the computation act
. The window will be destroyed
on exit from withWindow
whether by normal termination or by raising an
exception. Make sure not to use the Window
outside the act
computation!
Event handling
Keyboard
Mouse
data EventFlags Source #
Context for a mouse Event
Information about which buttons and modifier keys where pressed during the event.
hasLButton :: EventFlags -> Bool Source #
hasRButton :: EventFlags -> Bool Source #
hasMButton :: EventFlags -> Bool Source #
hasCtrlKey :: EventFlags -> Bool Source #
hasShiftKey :: EventFlags -> Bool Source #
hasAltKey :: EventFlags -> Bool Source #
data EventFlagsRec Source #
More convenient representation of EventFlags
EventFlagsRec | |
|
flagsToRec :: EventFlags -> EventFlagsRec Source #
type MouseCallback Source #
= Event | What happened to cause the callback to be fired. |
-> Int32 | The x-coordinate of the mouse event. |
-> Int32 | The y-coordinate of the mouse event. |
-> EventFlags | Context for the event, such as buttons and modifier keys pressed during the event. |
-> IO () |
Callback function for mouse events
setMouseCallback :: Window -> MouseCallback -> IO () Source #
Trackbars
type TrackbarCallback Source #
Callback function for trackbars