OpenCV基础知识
叙述OpenCV的基础知识
sxj731533730
Sighic Limit
展开
-
25、opencv的仿射变换
基本思想:opencv仿射变换不是太准,存在于嵌套仿射的情况,存在这样的问题,在角点的四个外围坐标仿射为正向坐标之后,通过仿射矩阵M去计算内部存在的嵌套矩形框,计算存在偏差,同时以截图为遮挡,仿射的外围四个角点还是存在误差的,需要添加平移参数调整。原创 2022-11-03 13:54:26 · 959 阅读 · 0 评论 -
24、OpenCV使用两种方法对图片进行均值和方差运算
基本思想,使用直接访问Mat元素的方式和使用opencv函数方式对图片进行均值和方差运算,只要用在深度学习图片预处理中#include <iostream>#include<opencv2/core.hpp>#include<opencv2/imgproc.hpp>#include<opencv2/highgui.hpp>//depth:深度,即每一个像素的位数(bits),在opencv的Mat.depth()中得到的是一个 0 – 6 的数字原创 2022-01-23 16:23:55 · 3813 阅读 · 0 评论 -
23、使用OpenCV和NCNN进行人物抠图并将背景设置成透明色
#include<iostream>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <iostream>#include <vector>#include <algorithm>using namespace cv;usin.原创 2021-09-23 20:46:19 · 4793 阅读 · 11 评论 -
3、Opencv 进行区域的面积计算
基本思想:对一个多边形使用opencv进行面积计算(使用起内部实现方式的向量计算法)进行计算#include <opencv2/opencv.hpp>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <iostream>using namespace std;using namespace cv;int main() { .原创 2021-01-23 20:26:41 · 8618 阅读 · 1 评论 -
22、使用Opencv的circle函数绘制圆转成使用polylines函数绘制圆,并将外轮廓坐标点输出
基本思想:使用opencv的 circle(circleImg, Point(100, 50), 40, Scalar(255, 255, 255), 1, 8)函数绘制圆形,转成使用polylines(img, circlePoint, false, Scalar(255, 255, 255), 1, 8)绘制,并输出绘制的关键点,其实本菜鸟就是为了得到圆的外轮廓坐标点Clion工具CMakeLists.txtcmake_minimum_required(VERSION 3.16)proj原创 2021-09-10 11:51:28 · 831 阅读 · 3 评论 -
21、使用Opencv进行递归文件目录读取和txt文本写入
基本思想:最近想测试一下人证比对算法的准确性,写了个opecv简单递归目录的代码// 进行人证比对算法测试#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <iostream>#include <vector>using namespace cv;using namespace std;int main(){原创 2021-08-23 15:26:18 · 419 阅读 · 0 评论 -
20、Opencv4.4 将两张图片进行黏贴
基本思想:将某人的身份证信息贴到另一张图片的指定位置#include <iostream>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>using namespace cv;using namespace std;int main() { cv::Mat mat = cv::imread("F:\\1.jpg"); cv::imsh原创 2021-05-14 17:34:47 · 332 阅读 · 1 评论 -
19、Opencv4.4的仿射矩阵处理
基本思想:深入学习一下仿射矩阵的使用和分解 环境 window10+Mingw32+Opencv4.4.0+Eigen这里仅说明一下Eigen库的导入方法,首先去Eigen官网下载Eigen源码,解压导入Clion工程中,修改CMakeLists.txt, 配置Opencv4.4.0试一下Reflectabout origin的方法CMakeLists.txtcmake_minimum_required(VERSION 3.17)project(untitled6)se..原创 2021-01-16 09:50:44 · 506 阅读 · 0 评论 -
18、window10+Clion2022+minGW编译opencv4.4.0+opencv_contrib4.4.0并测试
基本思想:在window10想配置一下opencv4.4.0,同时导入clion2020.1中使用,逐记录一下;首先下载minGW工具和opencv4.4.0源码minGW:可以自行下载https://sourceforge.net/projects/mingw-w64/files/?source=navbar;建议使用window10 自带的linux 内核下载离线安装包, 这样比较快~ axel -n 100 https://sourceforge.net/projects/min...原创 2021-01-16 09:54:38 · 2151 阅读 · 2 评论 -
17、OpenCV灰度翻转\增强\压缩\伽马变化
基本思想:基本原理参考OpenCV手册,此处只记录一下如何使用;#include<opencv2/opencv.hpp>#include<iostream>#include<vector>using namespace std;using namespace cv;int main() { Mat img = imread("/home/ubuntu/Downloads/a.jpeg"); cout << img.col原创 2021-01-17 23:17:46 · 622 阅读 · 0 评论 -
16、OpenCV4.4分离通道及通道合并
基本思想:因为考试华为中级AI需要,简单记录一下复习的图像知识,使用OpenCV进行像素通道的分离和合并#include<opencv2/opencv.hpp>#include<iostream>#include<vector>using namespace std;using namespace cv;int main() { Mat img = imread("/home/ubuntu/Downloads/a.jpeg"); c原创 2021-01-18 10:42:08 · 510 阅读 · 0 评论 -
15、Opencv4.4仿射变化
基本思想:对图像进行仿射处理#include <opencv2/opencv.hpp>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <iostream>using namespace std;using namespace cv;int main() { Point2f srcTriangle[3]; Point原创 2020-06-18 20:36:11 · 237 阅读 · 0 评论 -
14、OpenCV4.4进行区域的相交比计算
基本思想:进行两个区域的相交比计算#include <opencv2/opencv.hpp>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <iostream>using namespace std;using namespace cv;int main() { //Mat test = imread("/..原创 2020-06-17 21:14:36 · 1431 阅读 · 0 评论 -
13、OpenCV4.4 仿射变换
Parameters: src– Coordinates of triangle vertices in the source image. dst– Coordinates of the corresponding triangle vertices in the destination image. The function calculates the...原创 2019-06-30 21:03:52 · 237 阅读 · 0 评论 -
5、openCV 图像尺寸调整
# -*- coding: utf-8 -*-import cv2, matplotlibimport numpy as npimport matplotlib.pyplot as pltimage = cv2.imread('1.jpg')width = image.shape[0]height = image.shape[1]resizeImg = cv2.resize(ima...原创 2019-05-02 15:56:58 · 3231 阅读 · 2 评论 -
6、OpenCV4.4图像旋转及位移
对一个图像进行旋转和位移:cv2.getRotationMatrix2Dcv2.warpAffine# -*- coding: utf-8 -*- import cv2 import numpy as np img = cv2.imread('1.png') x,y,c=img.shape rotMat = cv2.getRotationMatrix2D...原创 2019-05-08 10:39:13 · 581 阅读 · 0 评论 -
7、OpenCV翻转及复制
Python:cv.Flip(src, dst=None,flipMode=0)→ None¶Parameters: src– input array. dst– output array of the same size and type assrc. flipCode– a flag to specify how toflipthe arra...原创 2019-05-08 12:26:30 · 337 阅读 · 0 评论 -
8、OpenCV4.4绘图-圆
cv2.circle(empty,center,radius,color,thickness)# -*- coding: utf-8 -*-import cv2import numpy as npempty = np.zeros([300,500],np.uint8) x,y=empty.shapecenter=tuple([x/3,y/3])#tuple要转换为元组的序列ra...原创 2019-05-08 12:55:06 · 367 阅读 · 0 评论 -
9、OpenCV4.4 色彩抽出
色彩的空间变换# -*- coding: utf-8 -*-import cv2import numpy as nporiginal = cv2.imread('1.jpg', 1)img = original.copy()#副本dst = np.zeros(img.shape,np.uint8)#创建相同的图像矩阵hsv = cv2.cvtColor(img,cv2.COL...原创 2019-05-08 13:23:48 · 222 阅读 · 0 评论 -
10、OpenCV像素处理
Python:cv2.split(m[, mv])→ mv 直译:一个通道数组拆分多数组Python:cv2.merge(mv[, dst])→ dst¶直译:多通道数组合并为单数组# -*- coding: utf-8 -*-import cv2import numpy as npimport matplotlibimport matplotlib.pyplot as...原创 2019-05-08 13:51:55 · 266 阅读 · 0 评论 -
11、OpenCV图像二值化处理
Python:cv.Threshold(src, dst,threshold, maxValue,thresholdType)→ NoneParameters: src– input array (single-channel, 8-bit or 32-bit floating point). dst– output array of the same ...原创 2019-05-08 17:08:41 · 346 阅读 · 0 评论 -
2、openCV图像加载
# -*- coding: utf-8 -*-import cv2img = cv2.imread('1.jpg')#Python: cv2.imread(filename[, flags]) → retva 技术手册显示的函数原型,# imread 表示图片读入 其函数含义为 image read ===>imread # 其参数为 第一个为图片名 第二个为参数可选 具体含...原创 2019-05-01 11:17:31 · 245 阅读 · 0 评论 -
1、OpenCV4.4 图片生成
# -*- coding: utf-8 -*-import numpy as npimport cv2#width = 3#height = 3width = 300height = 300pixel = np.array([255,0,0],np.uint8)#numpy.array(object, dtype = None, copy = True, order = None...原创 2019-05-01 14:20:21 · 2632 阅读 · 0 评论 -
12、OpenCV4.4的图像物体跟踪
Parameters: src– First source array. lowerb– Inclusive lower boundary array or a scalar. upperb– Inclusive upper boundary array or a scalar. dst– Destination array of the same s...原创 2019-06-30 00:03:07 · 437 阅读 · 0 评论 -
4、openCV 图像像素
# -*- coding: utf-8 -*-import cv2, matplotlibimport numpy as npimport matplotlib.pyplot as pltcols = 640rows = 480image = cv2.imread('2.jpg')print image.shapewidth = image.shape[0]height = i...原创 2019-05-02 12:43:44 · 201 阅读 · 0 评论