OpenCV 方法及应用速查表

序  号方    法说    明技术分类
1image = cv2.imread(filename, flags)读取图像基本操作
2cv2.imshow(winname, mat)显示图像基本操作
3cv2.destroyAllWindows()销毁所有正在显示图像的窗口基本操作
4cv2.imwrite(filename, img)保存图像基本操作
5dst = cv2.cvtColor(src, code)转换色彩空间图像基础
6h, s, v = cv2.split(hsv_image)拆分图像通道图像基础
7bgr = cv2.merge([b, g, r])合并通道图像基础
8img = numpy.zeros((height, width), np.uint8)纯黑图像图像基础
9img = numpy.ones((height, width), np.uint8) * 255纯白图像图像基础
10img = numpy.hstack((img1,img2))水平拼接图像基础
11img = numpy.vstack((img1,img2))垂直拼接图像基础
12cv2.line(img, pt1, pt2, color, thickness)绘制线段绘图
13cv2.rectangle(img, pt1, pt2, color, thickness)绘制矩形绘图
14cv2.circle(img, center, radius, color, thickness)绘制圆形绘图
15cv2.polylines(img, pts, isClosed, color, thickness)绘制多边形绘图
16cv2.putText(img, text, org, fontFace, fontScale, color, thickness, lineType, bottomLeftOrigin)绘制文字绘图
17retval, dst = cv2.threshold(src, thresh, maxval, type)阈值处理阈值处理
18dst = cv2.adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C)自适应阈值阈值处理
19dst = cv2.resize(src, dsize, fx, fy, interpolation)缩放几何变换
20dst = cv2.flip(src, flipCode)翻转几何变换
21dst = cv2.warpAffine(src, M, dsize, flags, borderMode, borderValue)仿射几何变换
22M = cv2.getRotationMatrix2D(center, angle, scale)计算旋转 M 矩阵几何变换
23M = cv2.getAffineTransform(src, dst)计算仿射 M 矩阵几何变换
24dst = cv2.warpPerspective(src, M, dsize, flags, borderMode, borderValue)透视几何变换
25M = cv2.getPerspectiveTransform(src, dst)计算透视 M 矩阵几何变换
26dst = cv2.add(src1, src2, mask, dtype)图像加运算图像运算
27dst = cv2.bitwise_and(src1, src2, mask)图像与运算图像运算
28dst = cv2.bitwise_or(src1, src2, mask)图像或运算图像运算
29dst = cv2.bitwise_not(src, mask)图像取反运算图像运算
30dst = cv2.bitwise_xor(src, mask)图像异或运算图像运算
31dst = cv2.addWeighted(src1, alpha, src2, beta, gamma)图像加权和运算图像运算
32dst = cv2.blur(src, ksize, anchor, borderType)均值滤波平滑处理
33dst = cv2.medianBlur(src, ksize)中值滤波平滑处理
34dst = cv2.GaussianBlur(src, ksize, sigmaX, sigmaY, borderType)高斯滤波平滑处理
35dst = cv2.bilateralFilter(src, d, sigmaColor, sigmaSpace, borderType)双边滤波平滑处理
36dst = cv2.erode(src, kernel, anchor, iterations, borderType, borderValue)腐蚀形态学操作
37dst = cv2.dilate(src, kernel, anchor, iterations, borderType, borderValue)膨胀形态学操作
38dst = cv2.morphologyEx(src, op, kernel, anchor, iterations, borderType, borderValue)形态学运算形态学操作
39contours, hierarchy = cv2.findContours(image, mode, methode)检测轮廓轮廓检测
40image = cv2.drawContours(image, contours, contourIdx, color, thickness, lineTypee, hierarchy, maxLevel, offse)绘制轮廓轮廓检测
41retval = cv2.boundingRect (array)最小矩形包围框轮廓检测
42center, radius = cv2.minEnclosingCircle(points)最小圆形包围框轮廓检测
43hull = cv2.convexHull(points, clockwise, returnPoints)获取凸包轮廓检测
44edges = cv2.Canny(image, threshold1, threshold2, apertureSize, L2gradient)Canny 边缘检测边缘检测
45lines = cv2.HoughLinesP(image, rho, theta, threshold, minLineLength, maxLineGap)检测直线霍夫变换
46circles = cv2.HoughCircles(image, method, dp, minDist, param1, param2, minRadius, maxRadius)检测圆环霍夫变换
47result = cv2.matchTemplate(image, templ, method, mask)模板匹配模板匹配
48minValue, maxValue, minLoc, maxLoc = cv2.minMaxLoc(src, mask)解析二维数组中的最大值、最 小值以及这两个值对应的位置模板匹配
49capture = cv2.VideoCapture(index)获取摄像头摄像头操作
50retval = cv2.VideoCapture.isOpened()检验摄像头初始化是否成功摄像头操作
51cv2.VideoCapture.read()读取一帧摄像头操作
52cv2.VideoCapture.release()释放摄像头摄像头操作
53video = cv2.VideoCapture(filename)读取视频文件视频文件操作
54retval = cv2.VideoCapture.get(propId)获取视频文件的属性视频文件操作
55<VideoWriter object> = cv2.VideoWriter(filename, fourcc, fps, frameSize)创建视频输出流,保存视频文件视频文件操作
56cv2.VideoWriter.write(frame)保存视频文件( 简写方式)视频文件操作
57cv2.VideoWriter.release()释放视频输出流视频文件操作
58<CascadeClassifier object> = cv2.CascadeClassifier(filename)加载级联分类器人脸识别
59objects = cascade.detectMultiScale(image, scaleFactor, minNeighbors, flags, minSize, maxSize)级联分类器对象识别图像人脸识别
60recognizer = cv2.face.EigenFaceRecognizer_create(num_components, threshold)创建 Eigenfaces人脸识别器人脸识别
61recognizer = cv2.face.FisherFaceRecognizer_create(num_components, threshold)创建 Fisherfaces 人脸识别器人脸识别
62recognizer = cv2.face.LBPHFaceRecognizer_create(radius, neighbors, grid_x, grid_y, threshold)创建 LBPH人脸识别器人脸识别
63recognizer.train(src, labels)训练人脸识别器人脸识别
64label, confidence = recognizer.predict(src)人脸识别器对图像进行识别人脸识别
posted @   天天代码码天天  阅读(25)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示