master
Trouvaille 2 years ago
parent 142206f009
commit c9152c1764

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1 @@
main.py

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
</profile>
</component>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (python38)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Image_Processing.iml" filepath="$PROJECT_DIR$/.idea/Image_Processing.iml" />
</modules>
</component>
</project>

@ -0,0 +1,65 @@
# 图像处理程序
这是一个基于opencv和pytorch的图像处理程序实现了模糊、锐化、边缘检测等图像处理基本功能提供了图像矫正等实际应用以及基于深度学习的图像/视频风格迁移功能采用pyqt5制作图形化用户界面。
## 项目背景
图像处理是计算机视觉领域的一个重要分支,它涉及到对图像进行各种操作,如滤波、增强、变换、分割、检测等,以达到改善图像质量、提取图像信息、增加图像效果等目的。图像处理的应用场景非常广泛,如医学影像、卫星遥感、人脸识别、数字水印等。
随着深度学习技术的发展,图像处理也出现了一些新的方法和应用,如风格迁移、超分辨率、图像生成等。这些方法利用深度神经网络来学习图像之间的映射关系或潜在特征,从而实现对图像的高级处理。
本项目是一个基于opencv和pytorch的图像处理程序旨在结合传统的图像处理方法和深度学习方法实现一些常见的图像处理功能和应用并提供一个友好的图形化用户界面方便用户使用。本项目可以作为一个学习和交流的平台也可以作为一个实用的工具为用户提供高效和高质量的图像处理服务。
## 功能特性
- 基本功能,包括图像缩放、图像调节、灰度化、二值化、反相、浮雕、模糊、锐化、边缘检测、旋转
- 实际应用,利用高斯滤波和开闭运算计算矩形顶点,通过透视变化进行图像矫正
- 高级功能基于pytorch深度学习实现图像风格迁移进一步改进后实现视频风格迁移
- 图形界面,集成了多种功能,可以方便地打开、处理、刷新、保存图片,并直观地展现原图和处理后图片的差别
## 环境依赖
- Python 3.9
- Anaconda
## 部署步骤
1. 克隆项目到本地
```bash
git clone ssh
```
2. 配置Anaconda及pytorch
参考以下博客:
https://blog.csdn.net/weixin_52836217/article/details/126674089
3. 安装依赖库
```bash
pip install -r requirements.txt
```
4. 运行主程序
```bash
python main.py
```
## 目录结构描述
- UI存放QtDesigner设计的ui文件及转化后的py文件
- image程序工作过程需要调用的图片
- original原图
- sample视频示例
- style风格图片
- style.pth训练后的风格模型
- main.py: 主程序入口文件
- README.md: 项目说明文件
## 贡献
- 华东师范大学 张宜添
- 华东师范大学 马鼎
- 华东师范大学 张国帅

