IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
Public Member Functions | Public Attributes | List of all members
Board Class Reference

Public Member Functions

def __init__ (self, *argv)
 
def addPiece (self, piece, ORIGINAL_ID=False)
 
def boundingBox (self)
 
def clear (self)
 
def display (self, theImage=None, fh=None, TITLE=None, ID_DISPLAY=False, ID_DISPLAY_OPTION=0, ID_COLOR=(255, 255, 255), CONTOUR_DISPLAY=True, BOUNDING_BOX=True)
 
def extents (self)
 
Template getPiece (self, id)
 
def pieceLocations (self, isCenter=False)
 
def rmPiece (self, id)
 
def size (self)
 
def testAdjacent (self, id_A, id_B, tauAdj)
 
def toImage (self, theImage=None, ID_DISPLAY=False, ID_DISPLAY_OPTION=0, COLOR=(0, 0, 0), ID_COLOR=(255, 255, 255), CONTOUR_DISPLAY=True, BOUNDING_BOX=True)
 

Public Attributes

 id_count
 
 pieces
 

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
argv 
)
@brief  Constructor for puzzle board. Can pass contents at
instantiation time or delay until later.

Args:
    *argv: The input params.

Member Function Documentation

◆ addPiece()

def addPiece (   self,
  piece,
  ORIGINAL_ID = False 
)
@brief  Add puzzle piece instance to the board.

Args:
    piece: A puzzle piece instance.

◆ boundingBox()

def boundingBox (   self)
@brief  Iterate through the puzzle pieces to figure out the tight
bounding box of the board.

Returns:
    bbox: The bounding box coordinates. [[min x, min y], [max x, max y]]

◆ clear()

def clear (   self)
@brief Clear all the puzzle pieces from the board.

◆ display()

def display (   self,
  theImage = None,
  fh = None,
  TITLE = None,
  ID_DISPLAY = False,
  ID_DISPLAY_OPTION = 0,
  ID_COLOR = (255, 255, 255),
  CONTOUR_DISPLAY = True,
  BOUNDING_BOX = True 
)
@brief  Display the puzzle board as an image.

Args:
    fh: The figure handle if available.
    TITLE: The title of the figure.
    ID_DISPLAY: The flag indicating displaying ID or not.
    CONTOUR_DISPLAY: The flag indicating drawing contour or not.

Returns:
    fh: The figure handle.

◆ extents()

def extents (   self)
@brief  Iterate through the puzzle pieces to figure out the tight
bounding box extents of the board.

Returns:
    lengths: The bounding box side lengths. [x,y]

◆ getPiece()

Template getPiece (   self,
  id 
)
Get a puzzle piece instance given the id

Args:
    id (int): The puzzle piece id

◆ pieceLocations()

def pieceLocations (   self,
  isCenter = False 
)
@brief      Returns a dict of puzzle piece locations.

Args:
    isCenter: The flag indicating whether the given location is for the center.
        Otherwise, the returned is the upper left corner locations.

Returns:
    pLocs: A dict of puzzle piece id & location.

◆ rmPiece()

def rmPiece (   self,
  id 
)
@brief Remove puzzle piece instance from the board

Args:
    id: The puzzle piece id (for display)

◆ size()

def size (   self)
@brief  Return the number of pieces on the board.

Returns:
    nPieces: The number of pieces on the board.

◆ testAdjacent()

def testAdjacent (   self,
  id_A,
  id_B,
  tauAdj 
)
@brief  Check if two puzzle pieces are adjacent or not

Args:
    id_A: The id of the puzzle piece A.
    id_B: The id of the puzzle piece B.
    tauAdj: The threshold of the distance.

Returns:
    theFlag: The flag indicating whether two puzzle pieces are adjacent or not.

◆ toImage()

def toImage (   self,
  theImage = None,
  ID_DISPLAY = False,
  ID_DISPLAY_OPTION = 0,
  COLOR = (0, 0, 0),
  ID_COLOR = (255, 255, 255),
  CONTOUR_DISPLAY = True,
  BOUNDING_BOX = True 
)
@brief  Uses puzzle piece locations to create an image for
visualizing them.  If given an image, then will place in it.
Recommended to provide theImage & BOUNDING_BOX option off.
Currently, we have four cases:
- Image provided & BOUNDING_BOX off -> An exact region is visible
- Image provided & BOUNDING_BOX on -> The visible region will be adjusted. Should have the same size image output.
- Image not provided & BOUNDING_BOX off -> May have some trouble if some region is out of the bounds (e.g., -2) then they will be shown on the other boundary.
- Image not provided & BOUNDING_BOX on -> A bounding box region is visible.

Args:
    theImage: The image to insert pieces into.
    ID_DISPLAY: The flag indicating displaying ID or not.
    ID_DISPLAY_OPTION: The option for displaying ID. 0: Piece ID. 1: Cluster ID.
    COLOR: The background color.
    ID_COLOR: The ID color.
    CONTOUR_DISPLAY: The flag indicating drawing contour or not.
    BOUNDING_BOX: The flag indicating outputting a bounding box area (with the updated (0,0)) or not (with the original (0,0)).

Returns:
    theImage: The rendered image.

Member Data Documentation

◆ id_count

id_count

◆ pieces

pieces

The documentation for this class was generated from the following file: