def test_ReadAvi(self): debug = False # "0","1" titles = ['scholarsmate', 'emptyBoard001'] expectedFrames = [334, 52] # (1920,1080),(1280,720), expectedSize = [(640, 480), (640, 480)] for index, title in enumerate(titles): args = Args("test") if Video.is_int(title): device = title else: device = testEnv.testMedia + title + ".avi" args.parse(["--input", device]) vision = ChessBoardVision(args.args) vision.showDebug = debug vision.open(args.args.input) frameIndex = 0 while True: cbImageSet = vision.readChessBoardImage() if not vision.hasImage: break frameIndex += 1 cbImage = cbImageSet.cbImage if debug: print("%d x %d" % (cbImage.width, cbImage.height)) assert (cbImage.width, cbImage.height) == expectedSize[index] assert (cbImageSet.frameIndex == frameIndex) if debug: print("%3d %.2fs" % (cbImageSet.frameIndex, cbImageSet.timeStamp)) assert frameIndex == expectedFrames[index] vision.save()
def __getstate__(self): state={} state["title"]=self.title device=self.device if not Video.is_int(device): cwd=os.getcwd() devicepath=os.path.dirname(device) root=os.path.commonpath([cwd,devicepath]) device=os.path.relpath(devicepath,root)+'/'+os.path.basename(device) state["device"]=device state["timestamps"]=self.timestamps return state
def test_device(self): assert Video.is_int("0") v0 = int("0") assert v0 == 0