示例#1
0
def deepstar_path():
    with tempdir() as tempdir_:
        with mock.patch.dict(os.environ, {'DEEPSTAR_PATH': tempdir_}):
            Deepstar.init()

            try:
                yield
            finally:
                Model.close()
示例#2
0
    def test(self):
        t = None

        with tempdir() as tempdir_:
            self.assertTrue(os.path.isdir(tempdir_))

            t = tempdir_

        self.assertFalse(os.path.isdir(t))
示例#3
0
    def test_create_one_video_file_from_one_image_file_fails_to_open_image(
            self):  # noqa
        image_0001 = 'test'

        with tempdir() as tempdir_:
            video_path = os.path.join(tempdir_, 'video.mp4')

            ret = create_one_video_file_from_one_image_file(image_0001,
                                                            video_path,
                                                            frame_count=5)
            self.assertFalse(ret)
示例#4
0
    def test_create_one_video_file_from_one_image_file(self):
        image_0001 = os.path.dirname(os.path.realpath(
            __file__)) + '/../../support/image_0001.jpg'  # noqa

        with tempdir() as tempdir_:
            video_path = os.path.join(tempdir_, 'video.mp4')

            ret = create_one_video_file_from_one_image_file(
                image_0001, video_path)

            self.assertTrue(ret)

            vc = cv2.VideoCapture(video_path)

            try:
                self.assertTrue(vc.isOpened())
                self.assertEqual(vc.get(cv2.CAP_PROP_FRAME_COUNT), 1)
            finally:
                vc.release()
示例#5
0
    def insert_image(self, image_path, opts):
        """
        This method inserts a video from an image.

        :param str image_path: The path to the image.
        :param dict opts: The dict of options.
        :rtype: None
        """

        with tempdir() as tempdir_:
            video_path = os.path.join(tempdir_, 'video.mp4')

            ret = create_one_video_file_from_one_image_file(
                image_path, video_path,
                frame_count=int(opts.get('frame-count', '1')))
            if ret is False:
                raise CommandLineRouteHandlerError(
                    'An error occured while attempting to create one video '
                    'file from one image file')

            self.insert_file(video_path, opts)