@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'BaseAdjustDialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_baseAdjustDialog(object):
def setupUi(self, baseAdjustDialog):
baseAdjustDialog.setObjectName("baseAdjustDialog")
baseAdjustDialog.resize(384, 424)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(baseAdjustDialog)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.widget = QtWidgets.QWidget(baseAdjustDialog)
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.bright = QtWidgets.QLabel(self.widget)
self.bright.setObjectName("bright")
self.horizontalLayout.addWidget(self.bright)
spacerItem = QtWidgets.QSpacerItem(280, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.brightLabel = QtWidgets.QLabel(self.widget)
self.brightLabel.setObjectName("brightLabel")
self.horizontalLayout.addWidget(self.brightLabel)
self.verticalLayout_2.addWidget(self.widget)
self.brightSlider = QtWidgets.QSlider(baseAdjustDialog)
self.brightSlider.setMinimum(-100)
self.brightSlider.setMaximum(100)
self.brightSlider.setOrientation(QtCore.Qt.Horizontal)
self.brightSlider.setObjectName("brightSlider")
self.verticalLayout_2.addWidget(self.brightSlider)
self.widget_2 = QtWidgets.QWidget(baseAdjustDialog)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.contrast = QtWidgets.QLabel(self.widget_2)
self.contrast.setObjectName("contrast")
self.horizontalLayout_2.addWidget(self.contrast)
spacerItem1 = QtWidgets.QSpacerItem(267, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.contrastLabel = QtWidgets.QLabel(self.widget_2)
self.contrastLabel.setObjectName("contrastLabel")
self.horizontalLayout_2.addWidget(self.contrastLabel)
self.verticalLayout_2.addWidget(self.widget_2)
self.contrastSlider = QtWidgets.QSlider(baseAdjustDialog)
self.contrastSlider.setMinimum(-100)
self.contrastSlider.setMaximum(100)
self.contrastSlider.setOrientation(QtCore.Qt.Horizontal)
self.contrastSlider.setObjectName("contrastSlider")
self.verticalLayout_2.addWidget(self.contrastSlider)
self.widget_3 = QtWidgets.QWidget(baseAdjustDialog)
self.widget_3.setObjectName("widget_3")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_3)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.saturability = QtWidgets.QLabel(self.widget_3)
self.saturability.setObjectName("saturability")
self.horizontalLayout_3.addWidget(self.saturability)
spacerItem2 = QtWidgets.QSpacerItem(267, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem2)
self.saturabilityLabel = QtWidgets.QLabel(self.widget_3)
self.saturabilityLabel.setObjectName("saturabilityLabel")
self.horizontalLayout_3.addWidget(self.saturabilityLabel)
self.verticalLayout_2.addWidget(self.widget_3)
self.saturabilitySlider = QtWidgets.QSlider(baseAdjustDialog)
self.saturabilitySlider.setMinimum(-100)
self.saturabilitySlider.setMaximum(100)
self.saturabilitySlider.setOrientation(QtCore.Qt.Horizontal)
self.saturabilitySlider.setObjectName("saturabilitySlider")
self.verticalLayout_2.addWidget(self.saturabilitySlider)
self.widget_4 = QtWidgets.QWidget(baseAdjustDialog)
self.widget_4.setObjectName("widget_4")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.widget_4)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.warm = QtWidgets.QLabel(self.widget_4)
self.warm.setObjectName("warm")
self.horizontalLayout_4.addWidget(self.warm)
spacerItem3 = QtWidgets.QSpacerItem(267, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_4.addItem(spacerItem3)
self.warmLabel = QtWidgets.QLabel(self.widget_4)
self.warmLabel.setObjectName("warmLabel")
self.horizontalLayout_4.addWidget(self.warmLabel)
self.verticalLayout_2.addWidget(self.widget_4)
self.warmSlider = QtWidgets.QSlider(baseAdjustDialog)
self.warmSlider.setMinimum(-100)
self.warmSlider.setMaximum(100)
self.warmSlider.setOrientation(QtCore.Qt.Horizontal)
self.warmSlider.setObjectName("warmSlider")
self.verticalLayout_2.addWidget(self.warmSlider)
self.dialogBtnBox = QtWidgets.QDialogButtonBox(baseAdjustDialog)
self.dialogBtnBox.setOrientation(QtCore.Qt.Horizontal)
self.dialogBtnBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.dialogBtnBox.setObjectName("dialogBtnBox")
self.verticalLayout_2.addWidget(self.dialogBtnBox)
self.retranslateUi(baseAdjustDialog)
self.dialogBtnBox.accepted.connect(baseAdjustDialog.accept) # type: ignore
self.dialogBtnBox.rejected.connect(baseAdjustDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(baseAdjustDialog)
def retranslateUi(self, baseAdjustDialog):
_translate = QtCore.QCoreApplication.translate
baseAdjustDialog.setWindowTitle(_translate("baseAdjustDialog", "基础调整"))
self.bright.setText(_translate("baseAdjustDialog", "亮度"))
self.brightLabel.setText(_translate("baseAdjustDialog", "0"))
self.contrast.setText(_translate("baseAdjustDialog", "对比度"))
self.contrastLabel.setText(_translate("baseAdjustDialog", "0"))
self.saturability.setText(_translate("baseAdjustDialog", "饱和度"))
self.saturabilityLabel.setText(_translate("baseAdjustDialog", "0"))
self.warm.setText(_translate("baseAdjustDialog", "暖色调"))
self.warmLabel.setText(_translate("baseAdjustDialog", "0"))

@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>baseAdjustDialog</class>
<widget class="QDialog" name="baseAdjustDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>424</height>
</rect>
</property>
<property name="windowTitle">
<string>基础调整</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="bright">
<property name="text">
<string>亮度</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>280</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="brightLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="brightSlider">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="contrast">
<property name="text">
<string>对比度</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>267</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="contrastLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="contrastSlider">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="saturability">
<property name="text">
<string>饱和度</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>267</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="saturabilityLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="saturabilitySlider">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="warm">
<property name="text">
<string>暖色调</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>267</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="warmLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="warmSlider">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="dialogBtnBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>dialogBtnBox</sender>
<signal>accepted()</signal>
<receiver>baseAdjustDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>dialogBtnBox</sender>
<signal>rejected()</signal>
<receiver>baseAdjustDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -0,0 +1,128 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ChangeColor.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(475, 419)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(-10, 340, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.line = QtWidgets.QFrame(Dialog)
self.line.setGeometry(QtCore.QRect(30, 60, 20, 241))
self.line.setFrameShape(QtWidgets.QFrame.VLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.line_2 = QtWidgets.QFrame(Dialog)
self.line_2.setGeometry(QtCore.QRect(40, 50, 91, 16))
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.line_3 = QtWidgets.QFrame(Dialog)
self.line_3.setGeometry(QtCore.QRect(120, 50, 20, 251))
self.line_3.setFrameShape(QtWidgets.QFrame.VLine)
self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_3.setObjectName("line_3")
self.line_4 = QtWidgets.QFrame(Dialog)
self.line_4.setGeometry(QtCore.QRect(40, 290, 91, 16))
self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_4.setObjectName("line_4")
self.line_5 = QtWidgets.QFrame(Dialog)
self.line_5.setGeometry(QtCore.QRect(320, 50, 20, 241))
self.line_5.setFrameShape(QtWidgets.QFrame.VLine)
self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_5.setObjectName("line_5")
self.line_6 = QtWidgets.QFrame(Dialog)
self.line_6.setGeometry(QtCore.QRect(400, 60, 41, 231))
self.line_6.setFrameShape(QtWidgets.QFrame.VLine)
self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_6.setObjectName("line_6")
self.line_7 = QtWidgets.QFrame(Dialog)
self.line_7.setGeometry(QtCore.QRect(330, 50, 91, 20))
self.line_7.setFrameShape(QtWidgets.QFrame.HLine)
self.line_7.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_7.setObjectName("line_7")
self.line_8 = QtWidgets.QFrame(Dialog)
self.line_8.setGeometry(QtCore.QRect(330, 290, 91, 16))
self.line_8.setFrameShape(QtWidgets.QFrame.HLine)
self.line_8.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_8.setObjectName("line_8")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setGeometry(QtCore.QRect(60, 50, 191, 241))
self.widget.setObjectName("widget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.checkBox = QtWidgets.QCheckBox(self.widget)
self.checkBox.setObjectName("checkBox")
self.verticalLayout.addWidget(self.checkBox)
self.checkBox_2 = QtWidgets.QCheckBox(self.widget)
self.checkBox_2.setObjectName("checkBox_2")
self.verticalLayout.addWidget(self.checkBox_2)
self.checkBox_3 = QtWidgets.QCheckBox(self.widget)
self.checkBox_3.setObjectName("checkBox_3")
self.verticalLayout.addWidget(self.checkBox_3)
self.widget1 = QtWidgets.QWidget(Dialog)
self.widget1.setGeometry(QtCore.QRect(350, 50, 191, 241))
self.widget1.setObjectName("widget1")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget1)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.checkBox_4 = QtWidgets.QCheckBox(self.widget1)
self.checkBox_4.setObjectName("checkBox_4")
self.verticalLayout_2.addWidget(self.checkBox_4)
self.checkBox_5 = QtWidgets.QCheckBox(self.widget1)
self.checkBox_5.setObjectName("checkBox_5")
self.verticalLayout_2.addWidget(self.checkBox_5)
self.checkBox_6 = QtWidgets.QCheckBox(self.widget1)
self.checkBox_6.setObjectName("checkBox_6")
self.verticalLayout_2.addWidget(self.checkBox_6)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(150, 160, 221, 24))
font = QtGui.QFont()
font.setFamily("Agency FB")
font.setPointSize(16)
self.label.setFont(font)
self.label.setObjectName("label")
self.buttonBox.raise_()
self.checkBox.raise_()
self.checkBox_2.raise_()
self.checkBox_3.raise_()
self.line.raise_()
self.line_2.raise_()
self.line_3.raise_()
self.line_4.raise_()
self.line_5.raise_()
self.line_6.raise_()
self.line_7.raise_()
self.line_8.raise_()
self.label.raise_()
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "颜色变化"))
self.checkBox.setText(_translate("Dialog", "红色"))
self.checkBox_2.setText(_translate("Dialog", "蓝色"))
self.checkBox_3.setText(_translate("Dialog", "白色"))
self.checkBox_4.setText(_translate("Dialog", "红色"))
self.checkBox_5.setText(_translate("Dialog", "蓝色"))
self.checkBox_6.setText(_translate("Dialog", "白色"))
self.label.setText(_translate("Dialog", "--transferTo-->"))

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>419</height>
</rect>
</property>
<property name="windowTitle">
<string>颜色变化</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>-10</x>
<y>340</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>30</x>
<y>60</y>
<width>20</width>
<height>241</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_3">
<property name="geometry">
<rect>
<x>120</x>
<y>50</y>
<width>20</width>
<height>251</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_4">
<property name="geometry">
<rect>
<x>40</x>
<y>290</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_5">
<property name="geometry">
<rect>
<x>320</x>
<y>50</y>
<width>20</width>
<height>241</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_6">
<property name="geometry">
<rect>
<x>400</x>
<y>60</y>
<width>41</width>
<height>231</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="Line" name="line_7">
<property name="geometry">
<rect>
<x>330</x>
<y>50</y>
<width>91</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_8">
<property name="geometry">
<rect>
<x>330</x>
<y>290</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>60</x>
<y>50</y>
<width>191</width>
<height>241</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>红色</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>蓝色</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>白色</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>350</x>
<y>50</y>
<width>191</width>
<height>241</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>红色</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>蓝色</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string>白色</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>150</x>
<y>160</y>
<width>221</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>--transferTo--&gt;</string>
</property>
</widget>
<zorder>buttonBox</zorder>
<zorder>checkBox</zorder>
<zorder>checkBox_2</zorder>
<zorder>checkBox_3</zorder>
<zorder>layoutWidget</zorder>
<zorder>line</zorder>
<zorder>line_2</zorder>
<zorder>line_3</zorder>
<zorder>line_4</zorder>
<zorder>line_5</zorder>
<zorder>line_6</zorder>
<zorder>line_7</zorder>
<zorder>line_8</zorder>
<zorder>label</zorder>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'selectStyle.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_dialog(object):
def setupUi(self, dialog):
dialog.setObjectName("dialog")
dialog.resize(588, 437)
self.pushButton = QtWidgets.QPushButton(dialog)
self.pushButton.setGeometry(QtCore.QRect(120, 340, 91, 31))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(dialog)
self.pushButton_2.setGeometry(QtCore.QRect(360, 340, 101, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.layoutWidget = QtWidgets.QWidget(dialog)
self.layoutWidget.setGeometry(QtCore.QRect(30, 50, 531, 221))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.layoutWidget)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.label_2 = QtWidgets.QLabel(self.layoutWidget)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.textBrowser = QtWidgets.QTextBrowser(dialog)
self.textBrowser.setGeometry(QtCore.QRect(100, 278, 419, 41))
self.textBrowser.setObjectName("textBrowser")
self.retranslateUi(dialog)
QtCore.QMetaObject.connectSlotsByName(dialog)
def retranslateUi(self, dialog):
_translate = QtCore.QCoreApplication.translate
dialog.setWindowTitle(_translate("dialog", "视频风格"))
self.pushButton.setText(_translate("dialog", "style1"))
self.pushButton_2.setText(_translate("dialog", "style2"))
self.label.setText(_translate("dialog", "style1"))
self.label_2.setText(_translate("dialog", "style2"))

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dialog</class>
<widget class="QDialog" name="dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<height>437</height>
</rect>
</property>
<property name="windowTitle">
<string>视频风格</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>120</x>
<y>340</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>style1</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>360</x>
<y>340</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>style2</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>531</width>
<height>221</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>style1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>style2</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>100</x>
<y>270</y>
<width>421</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string>生成视频,可能需要几分钟的时间,视频将保存在原目录下</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,185 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'demo.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1600, 900)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.layoutWidget = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget.setGeometry(QtCore.QRect(210, 70, 1341, 561))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.line_4 = QtWidgets.QFrame(self.layoutWidget)
self.line_4.setFrameShape(QtWidgets.QFrame.VLine)
self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_4.setObjectName("line_4")
self.horizontalLayout.addWidget(self.line_4)
self.src_image = QtWidgets.QLabel(self.layoutWidget)
self.src_image.setMinimumSize(QtCore.QSize(281, 271))
self.src_image.setText("")
self.src_image.setObjectName("src_image")
self.horizontalLayout.addWidget(self.src_image)
self.line = QtWidgets.QFrame(self.layoutWidget)
self.line.setFrameShape(QtWidgets.QFrame.VLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.horizontalLayout.addWidget(self.line)
self.dest_image = QtWidgets.QLabel(self.layoutWidget)
self.dest_image.setMinimumSize(QtCore.QSize(311, 291))
self.dest_image.setText("")
self.dest_image.setObjectName("dest_image")
self.horizontalLayout.addWidget(self.dest_image)
self.line_5 = QtWidgets.QFrame(self.layoutWidget)
self.line_5.setFrameShape(QtWidgets.QFrame.VLine)
self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_5.setObjectName("line_5")
self.horizontalLayout.addWidget(self.line_5)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(1200, 690, 61, 21))
self.label_2.setStyleSheet("Qlable{\n"
" font: 75 24pt \"Arial\";\n"
" rgb(170, 0, 0)\n"
"}")
self.label_2.setObjectName("label_2")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(530, 690, 51, 21))
self.label.setStyleSheet("Qlable{\n"
" font: 75 24pt \"Arial\";\n"
" rgb(170, 0, 0)\n"
"}")
self.label.setTextFormat(QtCore.Qt.AutoText)
self.label.setObjectName("label")
self.line_2 = QtWidgets.QFrame(self.centralwidget)
self.line_2.setGeometry(QtCore.QRect(210, 60, 1341, 21))
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.line_3 = QtWidgets.QFrame(self.centralwidget)
self.line_3.setGeometry(QtCore.QRect(210, 630, 1341, 16))
self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_3.setObjectName("line_3")
self.layoutWidget1 = QtWidgets.QWidget(self.centralwidget)
self.layoutWidget1.setGeometry(QtCore.QRect(40, 90, 121, 361))
self.layoutWidget1.setObjectName("layoutWidget1")
self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget1)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton.setObjectName("pushButton")
self.verticalLayout.addWidget(self.pushButton)
self.pushButton_2 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_2.setObjectName("pushButton_2")
self.verticalLayout.addWidget(self.pushButton_2)
self.pushButton_3 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_3.setObjectName("pushButton_3")
self.verticalLayout.addWidget(self.pushButton_3)
self.pushButton_4 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_4.setObjectName("pushButton_4")
self.verticalLayout.addWidget(self.pushButton_4)
self.pushButton_5 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_5.setObjectName("pushButton_5")
self.verticalLayout.addWidget(self.pushButton_5)
self.pushButton_6 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_6.setObjectName("pushButton_6")
self.verticalLayout.addWidget(self.pushButton_6)
self.pushButton_7 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_7.setObjectName("pushButton_7")
self.verticalLayout.addWidget(self.pushButton_7)
self.pushButton_8 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_8.setObjectName("pushButton_8")
self.verticalLayout.addWidget(self.pushButton_8)
self.pushButton_9 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_9.setObjectName("pushButton_9")
self.verticalLayout.addWidget(self.pushButton_9)
self.pushButton_10 = QtWidgets.QPushButton(self.layoutWidget1)
self.pushButton_10.setObjectName("pushButton_10")
self.verticalLayout.addWidget(self.pushButton_10)
self.pushButton_11 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_11.setGeometry(QtCore.QRect(1450, 20, 109, 23))
self.pushButton_11.setObjectName("pushButton_11")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1600, 24))
self.menubar.setObjectName("menubar")
self.menu = QtWidgets.QMenu(self.menubar)
self.menu.setObjectName("menu")
self.menug = QtWidgets.QMenu(self.menubar)
self.menug.setObjectName("menug")
self.menu_2 = QtWidgets.QMenu(self.menubar)
self.menu_2.setObjectName("menu_2")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.actionopen = QtWidgets.QAction(MainWindow)
self.actionopen.setObjectName("actionopen")
self.actionsave = QtWidgets.QAction(MainWindow)
self.actionsave.setObjectName("actionsave")
self.actiontansfer = QtWidgets.QAction(MainWindow)
self.actiontansfer.setObjectName("actiontansfer")
self.actionvideo = QtWidgets.QAction(MainWindow)
self.actionvideo.setObjectName("actionvideo")
self.actionCorrect = QtWidgets.QAction(MainWindow)
self.actionCorrect.setObjectName("actionCorrect")
self.actioncorrect_2 = QtWidgets.QAction(MainWindow)
self.actioncorrect_2.setObjectName("actioncorrect_2")
self.actionChangeColor = QtWidgets.QAction(MainWindow)
self.actionChangeColor.setObjectName("actionChangeColor")
self.menu.addAction(self.actionopen)
self.menu.addAction(self.actionsave)
self.menug.addAction(self.actiontansfer)
self.menug.addAction(self.actionvideo)
self.menu_2.addAction(self.actionCorrect)
self.menu_2.addAction(self.actioncorrect_2)
self.menu_2.addAction(self.actionChangeColor)
self.menubar.addAction(self.menu.menuAction())
self.menubar.addAction(self.menu_2.menuAction())
self.menubar.addAction(self.menug.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "图像处理程序"))
self.label_2.setText(_translate("MainWindow", "处理后"))
self.label.setText(_translate("MainWindow", "原图"))
self.pushButton.setText(_translate("MainWindow", "图像缩放"))
self.pushButton_2.setText(_translate("MainWindow", "图像调节"))
self.pushButton_3.setText(_translate("MainWindow", "灰度化"))
self.pushButton_4.setText(_translate("MainWindow", "二值化"))
self.pushButton_5.setText(_translate("MainWindow", "反相"))
self.pushButton_6.setText(_translate("MainWindow", "浮雕"))
self.pushButton_7.setText(_translate("MainWindow", "边缘检测"))
self.pushButton_8.setText(_translate("MainWindow", "模糊"))
self.pushButton_9.setText(_translate("MainWindow", "锐化"))
self.pushButton_10.setText(_translate("MainWindow", "旋转"))
self.pushButton_11.setText(_translate("MainWindow", "刷新"))
self.menu.setTitle(_translate("MainWindow", "文件"))
self.menug.setTitle(_translate("MainWindow", "高级功能"))
self.menu_2.setTitle(_translate("MainWindow", "实际应用"))
self.actionopen.setText(_translate("MainWindow", "打开图片"))
self.actionopen.setToolTip(_translate("MainWindow", "打开图片"))
self.actionsave.setText(_translate("MainWindow", "保存图片"))
self.actiontansfer.setText(_translate("MainWindow", "图像风格迁移"))
self.actionvideo.setText(_translate("MainWindow", "视频风格迁移"))
self.actionCorrect.setText(_translate("MainWindow", "证件矫正"))
self.actionCorrect.setToolTip(_translate("MainWindow", "证件矫正"))
self.actioncorrect_2.setText(_translate("MainWindow", "书页矫正"))
self.actioncorrect_2.setToolTip(_translate("MainWindow", "书页矫正"))
self.actionChangeColor.setText(_translate("MainWindow", "证件底色转换"))

