关于opencv-Python的函数

Chapter one:图片
读入图像 cv2.imread(filename[, flags]) → retval
显示图像 cv2.imshow(winname, mat) → None
cv2.waitKey([delay]) → retval
创建窗口 cv2.namedWindow(winname[, flags]) → None
摧毁窗口 cv2.destroyWindow(winname) → None
cv2.destroyAllWindows()→ None
保存图像 cv2.imwrite(filename,img[, params]) → retval

Chapter two: 视频
读取视频文件、摄像头获取视频 cv2.VideoCapture(filename/device) →
.read([image]) → retval,image
.open()→ retval
.isOpened()→ retval
视频文件属性、设置 .get(prodId) → retval
.set(prodId,value) → retval
保存视频文件 cv2.VideoWriter([filename,fourcc,fps,framesize[,isColor]]) →
.write(image) → None
关闭视频文件 .release()→ None

Chapter three: 绘图
http://wiki.opencv.org.cn/index.php/Cxcore绘图函数#GetTextSize
只有C++:InitFont、arrowedLine、

画圆 cv2.circle(img,center,radius,color[,thickness[,lineType[,shift]]]) → None
画矩阵 cv2.rectangle(img,pt1,pt2,color[,thickness[,lineType[,shift]]]) → None
画线段 cv2.Line(img,pt1,pt2,color[,thickness[,lineType[,shift]]]) → None
画折线 cv2.polyLines(img,pts,isClosed,color[,thickness[,linrType[,shift]]]) → None
剪切矩形内部的直线 cv2.clipLine(imgRect,pt1,pt2) → retval,pt1,pt2
画椭圆 cv2.ellipse(img,center,axes,angle,startAngle,endAngle,color[,thickness[,lineType[,shift]]]) → None
cv2.ellipse(img,box,color[,thickness[,lineType]]) → None
用折线逼近椭圆弧 cv2.ellipse2Poly(center,axes,angle,arcStart,arcEnd,delta) → pts
填充多边形 cv2.fillConvexPoly(img,points,color[,lineType[,shift]]) → None
填充多边形内部 cv2.fillPoly(img,pts,color[,lineType[,shift[,offset]]]) → None
在图像中显示文本字符串 cv2.putText(img,text,org,fontFace,fontScale,color[,thickness[,lineType[,bottomLeftOrigin]]]) → None
获得文本字符串的宽度和高度 cv2.getTextSize(text,fontFace,fontScale,thickness) → retval, baseLine
画外部和内部的轮廓 cv2.drawContours(image,contours,contourIdx,color[,thickness[,lineType[,hierarchy[,maxLevel[,offset]]]]]) → None

Chapter four: 处理鼠标事件
处理鼠标事件 cv2.SetMouseCallback(winname,onMouse,param=None) → None

Chapter five: 滑动条
创建滑动条 cv2.createTrackbar(trackname,winname,value,count,onChange) → None
return 滑动条属性 cv2.getTrackbarPos(trackname,winname) → retval
设置滑动条属性 cv2.setTrackbarPos(trackname,winname,pos) → None

Chapter six:图像操作
获取图像形状 .shape
获取像素数目 .size
获取图像数据类型 .dtype
拆分、合并通道 cv2.split(m[,mv]) → mv
cv2.merge(mv[,dst]) → dst
图像扩边 cv2.copyMakeBorder(src,top,bottom,left,right,borderType[,dst[,value]]) → dst
图像减法 cv2.subtract(src1,src2[,dst[,mask[,dtype]]])→dst
图像加法 cv2.add(src1,src2[,dst[,mask[,dtype]]]) → dst
图像混合 cv2.addWeighted(src1,alpha,sec2,beta,gamma[,dst[,dtype]]) → dst
图像位运算 cv2.bitwise_and(src1,src2[,dst[,mask]]) → dst
cv2.bitwise_not(src[,dst[,mask]]) → dst
cv2.bitwise_or(src1,src2[,dst[,mask]]) → dst
cv2.bitwise_xor(src1,src2[,dst[,mask]]) → dst

Chapter seven: 颜色空间转换
转换颜色空间 cv2.cvtColor(src,code[,dst[,dstcn]]) → dst
检查数组元素是否在两个数量之间 cv2.inRange(src,lowerb,upperb[,dst]) → dst

