Esempio n. 1
0
 def pattern_open(self, image):
     if isinstance(image, Pattern):
         if image._image is None:
             image_path = self._search_image(image._name)
             image._image = imutils.open(image_path)
         return image
     elif isinstance(image, basestring):
         image_path = base.search_image(image, self.image_path)
         if image_path is None:
             raise IOError('image file not found: {}'.format(image))
         return Pattern(image_path, image=imutils.open(image_path))
     elif 'numpy' in str(type(image)):
         return Pattern('unknown', image=image)
     else:
         raise TypeError("Not supported image type: {}".format(type(image)))
Esempio n. 2
0
 def pattern_open(self, image):
     if isinstance(image, Pattern):
         if image._image is None:
             image_path = self._search_image(image._name)
             image._image = imutils.open(image_path)
         return image
     elif isinstance(image, basestring):
         image_path = base.search_image(image, self.image_path)
         if image_path is None:
             raise IOError('image file not found: {}'.format(image))
         return Pattern(image_path, image=imutils.open(image_path))
     elif 'numpy' in str(type(image)):
         return Pattern('unknown', image=image)
     else:
         raise TypeError("Not supported image type: {}".format(type(image)))
Esempio n. 3
0
 def post(self):
     screenname = self.get_argument('screenname')
     filename = self.get_argument('filename').encode(
         locale.getpreferredencoding(), 'ignore')
     bound = self.get_arguments('bound[]')
     l, t, r, b = map(int, bound)
     image = imutils.open(screenname)
     image = imutils.crop(image, l, t, r, b)
     cv2.imwrite(filename, image)
     self.write({'status': 'ok'})
Esempio n. 4
0
 def post(self):
     screenname = self.get_argument('screenname')
     filename = self.get_argument('filename').encode(locale.getpreferredencoding(), 'ignore')
     bound = self.get_arguments('bound[]')
     l, t, r, b = map(int, bound)
     image = imutils.open(screenname)
     image = imutils.crop(image, l, t, r, b)
     if self.request.remote_ip not in screen_crop_folder:
         screen_crop_folder[self.request.remote_ip] = '.'
     cv2.imwrite(os.path.join(screen_crop_folder[self.request.remote_ip], filename.decode('utf8')).replace('\\', '/'), image)
     self.write({'status': 'ok'})
Esempio n. 5
0
    def pattern_open(self, image):
        if self.__screensize is None:
            self.__screensize = self.display

        if isinstance(image, Pattern):
            if image._image is None:
                image_path = self._search_image(image._name)
                image._image = imutils.open(image_path)
            return image

        if isinstance(image, basestring):
            image_path = base.lookup_image(image, self.__screensize[0],
                                           self.__screensize[1])
            if image_path is None:
                raise IOError('file not found: {}'.format(image))
            return Pattern(image_path, image=imutils.open(image_path))

        if 'numpy' in str(type(image)):
            return Pattern('unknown', image=image)

        raise TypeError("Not supported image type: {}".format(type(image)))
Esempio n. 6
0
 def __init__(self, image, offset=(0, 0), anchor=0, rsl=None, resolution=None):
     """
     Args:
         image: image filename or image URL
         offset: offset of image center
         anchor: not supported
         resolution: image origin screen resolution
         rsl: alias of resolution
     """
     self._name = image if isinstance(image, basestring) else 'unknown'
     self._image = imutils.open(image)
     self._offset = offset
     self._resolution = rsl or resolution
     if isinstance(image, basestring):
         self._name = image
Esempio n. 7
0
    def __init__(self,
                 image,
                 offset=(0, 0),
                 anchor=0,
                 rsl=None,
                 resolution=None):
        """
        Args:
            image: image filename or image URL
            offset: offset of image center
            anchor: not supported
            resolution: image origin screen resolution
            rsl: alias of resolution
        """
        self._name = None
        self._image = imutils.open(image)
        self._offset = offset
        self._resolution = rsl or resolution

        if isinstance(image, basestring):
            self._name = image
Esempio n. 8
0
 def post(self):
     raw_image = self.get_argument('raw_image')
     filename = self.get_argument('filename')
     image = imutils.open(raw_image)
     cv2.imwrite(filename, image)
     self.write({'status': 'ok'})
Esempio n. 9
0
 def _open_image_file(self, path):
     realpath = base.lookup_image(path, self.__screensize[0], self.__screensize[1])
     if realpath is None:
         raise IOError('file not found: {}'.format(path))
     return imutils.open(realpath)
Esempio n. 10
0
 def pattern_open(path):
     return Pattern('unknown', image=imutils.open(path))
Esempio n. 11
0
 def post(self):
     raw_image = self.get_argument('raw_image')
     filename = self.get_argument('filename')
     image = imutils.open(raw_image)
     cv2.imwrite(filename, image)
     self.write({'status': 'ok'})