IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
|
Puzzle with interlocking pieces. More...
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... | |
![]() | |
def | processAdjacency (self) |
Process the solution board and determine what pieces are adjacent or "close enough." It will determine the adjacency matrix. More... | |
![]() | |
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... | |
![]() | |
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 | |
![]() | |
adjMat | |
![]() | |
params | |
![]() | |
id_count | |
pieces | |
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.
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.
|
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.
|
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.
|
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.
|
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.
|
static |
|
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.
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.
ilMat |