def generate_image(self): self.vapory_sene = vapory.Scene( self.vapory_camera, objects=[self.vapory_light, self.simulated_loop.loop_object]) image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update)
def _do_imagePolling(self, sleep_time): """ Descript. : """ while True: image_array = self.vapory_sene.render( "/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) time.sleep(sleep_time)
def uic_findImage(name): global embed_image_vec for (w,h,depth,data,comp,nrCol,colTab,alpha,iname) in embed_image_vec: if iname == str(name): data = qUncompress(data).data() img = QImage(data,w,h,depth,colTab,nrCol,QImage.BigEndian).copy() if alpha: img.setAlphaBuffer(1) return img return QImage()
def init(self): """ Descript. : """ self.qimage = QImage() current_path = os.path.dirname(os.path.abspath(__file__)).split(os.sep) current_path = os.path.join(*current_path[1:-1]) image_path = os.path.join("/", current_path, "ExampleFiles/fakeimg.jpg") self.qimage.load(image_path) self.force_update = False self.image_dimensions = [600, 400] self.image_type = JpegType() self.setIsReady(True)
def pot_square_resize(img, maximum=None): """Resize image to power of two square :type img: QImage :param img: input image :type maximum: int or None :param maximum: maximum size (must be 2**n) :return: resized image """ resized = pot_resize(img, maximum=maximum) w, h = resized.width(), resized.height() base = max(w, h) #pad = base - min(w, h) new_img = QImage(base, base, img.format()) new_img.fill(QColor(0, 0, 0)) painter = QPainter(new_img) painter.drawImage(0, 0, resized) return new_img, w / base, h / base
def generate_image(self): self.vapory_sene = vapory.Scene(self.vapory_camera, objects= [self.vapory_light, self.simulated_loop.loop_object]) image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update)
def _do_imagePolling(self, sleep_time): """ Descript. : """ while True: image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) time.sleep(sleep_time)
def __call__(self, img_flex, palette_in, min_i, max_i): flex_2d_data = img_flex.as_double() flex_2d_mask = flex.double( flex.grid(flex_2d_data.all()[0], flex_2d_data.all()[1]), 0) arr_i = self.arr_img(flex_2d_data, flex_2d_mask, i_min=min_i, i_max=max_i, palette=palette_in) q_img = QImage( arr_i.data, np.size(arr_i[0:1, :, 0:1]), np.size(arr_i[:, 0:1, 0:1]), QImage.Format_RGB32, ) return q_img
class VideoMockup(BaseHardwareObjects.Device): """ Descript. : """ def __init__(self, name): """ Descript. : """ BaseHardwareObjects.Device.__init__(self, name) self.force_update = None self.image_dimensions = None self.image_polling = None self.image_type = None self.qimage = None def init(self): """ Descript. : """ self.qimage = QImage() current_path = os.path.dirname(os.path.abspath(__file__)).split(os.sep) current_path = os.path.join(*current_path[1:-1]) image_path = os.path.join("/", current_path, "ExampleFiles/fakeimg.jpg") self.qimage.load(image_path) self.force_update = False self.image_dimensions = [600, 400] self.image_type = JpegType() self.setIsReady(True) def imageType(self): """ Descript. : """ return self.image_type def contrastExists(self): """ Descript. : """ return def setContrast(self, contrast): """ Descript. : """ return def getContrast(self): """ Descript. : """ return def getContrastMinMax(self): """ Descript. : """ return def brightnessExists(self): """ Descript. : """ return def setBrightness(self, brightness): """ Descript. : """ return def getBrightness(self): """ Descript. : """ return def getBrightnessMinMax(self): """ Descript. : """ return def gainExists(self): """ Descript. : """ return def setGain(self, gain): """ Descript. : """ return def getGain(self): """ Descript. : """ return def getGainMinMax(self): """ Descript. : """ return def gammaExists(self): """ Descript. : """ return def setGamma(self, gamma): """ Descript. : """ return def getGamma(self): """ Descript. : """ return def getGammaMinMax(self): """ Descript. : """ return (0, 1) def setLive(self, mode): """ Descript. : """ return def getWidth(self): """ Descript. : """ return self.image_dimensions[0] def getHeight(self): """ Descript. : """ return self.image_dimensions[1] def _do_imagePolling(self, sleep_time): """ Descript. : """ self.image_dimensions = (self.qimage.width(), self.qimage.height()) while True: self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) time.sleep(sleep_time) def connectNotify(self, signal): """ Descript. : """ if signal == "imageReceived": self.image_polling = gevent.spawn(self._do_imagePolling, 1)
class VaporyVideo(BaseHardwareObjects.Device): """ Descript. : """ def __init__(self, name): """ Descript. : """ BaseHardwareObjects.Device.__init__(self, name) self.force_update = None self.image_dimensions = None self.image_polling = None self.image_type = None self.qimage = None def init(self): """ Descript. : """ self.vapory_camera = vapory.Camera('location', [0, 2, -3], 'look_at', [0, 1, 2]) self.vapory_light = vapory.LightSource([2, 4, -3], 'color', [1, 1, 1]) self.simulated_loop = SimulatedLoop() self.simulated_loop.set_position(0, 0, 0) self.force_update = False self.image_dimensions = [600, 400] self.image_type = JpegType() self.setIsReady(True) self.generate_image() self.image_polling = gevent.spawn(self._do_imagePolling, 1) def rotate_scene_absolute(self, angle): self.simulated_loop.set_position(angle, 0, 0) self.generate_image() def rotate_scene_relative(self, angle): return def generate_image(self): self.vapory_sene = vapory.Scene( self.vapory_camera, objects=[self.vapory_light, self.simulated_loop.loop_object]) image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) def imageType(self): """ Descript. : """ return self.image_type def contrastExists(self): """ Descript. : """ return def setContrast(self, contrast): """ Descript. : """ return def getContrast(self): """ Descript. : """ return def getContrastMinMax(self): """ Descript. : """ return def brightnessExists(self): """ Descript. : """ return def setBrightness(self, brightness): """ Descript. : """ return def getBrightness(self): """ Descript. : """ return def getBrightnessMinMax(self): """ Descript. : """ return def gainExists(self): """ Descript. : """ return def setGain(self, gain): """ Descript. : """ return def getGain(self): """ Descript. : """ return def getGainMinMax(self): """ Descript. : """ return def gammaExists(self): """ Descript. : """ return def setGamma(self, gamma): """ Descript. : """ return def getGamma(self): """ Descript. : """ return def getGammaMinMax(self): """ Descript. : """ return (0, 1) def setLive(self, mode): """ Descript. : """ return def getWidth(self): """ Descript. : """ return self.image_dimensions[0] def getHeight(self): """ Descript. : """ return self.image_dimensions[1] def _do_imagePolling(self, sleep_time): """ Descript. : """ while True: image_array = self.vapory_sene.render( "/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) time.sleep(sleep_time)
class VaporyVideo(BaseHardwareObjects.Device): """ Descript. : """ def __init__(self, name): """ Descript. : """ BaseHardwareObjects.Device.__init__(self, name) self.force_update = None self.image_dimensions = None self.image_polling = None self.image_type = None self.qimage = None def init(self): """ Descript. : """ self.vapory_camera = vapory.Camera('location', [0,2,-3], 'look_at', [0,1,2] ) self.vapory_light = vapory.LightSource([2,4,-3], 'color', [1,1,1] ) self.simulated_loop = SimulatedLoop() self.simulated_loop.set_position(0, 0, 0) self.force_update = False self.image_dimensions = [600, 400] self.image_type = JpegType() self.setIsReady(True) self.generate_image() self.image_polling = gevent.spawn(self._do_imagePolling, 1) def rotate_scene_absolute(self, angle): self.simulated_loop.set_position(angle, 0, 0) self.generate_image() def rotate_scene_relative(self, angle): return def generate_image(self): self.vapory_sene = vapory.Scene(self.vapory_camera, objects= [self.vapory_light, self.simulated_loop.loop_object]) image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) def imageType(self): """ Descript. : """ return self.image_type def contrastExists(self): """ Descript. : """ return def setContrast(self, contrast): """ Descript. : """ return def getContrast(self): """ Descript. : """ return def getContrastMinMax(self): """ Descript. : """ return def brightnessExists(self): """ Descript. : """ return def setBrightness(self, brightness): """ Descript. : """ return def getBrightness(self): """ Descript. : """ return def getBrightnessMinMax(self): """ Descript. : """ return def gainExists(self): """ Descript. : """ return def setGain(self, gain): """ Descript. : """ return def getGain(self): """ Descript. : """ return def getGainMinMax(self): """ Descript. : """ return def gammaExists(self): """ Descript. : """ return def setGamma(self, gamma): """ Descript. : """ return def getGamma(self): """ Descript. : """ return def getGammaMinMax(self): """ Descript. : """ return (0, 1) def setLive(self, mode): """ Descript. : """ return def getWidth(self): """ Descript. : """ return self.image_dimensions[0] def getHeight(self): """ Descript. : """ return self.image_dimensions[1] def _do_imagePolling(self, sleep_time): """ Descript. : """ while True: image_array = self.vapory_sene.render("/tmp/vapory_tmp_image.png", width=self.image_dimensions[0], height=self.image_dimensions[1]) self.qimage = QImage("/tmp/vapory_tmp_image.png") self.emit("imageReceived", self.qimage, self.qimage.width(), self.qimage.height(), self.force_update) time.sleep(sleep_time)
def fromData(cls, texture, data, rect=None): return cls._create(texture, QImage.fromData(data), rect)