欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > PPT文档下载  

    Visual.Studio2013OpenCV3.0b机器视觉应用.ppt

    • 资源ID:6523014       资源大小:1.87MB        全文页数:65页
    • 资源格式: PPT        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Visual.Studio2013OpenCV3.0b机器视觉应用.ppt

    Visual Studio&OpenCV机器视觉应用,3.0,Open Source Computer Vision:开源计算机视觉(库),OpenCV现有中文教材,基于OpenCV1.X,建议基本掌握2.x基本环境后,再阅读。,OpenCV现有中文教材,基于OpenCV2.X,OpenCV帮助,opencvdoc1、opencv_cheatsheet.pdf(OpenCV简明表)2、opencv_tutorials.pdf(OpenCV案例教程)*3、opencv2refman.pdf(OpenCV参考手册)*4、opencv_user.pdf(OpenCV用户入门)5、opencv2manager.pdf(OpenCV安卓配置)http:/OpenCV网址:http:/opencv.org/http:/http:/,opencv_cheatsheet.pdf:简明表(2页),Key OpenCV Classes:关键类Matrix Basics:矩阵基础Matrix Manipulations:Copying,Shuffling,Part Access:矩阵的操作Image Processing:图像处理Data I/O:数据输入输出Simple GUI(highgui module):简单界面Camera Calibration,Pose Estimation and Depth Estimation:摄像机标定 Object Detection:物体探测,opencv_user.pdf:用户入门(23页),1 Operations with images:操作数字图像2 Features2d:特征点3 HighGUI:使用Kinect(微软注册)体感摄影机和其他OpenNI兼容的深度传感器。OpenNI(开放自然交互)是一个多语言,跨平台的框架。4 Cascade Classifier Training:级联分类器训练5 HighGUI:使用英特尔Creative Senz3D或其它感知计算SDK 兼容的深度传感器,重点说明,opencv_tutorials.pdf:案例教程(493页),1 Introduction to OpenCV2 core module.The Core Functionality3 imgproc module.Image Processing4 highgui module.High Level GUI and Media5 calib3d module.Camera calibration and 3D reconstruction6 feature2d module.2D Features framework7 video module.Video analysis8 objdetect module.Object Detection9 ml module.Machine Learning10 photo module.Computational photography11 gpu module.GPU-Accelerated Computer Vision12 OpenCV iOS13 OpenCV Viz14 General tutorials,完整实例,opencv2refman.pdf:参考手册(731页),1 Introduction2 core.The Core Functionality3 imgproc.Image Processing4 imgcodecs.Image file reading and writing5 videoio.Media I/O6 highgui.High-level GUI and Media I/O7 video.Video Analysis8 calib3d.Camera Calibration and 3D Reconstruction9 features2d.2D Features Framework10 objdetect.Object Detection11 ml.Machine Learning12 flann.Clustering and Search in Multi-Dimensional Spaces13 photo.Computational Photography14 stitching.Images stitching15 cuda.CUDA-accelerated Computer Vision16 cudaarithm.CUDA-accelerated Operations on Matrices17 cudabgsegm.CUDA-accelerated Background Segmentation18 cudacodec.CUDA-accelerated Video Encoding/Decoding19 cudafeatures2d.CUDA-accelerated Feature Detection and Description20 cudafilters.CUDA-accelerated Image Filtering21 cudaimgproc.CUDA-accelerated Image Processing22 cudaoptflow.CUDA-accelerated Optical Flow23 cudastereo.CUDA-accelerated Stereo Correspondence24 cudawarping.CUDA-accelerated Image Warping25 shape.Shape Distance and Matching26 superres.Super Resolution27 videostab.Video Stabilization28 viz.3D Visualizer,片段说明,OpenCV版本,Version 3.0b,Visual C+及其MFC版本,MFC version 6.0(still mfc42.dll)Visual C+version 6.0MFC version 7.0(mfc70.dll)Visual C+.NET 2002MFC version 7.1(mfc71.dll)Visual C+.NET 2003MFC version 8.0(mfc80.dll)Visual C+2005MFC version 9.0(mfc90.dll)Visual C+2008MFC version 10.0(mfc100.dll)Visual C+2010,MFC version 11.0 Visual C+2012MFC version 12.0 Visual C+2013,OpenCV的目录,D:Program FilesOpenCVsourcesD:Program FilesOpenCVbuild,OpenCV2.4.3+Visual Studio2008 配置,运行库系统环境变量Path:.OpenCV2.4.3buildx86vc9bin;包含文件目录:.OpenCV2.4.3buildinclude编译库文件目录:.OpenCV2.4.3buildx86vc9lib,链接/输入/附加依赖项目:(带d的为Debug,不带为Release)opencv_core243.lib opencv_core243d.libopencv_highgui243.lib opencv_highgui243d.libopencv_ml243.lib opencv_ml243d.lib。,OpenCV3.0b+Visual Studio2013 配置1,Vs2010以后采用属性表作为工程设置运行库系统环境变量Path:.OpenCV3.0bbuildx86vc12bin;编译库文件目录:.OpenCV3.0bbuildx86vc12lib包含文件目录:.OpenCV3.0bbuildinclude,链接/输入/附加依赖项目:(带d的为Debug,不带为Release)opencv_ts300.libopencv_world300.libopencv_ts300d.libopencv_world300d.lib,OpenCV3.0b+Visual Studio2013 配置2,OpenCV3.0b+Visual Studio2013 配置3,实例ReadImg,读取一张图片-旧,#include stdafx.h#include#include opencv/cv.h/使用旧版本函数#include opencv/highgui.husing namespace cv;using namespace std;int main(int argc,_TCHAR*argv)IplImage*myImg=cvLoadImage(D:1.bmp);/读入图像 if(!myImg)/如果读入图像失败 return-1;namedWindow(zdq,1);/创建窗口 cvShowImage(zdq,myImg);/显示图像 waitKey();/等待按键,按键盘任意键返回 cvDestroyWindow(zdq);/释放窗口 return 0;,Release版本项目属性,链接器,输入opencv_core243.libopencv_highgui243.libopencv_ml243.lib,实例UseCam-旧,#include stdafx.h#include#include opencv/cv.h#include opencv/highgui.husing namespace cv;using namespace std;CvCapture*capture;int c;IplImage*frame;void on_trackbar()while(true)frame=cvQueryFrame(capture);/循环获得摄像机得到的帧 if(!frame)break;if(c=cvWaitKey(100)=27)break;/Esc的时候退出循环 cvShowImage(frame,frame);cvWaitKey(1000);int main(int argc,char*argv)capture=cvCaptureFromCAM(1);/获取摄像头 if(!capture)printf(Could not initialize capturing.n);return-1;cvNamedWindow(frame,1);/构建窗口on_trackbar();cvWaitKey(0);cvReleaseCapture(,Release版本项目属性,链接器,输入opencv_core243.libopencv_highgui243.libopencv_ml243.lib,01加载并显示图像(CV01_ShowImage),#include/OpenCV统一的头文件#include int main(int argc,char*argv)const char*imageName=./pic.jpg;/图像路径及文件名cv:Mat image=cv:imread(imageName,cv:IMREAD_COLOR);if(!image.data)/数据校验std:cout 无法打开图像 std:endl;cv:waitKey();return-1;cv:namedWindow(“Display window”,cv:WINDOW_AUTOSIZE);/窗口cv:imshow(Display window,image);/将图像显示在窗口cv:waitKey(0);/等待按键cv:destroyWindow(Display window);/销毁窗口return 0;,02加载并播放视频文件(CV02_PlayVideo),#include/OpenCV统一的头文件#include int main(int argc,char*argv)const char*imageName=./avi.avi;/图像路径及文件名cv:VideoCapture captureVedio(imageName);if(!captureVedio.isOpened()std:cout frameVedio;bool isStop=false;cv:namedWindow(frameVedio,1);while(!isStop)/应该判断视频文件结束captureVedioframeVedio;/captureVedio.read(frameVedio);if(frameVedio.data)/循环获得视频文件的帧cv:imshow(frameVedio,frameVedio);if(cv:waitKey(30)=27)isStop=true;/读取时间,遇到esc退出elseisStop=true;/播放完毕captureVedio.release();cv:destroyWindow(frameVedio);/销毁窗口return 0;,03获取摄像头并录像(CV03_CameraRecorder),#include/OpenCV统一的头文件#include int main(int argc,char*argv)cv:VideoCapture captureCamera(0);/获取摄像头/double rate=captureCamera.get(CV_CAP_PROP_FPS);if(!captureCamera.isOpened()std:cout frameCamera;bool isStop=false;cv:VideoWriter frameWriter;/不可直接关闭程序,否则文件不可以播放frameWriter.open(./Recorded.avi,0,24,cv:Size(640,480),true);while(!isStop)/应该判断视频文件结束if(captureCamera.read(frameCamera)/循环获得摄像机得到的帧cv:imshow(frameCamera,frameCamera);frameWriter.write(frameCamera);if(cv:waitKey(30)=27)isStop=true;/写入需要时间,另外遇到esc退出elseisStop=true;frameWriter.release();captureCamera.release();cv:destroyWindow(frameCamera);return 0;,04遍历像素算运行时间(CV04_AccessPixelTime),void colorReduceMask(cv:Mat,05锐化图像(CV05_Sharpen),void sharpen(const cv:Mat,06颜色匹配类(CV06_FindColorClass),class ColorDetectorprivate:int maxDistance;/可接受的最大差距cv:Vec3b target;/目标像素cv:Mat_ result;/检测结果图像public:ColorDetector(int dis=100,cv:Vec3b color=cv:Vec3b(0,0,0)if(dis(i);uchar*itOut=result.ptr(i);for(int j=0;j(abs(*data+-target0);/防止超限getDist+=cv:saturate_cast(abs(*(data+)-target1);getDist+=cv:saturate_cast(abs(*(data+)-target2);if(getDist M;result.copyTo(M);return M;,07直方图(CV07_Histogram),/直方图用于统计和查找#include/好像编译后的文件会大一点#include class Histogram1Dprivate:int histSize1;/横坐标项的数量float hranges2;/像素的最大和最小值const float*ranges1;int channels1;public:Histogram1D();/构造函数cv:MatND getHistogram(const cv:Mat,Mat类(CV08_Mat),#include#include using namespace cv;using namespace std;int main(int argc,char*argv)Mat A=imread(./pic.jpg,IMREAD_COLOR);if(!A.data)cout compression_params;compression_params.push_back(cv:IMWRITE_PNG_COMPRESSION);compression_params.push_back(9);tryimwrite(./D.jpg,D,compression_params);catch(runtime_error,Mat是一个模板类,Mat M(2,2,CV_8UC3,Scalar(0,0,255);Mat L(3,3,CV_8UC1,Scalar:all(0);M.create(4,4,CV_8UC3);Mat E=Mat:eye(4,4,CV_64F);Mat O=Mat:ones(2,2,CV_32F);Mat Z=Mat:zeros(3,3,CV_8UC1);format(R,python);Mat E=A(Range:all(),Range(1,100);/行列范围,Mat()Constructor构造函数,#include stdafx.h#include#include/#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat M(2,2,CV_8UC3,Scalar(0,0,255);cout M=endl M endl endl;Mat L(3,3,CV_8UC1,Scalar:all(0);cout L=endl L endl endl;/运行时回报错,输出有问题return 0;,Mat.create(),#include stdafx.h#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat M;M.create(4,4,CV_8UC3);cout M=endl M endl endl;return 0;,zeros(),ones(),eyes(),#include stdafx.h#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat E=Mat:eye(4,4,CV_64F);cout E=endl E endl endl;Mat O=Mat:ones(2,2,CV_32F);cout O=endl O endl endl;Mat Z=Mat:zeros(3,3,CV_8UC1);cout Z=endl Z endl endl;return 0;,小矩阵的初始化,#include stdafx.h#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat C=(Mat_(3,3)0,-1,0,-1,5,-1,0,-1,0);cout C=endl C endl endl;return 0;,Mat.row(1).clone(),#include stdafx.h#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat C=(Mat_(3,3)0,-1,0,-1,5,-1,0,1,2);Mat RowClone=C.row(2).clone();cout RowClone=endl RowClone endl endl;return 0;,randu()随机产生元素,#include#include/#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat R=Mat(3,2,CV_8UC3);randu(R,Scalar:all(0),Scalar:all(5);/指定范围coutRendlendl;return 0;,矩阵的格式化输出,#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Mat R=Mat(3,2,CV_8UC3);cout R(default)=endl R endl endl;cout R(python)=endl format(R,python)endl endl;cout R(csv)=endl format(R,csv)endl endl;cout R(numpy)=endl format(R,numpy)endl endl;cout R(c)=endl format(R,C)endl endl;return 0;,输出其它类型,#include stdafx.h#include#include#include#pragma comment(lib,opencv_core243.lib)/Releaseusing namespace cv;using namespace std;int _tmain(int argc,_TCHAR*argv)Point2f P(5,1);cout v;v.push_back(float)CV_PI);v.push_back(2);v.push_back(3.01f);cout vPoints(20);for(size_t E=0;E vPoints.size();+E)vPointsE=Point2f(float)(E*5),(float)(E%7);cout A vector of 2D Points=vPoints endl endl;return 0;,图像矩阵在内存中的存储方式,gray scale imageRGB color system,高效的访问元素方法,Mat,迭代器法(安全),Mat,The Core Function,Mat R=Mat(200,400,CV_8UC3);randu(R,Scalar:all(0),Scalar:all(255);/指定范围/coutformat(R,python)endl;uchar tb256;for(int i=0;i256;+i)if(i%3=0)tbi=0;else if(i%3=1)tbi=0;elsetbi=255;Mat lookUpTable(1,256,CV_8U);uchar*p=lookUpTable.data;for(int i=0;i 256;+i)pi=tbi;LUT(R,lookUpTable,R);,矩阵的mask操作,The idea is that we recalculate each pixels value in an image according to a mask matrix(also known as kernel).This mask holds values that will adjust how much influence neighboring pixels(and the current pixel)have on the new pixel value.From a mathematical point of view we make a weighted average,with our specified values,图像对比度增强,基本方法,void Sharpen(const Mat,库函数filter2D,Mat A=imread(./Release/Gray.jpg,CV_LOAD_IMAGE_COLOR);if(!A.data)cout(3,3)0,-1,0,-1,5,-1,0,-1,0),B;filter2D(A,B,A.depth(),kern);,混合两张图像,double alpha=0.5;double beta;double input;Mat src1,src2,dst;std:coutinput;if(alpha=0,改变图像的亮度和对比度,访问像素初始化为零明白saturate_cast 如何工作图像变换可以这样:点操作(像素变换)邻域(基于面域)操作,亮度与对比度的调整,Two commonly used point processes are multiplication and addition with a constantThe parameters a 0 and b are often called the gain and bias parameters;sometimes these parameters are said to control contrast and brightness respectively.You can think of f(x)as the source image pixels and g(x)as the output image pixels.Then,more conveniently,for(int y=0;y(y,x)c=saturate_cast(alpha*(image.at(y,x)c)+beta);,基本图形的绘制,Use Point to define 2D points in an image.Use Scalar and why it is usefulDraw a line by using the OpenCV function lineDraw an ellipse by using the OpenCV function ellipseDraw a rectangle by using the OpenCV function rectangleDraw a circle by using the OpenCV function circleDraw a filled polygon by using the OpenCV function fillPoly,绘图,说明,/定义窗口名称 char atom_window=图原子运动;char rook_window=图灯塔;/创建2张400*400黑色图片 Mat atom_image=Mat:zeros(400,400,CV_8UC3);Mat rook_image=Mat:zeros(400,w,CV_8UC3);/用自定义函数创建四个椭圆和一个实心圆MyEllipse(atom_image,90);MyEllipse(atom_image,0);MyEllipse(atom_image,45);MyEllipse(atom_image,-45);MyFilledCircle(atom_image,Point(w/2,w/2);,画椭圆,void MyEllipse(Mat img,double angle)int thickness=2;int lineType=8;ellipse(img,Point(w/2,w/2),Size(w/4,w/16),angle,0,360,Scalar(255,0,0),/蓝色向量BRG thickness,lineType);,画实心圆,void MyFilledCircle(Mat img,Point center)int thickness=-1;/厚度小于0则为填充 int lineType=8;circle(img,center,w/32,Scalar(0,0,255),thickness,lineType);,画多边形,矩形,直线,MyPolygon(rook_image);rectangle(rook_image,Point(0,7*w/8),Point(w,w),Scalar(0,255,255),-1,8);MyLine(rook_image,Point(0,15*w/16),Point(w,15*w/16);MyLine(rook_image,Point(w/4,7*w/8),Point(w/4,w);MyLine(rook_image,Point(w/2,7*w/8),Point(w/2,w);MyLine(rook_image,Point(3*w/4,7*w/8),Point(3*w/4,w);,画多边形,void MyPolygon(Mat img)int lineType=8;Point rook_points120;rook_points00=Point(w/4,7*w/8);rook_points01=Point(3*w/4,7*w/8);rook_points02=Point(3*w/4,13*w/16);rook_points03=Point(11*w/16,13*w/16);rook_points04=Point(19*w/32,3*w/8);rook_points05=Point(3*w/4,3*w/8);rook_points06=Point(3*w/4,w/8);rook_points07=Point(26*w/40,w/8);rook_points08=Point(26*w/40,w/4);rook_points09=Point(22*w/40,w/4);rook_points010=Point(22*w/40,w/8);rook_points011=Point(18*w/40,w/8);rook_points012=Point(18*w/40,w/4);rook_points013=Point(14*w/40,w/4);rook_points014=Point(14*w/40,w/8);rook_points015=Point(w/4,w/8);rook_points016=Point(w/4,3*w/8);rook_points017=Point(13*w/32,3*w/8);rook_points018=Point(5*w/16,13*w/16);rook_points019=Point(w/4,13*w/16);const Point*ppt1=rook_points0;int npt=20;fillPoly(img,ppt,npt,1,Scalar(0,0,255),lineType);,画矩形和直线,rectangle(rook_image,Point(0,7*w/8),Point(w,w),Scalar(0,255,255),-1,8);void MyLine(Mat img,Point start,Point end)int thickness=2;int lineType=8;line(img,start,end,Scalar(0,0,0),thickness,lineType);,显示窗口及位置,imshow(atom_window,atom_image);moveWindow(atom_window,0,200);imshow(rook_window,rook_image);moveWindow(rook_window,w,200);,Random generator and text with OpenCV,随机图像说明,/产生一个随机数产生对象RNG rng(0 xFFFFFFFF);/产生一个零矩阵 Mat image=Mat:zeros(window_height,window_width,CV_8UC3);/在窗口中显示并演示几个毫秒imshow(window_name,image);waitKey(DELAY);/划线-自定义函数 c=Drawing_Random_Lines(image,window_name,rng);if(c!=0)return 0;static Scalar randomColor(RNG,画随机线-自定义,int Drawing_Random_Lines(Mat image,char*window_name,RNG rng)Point pt1,pt2;for(int i=0;i=0)return-1;/有按键就退出 return 0;,画任意矩形-自定义函数,int Drawing_Random_Rectangles(Mat image,char*window_name,RNG rng)Point pt1,pt2;int lineType=8;int thickness=rng.uniform(-3,10);for(int i=0;i=0)return-1;return 0;,产生任意字符,int Displaying_Random_Text(Mat image,char*window_name,RNG rng)int lineType=8;for(int i=1;i=0)return-1;return 0;,结尾字符-颜色渐变,int Displaying_Big_End(Mat image,char*window_name,RNG)Size textsize=getTextSize(OpenCV forever!,FONT_HERSHEY_COMPLEX,3,5,0);Point org(window_width-textsize.width)/2,(window_height-textsize.height)/2);int lineType=8;Mat image2;for(int i=0;i=0)return-1;return 0;,Discrete Fourier Transform,解读,/转换成灰度图Mat I=imread(./Release/lena.jpg,CV_LOAD_IMAGE_GRAYSCALE);/对于给定的矢量尺寸返回最优DFT尺寸int m=getOptimalDFTSize(I.rows);int n=getOptimalDFTSize(I.cols);/多出部分补零,相当于加边框,padded是输出图像 copyMakeBorder(I,padded,0,m-I.rows,0,n-I.cols,BORDER_CONSTANT,Scala

    注意事项

    本文(Visual.Studio2013OpenCV3.0b机器视觉应用.ppt)为本站会员(牧羊曲112)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开