OpenCV

Creating rectangle within a blob using OpenCV

爱⌒轻易说出口 提交于 2021-02-04 13:52:14
问题 Input Image: Output Image: I have several colored blobs in an image and I'm trying to create rectangles (or squares--which seems to be much easier) inside the largest blob of each color. I've found the answer to how to create a rectangle that bounds a single largest blob, but am unsure as to how to find a square that simply fits inside a blob. It doesn't have to be the largest, it just has to be larger than a certain area otherwise I just won't include it. I've also seen some work done on

Bad disparity map using StereoBM in OpenCV

痴心易碎 提交于 2021-02-04 10:49:06
问题 I've put together a stereo cam rig and am having trouble using it to produce a good disparity map. Here's an example of two rectified images and the disparity map I produced with them: As you can see, the results are pretty bad. Changing the StereoBM's settings doesn't change much. The setup Both cameras are the same model and connect to my computer with USB. They are fixed to a rigid wooden board so that they don't move. I aligned them as best I could, but of course it's not perfect. They

cv2.matchTemplate finds wrong template in image

非 Y 不嫁゛ 提交于 2021-02-04 05:11:54
问题 I'm trying to create a program that knows what number is on an image with the following function: def img_in_img(big_picture, small_picture, tamper): big_picture = str(big_picture) small_picture = str(small_picture) if os.path.isfile(big_picture) == False or os.path.isfile(small_picture) == False: return "Image does not exist" img = cv2.imread(big_picture,0) templace_loc = small_picture template = cv2.imread(templace_loc,0) w, h = template.shape[::-1] method = cv2.TM_CCOEFF tamper = int

cv2.matchTemplate finds wrong template in image

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-04 05:09:12
问题 I'm trying to create a program that knows what number is on an image with the following function: def img_in_img(big_picture, small_picture, tamper): big_picture = str(big_picture) small_picture = str(small_picture) if os.path.isfile(big_picture) == False or os.path.isfile(small_picture) == False: return "Image does not exist" img = cv2.imread(big_picture,0) templace_loc = small_picture template = cv2.imread(templace_loc,0) w, h = template.shape[::-1] method = cv2.TM_CCOEFF tamper = int

cv2.matchTemplate finds wrong template in image

廉价感情. 提交于 2021-02-04 05:08:37
问题 I'm trying to create a program that knows what number is on an image with the following function: def img_in_img(big_picture, small_picture, tamper): big_picture = str(big_picture) small_picture = str(small_picture) if os.path.isfile(big_picture) == False or os.path.isfile(small_picture) == False: return "Image does not exist" img = cv2.imread(big_picture,0) templace_loc = small_picture template = cv2.imread(templace_loc,0) w, h = template.shape[::-1] method = cv2.TM_CCOEFF tamper = int

opencv 视觉项目学习笔记(二): 基于 svm 和 knn 车牌识别

