The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PDL::OpenCV::Highgui - PDL bindings for OpenCV Highgui

SYNOPSIS

 use PDL::OpenCV::Highgui;

FUNCTIONS

namedWindow

Creates a window.

 namedWindow($winname); # with defaults
 namedWindow($winname,$flags);

The function namedWindow creates a window that can be used as a placeholder for images and trackbars. Created windows are referred to by their names. If a window with the same name already exists, the function does nothing. You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated memory usage. For a simple program, you do not really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit. @note Qt backend supports additional flags: - **WINDOW_NORMAL or WINDOW_AUTOSIZE:** WINDOW_NORMAL enables you to resize the window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the displayed image (see imshow ), and you cannot change the window size manually. - **WINDOW_FREERATIO or WINDOW_KEEPRATIO:** WINDOW_FREERATIO adjusts the image with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio. - **WINDOW_GUI_NORMAL or WINDOW_GUI_EXPANDED:** WINDOW_GUI_NORMAL is the old way to draw the window without statusbar and toolbar, whereas WINDOW_GUI_EXPANDED is a new enhanced GUI. By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | WINDOW_GUI_EXPANDED

Parameters:

winname

Name of the window in the window caption that may be used as a window identifier.

flags

Flags of the window. The supported flags are: (cv::WindowFlags)

destroyWindow

Destroys the specified window.

 destroyWindow($winname);

The function destroyWindow destroys the window with the given name.

Parameters:

winname

Name of the window to be destroyed.

destroyAllWindows

Destroys all of the HighGUI windows.

 destroyAllWindows;

The function destroyAllWindows destroys all of the opened HighGUI windows.

startWindowThread

 $res = startWindowThread;

waitKeyEx

Similar to #waitKey, but returns full key code.

 $res = waitKeyEx; # with defaults
 $res = waitKeyEx($delay);

@note Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc

waitKey

Waits for a pressed key.

 $res = waitKey; # with defaults
 $res = waitKey($delay);

The function waitKey waits for a key event infinitely (when \texttt{delay}\leq 0) or for delay milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is running on your computer at that time. It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed. To check for a key press but not wait for it, use #pollKey. @note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle GUI events, so one of them needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing. @note The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.

Parameters:

delay

Delay in milliseconds. 0 is the special value that means "forever".

pollKey

Polls for a pressed key.

 $res = pollKey;

The function pollKey polls for a key event without waiting. It returns the code of the pressed key or -1 if no key was pressed since the last invocation. To wait until a key was pressed, use #waitKey. @note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle GUI events, so one of them needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing. @note The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.

imshow

  Signature: ([phys] mat(l2,c2,r2); StringWrapper* winname)

Displays an image in the specified window.

 imshow($winname,$mat);

The function imshow displays an image in the specified window. If the window was created with the cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution. Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth: - If the image is 8-bit unsigned, it is displayed as is. - If the image is 16-bit unsigned, the pixels are divided by 256. That is, the value range [0,255*256] is mapped to [0,255]. - If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255]. - 32-bit integer images are not processed anymore due to ambiguouty of required transform. Convert to 8-bit unsigned matrix using a custom preprocessing specific to image's context. If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and cuda::GpuMat as input. If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE. If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow. @note This function should be followed by a call to cv::waitKey or cv::pollKey to perform GUI housekeeping tasks that are necessary to actually show the given image and make the window respond to mouse and keyboard events. Otherwise, it won't display the image and the window might lock up. For example, **waitKey(0)** will display the window infinitely until any keypress (it is suitable for image display). **waitKey(25)** will display a frame and wait approximately 25 ms for a key press (suitable for displaying a video frame-by-frame). To remove the window, use cv::destroyWindow. @note [__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard. [__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image.

Parameters:

winname

Name of the window.

mat

Image to be shown.

imshow ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

resizeWindow

Resizes the window to the specified size

 resizeWindow($winname,$width,$height);

@note - The specified window size is for the image area. Toolbars are not counted. - Only windows created without cv::WINDOW_AUTOSIZE flag can be resized.

Parameters:

winname

Window name.

width

The new window width.

height

The new window height.

resizeWindow2

  Signature: (indx [phys] size(n2=2); StringWrapper* winname)
 resizeWindow2($winname,$size);

@overload

Parameters:

winname

Window name.

size

The new window size.

resizeWindow2 ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

moveWindow

Moves the window to the specified position

 moveWindow($winname,$x,$y);

Parameters:

winname

Name of the window.

x

The new x-coordinate of the window.

y

The new y-coordinate of the window.

setWindowProperty

Changes parameters of a window dynamically.

 setWindowProperty($winname,$prop_id,$prop_value);

The function setWindowProperty enables changing properties of a window.

Parameters:

winname

Name of the window.

prop_id

Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags)

prop_value

New value of the window property. The supported flags are: (cv::WindowFlags)

setWindowTitle

Updates window title

 setWindowTitle($winname,$title);

Parameters:

winname

Name of the window.

title

New title.

getWindowProperty

Provides parameters of a window.

 $res = getWindowProperty($winname,$prop_id);

The function getWindowProperty returns properties of a window.

Parameters:

winname

Name of the window.

prop_id

Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags)

