예제 #1
0
 def initPockets(self, emptyImageList ):
     ''' generates the pocket objects with default data '''
     
     self.pockets = {}
     for col in range(0, self.gridsize.x):
         for row in range(0, self.gridsize.y):
             pointTL = self._PointTL + point( col*self.pocketsize, row*self.pocketsize)
             self.pockets[(col, row)] = pocket( pointTL, emptyImageList[(col, row)] )
예제 #2
0
    def testSetValue(self):
        bigImage = numpy.zeros((pocketSize * 10, pocketSize * 10, 3),
                               numpy.float32)

        p = pocket(offsetPoint, smallBlackImage)
        p.setValue('X')
        self.assertEqual(p.value, 'X')

        p.ShowValue((0, 0, 255), bigImage)
예제 #3
0
    def testGetImage(self):
        p = pocket(offsetPoint, smallBlackImage)

        subimage = p.getImage(bigWhiteImage)
        expectedSubImage = bigWhiteImage[offsetPoint.y:offsetPoint.y +
                                         pocketSize,
                                         offsetPoint.x:offsetPoint.x +
                                         pocketSize, :]

        self.assertTrue(numpy.array_equal(subimage, expectedSubImage))
예제 #4
0
    def testDrawrectangle(self):
        color = (0, 0, 255)
        p = pocket(offsetPoint, smallBlackImage)

        bigImage = numpy.zeros((pocketSize * 10, pocketSize * 10, 3),
                               numpy.float32)
        p.ShowBoundary(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])
예제 #5
0
 def testIsEmpty(self):
     p = pocket(offsetPoint, smallBlackImage)
     # it is empty if "emptyimage" is located at the offset, ie. all black
     self.assertTrue(p.isEmpty(bigBlackImage))
     self.assertFalse(p.isEmpty(bigWhiteImage))
예제 #6
0
 def testPocket(self):
     p = pocket(offsetPoint, smallBlackImage)
     self.assertEqual(p.pointTopLeft, offsetPoint)
     self.assertEqual(p.pointBottomRight,
                      offsetPoint + point(pocketSize - 1, pocketSize - 1))
     pass