团队开发第二阶段9


现在是我们团队开发阶段的倒数第二天,基本任务已经完成,昨日已进行组内的基本测试。在测试中,我们发现了部分错误数据,不合理数据,而且某些异常情况下terminal内会有乱码数据。现在我们将针对这些错误数据进行处理

import os
import shutil

import cv2
import numpy as np
from PyQt5.QtCore import QSize
from PyQt5.QtGui import QImage, QPixmap, QIcon
from PyQt5.QtWidgets import QListWidgetItem, QWidget, QListWidget, QInputDialog, QLineEdit, QMessageBox

from ui.cheating_list_item import Ui_CheatingListItem
from ui.real_time_catch import Ui_RealTimeCatch
from utils.common import second2str, validFileName
from utils.img_cropper import CropImage


class FrameData(QListWidgetItem):

def __init__(self, list_widget: QListWidget, data, filter_idx=0):
super(FrameData, self).__init__()
self.list_widget = list_widget
self.data_ = data
self.frame_num = data.frame_num
self.widget = FrameData.Widget(list_widget)
self.time_process = second2str(data.time_process)

color1 = '#ff0000' if data.num_of_passing > 0 else '#ffffff'
color2 = '#ff0000' if data.num_of_peep > 0 else '#ffffff'
color3 = '#ff0000' if data.num_of_gazing_around > 0 else '#ffffff'
self.str = f"时间[{self.time_process}] " \
f"<span style=\" color: {color1};\">传纸条: {data.num_of_passing}</span> " \
f"<span style=\" color: {color2};\">低头偷看: {data.num_of_peep}</span> " \
f"<span style=\" color: {color3};\">东张西望: {data.num_of_gazing_around}</span>"
self.widget.lbl.setText(self.str)
idx = filter_idx
if idx == 0:
self.setHidden(True)
elif idx == 1:
self.setHidden(self.data_.num_of_passing == 0)
elif idx == 2:
self.setHidden(self.data_.num_of_peep == 0)
elif idx == 3:
self.setHidden(self.data_.num_of_gazing_around == 0)

self.setSizeHint(QSize(400, 46))

def add_item(self):
size = self.sizeHint()
self.list_widget.addItem(self) # 添加
self.widget.setSizeIncrement(size.width(), size.height())
self.list_widget.setItemWidget(self, self.widget)

class Widget(QWidget, Ui_CheatingListItem):
def __init__(self, parent=None):
super(FrameData.Widget, self).__init__(parent)
self.setupUi(self)

# class Widget(QLabel):
# def __init__(self, parent=None):
# super(FrameData.Widget, self).__init__(parent)


class RealTimeCatchItem(QListWidgetItem):
def __init__(self, list_widget: QListWidget, img, detection, time_process, cheating_type, frame_num):
super(RealTimeCatchItem, self).__init__()
self.list_widget = list_widget
self.widget = RealTimeCatchItem.Widget(list_widget)
self.setSizeHint(QSize(200, 200))

self.img = img
self.time_process = time_process
self.cheating_type = cheating_type
self.frame_num = frame_num
self.detection = detection

def add_item(self):
size = self.sizeHint()
self.list_widget.insertItem(0, self) # 添加
self.widget.setSizeIncrement(size.width(), size.height())
self.list_widget.setItemWidget(self, self.widget)
# 设置图像
catch_img = self.widget.catch_img
frame = CropImage.crop(self.img, self.detection, 1, catch_img.width(), catch_img.height())
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image_height, image_width, image_depth = frame.shape
frame = QImage(frame.data, image_width, image_height, # 创建QImage格式的图像,并读入图像信息
image_width * image_depth,
QImage.Format_RGB888)
self.widget.catch_img.setPixmap(QPixmap.fromImage(frame))
# 设置时间
self.widget.time_lbl.setText(f'{second2str(self.time_process)}')
self.widget.cheating_type_lbl.setText(self.cheating_type)

class Widget(QWidget, Ui_RealTimeCatch):
def __init__(self, parent=None):
super(RealTimeCatchItem.Widget, self).__init__(parent)
self.setupUi(self)


class VideoSourceItem(QListWidgetItem):
def __init__(self, list_widget, name, src, ico_src=":/videos/web-camera.ico"):
super(VideoSourceItem, self).__init__()
icon = QIcon()
icon.addPixmap(QPixmap(ico_src), QIcon.Normal, QIcon.Off)
self.setIcon(icon)
self.setText(name)
self.src = src
self.list_widget = list_widget

def add_item(self):
self.list_widget.addItem(self)
posted @   Joranger  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示