See also: setWindowProperty

getWindowImageRect

  Signature: (indx [o,phys] res(n2=4); StringWrapper* winname)

Provides rectangle of image in the window.

 $res = getWindowImageRect($winname);

The function getWindowImageRect returns the client screen coordinates, width and height of the image rendering area.

Parameters:

winname

Name of the window.

See also: resizeWindow moveWindow

getWindowImageRect ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

selectROI

  Signature: ([phys] img(l2,c2,r2); byte [phys] showCrosshair(); byte [phys] fromCenter(); indx [o,phys] res(n5=4); StringWrapper* windowName)

Allows users to select a ROI on the given image.

 $res = selectROI($windowName,$img); # with defaults
 $res = selectROI($windowName,$img,$showCrosshair,$fromCenter);

The function creates a window and allows users to select a ROI using the mouse. Controls: use `space` or `enter` to finish selection, use key `c` to cancel selection (function will return the zero cv::Rect). @note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). After finish of work an empty callback will be set for the used window.

Parameters:

windowName

name of the window where selection process will be shown.

img

image to select a ROI.

showCrosshair

if true crosshair of selection rectangle will be shown.

fromCenter

if true center of selection will match initial mouse position. In opposite case a corner of selection rectangle will correspont to the initial mouse position.

Returns: selected ROI or empty rect if selection canceled.

selectROI ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

selectROI2

  Signature: ([phys] img(l1,c1,r1); byte [phys] showCrosshair(); byte [phys] fromCenter(); indx [o,phys] res(n4=4))
 $res = selectROI2($img); # with defaults
 $res = selectROI2($img,$showCrosshair,$fromCenter);

@overload

selectROI2 ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

selectROIs

  Signature: ([phys] img(l2,c2,r2); indx [o,phys] boundingBoxes(n3=4,n3d0); byte [phys] showCrosshair(); byte [phys] fromCenter(); StringWrapper* windowName)

Allows users to select multiple ROIs on the given image. NO BROADCASTING.

 $boundingBoxes = selectROIs($windowName,$img); # with defaults
 $boundingBoxes = selectROIs($windowName,$img,$showCrosshair,$fromCenter);

The function creates a window and allows users to select multiple ROIs using the mouse. Controls: use `space` or `enter` to finish current selection and start a new one, use `esc` to terminate multiple ROI selection process. @note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). After finish of work an empty callback will be set for the used window.

Parameters:

windowName

name of the window where selection process will be shown.

img

image to select a ROI.

boundingBoxes

selected ROIs.

showCrosshair

if true crosshair of selection rectangle will be shown.

fromCenter

if true center of selection will match initial mouse position. In opposite case a corner of selection rectangle will correspont to the initial mouse position.

selectROIs ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

getTrackbarPos

Returns the trackbar position.

 $res = getTrackbarPos($trackbarname,$winname);

The function returns the current position of the specified trackbar. @note [__Qt Backend Only__] winname can be empty if the trackbar is attached to the control panel.

Parameters:

trackbarname

Name of the trackbar.

winname

Name of the window that is the parent of the trackbar.

setTrackbarPos

Sets the trackbar position.

 setTrackbarPos($trackbarname,$winname,$pos);

The function sets the position of the specified trackbar in the specified window. @note [__Qt Backend Only__] winname can be empty if the trackbar is attached to the control panel.

Parameters:

trackbarname

Name of the trackbar.

winname

Name of the window that is the parent of trackbar.

pos

New position.

setTrackbarMax

Sets the trackbar maximum position.

 setTrackbarMax($trackbarname,$winname,$maxval);

The function sets the maximum position of the specified trackbar in the specified window. @note [__Qt Backend Only__] winname can be empty if the trackbar is attached to the control panel.

Parameters:

trackbarname

Name of the trackbar.

winname

Name of the window that is the parent of trackbar.

maxval

New maximum position.

setTrackbarMin

Sets the trackbar minimum position.

 setTrackbarMin($trackbarname,$winname,$minval);

The function sets the minimum position of the specified trackbar in the specified window. @note [__Qt Backend Only__] winname can be empty if the trackbar is attached to the control panel.

Parameters:

trackbarname

Name of the trackbar.

winname

Name of the window that is the parent of trackbar.

minval

New minimum position.

addText

  Signature: ([phys] img(l1,c1,r1); indx [phys] org(n3=2); int [phys] pointSize(); double [phys] color(n6=4); int [phys] weight(); int [phys] style(); int [phys] spacing(); StringWrapper* text; StringWrapper* nameFont)

Draws a text on the image.

 addText($img,$text,$org,$nameFont); # with defaults
 addText($img,$text,$org,$nameFont,$pointSize,$color,$weight,$style,$spacing);

