IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
All Classes Namespaces Files Functions Variables Modules Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Interlocking Class Reference

Puzzle with interlocking pieces. More...

Inheritance diagram for Interlocking:
Inheritance graph
[legend]
Collaboration diagram for Interlocking:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, theBoard=[], theParams=CfgInterlocking)
 Constructor for the puzzle.builder.adjacent class. More...
 
def processInterlocking (self)
 Process the solution board and determine what pieces are interlocking or adjacent. More...
 
- Public Member Functions inherited from Adjacent
def processAdjacency (self)
 Process the solution board and determine what pieces are adjacent or "close enough." It will determine the adjacency matrix. More...
 
- Public Member Functions inherited from Arrangement
def corrections (self, pLoc)
 Given an array of locations that correspond to the puzzle board (e.g., in the same order as puzzle board list), provide the correction vector that would move them to the calibrated locations. More...
 
def distances (self, pLoc)
 Given an array of locations that correspond to the puzzle board (e.g., in same order as puzzle board list), provide the distances between the locations and the calibrated locations. More...
 
def piecesInPlace (self, pLoc, tauDist=None)
 Return boolean array indicating whether the piece is correctly in place or not. More...
 
def scoreBoard (self, theBoard)
 Given a puzzle board with in ordered correspondence with the calibrated puzzle board, in the same order as puzzle board list), provide a score for the distance between the puzzle piece locations and the calibrated locations. More...
 
def scoreByLocation (self, pLoc)
 Given an array of locations that correspond to the puzzle board (e.g., in same order as puzzle board list), provide a score for the distance between the locations and the calibrated locations. More...
 
- Public Member Functions inherited from Board
def __init__ (self, *argv)
 Constructor for puzzle board. More...
 
def addPiece (self, piece, ORIGINAL_ID=False)
 Add puzzle piece instance to the board. More...
 
def addPieceFromImageAndMask (self, theImage, theMask, cLoc=None)
 Given a mask and an image of same base dimensions, use to instantiate a puzzle piece template. More...
 
def addPieces (self, pieces)
 Add puzzle piece to board. More...
 
def boundingBox (self)
 Iterate through pieces to get tight bounding box. More...
 
def clear (self)
 
def display_cv (self, theImage=None, fh=None, ID_DISPLAY=False, CONTOUR_DISPLAY=False, BOUNDING_BOX=False, window_name='Puzzle')
 Display the puzzle board as an image using matplot library. More...
 
def display_mp (self, theImage=None, ax=None, fh=None, ID_DISPLAY=False, CONTOUR_DISPLAY=False, BOUNDING_BOX=False)
 Display the puzzle board as an image using matplot library. More...
 
def extents (self)
 Iterate through puzzle pieces to get tight bounding box extents of the board. More...
 
def fromImageAndLabels (self, theImage, theLabels)
 
Template getPiece (self, id)
 Get puzzle piece instance based on id. More...
 
def markMissing (self, indSetMeasured)
 Given set of indices to measured pieces, mark remaining as unmeasured. More...
 
def offset (self, dr)
 Offset the location of the entire puzzle in the board. More...
 
def pieceLocations (self, isCenter=False)
 Returns list/array of puzzle piece locations. More...
 
def relabel (self, newLabels, idContinue)
 Relabel the puzzle piece IDs in the board using new label reassignments and adjust IDs for those without reassignment. More...
 
def rmPiece (self, id)
 
def size (self)
 Number of pieces on the board. More...
 
def testAdjacent (self, id_A, id_B, tauAdj)
 Check if two puzzle pieces are adjacent or not. More...
 
def toImage (self, theImage=None, ID_DISPLAY=False, COLOR=(0, 0, 0), ID_COLOR=(255, 255, 255), CONTOUR_DISPLAY=True, BOUNDING_BOX=True)
 Uses puzzle piece locations to create an image for visualizing them. More...
 

Static Public Member Functions

def buildFrom_ImageAndMask (theImage, theMask, theParams=None)
 Given an image and an image mask, parse both to recover the puzzle calibration/solution. More...
 
def buildFrom_ImageProcessing (theImage, theProcessor=None, theDetector=None, theParams=None)
 Given an image with regions clearly separated by some color or threshold, parse it to recover the puzzle calibration/solution. More...
 
def buildFrom_Sketch (theImage, theMask, theProcessor=None, theDetector=None, theParams=None)
 Given an image with regions clearly separated by some color or threshold, parse it to recover the puzzle calibration/solution. More...
 