Chapter eight: 几何变换
http://www.cnblogs.com/dupuleng/articles/4055020.html
扩展缩放 cv2.resize(src,dsize[,dst[,fx[,fy[,interpolation]]]]) → dst
仿射变换 cv2.getAffineTransform(src,dst) → retval
cv2.warpAffine(src,M,dsize[,dst[,flags[,borderMode[,borderValue]]]]) → dst
旋转 cv2.getRotationMatrix2D(center,angle,scale)→ret
透视变换 cv2.getPerspectiveTransform(src,dst) → retval
cv2.warpPerspective(src,M,dsize[,dst[,flags[,borderMod[,borderValue]]]]) → dst

Chapter nine:图像阈值
简单阈值 cv2.threshold(src,thresh,maxvalue,type[,dst])→retval,dst
自适应阈值 cv2.adaptiveThreshold(src,maxvalue,adaptiveMethod,thresholdType,blockSize,[,dst]) → dst

Chapter ten: 图像平滑
2D卷积 cv2.filter2D(src,ddepth,kernel[,dst[,anchor[,delta[,borderType]]]]) → dst
平均 cv2.blur(src,ksize,[,dst[,anchor[,borderType]]])→dst
cv2.boxFilter(src,ddepth,ksize[,dst[,anchor[,normalize[,borderType]]]]) → dst
高斯模糊 cv2.GuassianBlur(src,ksize,sigmaX[,dst[,sigmaY[,borderType]]]) → dst
cv2.getGuassianKernel(ksize,sigma[,kType]) → retval
中值模糊 cv2.medianBlur(src,ksize[,dst]) → dst
双边滤波 cv2.bilateralFilter(src,d,sigmaColor,sigmaSpace[,dst[,borderType]]) → dst

Chapter eleven: 形态学转换
腐蚀 cv2.erode(src,kernel[,dst[,anchor[,iterations[,borderType[,borderType]]]]]) → dst
膨胀 cv2.dilate(src,kernel[,dst[,anchor[,iterations[,borderType[,borderType]]]]]) → dst
形态学操作(开运算,闭运算,梯度,礼帽,黑帽) cv2.morphologyEx(src,op,kernel[,dst[,anchor[,iterations[,borderType[,borderValue]]]]])→ dst
结构化元素 cv2.getStructuringElement(shape,ksize[,anchor])→retval

Chapter twelve: 图像梯度
Sobel算子 cv2.Sobel(src,ddepth,dx,dy[,dst[,ksize[,scale[,delta[,borderType]]]]]) →dst
Scharr算子 cv2.Scharr(src,ddepth,dx,dy[,dst[,scale[,delta[,borderType]]]]) → dst
Laplacian算子 cv2.Laplacian(src,ddepth[,dst[,ksize[,scale[,delta[,borderType]]]]])→dst

Chapter thirteen: canny边缘检测
cv2.Canny(image,threshold1,threshold2[,edges[,apertureSize[,L2gradient]]]) → edges

Chapter fourteen: 轮廓
查找轮廓 cv2.findContours(image,mode,method[,contours[,hierarchy[,offset]]]) → contours,hierarchy
绘制轮廓 cv2.drawContours(image,contours,contourIdx,color[,thickness[,lineType[,hierarchy[,maxLevel[,offset]]]]]) → None
图像的矩 cv2.moments(array[,binaryImage]) → retval
轮廓面积 cv2.contourArea(contour[,oriented]) → retval
轮廓周长 cv2.arcLength(curve,closed) → retval
轮廓近似 cv2.approxPolyDP(curve,epsilon,closed[,approxCurvel])→approxCurvel
凸包 cv2.convexHull(point[,hull[,clockwise[,returnPoints]]]) → hull
凸缺陷 cv2.convexityDefects(contour,convexhull[,convexityDefects])→convexityDefects
凸性检测 cv2.isContourConvex(contour) → retval
边界矩形 cv2.boundingRect(points) → retval
cv2.minAreaRect(points) → retval
cv2.boxPoints()
最小外接圆 cv2.minEnclosingCircle(points) → center,radius
点到轮廓距离 cv2.pointPolygonTest(contour,pt,measureDist) → retval
椭圆拟合 cv2.fitEllipse(points) → retval
直线拟合 cv2.fitLine(points,distType,param,reps,aeps[,line]) → line
形状匹配 cv2.matchShapes(contour1,contour2,method,paramter) → retval
模块匹配 cv2.matchTemplate(image,temp1,method[,result]) → result
最值及其位置 cv2.minMaxLoc(src[,mask]) → minVal,maxVal,minLoc,maxLoc
平均颜色/灰度 cv2.mean(src[,mask]) → retval

