OpenCV官方文档阅读笔记

作者: 深度学习模型优化 | 来源:发表于2019-04-14 09:12 被阅读0次

    1 OpenCV简介

    import cv2
    import numpy as np
    from matplotlib import pyplot as  plt
    

    2 OpenCV的GUI使用

    • OpenCV的GUI使用-Gui Features in OpenCV

      Here you will learn how to display and save images and videos, control mouse events and create trackbar.
      学习如何显示和保存图像和视频,鼠标操作事件响应和创建跟踪条。

    # images
    cv2.imread()
    cv2.imshow()
    cv2.imwrite()
    
    # video
    cv2.VideoCapture()
    cv2.VideoWriter()
    
    # drawing function
    cv2.line()
    cv2.circle()
    cv2.rectangle()
    cv2.ellipse()
    cv2.putText()
    
    # mouse key event
    cv2.setMouseCallback()
    
    # trackbar
    cv2.getTrackbarPos()
    cv2.createTrackbar()
    

    3 OpenCV的核心操作

    • 核心操作-Core Operations

      In this section you will learn basic operations on image like pixel editing, geometric transformations, code optimization, some mathematical tools etc.
      学习基本的图像操作,例如像素编辑、几何变换、代码优化和一些OpenCV的数学工具等等。

    # basic operations
    cv2.split()
    cv2.copyMakeBorder()
    
    # arithmetic operations
    cv2.add()
    cv2.subtract()
    cv2.addWeighted()
    
    # performance
    cv2.getTickCount()
    cv2.getTickFrequency()
    
    %timeit
    

    4 OpenCV的图像处理

    # 改变颜色空间
    cv2.cvtColor()
    cv2.inRange()
    
    # 图像几何变换
    cv2.resize()
    cv2.warpAffine()
    cv2.getRotationMatrix2D()
    cv2.getAffineTransform()
    cv2.getPerspectiveTransform()
    cv2.warpPerspective()
    
    # 图像门限
    cv2.threshold()
    cv2.medianBlur()
    cv2.adaptiveThreshold()
    cv2.THRESH_OTSU
    cv2.GaussianBlur()
    
    # 图像滤波
    cv2.filter2D()
    cv2.blur()
    cv2.GaussianBlur()
    cv2.medianBlur()
    cv2.bilateralFilter()
    
    # 形态学变换
    cv2.erode()
    cv2.dilate()
    cv2.morphologyEx()
    cv2.MORPH_OPEN
    cv2.MORPH_CLOSE
    cv2.MORPH_GRADIENT
    cv2.MORPH_TOPHAT
    cv2.MORPH_BLACKHAT
    cv2.getStructuringElement()
    cv2.MORPH_RECT
    cv2.MORPH_ELLIPSE
    cv2.MORPH_CROSS
    
    # 图像梯度
    cv2.Laplancian()
    cv2.Sobel() # 1, 0和0,1的区别,分别对应x轴和y轴的sobel变换
    
    # Canny边缘检测
    cv2.Canny() # 注意上下门限
    
    # 图像金字塔
    cv2.pyrUp()
    cv2.pyrDown()
    
    # 轮廓检测
    cv2.findContours()
    cv2.drawContours()
    cv2.moments()
    cv2.contourArea()
    cv2.arcLength()
    cv2.approxPolyDP()
    cv2.convexHull()
    cv2.isContourConvex()
    cv2.boundingRect()
    cv2.minAreaRect()
    cv2.boxPoints()
    cv2.minEnclosingCircle()
    cv2.fitEllipse()
    cv2.fitLine()
    cv2.boundingRect()
    cv2.minMaxLoc()
    cv2.mean()
    cv2.convexityDefects()
    cv2.pointPolygonTest()
    cv2.matchShapes()
    cv2.HuMoments()
    
    # 灰度直方图
    cv2.calcHist()
    cv2.equalizeHist()
    cv2.createCLAHE()
    cv2.normalize()
    cv2.calcBackProject()
    
    # 傅里叶变换
    np.fft.fft2()
    np.fft.fftshift()
    cv2.dft()
    cv2.cartToPolar()
    cv2.idft()
    cv2.getOptimalDFTSize()
    cv2.copyMakeBorder()
    
    # 模板匹配
    cv2.matchTemplate()
    cv2.minMaxLoc()
    cv2.matchTemplate()
    
    # Hough线变换
    cv2.HoughLines()
    cv2.HoughLinesP()
    
    # Hough圆环变换
    cv2.HoughCircles()
    
    #  Watershed算法实现图像分割
    cv2.watershed()
    cv2.connectedComponents()
    
    # GrabCut算法实现交互前景分割
    cv2.grabCut()
    

    5 特征检测和描述

    # Harris拐角检测
    cv2.cornerHarris()
    cv2.cornerSubPix()
    
    # Shi-Tomasi拐角检测和用于跟踪的良好特征
    cv2.goodFeaturesToTrack()
    
    # SIFT
    cv2.xfeature2d.SIFT_create()
    cv2.xfeature2d.SIFT_create().detectAndCompute()
    cv2.drawKeyPoints()
    
    # SUFT
    cv2.xfeature2d.SUFT_create()
    cv2.xfeature2d.SUFT_create().detectAndCompute()
    cv2.xfeature2d.SUFT_create().detect()
    
    # FAST算法用于拐角检测
    cv2.FastFeatureDetector_create()
    
    # BRIEF
    cv2.xfeatures2d.StarDetector_create()
    cv2.xfeatures2d.BriefDescriptorExtractor_create()
    
    # ORB
    cv.ORB_create()
    
    # 特征匹配
    cv2.BFMatcher()
    cv2.drawMatches()
    cv2.BFMatcher().knnMatch()
    
    # 特征匹配与单应性变化来检测目标
    cv2.FlannBasedMatcher()
    cv2.findHomography()
    cv2.perspectiveTransform()
    

    6 视频分析

    • 视频分析-Video Analysis

      In this section you will learn different techniques to work with videos like object tracking etc.
      学习视频处理的不同技术,例如目标跟踪等等。

    # meanshift和camshift
    cv2.meanShift()
    cv2.camShift()
    
    # 光流
    cv2.calcOpticalFlowPyrLK()
    cv2.cartToPolar()
    
    # 背景消除
    cv2.bgsegm.createBackgroundSubtractorMOG()
    cv2.bgsegm.createBackgroundSubtractorMOG2()
    cv2.bgsegm.createBackgroundSubtractorGMG()
    

    7 摄像头矫正和3D重构

    # 摄像头矫正
    cv2.findChessboardCorners()
    cv2.cornerSubPix()
    cv2.drawChessboardCorners()
    cv2.calibrateCamera()
    cv2.getOptimalNewCameraMatrix()
    cv2.undistort()
    cv2.initUndistortRectifyMap()
    cv2.remap()
    cv2.projectPoints()
    cv2.norm()
    
    # 姿态估计
    cv2.solvePnPRansac()
    
    # 极对数几何
    cv2.FlannBasedMatcher()
    cv2.findFundamentalMat()
    cv2.computeCorrespondEpilines()
    
    # 从立体图像中得到深度图
    cv2.StereoBM_create()
    

    8 机器学习

    • 机器学习-Machine Learning

      In this section you will learn different image processing functions inside OpenCV.
      学习OpenCV中不同的机器学习相关的图像处理函数。

    # KNN算法
    cv2.ml.KNearest_create()
    cv2.ml.KNearest_create().train()
    cv2.ml.KNearest_create().findNearest()
    
    # SVM算法
    svm = cv.ml.SVM_create()
    svm.setKernel(cv.ml.SVM_LINEAR)
    svm.setType(cv.ml.SVM_C_SVC)
    svm.setC(2.67)
    svm.setGamma(5.383)
    svm.train(trainData, cv.ml.ROW_SAMPLE, responses)
    svm.save('svm_data.dat')
    
    # K均值聚类
    cv2.kmeans()
    

    9 计算机图像学

    • 计算机图像学-Computational Photography

      In this section you will learn different computational photography techniques like image denoising etc.
      学习不同的计算机图像学技术,例如图像去噪等等。

    # 图像去噪
    cv2.fastNIMeansDenoising()
    cv2.fastNIMeansDenoisingColored()
    cv2.fastNIMeansDenoisingMulti()
    cv2.fastNIMeansDenoisingColoredMulti()
    
    # 图像修复
    cv2.inpaint()
    
    # HDR高动态范围图像
    cv2.createMergeDebevec()
    cv2.createMergeRobertson()
    cv2.createTonemap()
    cv2.createMergeMertens()
    cv2.createCalibrateDebevec()
    cv2.createCalibrateRobertson()
    

    10 目标检测

    • 目标检测-Object Detection

      In this section you will object detection techniques like face detection etc.
      学习目标检测技术,例如人脸检测等等

    # 使用Haar层叠法进行人脸检测
    cv2.CascadeClassifier()
    

    11 OpenCV-Python绑定相关

    相关文章

      网友评论

        本文标题:OpenCV官方文档阅读笔记

        本文链接:https://www.haomeiwen.com/subject/xazdwqtx.html