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