def buildFromFile_ImageAndMask (fileName, theParams=None)
 Load a saved arrangement calibration/solution stored as an image and a mask. More...
 
def buildFromFile_Puzzle (fileName, theParams=None)
 Load a saved arrangement calibration/solution puzzle board. More...
 
def buildFromFiles_ImageAndMask (imFile, maskFile, theParams=None)
 Load a saved arrangement calibration/solution stored as separate image and mask files. More...
 

Public Attributes

 ilMat
 
- Public Attributes inherited from Adjacent
 adjMat
 
- Public Attributes inherited from Arrangement
 params
 
- Public Attributes inherited from Board
 id_count
 
 pieces
 

Detailed Description

Puzzle with interlocking pieces.

This class is a step up from the adjacency class. The adjacent puzzle pieces actually interlock.

It also includes a scoring mechanism to indicate how "close" a current solution would be to the calibrated solution.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  theBoard = [],
  theParams = CfgInterlocking 
)

Constructor for the puzzle.builder.adjacent class.

Args: theBoard: The input board instance. theParams: The params.

Reimplemented from Adjacent.

Reimplemented in Gridded.

Member Function Documentation

◆ buildFrom_ImageAndMask()

def buildFrom_ImageAndMask (   theImage,
  theMask,
  theParams = None 
)
static

Given an image and an image mask, parse both to recover the puzzle calibration/solution.

Instantiates a puzzle parser that gets applied to the submitted data to create a puzzle board instance. That instance is the calibration/solution.

Args: theImage: The puzzle image data. theMask: The puzzle mask data. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

◆ buildFrom_ImageProcessing()

def buildFrom_ImageProcessing (   theImage,
  theProcessor = None,
  theDetector = None,
  theParams = None 
)
static

Given an image with regions clearly separated by some color or threshold, parse it to recover the puzzle calibration/solution.

Can source alternative detector.

Instantiates a puzzle parser that gets applied to the submitted data to create a puzzle board instance. That instance is the calibration/solution.

Args: theImage: The puzzle image data. theProcessor: The processing scheme. theDetector: The detector scheme. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

Reimplemented in Gridded.

◆ buildFrom_Sketch()

def buildFrom_Sketch (   theImage,
  theMask,
  theProcessor = None,
  theDetector = None,
  theParams = None 
)
static

Given an image with regions clearly separated by some color or threshold, parse it to recover the puzzle calibration/solution.

Can source alternative detector.

Instantiates a puzzle parser that gets applied to the submitted data to create a puzzle board instance. That instance is the calibration/solution.

Args: theImage: The puzzle image data. theMask: The puzzle mask data. theProcessor: The processing scheme. theDetector: The detector scheme. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

Reimplemented in Gridded.

◆ buildFromFile_ImageAndMask()

def buildFromFile_ImageAndMask (   fileName,
  theParams = None 
)
static

Load a saved arrangement calibration/solution stored as an image and a mask.

The python file contains the puzzle board mask and image source data. It gets processed into an arrangement instance. If a threshold variable tauDist is found, then it is applied to the arrangement instance.

Args: fileName: The python file to load. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

Reimplemented in Gridded.

◆ buildFromFile_Puzzle()

def buildFromFile_Puzzle (   fileName,
  theParams = None 
)
static

Load a saved arrangement calibration/solution puzzle board.

Args: fileName: The python file to load. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

Reimplemented in Gridded.

◆ buildFromFiles_ImageAndMask()

def buildFromFiles_ImageAndMask (   imFile,
  maskFile,
  theParams = None 
)
static

Load a saved arrangement calibration/solution stored as separate image and mask files.

The source file contain the puzzle board image and mask data. It gets processed into an arrangement instance. If a threshold variable tauDist is found, then it is applied to the arrangement instance.

Args: imFile: The image file to load. maskFile: The mask file to load. theParams: The params.

Returns: thePuzzle: The interlocking puzzle board instance.

Reimplemented from Adjacent.

Reimplemented in Gridded.

◆ processInterlocking()

def processInterlocking (   self)

Process the solution board and determine what pieces are interlocking or adjacent.

Some pieces might be close to each other but not really interlocking. Mostly this happens at the corners, but maybe there are weird puzzles that can be thought of with a mix of adjacent and interlocking.

Member Data Documentation

◆ ilMat

ilMat

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