Пример #1
0
    def reload(self, **kwargs) -> True or utils.image_types:
        """
        Reloads image from drive with other params than in __init__
        :keyword kwargs:
            :key image_type:  PIL.Image.Image or numpy.ndarray, or passed in __init__
            :key resolution:  new resolution or passed in __init__
            :key return_image: if passed and set to True, method returns reloaded image, else returns True
        :return: look above
        """
        self.image = utils.load_image(self.init_params['full_path'], self.init_params['image_type'])
        resolution = self.init_params['kwargs']['resolution']
        image_type = kwargs.get('image_type', self.init_params['image_type'])

        if kwargs.get('resolution', None) is not None:
            resolution = kwargs['resolution']

        if resolution is not None:
            print('ImageHandler reloading, resize to', resolution)
            loaded_image_size = utils.get_image_size(self.image)
            if loaded_image_size != resolution:
                self.image = utils.convert_image_type(
                    source_image=cv_effects.cut_rect(
                        image=self.image,
                        src_box=(0, 0, *loaded_image_size),
                        size=resolution
                    ),
                    dest_type=image_type
                )
        self.init_params['reload_params'] = kwargs
        if kwargs.get('return_image', None) is not None:
            return self.image
        return True
    def next_frame(self, **params) -> dict:

        n = self.crop_params.next()
        print(f'_ExampleTravel::next_frame n={n}')
        im1 = cv_effects.cut_rect(self.image, n, self.frame_resolution)
        params['im1'] = im1
        params['to_save'] = im1
        return params
 def next_frame(self, **params) -> dict:
     image = self.image if 'image' not in params else params['image']
     cut_region = self.crop_params.next()
     print(f'LeftBottomZoomOut: {cut_region}, params="{params.keys()}"')
     im1 = cv_effects.cut_rect(image, cut_region, self.frame_resolution)
     params['im1'] = params['im2'] = im1
     params['to_save'] = im1
     return params
 def next_frame(self, **params) -> dict:
     image = self.image if 'image' not in params else params['image']
     print(f'@@ LeftTopZoomFull.next_frame {params.keys()}')
     n = self.crop_params.next()
     print(']$$$]', n)
     im1 = cv_effects.cut_rect(image, n, self.frame_resolution)
     params['im1'] = params['im2'] = im1
     params['to_save'] = im1
     return params
Пример #5
0
    def next_frame(self, **params) -> dict:
        n = self.crop_params.next()
        print(f'_ExampleTravel::next_frame n={n}')

        images = params.get('images', self.images)

        for index in range(len(images)):
            images[index] = cv_effects.cut_rect(images[index], n,
                                                self.frame_resolution)

        params['images'] = images
        return params