本文整理汇总了Python中wx.BitmapFromBuffer方法的典型用法代码示例。如果您正苦于以下问题:Python wx.BitmapFromBuffer方法的具体用法?Python wx.BitmapFromBuffer怎么用?Python wx.BitmapFromBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.BitmapFromBuffer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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()
示例2: pdf_show
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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
#==============================================================================
示例3: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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)
示例4: SetPicture
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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)
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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()
示例6: draw_preview
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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
示例7: on_game_individual_result
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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()
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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()
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import BitmapFromBuffer [as 别名]
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