Python wx.BitmapFromBuffer() Examples
The following are 10
code examples of wx.BitmapFromBuffer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: chapter2.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 6 votes |
def __init__(self, parent, id, title, capture, fps=15): # initialize screen capture self.capture = capture # determine window size and init wx.Frame frame,_ = freenect.sync_get_depth() self.imgHeight,self.imgWidth = frame.shape[:2] buffer = np.zeros((self.imgWidth,self.imgHeight,3),np.uint8) self.bmp = wx.BitmapFromBuffer(self.imgWidth, self.imgHeight, buffer) wx.Frame.__init__(self, parent, id, title, size=(self.imgWidth, self.imgHeight)) # set up periodic screen capture self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_TIMER, self.NextFrame) # counteract flicker def disable_event(*pargs,**kwargs): pass self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event) # create the layout, which draws all buttons and # connects events to class methods self.CreateLayout()
Example #2
Source File: recipe-580623.py From code with MIT License | 6 votes |
def pdf_show(seite): page_idx = getint(seite) - 1 pix = PDFcfg.doc.getPagePixmap(page_idx, matrix = scaling) # the following method returns just RGB data - no alpha bytes # this seems to be required in Windows versions of wx. # on other platforms try instead: #bmp = wx.BitmapfromBufferRGBA(pix.w, pix.h, pix.samples) a = pix.samplesRGB() # samples without alpha bytes bmp = wx.BitmapFromBuffer(pix.w, pix.h, a) pix = None a = None return bmp #============================================================================== # PDFTable = a tabular grid class in wx #==============================================================================
Example #3
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, capture, fps=24): wx.Panel.__init__(self, parent) self.capture = capture2 ret, frame = self.capture.read() sal = mr_sal.saliency(frame) sal = cv2.resize(sal,(320,240)).astype(sp.uint8) sal = cv2.normalize(sal, None, 0, 255, cv2.NORM_MINMAX) outsal = cv2.applyColorMap(sal,cv2.COLORMAP_HSV) self.bmp = wx.BitmapFromBuffer(320,240, outsal.astype(sp.uint8)) self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_TIMER, self.NextFrame)
Example #4
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, capture, fps=24): wx.Panel.__init__(self, parent) self.SetDoubleBuffered(True) self.capture = capture ret, frame = self.capture.read() height, width = frame.shape[:2] parent.SetSize((width, height)) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) self.bmp = wx.BitmapFromBuffer(width, height, frame) self.timer = wx.Timer(self) self.timer.Start(1000./fps) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_TIMER, self.NextFrame)
Example #5
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def SetPicture(self, picturePath = None, display = 0): if not picturePath: return width_ = GetMonitorDimensions()[display][2] height_ = GetMonitorDimensions()[display][3] pil = Image.open(picturePath) w, h = pil.size w, h = Resize(w, h, width_, height_) if pil.size != (w, h): pil = pil.resize((w, h), Image.NEAREST) bitmap = wx.BitmapFromBuffer( w, h, pil.convert('RGB').tobytes() ) self.staticBitmap.SetBitmap(bitmap) x = GetMonitorDimensions()[display][0] + (width_ - w) / 2 y = GetMonitorDimensions()[display][1] + (height_ - h) / 2 self.SetDimensions(x, y, w, h)
Example #6
Source File: gui.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 5 votes |
def __init__(self, parent, id, title, capture, fps=10): """Class constructor This method initializes all necessary parameters and generates a basic GUI layout that can then be modified by self.init_custom_layout() and self.create_custom_layout(). :param parent: A wx.Frame parent (often Null). If it is non-Null, the frame will be minimized when its parent is minimized and restored when it is restored. :param id: The window identifier. Value -1 indicates default value. :param title: The caption to be displayed on the frame's title bar. :param capture: A cv2.VideoCapture object to be used as camera feed. :param fps: frames per second at which to display camera feed """ self.capture = capture self.fps = fps # determine window size and init wx.Frame success, frame = self._acquire_frame() if not success: print "Could not acquire frame from camera." raise SystemExit self.imgHeight, self.imgWidth = frame.shape[:2] self.bmp = wx.BitmapFromBuffer(self.imgWidth, self.imgHeight, frame) wx.Frame.__init__(self, parent, id, title, size=(self.imgWidth, self.imgHeight)) self._init_base_layout() self._create_base_layout()
Example #7
Source File: preview.py From IkaLog with Apache License 2.0 | 5 votes |
def draw_preview(self): frame_rgb = None try: self.lock.acquire() if self.latest_frame is None: if self._prev_bmp: dc.DrawBitmap(self._prev_bmp, 0, 0) return False width, height = self.preview_size frame_rgb = cv2.cvtColor(self.latest_frame, cv2.COLOR_BGR2RGB) finally: self.lock.release() if frame_rgb is None: return False bmp = wx.BitmapFromBuffer(width, height, frame_rgb) dc = wx.ClientDC(self.preview_panel) dc.DrawBitmap(bmp, 0, 0) self._prev_bmp = bmp if self._enter: ox = int(width / 2) oy = int(height / 2) if self._pause: # Draw a triangle representing 'play'. dc.DrawPolygon([(ox - 20, oy - 30), (ox - 20, oy + 30), (ox + 20, oy)]) else: # Draw two rectangles representing 'pause'. dc.DrawRectangle(ox - 20, oy - 30, 15, 60) dc.DrawRectangle(ox + 10, oy - 30, 15, 60) # wx event
Example #8
Source File: last_result.py From IkaLog with Apache License 2.0 | 5 votes |
def on_game_individual_result(self, context): # FIXME return cv_frame = cv2.resize(context['engine']['frame'], self.size) img_frame_rgb = cv2.cvtColor(cv_frame, cv2.COLOR_BGR2RGB) height, width = img_frame_rgb.shape[0:2] self.result_image = wx.BitmapFromBuffer(width, height, img_frame_rgb) self.draw_image()
Example #9
Source File: gui.py From opencv-python-blueprints with GNU General Public License v3.0 | 5 votes |
def __init__(self, capture, title=None, parent=None, id=-1, fps=10): """Class constructor This method initializes all necessary parameters and generates a basic GUI layout that can then be modified by self.init_custom_layout() and self.create_custom_layout(). :param parent: A wx.Frame parent (often Null). If it is non-Null, the frame will be minimized when its parent is minimized and restored when it is restored. :param id: The window identifier. Value -1 indicates default value. :param title: The caption to be displayed on the frame's title bar. :param capture: A cv2.VideoCapture object to be used as camera feed. :param fps: frames per second at which to display camera feed """ self.capture = capture self.fps = fps # determine window size and init wx.Frame success, frame = self._acquire_frame() if not success: print "Could not acquire frame from camera." raise SystemExit self.imgHeight, self.imgWidth = frame.shape[:2] self.bmp = wx.BitmapFromBuffer(self.imgWidth, self.imgHeight, frame) wx.Frame.__init__(self, parent, id, title, size=(self.imgWidth, self.imgHeight)) self._init_base_layout() self._create_base_layout()
Example #10
Source File: main.py From python-examples with MIT License | 5 votes |
def __init__(self, parent, camera, fps=15, flip=False): wx.Window.__init__(self, parent) # remember arguments self.camera = camera self.fps = fps self.flip = flip # get frame size ret_value, frame = self.camera.read() height, width = frame.shape[:2] # resize panel with camera image self.SetSize( (width, height) ) #self.SetMinSize( (width, height) ) # resize main window self.GetParent().GetParent().SetSize( (width, height+37) ) # wymaga poprawki aby nie trzeba bylo dawac +37 #self.GetGrandParent().SetSize( (width, height+25) ) #self.GetTopLevelParent().SetSize( (width, height+25) ) # wrong parent frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) if self.flip: frame = cv2.flip(frame, 1) # create bitmap with frame self.bmp = wx.BitmapFromBuffer(width, height, frame) # timer to refresh frames self.timer = wx.Timer(self) self.timer.Start(1000./fps) # add functions to events self.Bind(wx.EVT_PAINT, self.OnPaint) # run when it is needed self.Bind(wx.EVT_TIMER, self.NextFrame) # run by timer