Beispiel #1
0
 def get_image_by_name(self, image_name):
     try:
         image = self._compute.images().get(project=self._project,
                                            image=image_name).execute()
         return image
     except Exception:
         raise ImageNotFoundError(image_name)
Beispiel #2
0
 def load_image(filename: str) -> pg.Surface:
     try:
         img = pg.image.load(os.path.join('data', 'img', filename))
     except FileNotFoundError:
         raise ImageNotFoundError(
             'Не удалось загрузить файл изображения %s' % filename)
     return img
Beispiel #3
0
    def _get_ami_id_by_name(self, image_name):
        matches = self.api.get_all_images(filters={'name': image_name})
        if not matches:
            raise ImageNotFoundError(image_name)
        elif len(matches) > 1:
            raise MultipleImagesError('Template name %s returned more than one image_name. '
                'Use the ami-ID or remove duplicates from EC2' % image_name)

        return matches[0].id
Beispiel #4
0
from img_proc import *
from constants import CANNY_THRESH_1, CANNY_THRESH_2, BLUR, MASK_DILATE_ITER, MASK_ERODE_ITER
from gesture_recognition import *
from cv2 import imread, imshow, waitKey, destroyAllWindows
from sys import argv
from io_utils import parseArguments
from exceptions import InvalidCommandLineArgsError, ImageNotFoundError

if __name__ == "__main__":
    # ---- read image -----
    if len(argv) < 2:
        raise InvalidCommandLineArgsError("Fatal error - image name must be provided")
    imagePath = argv[2]
    image = imread(imagePath)
    if image is None:
        raise ImageNotFoundError("Image file cannot be found. Check your image path.")

    arguments = argv[3:]
    parseArguments(arguments)

    # imshow("Original image", image)
    # waitKey(0)

    # ---- crop image and convert to grayscale -----

    if ImageParam.rotationAngle != 0:
        image = rotateImage(image, ImageParam.rotationAngle)
        # only for -90/90 deg rotations
        firstRow = findEdgeNonBlackPixel(image)
        if firstRow is not None:
            image = image[firstRow:, :]