@ -0,0 +1,322 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1600</width>
<height>900</height>
</rect>
</property>
<property name="windowTitle">
<string>图像处理程序</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>210</x>
<y>70</y>
<width>1341</width>
<height>561</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="src_image">
<property name="minimumSize">
<size>
<width>281</width>
<height>271</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dest_image">
<property name="minimumSize">
<size>
<width>311</width>
<height>291</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>1200</x>
<y>690</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">Qlable{
font: 75 24pt &quot;Arial&quot;;
rgb(170, 0, 0)
}</string>
</property>
<property name="text">
<string>处理后</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>530</x>
<y>690</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">Qlable{
font: 75 24pt &quot;Arial&quot;;
rgb(170, 0, 0)
}</string>
</property>
<property name="text">
<string>原图</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>210</x>
<y>60</y>
<width>1341</width>
<height>21</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_3">
<property name="geometry">
<rect>
<x>210</x>
<y>630</y>
<width>1341</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>90</y>
<width>121</width>
<height>361</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>图像缩放</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>图像调节</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>灰度化</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>二值化</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>反相</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>浮雕</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>边缘检测</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_8">
<property name="text">
<string>模糊</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>锐化</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_10">
<property name="text">
<string>旋转</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton_11">
<property name="geometry">
<rect>
<x>1450</x>
<y>20</y>
<width>109</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>刷新</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1600</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>文件</string>
</property>
<addaction name="actionopen"/>
<addaction name="actionsave"/>
</widget>
<widget class="QMenu" name="menug">
<property name="title">
<string>高级功能</string>
</property>
<addaction name="actiontansfer"/>
<addaction name="actionvideo"/>
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>实际应用</string>
</property>
<addaction name="actionCorrect"/>
<addaction name="actioncorrect_2"/>
<addaction name="actionChangeColor"/>
</widget>
<addaction name="menu"/>
<addaction name="menu_2"/>
<addaction name="menug"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionopen">
<property name="text">
<string>打开图片</string>
</property>
<property name="toolTip">
<string>打开图片</string>
</property>
</action>
<action name="actionsave">
<property name="text">
<string>保存图片</string>
</property>
</action>
<action name="actiontansfer">
<property name="text">
<string>图像风格迁移</string>
</property>
</action>
<action name="actionvideo">
<property name="text">
<string>视频风格迁移</string>
</property>
</action>
<action name="actionCorrect">
<property name="text">
<string>证件矫正</string>
</property>
<property name="toolTip">
<string>证件矫正</string>
</property>
</action>
<action name="actioncorrect_2">
<property name="text">
<string>书页矫正</string>
</property>
<property name="toolTip">
<string>书页矫正</string>
</property>
</action>
<action name="actionChangeColor">
<property name="text">
<string>证件底色转换</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'setsize.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(150, 190, 75, 23))
self.pushButton.setObjectName("pushButton")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(80, 70, 54, 31))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(80, 120, 54, 31))
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(140, 70, 113, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(140, 130, 113, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.retranslateUi(Dialog)
self.pushButton.clicked.connect(Dialog.close) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "大小调整"))
self.pushButton.setText(_translate("Dialog", "确定"))
self.label.setText(_translate("Dialog", "宽度:"))
self.label_2.setText(_translate("Dialog", "高度:"))

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>150</x>
<y>190</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>80</x>
<y>70</y>
<width>54</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>宽度:</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>80</x>
<y>120</y>
<width>54</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>高度:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>140</x>
<y>70</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>140</x>
<y>130</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>Dialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>183</x>
<y>201</y>
</hint>
<hint type="destinationlabel">
<x>295</x>
<y>189</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -0,0 +1,38 @@
from collections import namedtuple
import torch
from torchvision import models
class Vgg16(torch.nn.Module):
def __init__(self, requires_grad=False):
super(Vgg16, self).__init__()
vgg_pretrained_features = models.vgg16(pretrained=True).features
self.slice1 = torch.nn.Sequential()
self.slice2 = torch.nn.Sequential()
self.slice3 = torch.nn.Sequential()
self.slice4 = torch.nn.Sequential()
for x in range(4):
self.slice1.add_module(str(x), vgg_pretrained_features[x])
for x in range(4, 9):
self.slice2.add_module(str(x), vgg_pretrained_features[x])
for x in range(9, 16):
self.slice3.add_module(str(x), vgg_pretrained_features[x])
for x in range(16, 23):
self.slice4.add_module(str(x), vgg_pretrained_features[x])
if not requires_grad:
for param in self.parameters():
param.requires_grad = False
def forward(self, X):
h = self.slice1(X)
h_relu1_2 = h
h = self.slice2(h)
h_relu2_2 = h
h = self.slice3(h)
h_relu3_3 = h
h = self.slice4(h)
h_relu4_3 = h
vgg_outputs = namedtuple("VggOutputs", ['relu1_2', 'relu2_2', 'relu3_3', 'relu4_3'])
out = vgg_outputs(h_relu1_2, h_relu2_2, h_relu3_3, h_relu4_3)
return out

