Skip to main content

GrabCutTool

GrabCutTool

#include <GrabCutTool.hpp>

Public Functions

Name
GrabCutTool() =default
GrabCutTool(std::string const & img_path)
Constructor for the GrabCutTool given a path to an image.
GrabCutTool(cv::Mat img)
Constructor for the GrabCutTool given an image.
void runHighgui()
Run the OpenCV HighGUI loop for the grabcut tool.
cv::Mat getDisp()
Get the display image with the mask overlayed.
cv::Mat getMask()
Get the raw mask generated by the tool.
bool getRectStage() const
Expose rect stage variable.
void setMaskDispTransparency(float transparency)
Expose mask transparency variable used for generating display image in backend.
void mouseDown(int x, int y)
Mouse down event handler.
void mouseMove(int x, int y)
Mouse move event handler.
void mouseUp(int x, int y)
Mouse up event handler.
void setColor(uint8_t color)
Set the color to draw with.
void setBrushThickness(int thickness)
Set brush thickness to a specific value.
void increaseBrushThickness()
Increase brush thickness by 1.
void decreaseBrushThickness()
Decrease brush thickness by 1, but keep it at a minimum of 1.
void reset()
Reset the tool to the initial state.
void grabcutIter()
Run one iteration of grabCut.

Public Functions Documentation

function GrabCutTool

GrabCutTool() =default

function GrabCutTool

explicit GrabCutTool(
    std::string const & img_path
)

Constructor for the GrabCutTool given a path to an image.

Parameters:

  • path Path to the image to use for the grabcut tool

function GrabCutTool

explicit GrabCutTool(
    cv::Mat img
)

Constructor for the GrabCutTool given an image.

Parameters:

  • img Image to use for the grabcut tool, must be of format CV_8UC3

function runHighgui

void runHighgui()

Run the OpenCV HighGUI loop for the grabcut tool.

function getDisp

cv::Mat getDisp()

Get the display image with the mask overlayed.

function getMask

cv::Mat getMask()

Get the raw mask generated by the tool.

function getRectStage

bool getRectStage() const

Expose rect stage variable.

function setMaskDispTransparency

void setMaskDispTransparency(
    float transparency
)

Expose mask transparency variable used for generating display image in backend.

function mouseDown

void mouseDown(
    int x,
    int y
)

Mouse down event handler.

Parameters:

  • x x coordinate of the mouse
  • y y coordinate of the mouse

function mouseMove

void mouseMove(
    int x,
    int y
)

Mouse move event handler.

Parameters:

  • x x coordinate of the mouse
  • y y coordinate of the mouse

function mouseUp

void mouseUp(
    int x,
    int y
)

Mouse up event handler.

Parameters:

  • x x coordinate of the mouse
  • y y coordinate of the mouse

function setColor

void setColor(
    uint8_t color
)

Set the color to draw with.

Parameters:

  • color Color to set the brush to

function setBrushThickness

void setBrushThickness(
    int thickness
)

Set brush thickness to a specific value.

Parameters:

  • thickness Thickness to set the brush to

function increaseBrushThickness

void increaseBrushThickness()

Increase brush thickness by 1.

function decreaseBrushThickness

void decreaseBrushThickness()

Decrease brush thickness by 1, but keep it at a minimum of 1.

function reset

void reset()

Reset the tool to the initial state.

function grabcutIter

void grabcutIter()

Run one iteration of grabCut.


Updated on 2026-11-13 at 20:25:40 +0000