慢速网络摄像头Feed GTK

时间:2019-03-31 12:24:31

标签: opencv gtk cairo

所以我有一个通过从OpenCV捕获的小图像创建pixbuf的网络摄像头,但是说捕获太慢了,实际上我的代码看起来像这样。

builder.get_object('VideoCanvas').connect('draw', VideoCanvasDrawCb)

...

def VideoCanvasDrawCb(videoCanvas, context):
    success, frame = capture.read()
    frame = cv2.resize(frame, (480, 360))
    # Slowing down video recording
    for i in range(0, 3): output.writeFrame(frame)
    height, width, depth = frame.shape
    pixelBuffer = GdkPixbuf.Pixbuf.new_from_data(frame.tostring(),
    GdkPixbuf.Colorspace.RGB, False, 8, width, height, width * 3, None, None)
    builder.get_object('VideoCanvas').set_from_pixbuf(pixelBuffer)

代码运行良好,直到我到达最后一个函数set_from_pixbuf,而GUI却减慢了速度...我试图用GtkDrawingArea代替GtkImage并用开罗绘画pixbuf。但是性能是一样的...

还有另一种实时渲染pixbuf的方法,而不会完全降低整个应用程序的速度吗?

0 个答案:

没有答案
相关问题