没有合适的资源?快使用搜索试试~ 我知道了~
python学习随笔03 Opencv提取轮廓,对轮廓识别后,判断轮廓形状
30 下载量 86 浏览量
2021-01-06
14:21:19
上传
评论 1
收藏 59KB PDF 举报
温馨提示
试读
5页
''' @Author: your name @Date: 2020-02-13 13:30:07 @LastEditTime: 2020-02-20 16:17:34 @LastEditors: Please set LastEditors @Description: 高斯平滑展示,边缘检测展示, 能够通过按键时时控制高斯平滑,高斯选择改变后改变高斯图和边缘检测图 边缘检测通过右侧两个滑条更改检测阈值 加入圆形检测 ''' import tkinter import os import cv2 import
资源推荐
资源详情
资源评论
python学习随笔学习随笔03 Opencv提取轮廓,对轮廓识别后,判断轮提取轮廓,对轮廓识别后,判断轮
廓形状廓形状
'''
@Author: your name
@Date: 2020-02-13 13:30:07
@LastEditTime: 2020-02-20 16:17:34
@LastEditors: Please set LastEditors
@Description: 高斯平滑展示,边缘检测展示,
能够通过按键时时控制高斯平滑,高斯选择改变后改变高斯图和边缘检测图
边缘检测通过右侧两个滑条更改检测阈值
加入圆形检测
'''
import tkinter
import os
import cv2
import numpy
from PIL import Image,ImageTk
from tkinter import filedialog
# global start 全局变量定义初始化开始
#全局变量参数
carmela_hight = 200
carmela_width = 200
#Tkinter元素句柄参数
Source_Img_Label = None
Gray_Img_Label = None
Canny_Img_Label = None
Circles_Img_Label = None
Gaussian_Button = None
Counters_Button = None
Threshold_Min_Scale = None
Threshold_Max_Scale = None
Hough_Parm1_Scale = None
Hough_Parm2_Scale = None
#开关量参数
Gaussian_Enable = False
Counters_Enable = False
#获取当前文件路径
py_path=os.path.abspath(os.path.dirname(__file__))
#global end 全局变量定义初始化结束
#创建窗口对象以及窗口使用变量
root = tkinter.Tk()
Img_Path_String = tkinter.StringVar()
Img_Path_String.set('尚未选择文件')
Dp_Value = tkinter.StringVar()
Dp_Value.set('1')
#窗口使用变量初始化开始
screen_Width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
width = screen_Width//2
height = screen_height//2+50
root_win_par = '%dx%d+%d+%d'% (width, height, (screen_Width-width)/2, (screen_height-height)/2)
#窗口使用变量初始化结束
def resizeImage(image, width, height, inter=cv2.INTER_AREA):
size = image.shape
h, w = size[0], size[1] #长边缩放为min_side
min_side = min(width,height)
scale = max(w, h) / float(min_side)
new_w, new_h = int(w/scale), int(h/scale)
resize_img = cv2.resize(image, (new_w, new_h))
# 填充至min_side * min_side
if new_w % 2 != 0 and new_h % 2 == 0:
top, bottom, left, right = (min_side-new_h)/2, (min_side-new_h)/2, (min_side-new_w)/2 + 1, (min_side-new_w)/2
elif new_h % 2 != 0 and new_w % 2 == 0:
top, bottom, left, right = (min_side-new_h)/2 + 1, (min_side-new_h)/2, (min_side-new_w)/2, (min_side-new_w)/2
elif new_h % 2 == 0 and new_w % 2 == 0:
top, bottom, left, right = (min_side-new_h)/2, (min_side-new_h)/2, (min_side-new_w)/2, (min_side-new_w)/2
资源评论
假装高冷小姐姐
- 粉丝: 281
- 资源: 948
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功