def update_image(self, id_val, image, format="MONO8", xoffset=0, yoffset=0): image = numpy.asarray(image) if format == "RGB8": image = imops.rgb8_to_rgb8(image) elif format == "ARGB8": image = imops.argb8_to_rgb8(image) elif format == "YUV411": image = imops.yuv411_to_rgb8(image) elif format == "YUV422": image = imops.yuv422_to_rgb8(image) elif format == "MONO8": pass elif format == "RAW8": pass elif format == "MONO16": image = imops.mono16_to_mono8_middle8bits(image) else: raise ValueError("Unknown format '%s'" % (format,)) if id_val not in self.children: # The line gives us: # Gtk-CRITICAL **: gtk_widget_set_colormap: assertion `!GTK_WIDGET_REALIZED (widget)' failed self._new_child(id_val, image) else: child = self.children[id_val] child.update_image(image)
def update_image(self, id_val, image, format='MONO8', xoffset=0, yoffset=0, sort_add=False): image=numpy.asarray(image) if format == 'RGB8': image = imops.rgb8_to_rgb8( image ) elif format == 'ARGB8': image = imops.argb8_to_rgb8( image ) elif format == 'YUV411': image = imops.yuv411_to_rgb8( image ) elif format == 'YUV422': image = imops.yuv422_to_rgb8( image ) elif format == 'MONO8': pass elif format == 'RAW8': pass elif format == 'MONO16': image = imops.mono16_to_mono8_middle8bits( image ) elif format.startswith('MONO8:'): warnings.warn('no Bayer do-mosaicing code implemented.') # pass through the raw Bayer mosaic else: raise ValueError("Unknown format '%s'"%(format,)) if id_val not in self.children: self._new_child(id_val,image, sort_add=sort_add) self.children_full_roi_arr[id_val] = image else: child = self.children[id_val] previous_image = self.children_full_roi_arr[id_val] if not image.shape == previous_image.shape: fullh,fullw = previous_image.shape h,w = image.shape warnings.warn('use of ROI forces copy operation') # Current pyglet (v1.0) seems to assume width of image # to blit is width of full texture, so here we make a # full-size image rather than blitting the sub image. newim = copy_array_including_strides(previous_image) newim[yoffset:yoffset+h, xoffset:xoffset+w] = image image = newim self.children_full_roi_arr[id_val] = image child.update_image(image)