@ -0,0 +1,69 @@
import cv2
import numpy as np
import os
from PIL import Image
def run2(img, src_type, dst_type):
cv2.imwrite("image/tmp_src.jpg", img)
# 输入
in_path = "image/tmp_src.jpg"
# 输出
out_path = "image/tmp_dst.jpg"
# 要替换的背景颜色
color = "deepskyblue"
# 红red、蓝blue、黑black、白white
# 去掉背景颜色
os.system('backgroundremover -i "' + str(in_path) + '" -o "image/cg.jpg"')
# 加上背景颜色
no_bg_image = Image.open("image/cg.jpg")
x, y = no_bg_image.size
new_image = Image.new('RGBA', no_bg_image.size, color=color)
new_image.paste(no_bg_image, (0, 0, x, y), no_bg_image)
new_image.save(out_path)
res = cv2.imread(out_path)
return res
def run(image, src_type, dst_type):
# 图像缩放
img = cv2.resize(image, None, fx=1, fy=1)
rows, cols, channels = img.shape
# 图片转换为灰度图
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# 图片的二值化处理
if src_type == 'r':
lower_red = np.array([0, 150, 50])
upper_red = np.array([5, 255, 255])
mask = cv2.inRange(hsv, lower_red, upper_red)
lower_red2 = np.array([175, 150, 50])
upper_red2 = np.array([179, 255, 255])
mask2 = cv2.inRange(hsv, lower_red2, upper_red2)
mask=cv2.bitwise_or(mask,mask2)
elif src_type == 'b':
lower_blue = np.array([90, 70, 70])
upper_blue = np.array([110, 255, 255])
mask = cv2.inRange(hsv, lower_blue, upper_blue)
else:
mask = cv2.inRange(hsv, np.array([0, 0, 221]), np.array([180, 30, 255]))
# 腐蚀膨胀
erode = cv2.erode(mask, np.ones((10, 10), np.uint8), iterations=1)
dilate = cv2.dilate(erode, np.ones((10, 10), np.uint8), iterations=1)
# 转变为
if dst_type == 'w':
for i in range(rows):
for j in range(cols):
if dilate[i, j] == 255: # 像素点255表示白色
img[i, j] = (255, 255, 255) # 此处替换颜色为BGR通道不是RGB
elif dst_type == 'r':
for i in range(rows):
for j in range(cols):
if dilate[i, j] == 255: # 像素点255表示白色
img[i, j] = (0, 0, 255) # 此处替换颜色为BGR通道不是RGB
elif dst_type == 'b':
for i in range(rows):
for j in range(cols):
if dilate[i, j] == 255: # 像素点255表示白色
img[i, j] = (255, 0, 0) # 此处替换颜色为BGR通道不是RGB
return img