Chapter fifteen: 直方图
绘制直方图 cv2.calcHist(image,channels,mask,histSize,ranges[,hist[,accumulate]]) → hist
直方图均衡化 cv2.equalizeHist(src[,dst]) → dst
cv2.createCLAHE([,clipLimit[,tileGridSize]]) → retval
直方图反向投影 cv2.calcBackProject(image,channels,hist,range,scale[,dst]) → dst
归一化 cv2.normalize(src[,dst[,alpha[,beta[,norm_type[.dtype[,mask]]]]]])→dst

Chapter sixteen: 图像变换
傅立叶变换 cv2.dft(src[,dst[,flags[,nonzeroRows]]]) → dst
cv2.getOptimalDFTSize(vecsize) → retvach

Chapter seventeen: 霍夫变换
霍夫直线变换 cv2.HoughLines(image,rho,theta,threshold[,lines[,srn[,stn]]]) → lines
cv2.HoughLinesP(image,rho,theta,threshold[,lines[,minLineLength[,maxLineGap]]]) → lines
霍夫圆环变换 cv2.HoughCircles(image,method,dp,minDist[,circles[,param1[,param2[,minRadius[,maxRadius]]]]]) → lines

Chapter eighteen: 分水岭算法图像分割
分水岭算法 cv2.watershed(image,maskers) → None
连通分支 cv2.connectedComponents(image[,labels[,connectivity[,ltype]]]) → retval,labels

Chapter nineteen: grabcut算法交互式前景提取
cv2.grabcut(image,mask,rect,bgdModel,fgdModel,iterCount[,mode]) → None

Chapter twenty: 角点检测
C++:DescriptorExtractor_create()
Harris角点检测 cv2.cornerHarris(src,blockSize,ksize,k[,dst[,borderType]]) → dst
提炼角位置 cv2.cornerSubPix(image,corners,winSize,zeroZone,criteria) → None
Shi-Tomasi角点检测 cv2.goodFeaturesToTrack(image,maxCorners,qualityLevel,minDistance[,corners[,mask[,blockSize[,useHarrisDetect[,k]]]]]) → corners
SURF cv2.SURF([hessianThreshold[,n0ctaves[,n0ctaveLayers[,extend[,upright]]]]]) →
SURF检测和计算要点 .detect(image[,mask]) → keypoints
.detectAndCompute(image,mask[,descriptors[,useProvidedKeypoints]]) → keypoints,descriptors
FAST特征检测 cv2.FastFeatureDetector_create([,threshold[,nonmaxSuppression[,type]]]) → retval
绘制要点 cv2.drawKeypoints(image,keypoints,outImage[,color[,flags]])→outImg

Chapter twenty-one: 特征匹配
C++: FLANN
Brute-Force cv2.BFMatcher([,normType[,crossCheck]]) →
对象透视图变换 cv2.findHomography(srcPoints,dstPoints[,method[,ransacReprojThreshold[,mask]]]) → retval,mask

Chapter twenty-two: 在视频中找到并跟踪目标对象
Meanshift cv2.meanShift(proImage,window,criteria) → retval,window
camshift cv2.camShift(proImage,window,criteria) → retval,window

Chapter twenty-three: 光流
Lucas-Kanade光流 cv2.calcOpticalFlowPyrLK(prevImg,nextImg,prevPts[,nextPts[,status[,err[,winSize[,maxLevel[,criteria[,derivLambda[,flags]]]]]]]])
→nextPts,status,err
cv2.goodFeaturesToTrack(image,maxCorners,qualityLevel,minCorners[,corners[,mask[,blockSize[,useHarrisDetector[,k]]]]]) → corners
GF稠密光流 cv2.calcOpticalFlowFarneback(prevImg,nextImg,pyr_scale,levels,winsize,iterations,poly_n,poly_sigma,flags[,flow]) → flow

Chapter twenty-four: 背景减除
BackgroundSubtractorMOG
BackgroundSubtractorGMG

BackgroundSubtractorMOG cv2.BackgroundSubtractorMOG(history,nmixtures,backgroundRatio[,noiseSigma]) →
createBackgroundSubtractorMOG2([, history[, varThreshold[, detectShadows]]]) → retval

