@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1,13 @@
|
||||
<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" />
|
||||
<option value="N803" />
|
||||
</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.9" 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/opencv-pyqt5-master.iml" filepath="$PROJECT_DIR$/.idea/opencv-pyqt5-master.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -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,108 @@
|
||||
from custom.tableWidget import *
|
||||
from custom.listWidgetItems import *
|
||||
|
||||
|
||||
# Implemented functions
|
||||
items = [
|
||||
GrayingItem,
|
||||
FilterItem,
|
||||
EqualizeItem,
|
||||
MorphItem,
|
||||
GradItem,
|
||||
ThresholdItem,
|
||||
EdgeItem,
|
||||
ContourItem,
|
||||
HoughLineItem,
|
||||
GammaItem
|
||||
|
||||
]
|
||||
|
||||
items1 = [
|
||||
ImageCutItem,
|
||||
RotateAnyItem,
|
||||
RotateLeftItem,
|
||||
RotateRightItem,
|
||||
UpDownItem
|
||||
]
|
||||
|
||||
items2 = [
|
||||
ExposureItem,
|
||||
ContrastItem,
|
||||
LightItem
|
||||
]
|
||||
|
||||
items3 = [
|
||||
ColorTemperatureItem,
|
||||
HueItem,
|
||||
SaturationItem
|
||||
]
|
||||
|
||||
items4 = [
|
||||
HSLRedItem,
|
||||
HSLOrangeItem,
|
||||
HSLYellowItem,
|
||||
HSLGreenItem,
|
||||
HSLCyanItem,
|
||||
HSLBlueItem,
|
||||
HSLPurpleItem
|
||||
]
|
||||
|
||||
items5 = [
|
||||
PixelateItem,
|
||||
BlurItem
|
||||
|
||||
]
|
||||
|
||||
items6 = [
|
||||
CandyStyleTransformItem,
|
||||
CompositionStyleTransformItem,
|
||||
FeathersStyleTransformItem,
|
||||
MuseStyleTransformItem,
|
||||
MosaicStyleTransformItem,
|
||||
StarryNightStyleTransformItem,
|
||||
ScreamStyleTransformItem,
|
||||
WaveStyleTransformItem,
|
||||
UdnieStyleTransformItem
|
||||
]
|
||||
|
||||
items7 = [
|
||||
ClarityItem,
|
||||
NoiseItem
|
||||
]
|
||||
|
||||
tables = [
|
||||
GrayingTableWidget,
|
||||
FilterTabledWidget,
|
||||
EqualizeTableWidget,
|
||||
MorphTabledWidget,
|
||||
GradTabledWidget,
|
||||
ThresholdTableWidget,
|
||||
EdgeTableWidget,
|
||||
ContourTableWidget,
|
||||
HoughLineTableWidget,
|
||||
GammaITabelWidget,
|
||||
ImageCutTableWidget,
|
||||
RotateAnyTabelWidget,
|
||||
RotateLeftTableWidget,
|
||||
RotateRightTableWidget,
|
||||
UpDownTableWidget,
|
||||
ExposureTabelWidget,
|
||||
ContrastTabelWidget,
|
||||
LightTableWidget,
|
||||
ColorTemperatureTabelWidget,
|
||||
HueTabelWidget,
|
||||
SaturationTabelWidget,
|
||||
HSLRedWidget,
|
||||
HSLOrangeWidget,
|
||||
HSLYellowWidget,
|
||||
HSLGreenWidget,
|
||||
HSLCyanWidget,
|
||||
HSLBlueWidget,
|
||||
HSLPurpleWidget,
|
||||
PixelateTabelWidget,
|
||||
BlurTabelWidget,
|
||||
StyleTransformTableWidget,
|
||||
|
||||
|
||||
]
|
||||
|
@ -0,0 +1,87 @@
|
||||
import cv2
|
||||
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
|
||||
class GraphicsView(QGraphicsView):
|
||||
def __init__(self, parent=None):
|
||||
super(GraphicsView, self).__init__(parent=parent)
|
||||
self._zoom = 0
|
||||
self._empty = True
|
||||
self._photo = QGraphicsPixmapItem() # 创建pixmapItem对象用于显示图像
|
||||
self._scene = QGraphicsScene(self) # 创建存储图元的容器
|
||||
self._scene.addItem(self._photo)
|
||||
self.setScene(self._scene)
|
||||
self.setAlignment(Qt.AlignCenter) # 居中显示
|
||||
self.setDragMode(QGraphicsView.ScrollHandDrag) # 设置拖动
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.setMinimumSize(640, 480)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
if not self.has_photo():
|
||||
return
|
||||
menu = QMenu()
|
||||
save_action = QAction('另存为', self)
|
||||
save_action.triggered.connect(self.save_current) # 传递额外值
|
||||
menu.addAction(save_action)
|
||||
menu.exec(QCursor.pos())
|
||||
|
||||
def save_current(self):
|
||||
file_name = QFileDialog.getSaveFileName(self, '另存为', './',
|
||||
'Image files(*.jpg *.gif *.png)')[0]
|
||||
print(file_name)
|
||||
if file_name:
|
||||
self._photo.pixmap().save(file_name)
|
||||
|
||||
def get_image(self):
|
||||
if self.has_photo():
|
||||
return self._photo.pixmap().toImage() # 获取
|
||||
|
||||
def has_photo(self):
|
||||
return not self._empty
|
||||
|
||||
def img_to_pixmap(self, img):
|
||||
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # bgr -> rgb
|
||||
h, w, c = img.shape # 获取图片形状
|
||||
image = QImage(img, w, h, 3 * w, QImage.Format_RGB888)
|
||||
return QPixmap.fromImage(image)
|
||||
|
||||
def update_image(self, img):
|
||||
self._empty = False
|
||||
self._photo.setPixmap(self.img_to_pixmap(img))
|
||||
|
||||
def change_image(self, img):
|
||||
self.update_image(img)
|
||||
self.fitInView()
|
||||
|
||||
def fitInView(self, scale=True):
|
||||
rect = QRectF(self._photo.pixmap().rect())
|
||||
if not rect.isNull():
|
||||
self.setSceneRect(rect)
|
||||
if self.has_photo():
|
||||
unity = self.transform().mapRect(QRectF(0, 0, 1, 1))
|
||||
self.scale(1 / unity.width(), 1 / unity.height())
|
||||
viewrect = self.viewport().rect()
|
||||
scenerect = self.transform().mapRect(rect)
|
||||
factor = min(viewrect.width() / scenerect.width(),
|
||||
viewrect.height() / scenerect.height())
|
||||
self.scale(factor, factor)
|
||||
self._zoom = 0
|
||||
|
||||
def wheelEvent(self, event):
|
||||
if self.has_photo():
|
||||
if event.angleDelta().y() > 0:
|
||||
factor = 1.25
|
||||
self._zoom += 1
|
||||
else:
|
||||
factor = 0.8
|
||||
self._zoom -= 1
|
||||
if self._zoom > 0:
|
||||
self.scale(factor, factor)
|
||||
elif self._zoom == 0:
|
||||
self.fitInView()
|
||||
else:
|
||||
self._zoom = 0
|
@ -0,0 +1,310 @@
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
from config import items, items1, items2, items3, items4, items5, items6, items7
|
||||
|
||||
|
||||
class MyListWidget(QListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.mainwindow = parent
|
||||
self.setDragEnabled(True)
|
||||
# 选中不显示虚线
|
||||
# self.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.setFocusPolicy(Qt.NoFocus)
|
||||
|
||||
|
||||
class UsedListWidget(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setAcceptDrops(True)
|
||||
self.setFlow(QListView.TopToBottom) # 设置列表方向
|
||||
self.setDefaultDropAction(Qt.MoveAction) # 设置拖放为移动而不是复制一个
|
||||
self.setDragDropMode(QAbstractItemView.InternalMove) # 设置拖放模式, 内部拖放
|
||||
self.itemClicked.connect(self.show_attr)
|
||||
self.setMinimumWidth(200)
|
||||
|
||||
self.move_item = None
|
||||
|
||||
def contextMenuEvent(self, e):
|
||||
# 右键菜单事件
|
||||
item = self.itemAt(self.mapFromGlobal(QCursor.pos()))
|
||||
if not item:
|
||||
return # 判断是否是空白区域
|
||||
menu = QMenu()
|
||||
delete_action = QAction('删除', self)
|
||||
delete_action.triggered.connect(lambda: self.delete_item(item)) # 传递额外值
|
||||
menu.addAction(delete_action)
|
||||
menu.exec(QCursor.pos())
|
||||
|
||||
def delete_item(self, item):
|
||||
# 删除操作
|
||||
self.takeItem(self.row(item))
|
||||
self.mainwindow.update_image() # 更新frame
|
||||
self.mainwindow.dock_attr.close()
|
||||
|
||||
def dropEvent(self, event):
|
||||
super().dropEvent(event)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def show_attr(self):
|
||||
item = self.itemAt(self.mapFromGlobal(QCursor.pos()))
|
||||
if not item:
|
||||
return
|
||||
param = item.get_params() # 获取当前item的属性
|
||||
if type(item) in items:
|
||||
index = items.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items1:
|
||||
index = items1.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index + 10)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items2:
|
||||
index = items2.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index + 15)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items3:
|
||||
index = items3.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index + 18)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items4:
|
||||
index = items4.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index + 21)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items5:
|
||||
index = items5.index(type(item)) # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(index + 28)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items6: # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(30)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
if type(item) in items7: # 获取item对应的table索引
|
||||
self.mainwindow.stackedWidget.setCurrentIndex(30)
|
||||
self.mainwindow.stackedWidget.currentWidget().update_params(param) # 更新对应的table
|
||||
self.mainwindow.dock_attr.show()
|
||||
|
||||
|
||||
class FuncListWidget(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget1(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items1:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items1:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget2(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items2:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items2:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget3(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items3:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items3:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget4(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items4:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items4:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget5(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items5:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items5:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget6(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items6:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items6:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
||||
|
||||
class FuncListWidget7(MyListWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setFixedHeight(64 * 3)
|
||||
self.setFlow(QListView.LeftToRight) # 设置列表方向
|
||||
self.setViewMode(QListView.IconMode) # 设置列表模式
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # 关掉滑动条
|
||||
self.setAcceptDrops(False)
|
||||
for itemType in items7:
|
||||
self.addItem(itemType())
|
||||
self.itemClicked.connect(self.add_used_function)
|
||||
|
||||
def add_used_function(self):
|
||||
func_item = self.currentItem()
|
||||
if type(func_item) in items7:
|
||||
use_item = type(func_item)()
|
||||
self.mainwindow.useListWidget.addItem(use_item)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.setCursor(Qt.ArrowCursor)
|
||||
self.setCurrentRow(-1) # 取消选中状态
|
||||
|
@ -0,0 +1,10 @@
|
||||
from custom.tableWidget import *
|
||||
from config import tables
|
||||
|
||||
|
||||
class StackedWidget(QStackedWidget):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent=parent)
|
||||
for table in tables:
|
||||
self.addWidget(table(parent=parent))
|
||||
self.setMinimumWidth(200)
|
@ -0,0 +1,86 @@
|
||||
*{
|
||||
font-family: 微软雅黑;
|
||||
color: #BBBBBB;
|
||||
background-color: #2F2F2F;
|
||||
}
|
||||
|
||||
/* 设置目录树样式 */
|
||||
QTreeView{
|
||||
show-decoration-selected: 1;
|
||||
}
|
||||
QTreeView::item{
|
||||
height: 30px;
|
||||
}
|
||||
QTreeView::item:hover, QTreeView::branch:hover{
|
||||
background: #4B6EAF;
|
||||
}
|
||||
QTreeView::item:selected, QTreeView::branch:selected{
|
||||
background: #4B6EAF;
|
||||
}
|
||||
QTreeView::branch{
|
||||
color: #BBBBBB;
|
||||
}
|
||||
QTreeView::branch:has-children:!has-siblings:closed,
|
||||
QTreeView::branch:closed:has-children:has-siblings {
|
||||
border-image: none;
|
||||
image: url(icons/branch-close.png);
|
||||
}
|
||||
QTreeView::branch:open:has-children:!has-siblings,
|
||||
QTreeView::branch:open:has-children:has-siblings {
|
||||
border-image: none;
|
||||
image: url(icons/branch-open.png);
|
||||
}
|
||||
|
||||
/* 设置标签样式 */
|
||||
QLabel{
|
||||
font-size: 18px;
|
||||
border: 1px solid #BBBBBB;
|
||||
border-width: 1px 1px 0px 1px;
|
||||
}
|
||||
|
||||
/* 设置视图样式 */
|
||||
QGraphicsView{
|
||||
border: 1px solid #BBBBBB;
|
||||
background-color: #444444;
|
||||
}
|
||||
|
||||
/* 设置列表样式 */
|
||||
QListWidget::Item{
|
||||
border: 1px solid #BBBBBB;
|
||||
font-size: 20px;
|
||||
background: #717678;
|
||||
color: #DDDDDD;
|
||||
}
|
||||
|
||||
QListWidget::Item:hover{
|
||||
background: #4B6EAF;
|
||||
}
|
||||
|
||||
FuncListWidget::Item{
|
||||
border-style: inset;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #999999;
|
||||
margin:0px 1px 0px 0px
|
||||
}
|
||||
|
||||
UsedListWidget::Item{
|
||||
border: 2px solid #999999;
|
||||
margin:0px 0px 1px 0px
|
||||
}
|
||||
|
||||
UsedListWidget::Item:selected{
|
||||
background: #99CCFF;
|
||||
}
|
||||
|
||||
|
||||
/* 设置表格样式 */
|
||||
QTableWidget{
|
||||
alternate-background-color: #444444;
|
||||
}
|
||||
|
||||
|
||||
QToolButton:hover{
|
||||
background: #4B6EAF;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,690 @@
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
|
||||
class TableWidget(QTableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(TableWidget, self).__init__(parent=parent)
|
||||
self.mainwindow = parent
|
||||
self.setShowGrid(True) # 显示网格
|
||||
self.setAlternatingRowColors(True) # 隔行显示颜色
|
||||
self.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.horizontalHeader().setVisible(False)
|
||||
self.verticalHeader().setVisible(False)
|
||||
self.horizontalHeader().sectionResizeMode(QHeaderView.Stretch)
|
||||
self.verticalHeader().sectionResizeMode(QHeaderView.Stretch)
|
||||
self.horizontalHeader().setStretchLastSection(True)
|
||||
self.setFocusPolicy(Qt.NoFocus)
|
||||
|
||||
def signal_connect(self):
|
||||
for spinbox in self.findChildren(QSpinBox):
|
||||
spinbox.valueChanged.connect(self.update_item)
|
||||
for doublespinbox in self.findChildren(QDoubleSpinBox):
|
||||
doublespinbox.valueChanged.connect(self.update_item)
|
||||
for combox in self.findChildren(QComboBox):
|
||||
combox.currentIndexChanged.connect(self.update_item)
|
||||
for checkbox in self.findChildren(QCheckBox):
|
||||
checkbox.stateChanged.connect(self.update_item)
|
||||
|
||||
def update_item(self):
|
||||
param = self.get_params()
|
||||
self.mainwindow.useListWidget.currentItem().update_params(param)
|
||||
self.mainwindow.update_image()
|
||||
|
||||
def update_params(self, param=None):
|
||||
for key in param.keys():
|
||||
box = self.findChild(QWidget, name=key)
|
||||
if isinstance(box, QSpinBox) or isinstance(box, QDoubleSpinBox):
|
||||
box.setValue(param[key])
|
||||
elif isinstance(box, QComboBox):
|
||||
box.setCurrentIndex(param[key])
|
||||
elif isinstance(box, QCheckBox):
|
||||
box.setChecked(param[key])
|
||||
|
||||
def get_params(self):
|
||||
param = {}
|
||||
for spinbox in self.findChildren(QSpinBox):
|
||||
param[spinbox.objectName()] = spinbox.value()
|
||||
for doublespinbox in self.findChildren(QDoubleSpinBox):
|
||||
param[doublespinbox.objectName()] = doublespinbox.value()
|
||||
for combox in self.findChildren(QComboBox):
|
||||
param[combox.objectName()] = combox.currentIndex()
|
||||
for combox in self.findChildren(QCheckBox):
|
||||
param[combox.objectName()] = combox.isChecked()
|
||||
return param
|
||||
|
||||
|
||||
class GrayingTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(GrayingTableWidget, self).__init__(parent=parent)
|
||||
|
||||
|
||||
class FilterTabledWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(FilterTabledWidget, self).__init__(parent=parent)
|
||||
|
||||
self.kind_comBox = QComboBox()
|
||||
self.kind_comBox.addItems(['均值滤波', '高斯滤波', '中值滤波'])
|
||||
self.kind_comBox.setObjectName('kind')
|
||||
|
||||
self.ksize_spinBox = QSpinBox()
|
||||
self.ksize_spinBox.setObjectName('ksize')
|
||||
self.ksize_spinBox.setMinimum(1)
|
||||
self.ksize_spinBox.setSingleStep(2)
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('类型'))
|
||||
self.setCellWidget(0, 1, self.kind_comBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('核大小'))
|
||||
self.setCellWidget(1, 1, self.ksize_spinBox)
|
||||
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class MorphTabledWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(MorphTabledWidget, self).__init__(parent=parent)
|
||||
|
||||
self.op_comBox = QComboBox()
|
||||
self.op_comBox.addItems(['腐蚀操作', '膨胀操作', '开操作', '闭操作', '梯度操作', '顶帽操作', '黑帽操作'])
|
||||
self.op_comBox.setObjectName('op')
|
||||
|
||||
self.ksize_spinBox = QSpinBox()
|
||||
self.ksize_spinBox.setMinimum(1)
|
||||
self.ksize_spinBox.setSingleStep(2)
|
||||
self.ksize_spinBox.setObjectName('ksize')
|
||||
|
||||
self.kshape_comBox = QComboBox()
|
||||
self.kshape_comBox.addItems(['方形', '十字形', '椭圆形'])
|
||||
self.kshape_comBox.setObjectName('kshape')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(3)
|
||||
self.setItem(0, 0, QTableWidgetItem('类型'))
|
||||
self.setCellWidget(0, 1, self.op_comBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('核大小'))
|
||||
self.setCellWidget(1, 1, self.ksize_spinBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('核形状'))
|
||||
self.setCellWidget(2, 1, self.kshape_comBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class GradTabledWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(GradTabledWidget, self).__init__(parent=parent)
|
||||
|
||||
self.kind_comBox = QComboBox()
|
||||
self.kind_comBox.addItems(['Sobel算子', 'Scharr算子', 'Laplacian算子'])
|
||||
self.kind_comBox.setObjectName('kind')
|
||||
|
||||
self.ksize_spinBox = QSpinBox()
|
||||
self.ksize_spinBox.setMinimum(1)
|
||||
self.ksize_spinBox.setSingleStep(2)
|
||||
self.ksize_spinBox.setObjectName('ksize')
|
||||
|
||||
self.dx_spinBox = QSpinBox()
|
||||
self.dx_spinBox.setMaximum(1)
|
||||
self.dx_spinBox.setMinimum(0)
|
||||
self.dx_spinBox.setSingleStep(1)
|
||||
self.dx_spinBox.setObjectName('dx')
|
||||
|
||||
self.dy_spinBox = QSpinBox()
|
||||
self.dy_spinBox.setMaximum(1)
|
||||
self.dy_spinBox.setMinimum(0)
|
||||
self.dy_spinBox.setSingleStep(1)
|
||||
self.dy_spinBox.setObjectName('dy')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(4)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('类型'))
|
||||
self.setCellWidget(0, 1, self.kind_comBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('核大小'))
|
||||
self.setCellWidget(1, 1, self.ksize_spinBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('x方向'))
|
||||
self.setCellWidget(2, 1, self.dx_spinBox)
|
||||
self.setItem(3, 0, QTableWidgetItem('y方向'))
|
||||
self.setCellWidget(3, 1, self.dy_spinBox)
|
||||
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ThresholdTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ThresholdTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.thresh_spinBox = QSpinBox()
|
||||
self.thresh_spinBox.setObjectName('thresh')
|
||||
self.thresh_spinBox.setMaximum(255)
|
||||
self.thresh_spinBox.setMinimum(0)
|
||||
self.thresh_spinBox.setSingleStep(1)
|
||||
|
||||
self.maxval_spinBox = QSpinBox()
|
||||
self.maxval_spinBox.setObjectName('maxval')
|
||||
self.maxval_spinBox.setMaximum(255)
|
||||
self.maxval_spinBox.setMinimum(0)
|
||||
self.maxval_spinBox.setSingleStep(1)
|
||||
|
||||
self.method_comBox = QComboBox()
|
||||
self.method_comBox.addItems(['二进制阈值化', '反二进制阈值化', '截断阈值化', '阈值化为0', '反阈值化为0', '大津算法'])
|
||||
self.method_comBox.setObjectName('method')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(3)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('类型'))
|
||||
self.setCellWidget(0, 1, self.method_comBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('阈值'))
|
||||
self.setCellWidget(1, 1, self.thresh_spinBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('最大值'))
|
||||
self.setCellWidget(2, 1, self.maxval_spinBox)
|
||||
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class EdgeTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(EdgeTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.thresh1_spinBox = QSpinBox()
|
||||
self.thresh1_spinBox.setMinimum(0)
|
||||
self.thresh1_spinBox.setMaximum(255)
|
||||
self.thresh1_spinBox.setSingleStep(1)
|
||||
self.thresh1_spinBox.setObjectName('thresh1')
|
||||
|
||||
self.thresh2_spinBox = QSpinBox()
|
||||
self.thresh2_spinBox.setMinimum(0)
|
||||
self.thresh2_spinBox.setMaximum(255)
|
||||
self.thresh2_spinBox.setSingleStep(1)
|
||||
self.thresh2_spinBox.setObjectName('thresh2')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('阈值1'))
|
||||
self.setCellWidget(0, 1, self.thresh1_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('阈值2'))
|
||||
self.setCellWidget(1, 1, self.thresh2_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ImageCutTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ImageCutTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.x1_spinBox = QSpinBox()
|
||||
self.x1_spinBox.setMinimum(1)
|
||||
self.x1_spinBox.setMaximum(5000)
|
||||
self.x1_spinBox.setSingleStep(1)
|
||||
self.x1_spinBox.setObjectName('x1')
|
||||
|
||||
self.y1_spinBox = QSpinBox()
|
||||
self.y1_spinBox.setMinimum(1)
|
||||
self.y1_spinBox.setMaximum(5000)
|
||||
self.y1_spinBox.setSingleStep(1)
|
||||
self.y1_spinBox.setObjectName('y1')
|
||||
|
||||
self.x2_spinBox = QSpinBox()
|
||||
self.x2_spinBox.setMinimum(1)
|
||||
self.x2_spinBox.setMaximum(5000)
|
||||
self.x2_spinBox.setSingleStep(1)
|
||||
self.x2_spinBox.setObjectName('x2')
|
||||
|
||||
self.y2_spinBox = QSpinBox()
|
||||
self.y2_spinBox.setMinimum(1)
|
||||
self.y2_spinBox.setMaximum(5000)
|
||||
self.y2_spinBox.setSingleStep(1)
|
||||
self.y2_spinBox.setObjectName('y2')
|
||||
|
||||
self.setColumnCount(4)
|
||||
self.setRowCount(2)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('x1'))
|
||||
self.setCellWidget(0, 1, self.x1_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('y1'))
|
||||
self.setCellWidget(1, 1, self.y1_spinBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('x2'))
|
||||
self.setCellWidget(2, 1, self.x2_spinBox)
|
||||
self.setItem(3, 0, QTableWidgetItem('y2'))
|
||||
self.setCellWidget(3, 1, self.y2_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ContourTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ContourTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.bbox_comBox = QComboBox()
|
||||
self.bbox_comBox.addItems(['正常轮廓', '外接矩形', '最小外接矩形', '最小外接圆'])
|
||||
self.bbox_comBox.setObjectName('bbox')
|
||||
|
||||
self.mode_comBox = QComboBox()
|
||||
self.mode_comBox.addItems(['外轮廓', '轮廓列表', '外轮廓与内孔', '轮廓等级树'])
|
||||
self.mode_comBox.setObjectName('mode')
|
||||
|
||||
self.method_comBox = QComboBox()
|
||||
self.method_comBox.addItems(['无近似', '简易近似'])
|
||||
self.method_comBox.setObjectName('method')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(3)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('轮廓模式'))
|
||||
self.setCellWidget(0, 1, self.mode_comBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('轮廓近似'))
|
||||
self.setCellWidget(1, 1, self.method_comBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('边界模式'))
|
||||
self.setCellWidget(2, 1, self.bbox_comBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class EqualizeTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(EqualizeTableWidget, self).__init__(parent=parent)
|
||||
self.red_checkBox = QCheckBox()
|
||||
self.red_checkBox.setObjectName('red')
|
||||
self.red_checkBox.setTristate(False)
|
||||
self.blue_checkBox = QCheckBox()
|
||||
self.blue_checkBox.setObjectName('blue')
|
||||
self.blue_checkBox.setTristate(False)
|
||||
self.green_checkBox = QCheckBox()
|
||||
self.green_checkBox.setObjectName('green')
|
||||
self.green_checkBox.setTristate(False)
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(3)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('R通道'))
|
||||
self.setCellWidget(0, 1, self.red_checkBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('G通道'))
|
||||
self.setCellWidget(1, 1, self.green_checkBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('B通道'))
|
||||
self.setCellWidget(2, 1, self.blue_checkBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HoughLineTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HoughLineTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.thresh_spinBox = QSpinBox()
|
||||
self.thresh_spinBox.setMinimum(0)
|
||||
self.thresh_spinBox.setSingleStep(1)
|
||||
self.thresh_spinBox.setObjectName('thresh')
|
||||
|
||||
self.min_length_spinBox = QSpinBox()
|
||||
self.min_length_spinBox.setMinimum(0)
|
||||
self.min_length_spinBox.setSingleStep(1)
|
||||
self.min_length_spinBox.setObjectName('min_length')
|
||||
|
||||
self.max_gap_spinbox = QSpinBox()
|
||||
self.max_gap_spinbox.setMinimum(0)
|
||||
self.max_gap_spinbox.setSingleStep(1)
|
||||
self.max_gap_spinbox.setObjectName('max_gap')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(3)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('交点阈值'))
|
||||
self.setCellWidget(0, 1, self.thresh_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('最小长度'))
|
||||
self.setCellWidget(1, 1, self.min_length_spinBox)
|
||||
self.setItem(2, 0, QTableWidgetItem('最大间距'))
|
||||
self.setCellWidget(2, 1, self.max_gap_spinbox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class LightTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(LightTableWidget, self).__init__(parent=parent)
|
||||
|
||||
self.alpha_spinBox = QDoubleSpinBox()
|
||||
self.alpha_spinBox.setMinimum(0)
|
||||
self.alpha_spinBox.setMaximum(3)
|
||||
self.alpha_spinBox.setSingleStep(0.1)
|
||||
self.alpha_spinBox.setObjectName('alpha')
|
||||
|
||||
self.beta_spinbox = QSpinBox()
|
||||
self.beta_spinbox.setMinimum(0)
|
||||
self.beta_spinbox.setSingleStep(1)
|
||||
self.beta_spinbox.setObjectName('beta')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('alpha'))
|
||||
self.setCellWidget(0, 1, self.alpha_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('beta'))
|
||||
self.setCellWidget(1, 1, self.beta_spinbox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class GammaITabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(GammaITabelWidget, self).__init__(parent=parent)
|
||||
self.gamma_spinbox = QDoubleSpinBox()
|
||||
self.gamma_spinbox.setMinimum(0)
|
||||
self.gamma_spinbox.setSingleStep(0.1)
|
||||
self.gamma_spinbox.setObjectName('gamma')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('gamma'))
|
||||
self.setCellWidget(0, 1, self.gamma_spinbox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class RotateAnyTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(RotateAnyTabelWidget, self).__init__(parent=parent)
|
||||
self.angle_spinBox = QSpinBox()
|
||||
self.angle_spinBox.setMinimum(0)
|
||||
self.angle_spinBox.setSingleStep(1)
|
||||
self.angle_spinBox.setMaximum(360)
|
||||
self.angle_spinBox.setObjectName('angle')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('旋转角度'))
|
||||
self.setCellWidget(0, 1, self.angle_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ExposureTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ExposureTabelWidget, self).__init__(parent=parent)
|
||||
|
||||
self.alpha_spinBox = QDoubleSpinBox()
|
||||
self.alpha_spinBox.setMinimum(0)
|
||||
self.alpha_spinBox.setMaximum(3)
|
||||
self.alpha_spinBox.setSingleStep(0.1)
|
||||
self.alpha_spinBox.setObjectName('alpha')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('曝光度'))
|
||||
self.setCellWidget(0, 1, self.alpha_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ContrastTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ContrastTabelWidget, self).__init__(parent=parent)
|
||||
|
||||
self.alpha_spinBox = QDoubleSpinBox()
|
||||
self.alpha_spinBox.setMinimum(0)
|
||||
self.alpha_spinBox.setSingleStep(0.1)
|
||||
self.alpha_spinBox.setObjectName('alpha')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
|
||||
self.setItem(0, 0, QTableWidgetItem('对比度'))
|
||||
self.setCellWidget(0, 1, self.alpha_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class ColorTemperatureTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ColorTemperatureTabelWidget, self).__init__(parent=parent)
|
||||
self.alpha_spinBox = QSpinBox()
|
||||
self.alpha_spinBox.setRange(-200, 200)
|
||||
self.alpha_spinBox.setSingleStep(1)
|
||||
self.alpha_spinBox.setObjectName('n')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('色温'))
|
||||
self.setCellWidget(0, 1, self.alpha_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HueTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HueTabelWidget, self).__init__(parent=parent)
|
||||
self.alpha_spinBox = QSpinBox()
|
||||
self.alpha_spinBox.setRange(-200, 200)
|
||||
self.alpha_spinBox.setSingleStep(1)
|
||||
self.alpha_spinBox.setObjectName('n')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('色调'))
|
||||
self.setCellWidget(0, 1, self.alpha_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class SaturationTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(SaturationTabelWidget, self).__init__(parent=parent)
|
||||
self.angle_spinBox = QSpinBox()
|
||||
self.angle_spinBox.setRange(-50, 50)
|
||||
self.angle_spinBox.setSingleStep(1)
|
||||
self.angle_spinBox.setObjectName('x')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('饱和度'))
|
||||
self.setCellWidget(0, 1, self.angle_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class PixelateTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(PixelateTabelWidget, self).__init__(parent=parent)
|
||||
self.size_spinBox = QSpinBox()
|
||||
self.size_spinBox.setRange(1, 1000)
|
||||
self.size_spinBox.setSingleStep(10)
|
||||
self.size_spinBox.setObjectName('size')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('像素大小'))
|
||||
self.setCellWidget(0, 1, self.size_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class BlurTabelWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(BlurTabelWidget, self).__init__(parent=parent)
|
||||
self.size_spinBox = QSpinBox()
|
||||
self.size_spinBox.setRange(1, 100)
|
||||
self.size_spinBox.setSingleStep(1)
|
||||
self.size_spinBox.setObjectName('size')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(1)
|
||||
self.setItem(0, 0, QTableWidgetItem('模糊大小'))
|
||||
self.setCellWidget(0, 1, self.size_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLRedWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLRedWidget, self).__init__(parent=parent)
|
||||
self.red_param_s_spinBox = QDoubleSpinBox()
|
||||
self.red_param_s_spinBox.setMinimum(0)
|
||||
self.red_param_s_spinBox.setSingleStep(0.01)
|
||||
self.red_param_s_spinBox.setMaximum(2)
|
||||
self.red_param_s_spinBox.setObjectName('red_param_s')
|
||||
|
||||
self.red_param_v_spinBox = QDoubleSpinBox()
|
||||
self.red_param_v_spinBox.setMinimum(0)
|
||||
self.red_param_v_spinBox.setSingleStep(0.01)
|
||||
self.red_param_v_spinBox.setMaximum(2)
|
||||
self.red_param_v_spinBox.setObjectName('red_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('红色饱和度'))
|
||||
self.setCellWidget(0, 1, self.red_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('红色亮度'))
|
||||
self.setCellWidget(1, 1, self.red_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLOrangeWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLOrangeWidget, self).__init__(parent=parent)
|
||||
self.orange_param_s_spinBox = QDoubleSpinBox()
|
||||
self.orange_param_s_spinBox.setMinimum(0)
|
||||
self.orange_param_s_spinBox.setSingleStep(0.01)
|
||||
self.orange_param_s_spinBox.setMaximum(2)
|
||||
self.orange_param_s_spinBox.setObjectName('orange_param_s')
|
||||
|
||||
self.orange_param_v_spinBox = QDoubleSpinBox()
|
||||
self.orange_param_v_spinBox.setMinimum(0)
|
||||
self.orange_param_v_spinBox.setSingleStep(0.01)
|
||||
self.orange_param_v_spinBox.setMaximum(2)
|
||||
self.orange_param_v_spinBox.setObjectName('orange_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('橙色饱和度'))
|
||||
self.setCellWidget(0, 1, self.orange_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('橙色亮度'))
|
||||
self.setCellWidget(1, 1, self.orange_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLYellowWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLYellowWidget, self).__init__(parent=parent)
|
||||
self.yellow_param_s_spinBox = QDoubleSpinBox()
|
||||
self.yellow_param_s_spinBox.setMinimum(0)
|
||||
self.yellow_param_s_spinBox.setSingleStep(0.01)
|
||||
self.yellow_param_s_spinBox.setMaximum(2)
|
||||
self.yellow_param_s_spinBox.setObjectName('yellow_param_s')
|
||||
|
||||
self.yellow_param_v_spinBox = QDoubleSpinBox()
|
||||
self.yellow_param_v_spinBox.setMinimum(0)
|
||||
self.yellow_param_v_spinBox.setSingleStep(0.01)
|
||||
self.yellow_param_v_spinBox.setMaximum(2)
|
||||
self.yellow_param_v_spinBox.setObjectName('yellow_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('黄色饱和度'))
|
||||
self.setCellWidget(0, 1, self.yellow_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('黄色亮度'))
|
||||
self.setCellWidget(1, 1, self.yellow_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLGreenWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLGreenWidget, self).__init__(parent=parent)
|
||||
self.green_param_s_spinBox = QDoubleSpinBox()
|
||||
self.green_param_s_spinBox.setMinimum(0)
|
||||
self.green_param_s_spinBox.setSingleStep(0.01)
|
||||
self.green_param_s_spinBox.setMaximum(2)
|
||||
self.green_param_s_spinBox.setObjectName('green_param_s')
|
||||
|
||||
self.green_param_v_spinBox = QDoubleSpinBox()
|
||||
self.green_param_v_spinBox.setMinimum(0)
|
||||
self.green_param_v_spinBox.setSingleStep(0.01)
|
||||
self.green_param_v_spinBox.setMaximum(2)
|
||||
self.green_param_v_spinBox.setObjectName('green_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('绿色饱和度'))
|
||||
self.setCellWidget(0, 1, self.green_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('绿色亮度'))
|
||||
self.setCellWidget(1, 1, self.green_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLCyanWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLCyanWidget, self).__init__(parent=parent)
|
||||
self.cyan_param_s_spinBox = QDoubleSpinBox()
|
||||
self.cyan_param_s_spinBox.setMinimum(0)
|
||||
self.cyan_param_s_spinBox.setSingleStep(0.01)
|
||||
self.cyan_param_s_spinBox.setMaximum(2)
|
||||
self.cyan_param_s_spinBox.setObjectName('cyan_param_s')
|
||||
|
||||
self.cyan_param_v_spinBox = QDoubleSpinBox()
|
||||
self.cyan_param_v_spinBox.setMinimum(0)
|
||||
self.cyan_param_v_spinBox.setSingleStep(0.01)
|
||||
self.cyan_param_v_spinBox.setMaximum(2)
|
||||
self.cyan_param_v_spinBox.setObjectName('cyan_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('青色饱和度'))
|
||||
self.setCellWidget(0, 1, self.cyan_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('青色亮度'))
|
||||
self.setCellWidget(1, 1, self.cyan_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLBlueWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLBlueWidget, self).__init__(parent=parent)
|
||||
self.blue_param_s_spinBox = QDoubleSpinBox()
|
||||
self.blue_param_s_spinBox.setMinimum(0)
|
||||
self.blue_param_s_spinBox.setSingleStep(0.01)
|
||||
self.blue_param_s_spinBox.setMaximum(2)
|
||||
self.blue_param_s_spinBox.setObjectName('blue_param_s')
|
||||
|
||||
self.blue_param_v_spinBox = QDoubleSpinBox()
|
||||
self.blue_param_v_spinBox.setMinimum(0)
|
||||
self.blue_param_v_spinBox.setSingleStep(0.01)
|
||||
self.blue_param_v_spinBox.setMaximum(2)
|
||||
self.blue_param_v_spinBox.setObjectName('blue_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('蓝色饱和度'))
|
||||
self.setCellWidget(0, 1, self.blue_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('蓝色亮度'))
|
||||
self.setCellWidget(1, 1, self.blue_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class HSLPurpleWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(HSLPurpleWidget, self).__init__(parent=parent)
|
||||
self.purple_param_s_spinBox = QDoubleSpinBox()
|
||||
self.purple_param_s_spinBox.setMinimum(0)
|
||||
self.purple_param_s_spinBox.setSingleStep(0.01)
|
||||
self.purple_param_s_spinBox.setMaximum(2)
|
||||
self.purple_param_s_spinBox.setObjectName('purple_param_s')
|
||||
|
||||
self.purple_param_v_spinBox = QDoubleSpinBox()
|
||||
self.purple_param_v_spinBox.setMinimum(0)
|
||||
self.purple_param_v_spinBox.setSingleStep(0.01)
|
||||
self.purple_param_v_spinBox.setMaximum(2)
|
||||
self.purple_param_v_spinBox.setObjectName('purple_param_v')
|
||||
|
||||
self.setColumnCount(2)
|
||||
self.setRowCount(2)
|
||||
self.setItem(0, 0, QTableWidgetItem('紫色饱和度'))
|
||||
self.setCellWidget(0, 1, self.purple_param_v_spinBox)
|
||||
self.setItem(1, 0, QTableWidgetItem('紫色亮度'))
|
||||
self.setCellWidget(1, 1, self.purple_param_s_spinBox)
|
||||
self.signal_connect()
|
||||
|
||||
|
||||
class StyleTransformTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(StyleTransformTableWidget, self).__init__(parent=parent)
|
||||
|
||||
|
||||
class RotateLeftTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(RotateLeftTableWidget, self).__init__(parent=parent)
|
||||
|
||||
|
||||
class RotateRightTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(RotateRightTableWidget, self).__init__(parent=parent)
|
||||
|
||||
|
||||
class UpDownTableWidget(TableWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(UpDownTableWidget, self).__init__(parent=parent)
|
@ -0,0 +1,35 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
|
||||
class FileSystemTreeView(QTreeView, QDockWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.mainwindow = parent
|
||||
self.fileSystemModel = QFileSystemModel()
|
||||
self.fileSystemModel.setRootPath('.')
|
||||
self.setModel(self.fileSystemModel)
|
||||
# 隐藏size,date等列
|
||||
self.setColumnWidth(0, 200)
|
||||
self.setColumnHidden(1, True)
|
||||
self.setColumnHidden(2, True)
|
||||
self.setColumnHidden(3, True)
|
||||
# 不显示标题栏
|
||||
self.header().hide()
|
||||
# 设置动画
|
||||
self.setAnimated(True)
|
||||
# 选中不显示虚线
|
||||
self.setFocusPolicy(Qt.NoFocus)
|
||||
self.doubleClicked.connect(self.select_image)
|
||||
self.setMinimumWidth(200)
|
||||
|
||||
def select_image(self, file_index):
|
||||
file_name = self.fileSystemModel.filePath(file_index)
|
||||
if file_name.endswith(('.jpg', '.png', '.bmp')):
|
||||
src_img = cv2.imdecode(np.fromfile(file_name, dtype=np.uint8), -1)
|
||||
self.mainwindow.change_image(src_img)
|
||||
|
||||
|
||||
|
@ -0,0 +1,96 @@
|
||||
import cv2
|
||||
|
||||
GRAYING_STACKED_WIDGET = 0
|
||||
FILTER_STACKED_WIDGET = 1
|
||||
MORPH_STACKED_WIDGET = 2
|
||||
GRAD_STACKED_WIDGET = 3
|
||||
THRESH_STACKED_WIDGET = 4
|
||||
EDGE_STACKED_WIDGET = 5
|
||||
|
||||
BGR2GRAY_COLOR = 0
|
||||
GRAY2BGR_COLOR = 1
|
||||
COLOR = {
|
||||
BGR2GRAY_COLOR: cv2.COLOR_BGR2GRAY,
|
||||
GRAY2BGR_COLOR: cv2.COLOR_GRAY2BGR
|
||||
}
|
||||
|
||||
MEAN_FILTER = 0
|
||||
GAUSSIAN_FILTER = 1
|
||||
MEDIAN_FILTER = 2
|
||||
|
||||
ERODE_MORPH_OP = 0
|
||||
DILATE_MORPH_OP = 1
|
||||
OPEN_MORPH_OP = 2
|
||||
CLOSE_MORPH_OP = 3
|
||||
GRADIENT_MORPH_OP = 4
|
||||
TOPHAT_MORPH_OP = 5
|
||||
BLACKHAT_MORPH_OP = 6
|
||||
|
||||
MORPH_OP = {
|
||||
ERODE_MORPH_OP: cv2.MORPH_ERODE,
|
||||
DILATE_MORPH_OP: cv2.MORPH_DILATE,
|
||||
OPEN_MORPH_OP: cv2.MORPH_OPEN,
|
||||
CLOSE_MORPH_OP: cv2.MORPH_CLOSE,
|
||||
GRADIENT_MORPH_OP: cv2.MORPH_GRADIENT,
|
||||
TOPHAT_MORPH_OP: cv2.MORPH_TOPHAT,
|
||||
BLACKHAT_MORPH_OP: cv2.MORPH_BLACKHAT
|
||||
}
|
||||
|
||||
RECT_MORPH_SHAPE = 0
|
||||
CROSS_MORPH_SHAPE = 1
|
||||
ELLIPSE_MORPH_SHAPE = 2
|
||||
|
||||
MORPH_SHAPE = {
|
||||
RECT_MORPH_SHAPE: cv2.MORPH_RECT,
|
||||
CROSS_MORPH_SHAPE: cv2.MORPH_CROSS,
|
||||
ELLIPSE_MORPH_SHAPE: cv2.MORPH_ELLIPSE
|
||||
}
|
||||
|
||||
SOBEL_GRAD = 0
|
||||
SCHARR_GRAD = 1
|
||||
LAPLACIAN_GRAD = 2
|
||||
|
||||
BINARY_THRESH_METHOD = 0
|
||||
BINARY_INV_THRESH_METHOD = 1
|
||||
TRUNC_THRESH_METHOD = 2
|
||||
TOZERO_THRESH_METHOD = 3
|
||||
TOZERO_INV_THRESH_METHOD = 4
|
||||
OTSU_THRESH_METHOD = 5
|
||||
THRESH_METHOD = {
|
||||
BINARY_THRESH_METHOD: cv2.THRESH_BINARY, # 0
|
||||
BINARY_INV_THRESH_METHOD: cv2.THRESH_BINARY_INV, # 1
|
||||
TRUNC_THRESH_METHOD: cv2.THRESH_TRUNC, # 2
|
||||
TOZERO_THRESH_METHOD: cv2.THRESH_TOZERO, # 3
|
||||
TOZERO_INV_THRESH_METHOD: cv2.THRESH_TOZERO_INV, # 4
|
||||
OTSU_THRESH_METHOD: cv2.THRESH_OTSU # 5
|
||||
}
|
||||
|
||||
EXTERNAL_CONTOUR_MODE = 0
|
||||
LIST_CONTOUR_MODE = 1
|
||||
CCOMP_CONTOUR_MODE = 2
|
||||
TREE_CONTOUR_MODE = 3
|
||||
CONTOUR_MODE = {
|
||||
EXTERNAL_CONTOUR_MODE: cv2.RETR_EXTERNAL,
|
||||
LIST_CONTOUR_MODE: cv2.RETR_LIST,
|
||||
CCOMP_CONTOUR_MODE: cv2.RETR_CCOMP,
|
||||
TREE_CONTOUR_MODE: cv2.RETR_TREE
|
||||
}
|
||||
|
||||
NONE_CONTOUR_METHOD = 0
|
||||
SIMPLE_CONTOUR_METHOD = 1
|
||||
CONTOUR_METHOD = {
|
||||
NONE_CONTOUR_METHOD: cv2.CHAIN_APPROX_NONE,
|
||||
SIMPLE_CONTOUR_METHOD: cv2.CHAIN_APPROX_SIMPLE
|
||||
}
|
||||
|
||||
NORMAL_CONTOUR = 0
|
||||
RECT_CONTOUR = 1
|
||||
MINRECT_CONTOUR = 2
|
||||
MINCIRCLE_CONTOUR = 3
|
||||
|
||||
|
||||
# 均衡化
|
||||
BLUE_CHANNEL = 0
|
||||
GREEN_CHANNEL = 1
|
||||
RED_CHANNEL = 2
|
||||
ALL_CHANNEL = 3
|
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 862 B |
After Width: | Height: | Size: 833 B |
After Width: | Height: | Size: 465 B |