1

使用python3,gtk3。我正在开发一个需要操作和显示(播放)视频帧的计算机视觉应用程序。

目前,我Pixbuf使用静态方法创建了一个新方法,由从包含操纵帧的numpynew_from_data数组创建的字节序列馈送,并且我遇到了性能问题,例如无法以 20fps 播放视频。

我想知道:这是解决这类问题的方法吗?为每一帧创建一个新的 Pixbuf 是相对便宜还是昂贵?我应该使用其他方法,例如 usingnew_from_stream吗?(不熟悉)

4

1 回答 1

2

This is not an "easier" way, but if you're having performance issues, you should try using Clutter via Clutter-Gtk which will use hardware acceleration to draw the frames.

You can create a GtkClutterEmbed widget, which will give you a ClutterStage which is a ClutterActor. Everytime you have a new frame, you can create a new ClutterImage and do clutter_image_set_data() (which is just like new_from_data for the Pixbuf) and then set the ClutterContent of the ClutterActor (eg: the ClutterStage) to be this new ClutterImage.

This is how Gnome-Ring plays video, you can take a look at its source code here for inspiration.

于 2017-01-09T23:18:58.780 回答