久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

任何用于顯示來自相機(jī)的實(shí)時(shí)圖像的快速 Python

Any quick Python GUI to display live images from Camera(任何用于顯示來自相機(jī)的實(shí)時(shí)圖像的快速 Python GUI)
本文介紹了任何用于顯示來自相機(jī)的實(shí)時(shí)圖像的快速 Python GUI的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在嘗試顯示來自 1394 相機(jī)的實(shí)時(shí)圖像.目前,我的代碼能夠從相機(jī)循環(huán)獲取圖像,并且我正在尋找任何可以動(dòng)態(tài)更新的快速 GUI(作為單獨(dú)的線程).我可以在 PyQt 中做到這一點(diǎn),也許使用 QThreads 但有什么建議或更快的方法嗎?這是我的代碼

I am trying to display live images from my 1394 camera. Currently my code is able to obtain images in a loop from the camera and I was looking for any quick GUI that will update dynamically (as a separate thread). I can do this in PyQt maybe using QThreads but is there any recommendation or faster way of doing this?? Here's my code

#循環(huán)從相機(jī)捕捉幀

for frame in range(1,500):

print 'frame:',frame

TIME.sleep(1) #capture frame every second

image_binary    = pycam.cam.RetrieveBuffer()

#convert to PIL Image

pilimg = PIL.Image.frombuffer("L",(cimg.GetCols(),cimg.GetRows()),image_binary,'raw', "RGBA", 0, 1)
    # At this point I want to send my image data to a GUI window and display it

謝謝.

推薦答案

這是 wxPython 代碼...

import wx
from PIL import Image

SIZE = (640, 480)

def get_image():
    # Put your code here to return a PIL image from the camera.
    return Image.new('L', SIZE)

def pil_to_wx(image):
    width, height = image.size
    buffer = image.convert('RGB').tostring()
    bitmap = wx.BitmapFromBuffer(width, height, buffer)
    return bitmap

class Panel(wx.Panel):
    def __init__(self, parent):
        super(Panel, self).__init__(parent, -1)
        self.SetSize(SIZE)
        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.update()
    def update(self):
        self.Refresh()
        self.Update()
        wx.CallLater(15, self.update)
    def create_bitmap(self):
        image = get_image()
        bitmap = pil_to_wx(image)
        return bitmap
    def on_paint(self, event):
        bitmap = self.create_bitmap()
        dc = wx.AutoBufferedPaintDC(self)
        dc.DrawBitmap(bitmap, 0, 0)

class Frame(wx.Frame):
    def __init__(self):
        style = wx.DEFAULT_FRAME_STYLE & ~wx.RESIZE_BORDER & ~wx.MAXIMIZE_BOX
        super(Frame, self).__init__(None, -1, 'Camera Viewer', style=style)
        panel = Panel(self)
        self.Fit()

def main():
    app = wx.PySimpleApp()
    frame = Frame()
    frame.Center()
    frame.Show()
    app.MainLoop()

if __name__ == '__main__':
    main()

這篇關(guān)于任何用于顯示來自相機(jī)的實(shí)時(shí)圖像的快速 Python GUI的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How should I verify a log message when testing Python code under nose?(在鼻子下測試 Python 代碼時(shí),我應(yīng)該如何驗(yàn)證日志消息?)
Patch __call__ of a function(修補(bǔ)函數(shù)的 __call__)
How to call self in a mock method of an object in Python?(如何在 Python 中對(duì)象的模擬方法中調(diào)用 self?)
Mocking only a single method on an object(僅模擬對(duì)象上的單個(gè)方法)
Mocking a subprocess call in Python(在 Python 中模擬子進(jìn)程調(diào)用)
Checking call order across multiple mocks(檢查多個(gè)模擬的調(diào)用順序)
主站蜘蛛池模板: 午夜影院在线观看 | 欧美在线观看免费观看视频 | 91精品在线观看入口 | 中文一区 | 欧美激情久久久 | 97精品一区二区 | 天天操网 | 国产精品网址 | av网站免费 | 美女黄色在线观看 | 国产精品久久一区 | 久久剧场 | 欧洲成人午夜免费大片 | 欧美日日| www.日本三级 | 亚洲 欧美 日韩 精品 | 成人h动漫精品一区二区器材 | 国产日韩欧美 | 荷兰欧美一级毛片 | 亚洲成a | 99精品视频在线观看 | 欧美日韩精品久久久免费观看 | 精品乱码一区二区 | 国产伦一区二区三区 | 久久久久中文字幕 | 久久噜噜噜精品国产亚洲综合 | 国产清纯白嫩初高生视频在线观看 | 国产激情在线 | 黑人巨大精品欧美一区二区免费 | 午夜寂寞影院列表 | 日本三级网址 | www.五月天婷婷.com | 天天操天天干天天曰 | 欧美日韩精品久久久免费观看 | 亚洲成人久久久 | 天堂va在线 | 91看片网 | 亚洲国产成人精品女人久久久 | 刘亦菲国产毛片bd | 亚洲精品国产第一综合99久久 | 欧美一级片中文字幕 |