Parameters:

img

8-bit 3-channel image where the text should be drawn.

text

Text to write on an image.

org

Point(x,y) where the text should start on an image.

nameFont

Name of the font. The name should match the name of a system font (such as *Times*). If the font is not found, a default one is used.

pointSize

Size of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

color

Color of the font in BGRA where A = 255 is fully transparent.

weight

Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.

style

Font style. Available operation flags are : cv::QtFontStyles

spacing

Spacing between characters. It can be negative or positive.

addText ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

displayOverlay

Displays a text on a window image as an overlay for a specified duration.

 displayOverlay($winname,$text); # with defaults
 displayOverlay($winname,$text,$delayms);

The function displayOverlay displays useful information/tips on top of the window for a certain amount of time *delayms*. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.

Parameters:

winname

Name of the window.

text

Overlay text to write on a window image.

delayms

The period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

displayStatusBar

Displays a text on the window statusbar during the specified period of time.

 displayStatusBar($winname,$text); # with defaults
 displayStatusBar($winname,$text,$delayms);

The function displayStatusBar displays useful information/tips on top of the window for a certain amount of time *delayms* . This information is displayed on the window statusbar (the window must be created with the CV_GUI_EXPANDED flags).

Parameters:

winname

Name of the window.

text

Text to write on the window statusbar.

delayms

Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

CONSTANTS

PDL::OpenCV::Highgui::WINDOW_NORMAL()
PDL::OpenCV::Highgui::WINDOW_AUTOSIZE()
PDL::OpenCV::Highgui::WINDOW_OPENGL()
PDL::OpenCV::Highgui::WINDOW_FULLSCREEN()
PDL::OpenCV::Highgui::WINDOW_FREERATIO()
PDL::OpenCV::Highgui::WINDOW_KEEPRATIO()
PDL::OpenCV::Highgui::WINDOW_GUI_EXPANDED()
PDL::OpenCV::Highgui::WINDOW_GUI_NORMAL()
PDL::OpenCV::Highgui::WND_PROP_FULLSCREEN()
PDL::OpenCV::Highgui::WND_PROP_AUTOSIZE()
PDL::OpenCV::Highgui::WND_PROP_ASPECT_RATIO()
PDL::OpenCV::Highgui::WND_PROP_OPENGL()
PDL::OpenCV::Highgui::WND_PROP_VISIBLE()
PDL::OpenCV::Highgui::WND_PROP_TOPMOST()
PDL::OpenCV::Highgui::WND_PROP_VSYNC()
PDL::OpenCV::Highgui::EVENT_MOUSEMOVE()
PDL::OpenCV::Highgui::EVENT_LBUTTONDOWN()
PDL::OpenCV::Highgui::EVENT_RBUTTONDOWN()
PDL::OpenCV::Highgui::EVENT_MBUTTONDOWN()
PDL::OpenCV::Highgui::EVENT_LBUTTONUP()
PDL::OpenCV::Highgui::EVENT_RBUTTONUP()
PDL::OpenCV::Highgui::EVENT_MBUTTONUP()
PDL::OpenCV::Highgui::EVENT_LBUTTONDBLCLK()
PDL::OpenCV::Highgui::EVENT_RBUTTONDBLCLK()
PDL::OpenCV::Highgui::EVENT_MBUTTONDBLCLK()
PDL::OpenCV::Highgui::EVENT_MOUSEWHEEL()
PDL::OpenCV::Highgui::EVENT_MOUSEHWHEEL()
PDL::OpenCV::Highgui::EVENT_FLAG_LBUTTON()
PDL::OpenCV::Highgui::EVENT_FLAG_RBUTTON()
PDL::OpenCV::Highgui::EVENT_FLAG_MBUTTON()
PDL::OpenCV::Highgui::EVENT_FLAG_CTRLKEY()
PDL::OpenCV::Highgui::EVENT_FLAG_SHIFTKEY()
PDL::OpenCV::Highgui::EVENT_FLAG_ALTKEY()
PDL::OpenCV::Highgui::QT_FONT_LIGHT()
PDL::OpenCV::Highgui::QT_FONT_NORMAL()
PDL::OpenCV::Highgui::QT_FONT_DEMIBOLD()
PDL::OpenCV::Highgui::QT_FONT_BOLD()
PDL::OpenCV::Highgui::QT_FONT_BLACK()
PDL::OpenCV::Highgui::QT_STYLE_NORMAL()
PDL::OpenCV::Highgui::QT_STYLE_ITALIC()
PDL::OpenCV::Highgui::QT_STYLE_OBLIQUE()
PDL::OpenCV::Highgui::QT_PUSH_BUTTON()
PDL::OpenCV::Highgui::QT_CHECKBOX()
PDL::OpenCV::Highgui::QT_RADIOBOX()
PDL::OpenCV::Highgui::QT_NEW_BUTTONBAR()