1 Star 0 Fork 2

理科疯子/Multi-Video-Process

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Opencv_to_Qpixmap.py 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
理科疯子 提交于 2022-01-27 21:12 . Initial commit
import time
from threading import Thread
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtGui import QImage, QPixmap
# pickle QPixmap
class ThreadOpencvToQpixmap(Thread):
def __init__(self, my_thread_queue_image_done, my_process_queue_image_processed, my_end):
super(ThreadOpencvToQpixmap, self).__init__()
self.my_thread_queue_image_done = my_thread_queue_image_done
self.my_process_queue_image_processed = my_process_queue_image_processed
self.my_end = my_end
self.is_running = True
self.w = 960
self.h = 540
def run(self) -> None:
time.sleep(0.5)
while self.is_running:
flag = self.function()
if not flag:
time.sleep(0.0015)
def stop(self):
self.is_running = False
def function(self):
if self.my_process_queue_image_processed.empty():
if not self.my_end.empty():
self.is_running = False
return False
else:
frame, image, data = self.my_process_queue_image_processed.get()
size = QSize(self.w, self.h)
image = QImage(image.data.tobytes(), image.shape[1], image.shape[0], image.shape[1] * 3,
QImage.Format_RGB888)
image = QPixmap.fromImage(image.scaled(size, Qt.IgnoreAspectRatio))
self.my_thread_queue_image_done.put([frame, image, data])
return True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/likefengzi/Multi-Video-Process.git
[email protected]:likefengzi/Multi-Video-Process.git
likefengzi
Multi-Video-Process
Multi-Video-Process
master

搜索帮助