def testShowPocketValues(self): p = pockets(offsetPoint, emptyImageList) color = (0, 0, 255) bigImage = numpy.zeros((pocketSize * 10, pocketSize * 10, 3), numpy.float32) p.ShowPocketValues(color, bigImage)
def testPockets(self): p = pockets(offsetPoint, emptyImageList) self.assertEqual(p.pointTopLeft, offsetPoint) self.assertEqual( p.pointBottomRight, offsetPoint + 7 * point(pocketSize, pocketSize) - point(1, 1)) pass
def testShowPocketBoundaries(self): p = pockets( offsetPoint, emptyImageList ) color = (0, 0, 255) bigImage = numpy.zeros((pocketSize*10, pocketSize*10, 3), numpy.float32) p.ShowPocketBoundaries( color, bigImage ) # yes, x and y are inverted... self.assertEqual( bigImage[ offsetPoint.y, offsetPoint.x ][0], color[0] ) self.assertEqual( bigImage[ offsetPoint.y, offsetPoint.x ][1], color[1] ) self.assertEqual( bigImage[ offsetPoint.y, offsetPoint.x ][2], color[2] )
def testShowPocketBoundaries(self): p = pockets(offsetPoint, emptyImageList) color = (0, 0, 255) bigImage = numpy.zeros((pocketSize * 10, pocketSize * 10, 3), numpy.float32) p.ShowPocketBoundaries(color, bigImage) # yes, x and y are inverted... self.assertEqual(bigImage[offsetPoint.y, offsetPoint.x][0], color[0]) self.assertEqual(bigImage[offsetPoint.y, offsetPoint.x][1], color[1]) self.assertEqual(bigImage[offsetPoint.y, offsetPoint.x][2], color[2])
def testGetSetValue(self): p = pockets( offsetPoint, emptyImageList ) self.assertTrue( p.processImage( bigBlackImage ) ) p.setValue(2,2, 'X') self.assertEqual( p.getValue( 2, 2 ), 'X' )
def testShowPocketValues(self): p = pockets( offsetPoint, emptyImageList ) color = (0, 0, 255) bigImage = numpy.zeros((pocketSize*10, pocketSize*10, 3), numpy.float32) p.ShowPocketValues( color, bigImage )
def testGetImage(self): p = pockets( offsetPoint, emptyImageList ) self.assertTrue( p.processImage( bigBlackImage ) ) self.assertTrue( numpy.array_equal( p.getImage(2,2), smallBlackImage ) )
def testGetContent(self): p = pockets( offsetPoint, emptyImageList ) self.assertTrue( p.processImage( bigBlackImage ) ) self.assertTrue( p.isEmpty(2,2) )
def testPockets(self): p = pockets( offsetPoint, emptyImageList ) self.assertEqual( p.pointTopLeft, offsetPoint ) self.assertEqual( p.pointBottomRight, offsetPoint+7*point(pocketSize, pocketSize) - point( 1, 1 ) ) pass
CornerTL = FindCorner( image, screwtemplateTL ) CornerBR = FindCorner( image, screwtemplateBR ) size = CornerBR -CornerTL # TODO: magic values! DropItemsAreaTL = CornerTL + point(15,95) DropItemsAreaBR = DropItemsAreaTL + point( 281, 80 ) ScoreBoardOffset = point( 71, 34 ) # scoreboard relative to screw curScoreBoard = ScoreBoard( CornerTL + ScoreBoardOffset, digits) CurScore = curScoreBoard.ReadScore(image) # red squares in matrix offset = point( DropItemsAreaTL.x, DropItemsAreaBR.y ) curPockets = pockets( offset, emptyImageList ) curPockets.processImage(image) fileno = fileno + 1 emptycount = 0 unknownCount = 0 # draw pockets for col in range(0,7): for row in range(0,7): if curPockets.isEmpty(col, row): emptycount += 1 curPockets.setValue(col, row, 'X') continue item = items.findItem( curPockets.getImage(col, row))
def testGetSetValue(self): p = pockets(offsetPoint, emptyImageList) self.assertTrue(p.processImage(bigBlackImage)) p.setValue(2, 2, 'X') self.assertEqual(p.getValue(2, 2), 'X')
def testGetImage(self): p = pockets(offsetPoint, emptyImageList) self.assertTrue(p.processImage(bigBlackImage)) self.assertTrue(numpy.array_equal(p.getImage(2, 2), smallBlackImage))
def testGetContent(self): p = pockets(offsetPoint, emptyImageList) self.assertTrue(p.processImage(bigBlackImage)) self.assertTrue(p.isEmpty(2, 2))