예제 #1
0
class TestHyperlapse(unittest.TestCase):
    def setUp(self):
        video = Video('/home/victorhugomoura/Documents/example.mp4')

        extractor = 'face'
        velocity = 10

        self.hyperlapse = SemanticHyperlapse(video, extractor, velocity)

    def testExtractor(self):
        self.hyperlapse.checkExtractor()
        self.hyperlapse.extractor = ''
        self.assertRaises(InputError, self.hyperlapse.checkExtractor)

    def testVelocity(self):
        self.hyperlapse.checkAndSetVelocity()
        self.hyperlapse.velocity = ''
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = 'A'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = '1'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)

    def testOpticalFlowCommand(self):
        command = self.hyperlapse.opticalFlowCommand()
        expectedCommand = './optflow -v /home/victorhugomoura/Documents/example.mp4 ' + \
            '-c default-config.xml -o /home/victorhugomoura/Documents/example.csv'

        self.assertEqual(command, expectedCommand)

    def testOpticalFlowExists(self):
        self.assertTrue(self.hyperlapse.opticalFlowExists()
                        )  # works only if the file already exists

    def testCheckVideoInput(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)
        self.hyperlapse.video = Video(
            '/home/victorhugomoura/Documents/example.csv')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)

    def testInputError(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')

        try:
            self.hyperlapse.checkVideoInput()
        except InputError as IE:
            self.assertEqual(IE.__str__(), 'Please insert input video first')
예제 #2
0
class TestHyperlapse(unittest.TestCase):
    def setUp(self):
        video = Video('/home/victorhugomoura/Documents/example.mp4')

        extractor = 'face'
        velocity = 10

        alpha = ['1', '2']
        beta = ['4', '3']
        gama = ['5', '6']
        eta = ['8', '7']

        self.hyperlapse = SemanticHyperlapse(video, extractor, velocity, alpha,
                                             beta, gama, eta)

    def testExtractor(self):
        self.hyperlapse.checkExtractor()
        self.hyperlapse.extractor = ''
        self.assertRaises(InputError, self.hyperlapse.checkExtractor)

    def testVelocity(self):
        self.hyperlapse.checkAndSetVelocity()
        self.hyperlapse.velocity = ''
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = 'A'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = '1'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)

    def testCheckWeights(self):
        self.hyperlapse.checkAndSetWeights()
        self.hyperlapse.alpha = ['', '']
        self.assertRaises(InputError, self.hyperlapse.checkAndSetWeights)
        self.hyperlapse.alpha = ['1', '1']
        self.hyperlapse.beta = ['a', '10']
        self.assertRaises(InputError, self.hyperlapse.checkAndSetWeights)

    def testOpticalFlowCommand(self):
        command = self.hyperlapse.opticalFlowCommand()
        expectedCommand = './optflow -v /home/victorhugomoura/Documents/example.mp4 ' + \
            '-c default-config.xml -o /home/victorhugomoura/Documents/example.csv'

        self.assertEqual(command, expectedCommand)

    def testOpticalFlowExists(self):
        self.assertTrue(self.hyperlapse.opticalFlowExists()
                        )  # works only on Verlab machines

    def testCheckVideoInput(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)
        self.hyperlapse.video = Video(
            '/home/victorhugomoura/Documents/example.csv')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)

    def testCheckParameters(self):
        self.hyperlapse.checkParameters()

    def testInputError(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')

        try:
            self.hyperlapse.checkVideoInput()
        except InputError as IE:
            self.assertEqual(IE.__str__(), 'Please insert input video first')
class TestHyperlapse(unittest.TestCase):
    def setUp(self):
        video = Video('/home/victorhugomoura/Documents/example.mp4')

        extractor = 'face'
        velocity = 10

        self.hyperlapse = SemanticHyperlapse(video, extractor, velocity)

    def testExtractor(self):
        self.hyperlapse.checkExtractor()
        self.hyperlapse.extractor = ''
        self.assertRaises(InputError, self.hyperlapse.checkExtractor)

    def testVelocity(self):
        self.hyperlapse.checkAndSetVelocity()
        self.hyperlapse.velocity = ''
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = 'A'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)
        self.hyperlapse.velocity = '1'
        self.assertRaises(InputError, self.hyperlapse.checkAndSetVelocity)

    def testOpticalFlowCommand(self):
        command = self.hyperlapse.opticalFlowCommand()
        expectedCommand = './optflow -v /home/victorhugomoura/Documents/example.mp4 ' + \
            '-c default-config.xml -o /home/victorhugomoura/Documents/example.csv'

        self.assertEqual(command, expectedCommand)

    def testDarknetCommand(self):
        command = self.hyperlapse.darknetCommand()
        expectedCommand = './darknet detector demo cfg/coco.data cfg/yolo.cfg '\
            + 'yolo.weights /home/victorhugomoura/Documents/example.mp4 ' \
            + '/home/victorhugomoura/Documents/example_yolo_raw.txt'
        self.assertEqual(command, expectedCommand)

        self.hyperlapse.video = Video(
            '/home/victorhugomoura/Documents/teste.mp4')
        command = self.hyperlapse.darknetCommand()
        expectedCommand = './darknet detector demo cfg/coco.data cfg/yolo.cfg '\
            + 'yolo.weights /home/victorhugomoura/Documents/teste.mp4 ' \
            + '/home/victorhugomoura/Documents/teste_yolo_raw.txt'
        self.assertEqual(command, expectedCommand)

    def testCheckVideoInput(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)
        self.hyperlapse.video = Video(
            '/home/victorhugomoura/Documents/example.csv')
        self.assertRaises(InputError, self.hyperlapse.checkVideoInput)

    def testInputError(self):
        self.hyperlapse.checkVideoInput()
        self.hyperlapse.video = Video('')

        try:
            self.hyperlapse.checkVideoInput()
        except InputError as IE:
            self.assertEqual(IE.__str__(), 'Please insert input video first')