@ -0,0 +1,116 @@
import cv2
import math
import numpy as np
def Img_Outline(img):
original_img = img
gray_img = cv2.cvtColor(original_img, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray_img, (9, 9), 0) # 高斯模糊去噪(设定卷积核大小影响效果)
_, RedThresh = cv2.threshold(blurred, 165, 255, cv2.THRESH_BINARY) # 设定阈值165阈值影响开闭运算效果
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5)) # 定义矩形结构元素
closed = cv2.morphologyEx(RedThresh, cv2.MORPH_CLOSE, kernel) # 闭运算(链接块)
opened = cv2.morphologyEx(closed, cv2.MORPH_OPEN, kernel) # 开运算(去噪点)
return original_img, opened
def findContours_img(original_img, opened):
contours, hierarchy = cv2.findContours(opened, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
c = sorted(contours, key=cv2.contourArea, reverse=True)[1] # 计算最大轮廓的旋转包围盒
rect = cv2.minAreaRect(c) # 获取包围盒(中心点,宽高,旋转角度)
box = np.int0(cv2.boxPoints(rect)) # box
draw_img = cv2.drawContours(original_img.copy(), [box], -1, (0, 0, 255), 3)
print("box[0]:", box[0])
print("box[1]:", box[1])
print("box[2]:", box[2])
print("box[3]:", box[3])
return box, draw_img
def Perspective_transform(box, original_img):
# 获取画框宽高(x=orignal_W,y=orignal_H)
orignal_W = math.ceil(np.sqrt((box[3][1] - box[2][1]) ** 2 + (box[3][0] - box[2][0]) ** 2))
orignal_H = math.ceil(np.sqrt((box[3][1] - box[0][1]) ** 2 + (box[3][0] - box[0][0]) ** 2))
# 原图中的四个顶点,与变换矩阵
pts1 = np.float32([box[0], box[1], box[2], box[3]])
pts2 = np.float32(
[[int(orignal_W + 1), int(orignal_H + 1)], [0, int(orignal_H + 1)], [0, 0], [int(orignal_W + 1), 0]])
# 生成透视变换矩阵;进行透视变换
M = cv2.getPerspectiveTransform(pts1, pts2)
result_img = cv2.warpPerspective(original_img, M, (int(orignal_W + 3), int(orignal_H + 1)))
return result_img
def fourier_demo(img):
# 1、灰度化读取文件
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 2、图像延扩
h, w = img.shape[:2]
new_h = cv2.getOptimalDFTSize(h)
new_w = cv2.getOptimalDFTSize(w)
right = new_w - w
bottom = new_h - h
nimg = cv2.copyMakeBorder(img, 0, bottom, 0, right, borderType=cv2.BORDER_CONSTANT, value=0)
# 3、执行傅里叶变换并过得频域图像
f = np.fft.fft2(nimg)
fshift = np.fft.fftshift(f)
magnitude = np.log(np.abs(fshift))
# 二值化
magnitude_uint = magnitude.astype(np.uint8)
ret, thresh = cv2.threshold(magnitude_uint, 11, 255, cv2.THRESH_BINARY)
print(ret)
print(thresh.dtype)
# 霍夫直线变换
lines = cv2.HoughLinesP(thresh, 2, np.pi / 180, 30, minLineLength=40, maxLineGap=100)
print(len(lines))
# 创建一个新图像,标注直线
lineimg = np.ones(nimg.shape, dtype=np.uint8)
lineimg = lineimg * 255
piThresh = np.pi / 180
pi2 = np.pi / 2
print(piThresh)
for line in lines:
x1, y1, x2, y2 = line[0]
cv2.line(lineimg, (x1, y1), (x2, y2), (0, 255, 0), 2)
if x2 - x1 == 0:
continue
else:
theta = (y2 - y1) / (x2 - x1)
if abs(theta) < piThresh or abs(theta - pi2) < piThresh:
continue
else:
print(theta)
angle = math.atan(theta)
print(angle)
angle = angle * (180 / np.pi)
print(angle)
angle = (angle - 90) / (w / h)
print(angle)
center = (w // 2, h // 2)
M = cv2.getRotationMatrix2D(center, angle, 1.0)
rotated = cv2.warpAffine(img, M, (w, h), flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REPLICATE)
return rotated
def runCard(img):
original_img, opened = Img_Outline(img)
box, draw_img = findContours_img(original_img, opened)
result_img = Perspective_transform(box, original_img)
return result_img
def runPaper(img):
return fourier_demo(img)

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save