Chapter twenty-five: 摄像机设定和3D重构
将对象点转换到图像点 cv2.projectPoints(objectPoints,rvec,tvec,cameraMatrix,distCoeffs[,imagePoints[,jacobian[,aspectRatio]]])
→ imagePoints,jacobian
摄像机标定 cv2.calibrateCamera(objectPoints,imagePoints,imageSize[,cameraMatrix[,distCoeffs[,rvecs[,tvecs[,flags]]]]])
→ retval,cameraMatrix,distCoeffs,rvecs,tvecs
畸变校正 cv2.getOptimalNewCameraMatrix(cameraMatrix,distCoeffs,imageSize,alpha[,newImgSize[,centerPrincipalPoint]])
→retval,validPixROI
cv2.undistort(src,cameraMatrix,distCoeffs[,dst[,newCameraMatrix]]) → dst
cv2.remap(src,map1,map2,interpolation[,dst[,borderMode[,borderValue]]]) → dst
计算旋转和变换 cv2.solvePnPRansac(objectPoints,imagePoints,cameraMatrix,distCoeffs[,rvec[,tvec[,useExtrinsicGuess[,iterationsCount[,reprojectionError[,minInliersCount[,inliers[,flags]]]]]]]])
→ rvec,tvec,inliers

Chapter twenty-six: 机器学习
K近邻 cv2.KNearest.train(trainData,responses[,sampleIdx[,isRegression[,maxK[,updateBase]]]]) → retval
cv2.KNearest.find_nearest(samples,k[,results[,neighborResponses[,dists]]]) → retval,results,neighborResponses,dist
SVM机 cv2.SVM(trainData,responses[,varIdx[,sampleIdx[,params]]]) →
.train(traindata,responses[,varIdx[,sampleIdx[,params]]]) → retval
.train_auto(trainData,responses,varIdx,sampleIdx,params[,k_fold[,Cgrid[,gammaGrid[,pGrid[,nuGrid[,coeffGrid[,degreeGrid[,balanced]]]]]]]]) → retval
.predict(sample[, returnDFVal]) → retval
.save()
K值聚类 cv2.kmeans(data,K,criteria,attempts,flags[,bestLabels[,centers]]) → retval,bestLabels,centers

Chapter twenty-seven: 计算摄影学
图像去噪 cv2.fastNlMeansDenoising(src[,dst[,h[,templateWindowSize[,searchWindowSize]]]])→dst
cv2.fastNlMeansDenoising(src,h[,dst[,templateWindowSize[,searchWindowSize[,normType]]]])→dst
fastNlMeansDenoisingMulti(srcImgs,imgToDenoiseIndex,temporalWindowSize[,dst[,h[,templateWindowSize[,searchWindowSize]]]])→dst
cv2.fastNlMeansDenoisingMulti(srcImgs,imgToDenoiseIndex,temporalWindowSize,h[,dst[,templateWindowSize[,searchWindowSize[,normType]]]])→dst
cv2.fastNlMeansDenoisingColored(src[,dst[,h[,hColor[,templateWindowSize[,searchWindowSize]]]]])→dst
fastNlMeansDenoisingColoredMulti(srcImgs,imgToDenoiseIndex,temporalWindowSize[,dst[,h[,hColor[,templateWindowSize[,searchWindowSize]]]]])→dst
图像修补 cv2.inpaint(src,inpaintMask,inpaintRange,flags[,dst]) →dst

Chapter twenty-eight: 使用Haar 分类器进行面部检测
XML分类器 cv2.CascadeClassifier(filename)→
.empty()→retval
.load(filename) → retval
.detectMultiScale(image,rejectLevels,levelWeights[,scaleFactor[,minNeighbors[,flags[,minSize[,maxSize[,outputRejectLevels]]]]]]) → objects

这里面还有是很多缺陷,有一些函数在网站里是找不到的,有一些是这有C语言的,而不是python的。重新看了一遍才发现这些,感觉自己之前看的很粗糙,以后有时间再去把这些坑坑洼洼补上,还有着其他的思路去理解这些函数,虽然只是一个Brian Storming,但坚信有实现的机会和时间。最近还在忙着课程作业,为自己加油!!!

路途艰苦,天道酬勤。

你可能感兴趣的:(人工智能)