寵の児 提交于 2021-02-03 07:35:10
车牌识别的属于常见的 模式识别 , 其基本流程为下面三个步骤: 1) 分割: 检测并检测图像中感兴趣区域; 2)特征提取: 对字符图像集中的每个部分进行提取; 3)分类: 判断图像快是不是车牌或者 每个车牌字符的分类。 车牌识别分为两个步骤, 车牌检测, 车牌识别, 都属于模式识别 。 基本结构如下: 一、车牌检测   1、车牌局部化(分割车牌区域),根据尺寸等基本信息去除非车牌图像;   2、判断车牌是否存在 (训练支持向量机 -svm, 判断车牌是否存在)。 二、车牌识别   1、字符局部化(分割字符),根据尺寸等信息剔除不合格图像   2、字符识别 ( knn 分类) 1.1 车牌局部化、并剔除不合格区域   vector<Plate> DetectRegions::segment(Mat input) { vector <Plate> output; // 转为灰度图,并去噪 Mat img_gray; cvtColor(input, img_gray, CV_BGR2GRAY); blur(img_gray, img_gray, Size( 5 , 5 )); // 找垂直边 Mat img_sobel; Sobel(img_gray, img_sobel, CV_8U, 1 , 0 , 3 , 1 , 0 , BORDER_DEFAULT); // 阈值化过滤像素

OpenCV-几何变换-移动、旋转、仿射变换

半腔热情 提交于 2021-02-02 10:00:56
OpenCV 提供了两个变换函数, cv2.warpAffine 和 cv2.warpPerspective ,使用这两个函数你可以实现所有类型的变换。 cv2.warpAffine 接收的参数是2 × 3 的变换矩阵,而 cv2.warpPerspective 接收的参数是 3 × 3 的变换矩阵。 扩展缩放    方法: resize(src, dsize, dst=None, fx=None, fy=None, interpolation=None)      dsize 为缩放大小          fx,fy 为影响因子      interpolation 为插值算法(在缩放时推荐使用 cv2.INTER_AREA ,在扩展时推荐使用 cv2.INTER_CUBIC (慢) 和 cv2.INTER_LINEAR 。默认情况下所有改变图像尺寸大小的操作使用的插值方法都是 cv2.INTER_LINEAR ) 1 import numpy as np 2 import cv2 3 4 img1 = cv2.imread( " ../image/min.jpg " ) 5 6 # 方式一 7 img2 = cv2.resize(img1, None, fx=2, fy=2, interpolation= cv2.INTER_CUBIC) 8 9 # 方式二 10 height

关于python安装第三方库速度慢解决方案(opencv为例)

守給你的承諾、 提交于 2021-02-02 08:51:29
安装时使用国内镜像链接 阿里云 http:// mirrors.aliyun.com/pypi /simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http:// pypi.douban.com/simple/ 清华大学 https:// pypi.tuna.tsinghua.edu.cn /simple/ 中国科学技术大学 http:// pypi.mirrors.ustc.edu.cn /simple/ 使用指令指定源: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python 秒秒种成功安装 还有scarpy安装很烦 所以使用conda install scrapy也很快(必须安装anaconda) 来源: oschina 链接: https://my.oschina.net/u/4269500/blog/3626548

[Python图像处理] 三十六.OpenCV图像几何变换万字详解(平移缩放旋转、镜像仿射透视)

北慕城南 提交于 2021-02-02 08:22:22
该系列文章是讲解Python OpenCV图像处理知识,前期主要讲解图像入门、OpenCV基础用法,中期讲解图像处理的各种算法,包括图像锐化算子、图像增强技术、图像分割等,后期结合深度学习研究图像识别、图像分类应用。希望文章对您有所帮助,如果有不足之处,还请海涵~ 前面一篇文章介绍了OpenCV图像处理入门知识、算数逻辑运算与图像融合。这篇文章将介绍图像几何变换,包括:图像平移变换、图像缩放变换、图像旋转变换、图像镜像变换、图像仿射变换和图像透视变换,万字长文整理,希望对您有所帮助。 同时,该部分知识均为作者查阅资料撰写总结,并且开设成了收费专栏,为小宝赚点奶粉钱,感谢您的抬爱。当然如果您是在读学生或经济拮据,可以私聊我给你每篇文章开白名单,或者转发原文给你,更希望您能进步,一起加油喔~ https://github.com/eastmountyxz/ImageProcessing-Python 文章目录 一.图像几何变换概述 二.图像平移变换 三.图像缩放变换 四.图像旋转变换 五.图像镜像变换 六.图像仿射变换 七.图像透视变换 八.总结 前文参考: [Python图像处理] 一.图像处理基础知识及OpenCV入门函数 [Python图像处理] 二.OpenCV+Numpy库读取与修改像素 [Python图像处理] 三.获取图像属性、兴趣ROI区域及通道处理

Python实现RGB和Lab颜色空间互转

心不动则不痛 提交于 2021-02-02 07:20:28
Python实现RGB和Lab颜色空间互转 https://github.com/rubund/debian-home-assistant/blob/1a3e8f7e4b9ddec60a4380e141fb327d03ac69b5/homeassistant/util/color.py 在网上找了一圈,只找到C++版本的,有个python版本的只有RGB转Lab,只好自己写了。 C++版本传送门 ,这里把原理已经写的很清楚了,我只是比葫芦画瓢的写个python版本,没做任何优化。只有一点需要小心,opencv读取的图像格式是[b,g,r],剩下的就是按公式写代码了。 # -*- coding: utf-8 -*- # 提供图像处理辅助函数,色彩空间转换 # @Author : BQH # @File : tools.py # @Date : 2018-11-07 import numpy as np import cv2 # region 辅助函数 # RGB2XYZ空间的系数矩阵 M = np.array([[0.412453, 0.357580, 0.180423], [0.212671, 0.715160, 0.072169], [0.019334, 0.119193, 0.950227]]) # im_channel取值范围:[0,1] def f(im_channel):