├── .gitignore ├── README.md ├── ScreenShot1.png ├── XcodeProject ├── .gitignore └── LearningOpenCV.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── xcshareddata │ └── xcschemes │ └── LearningOpenCV.xcscheme ├── data ├── Distortion.xml ├── Intrinsics.xml ├── OpticalFlow0.jpg ├── OpticalFlow1.jpg ├── baboon.jpg ├── birdseye.jpg ├── birdseye │ ├── IMG_0214.jpg │ ├── IMG_0214L.jpg │ ├── IMG_0215.jpg │ ├── IMG_0215L.jpg │ ├── IMG_0217.jpg │ ├── IMG_0217L.jpg │ ├── IMG_0218.jpg │ ├── IMG_0218L.jpg │ ├── IMG_0219.jpg │ ├── IMG_0219L.jpg │ ├── IMG_0220.jpg │ └── IMG_0220L.jpg ├── calibration │ ├── IMG_0191.jpg │ ├── IMG_0192.jpg │ ├── IMG_0193.jpg │ ├── IMG_0194.jpg │ ├── IMG_0195.jpg │ ├── IMG_0196.jpg │ ├── IMG_0197.jpg │ ├── IMG_0198.jpg │ ├── IMG_0199.jpg │ ├── IMG_0200.jpg │ ├── IMG_0201.jpg │ ├── IMG_0202.jpg │ ├── IMG_0203.jpg │ ├── IMG_0204.jpg │ ├── IMG_0205.jpg │ ├── IMG_0206.jpg │ ├── IMG_0207.jpg │ ├── IMG_0208.jpg │ ├── IMG_0209.jpg │ ├── IMG_0210.jpg │ ├── IMG_0211.jpg │ ├── IMG_0212.jpg │ └── IMG_0213.jpg ├── ch12_list.txt ├── chessboards.txt ├── edge.png ├── faceScene.jpg ├── faceTemplate.jpg ├── fruits.jpg ├── stereoData │ ├── left01.jpg │ ├── left02.jpg │ ├── left03.jpg │ ├── left04.jpg │ ├── left05.jpg │ ├── left06.jpg │ ├── left07.jpg │ ├── left08.jpg │ ├── left09.jpg │ ├── left10.jpg │ ├── left11.jpg │ ├── left12.jpg │ ├── left13.jpg │ ├── left14.jpg │ ├── right01.jpg │ ├── right02.jpg │ ├── right03.jpg │ ├── right04.jpg │ ├── right05.jpg │ ├── right06.jpg │ ├── right07.jpg │ ├── right08.jpg │ ├── right09.jpg │ ├── right10.jpg │ ├── right11.jpg │ ├── right12.jpg │ ├── right13.jpg │ └── right14.jpg └── stuff.jpg └── src ├── Chapter02 ├── Practice5.cpp ├── cameraCapture.cpp ├── imageCannyAndPyrDown.cpp ├── load_image.cpp ├── load_video.cpp ├── load_videoTrackbar.cpp ├── smoothImage.cpp └── videoConver.cpp ├── Chapter04 ├── AlphaBlend.cpp ├── FileStorage.cpp └── imageROI.cpp ├── Chapter06 ├── AffineTransform.cpp ├── PerspectiveTransform.cpp ├── cvHoughCircles.cpp └── drawBoxs.cpp ├── Chapter07 ├── Histogrem-EMD.cpp ├── Histogrem.cpp └── MatchTemplate.cpp ├── Chapter08 ├── Contours1.cpp └── Contours2.cpp ├── Chapter10 ├── Kalman.cpp └── OpticalFlow.cpp ├── Chapter11 ├── calib.cpp └── calibFromFile.cpp ├── Chapter12 ├── 2DLineFitting.cpp ├── BirdsEye.cpp └── StereoCalib.cpp └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LearningOpenCV 2 | 3 | Source code for Learning OpenCV 4 | 5 | 《学习OpenCV》源码,使用 `OpenCV 2.4` 自带 Mac 项目 Xcode 工程。 6 | 7 | ![ScreenShot](ScreenShot1.png) 8 | 9 | ## 使用方法 10 | 11 | ### 下载源码 12 | 13 | ```sh 14 | git clone https://github.com/yourtion/LearningOpenCV.git 15 | ``` 16 | 17 | ### 加入OpenCV 18 | 19 | 使用 `HomeBrew` 安装: 20 | 21 | ```sh 22 | $ brew install opencv 23 | ``` 24 | 25 | 安装后 `OpenCV` 位于 `/usr/local/Cellar/opencv/2.4.13/lib`,也就是 Xcode 工程中的 `lib` 的位置。 26 | 27 | ### 使用Demo 28 | 29 | 所有源码按照章节放在 `src` 目录下,数据位于 `data` 目录。 30 | 31 | Checkout 到对应的 commit 即可运行对应的 Demo。 32 | 33 | ## 源码列表 34 | 35 | - [相机数据获取 - CameraCapture](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/cameraCapture.cpp) 36 | - [图片简单变换 - ImageCannyAndPyrDown](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/imageCannyAndPyrDown.cpp) 37 | - [加载图片 - LoadImage](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/load_image.cpp) 38 | - [加载视频文件 - LoadVideo](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/load_video.cpp) 39 | - [加载视频同时显示进度 - LoadVideoTrackbar](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/load_videoTrackbar.cpp) 40 | - [图片平滑 - SmoothImage](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/smoothImage.cpp) 41 | - [视频转换 - VideoConver](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter02/videoConver.cpp) 42 | - [半透明 - AlphaBlend](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter04/AlphaBlend.cpp) 43 | - [文件存储 - FileStorage](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter04/FileStorage.cpp) 44 | - [图片ROI - ImageROI](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter04/imageROI.cpp) 45 | - [仿射变换 - AffineTransform](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter06/AffineTransform.cpp) 46 | - [透视变换 - PerspectiveTransform](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter06/PerspectiveTransform.cpp) 47 | - [查找圆序列 - cvHoughCircles](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter06/cvHoughCircles.cpp) 48 | - [绘制盒子 - DrawBoxs](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter06/drawBoxs.cpp) 49 | - [直方图EMD计算 - Histogrem-EMD](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter07/Histogrem-EMD.cpp) 50 | - [直方图 - Histogrem](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter07/Histogrem.cpp) 51 | - [模版匹配 - MatchTemplate](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter07/MatchTemplate.cpp) 52 | - [轮廓1 - Contours1](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter08/Contours1.cpp) 53 | - [轮廓2 - Contours2](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter08/Contours2.cpp) 54 | - [Kalman滤波器 - Kalman](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter10/Kalman.cpp) 55 | - [金字塔光流L-K - OpticalFlow](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter10/OpticalFlow.cpp) 56 | - [摄像机标定 - Calib](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter11/calib.cpp) 57 | - [通过文件标定摄像机 - CalibFromFile](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter11/calibFromFile.cpp) 58 | - [直线拟合 - 2DLineFitting](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter12/2DLineFitting.cpp) 59 | - [生成鸟瞰图 - BirdsEye](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter12/BirdsEye.cpp) 60 | - [立体标定 - StereoCalib](https://github.com/yourtion/LearningOpenCV/blob/master/src/Chapter12/StereoCalib.cpp) 61 | -------------------------------------------------------------------------------- /ScreenShot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/ScreenShot1.png -------------------------------------------------------------------------------- /XcodeProject/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /XcodeProject/LearningOpenCV.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CB8E86A11D49B58D00884BD7 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8E86A01D49B58D00884BD7 /* main.cpp */; }; 11 | CB8E86E01D49B63400884BD7 /* libopencv_calib3d.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A31D49B63400884BD7 /* libopencv_calib3d.2.4.13.dylib */; }; 12 | CB8E86E11D49B63400884BD7 /* libopencv_calib3d.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A41D49B63400884BD7 /* libopencv_calib3d.2.4.dylib */; }; 13 | CB8E86E21D49B63400884BD7 /* libopencv_calib3d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A51D49B63400884BD7 /* libopencv_calib3d.dylib */; }; 14 | CB8E86E31D49B63400884BD7 /* libopencv_contrib.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A61D49B63400884BD7 /* libopencv_contrib.2.4.13.dylib */; }; 15 | CB8E86E41D49B63400884BD7 /* libopencv_contrib.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A71D49B63400884BD7 /* libopencv_contrib.2.4.dylib */; }; 16 | CB8E86E51D49B63400884BD7 /* libopencv_contrib.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A81D49B63400884BD7 /* libopencv_contrib.dylib */; }; 17 | CB8E86E61D49B63400884BD7 /* libopencv_core.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86A91D49B63400884BD7 /* libopencv_core.2.4.13.dylib */; }; 18 | CB8E86E71D49B63400884BD7 /* libopencv_core.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AA1D49B63400884BD7 /* libopencv_core.2.4.dylib */; }; 19 | CB8E86E81D49B63400884BD7 /* libopencv_core.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AB1D49B63400884BD7 /* libopencv_core.dylib */; }; 20 | CB8E86E91D49B63400884BD7 /* libopencv_features2d.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AC1D49B63400884BD7 /* libopencv_features2d.2.4.13.dylib */; }; 21 | CB8E86EA1D49B63400884BD7 /* libopencv_features2d.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AD1D49B63400884BD7 /* libopencv_features2d.2.4.dylib */; }; 22 | CB8E86EB1D49B63400884BD7 /* libopencv_features2d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AE1D49B63400884BD7 /* libopencv_features2d.dylib */; }; 23 | CB8E86EC1D49B63400884BD7 /* libopencv_flann.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86AF1D49B63400884BD7 /* libopencv_flann.2.4.13.dylib */; }; 24 | CB8E86ED1D49B63400884BD7 /* libopencv_flann.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B01D49B63400884BD7 /* libopencv_flann.2.4.dylib */; }; 25 | CB8E86EE1D49B63400884BD7 /* libopencv_flann.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B11D49B63400884BD7 /* libopencv_flann.dylib */; }; 26 | CB8E86EF1D49B63400884BD7 /* libopencv_gpu.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B21D49B63400884BD7 /* libopencv_gpu.2.4.13.dylib */; }; 27 | CB8E86F01D49B63400884BD7 /* libopencv_gpu.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B31D49B63400884BD7 /* libopencv_gpu.2.4.dylib */; }; 28 | CB8E86F11D49B63400884BD7 /* libopencv_gpu.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B41D49B63400884BD7 /* libopencv_gpu.dylib */; }; 29 | CB8E86F21D49B63400884BD7 /* libopencv_highgui.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B51D49B63400884BD7 /* libopencv_highgui.2.4.13.dylib */; }; 30 | CB8E86F31D49B63400884BD7 /* libopencv_highgui.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B61D49B63400884BD7 /* libopencv_highgui.2.4.dylib */; }; 31 | CB8E86F41D49B63400884BD7 /* libopencv_highgui.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B71D49B63400884BD7 /* libopencv_highgui.dylib */; }; 32 | CB8E86F51D49B63400884BD7 /* libopencv_imgproc.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B81D49B63400884BD7 /* libopencv_imgproc.2.4.13.dylib */; }; 33 | CB8E86F61D49B63400884BD7 /* libopencv_imgproc.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86B91D49B63400884BD7 /* libopencv_imgproc.2.4.dylib */; }; 34 | CB8E86F71D49B63400884BD7 /* libopencv_imgproc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BA1D49B63400884BD7 /* libopencv_imgproc.dylib */; }; 35 | CB8E86F81D49B63400884BD7 /* libopencv_legacy.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BB1D49B63400884BD7 /* libopencv_legacy.2.4.13.dylib */; }; 36 | CB8E86F91D49B63400884BD7 /* libopencv_legacy.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BC1D49B63400884BD7 /* libopencv_legacy.2.4.dylib */; }; 37 | CB8E86FA1D49B63400884BD7 /* libopencv_legacy.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BD1D49B63400884BD7 /* libopencv_legacy.dylib */; }; 38 | CB8E86FB1D49B63400884BD7 /* libopencv_ml.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BE1D49B63400884BD7 /* libopencv_ml.2.4.13.dylib */; }; 39 | CB8E86FC1D49B63400884BD7 /* libopencv_ml.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86BF1D49B63400884BD7 /* libopencv_ml.2.4.dylib */; }; 40 | CB8E86FD1D49B63400884BD7 /* libopencv_ml.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C01D49B63400884BD7 /* libopencv_ml.dylib */; }; 41 | CB8E86FE1D49B63400884BD7 /* libopencv_nonfree.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C11D49B63400884BD7 /* libopencv_nonfree.2.4.13.dylib */; }; 42 | CB8E86FF1D49B63400884BD7 /* libopencv_nonfree.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C21D49B63400884BD7 /* libopencv_nonfree.2.4.dylib */; }; 43 | CB8E87001D49B63400884BD7 /* libopencv_nonfree.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C31D49B63400884BD7 /* libopencv_nonfree.dylib */; }; 44 | CB8E87011D49B63400884BD7 /* libopencv_objdetect.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C41D49B63400884BD7 /* libopencv_objdetect.2.4.13.dylib */; }; 45 | CB8E87021D49B63400884BD7 /* libopencv_objdetect.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C51D49B63400884BD7 /* libopencv_objdetect.2.4.dylib */; }; 46 | CB8E87031D49B63400884BD7 /* libopencv_objdetect.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C61D49B63400884BD7 /* libopencv_objdetect.dylib */; }; 47 | CB8E87041D49B63400884BD7 /* libopencv_ocl.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C71D49B63400884BD7 /* libopencv_ocl.2.4.13.dylib */; }; 48 | CB8E87051D49B63400884BD7 /* libopencv_ocl.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C81D49B63400884BD7 /* libopencv_ocl.2.4.dylib */; }; 49 | CB8E87061D49B63400884BD7 /* libopencv_ocl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86C91D49B63400884BD7 /* libopencv_ocl.dylib */; }; 50 | CB8E87071D49B63400884BD7 /* libopencv_photo.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CA1D49B63400884BD7 /* libopencv_photo.2.4.13.dylib */; }; 51 | CB8E87081D49B63400884BD7 /* libopencv_photo.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CB1D49B63400884BD7 /* libopencv_photo.2.4.dylib */; }; 52 | CB8E87091D49B63400884BD7 /* libopencv_photo.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CC1D49B63400884BD7 /* libopencv_photo.dylib */; }; 53 | CB8E870A1D49B63400884BD7 /* libopencv_stitching.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CD1D49B63400884BD7 /* libopencv_stitching.2.4.13.dylib */; }; 54 | CB8E870B1D49B63400884BD7 /* libopencv_stitching.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CE1D49B63400884BD7 /* libopencv_stitching.2.4.dylib */; }; 55 | CB8E870C1D49B63400884BD7 /* libopencv_stitching.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86CF1D49B63400884BD7 /* libopencv_stitching.dylib */; }; 56 | CB8E870D1D49B63400884BD7 /* libopencv_superres.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D01D49B63400884BD7 /* libopencv_superres.2.4.13.dylib */; }; 57 | CB8E870E1D49B63400884BD7 /* libopencv_superres.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D11D49B63400884BD7 /* libopencv_superres.2.4.dylib */; }; 58 | CB8E870F1D49B63400884BD7 /* libopencv_superres.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D21D49B63400884BD7 /* libopencv_superres.dylib */; }; 59 | CB8E87101D49B63400884BD7 /* libopencv_ts.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D31D49B63400884BD7 /* libopencv_ts.a */; }; 60 | CB8E87111D49B63400884BD7 /* libopencv_video.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D41D49B63400884BD7 /* libopencv_video.2.4.13.dylib */; }; 61 | CB8E87121D49B63400884BD7 /* libopencv_video.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D51D49B63400884BD7 /* libopencv_video.2.4.dylib */; }; 62 | CB8E87131D49B63400884BD7 /* libopencv_video.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D61D49B63400884BD7 /* libopencv_video.dylib */; }; 63 | CB8E87141D49B63400884BD7 /* libopencv_videostab.2.4.13.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D71D49B63400884BD7 /* libopencv_videostab.2.4.13.dylib */; }; 64 | CB8E87151D49B63400884BD7 /* libopencv_videostab.2.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D81D49B63400884BD7 /* libopencv_videostab.2.4.dylib */; }; 65 | CB8E87161D49B63400884BD7 /* libopencv_videostab.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8E86D91D49B63400884BD7 /* libopencv_videostab.dylib */; }; 66 | CB96FA101D658E01009760DA /* data in CopyFiles */ = {isa = PBXBuildFile; fileRef = CB96FA0F1D658DEE009760DA /* data */; }; 67 | /* End PBXBuildFile section */ 68 | 69 | /* Begin PBXCopyFilesBuildPhase section */ 70 | CB8E86931D49B50100884BD7 /* CopyFiles */ = { 71 | isa = PBXCopyFilesBuildPhase; 72 | buildActionMask = 12; 73 | dstPath = ""; 74 | dstSubfolderSpec = 16; 75 | files = ( 76 | CB96FA101D658E01009760DA /* data in CopyFiles */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXCopyFilesBuildPhase section */ 81 | 82 | /* Begin PBXFileReference section */ 83 | CB8E86951D49B50100884BD7 /* LearningOpenCV */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LearningOpenCV; sourceTree = BUILT_PRODUCTS_DIR; }; 84 | CB8E86A01D49B58D00884BD7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 85 | CB8E86A31D49B63400884BD7 /* libopencv_calib3d.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_calib3d.2.4.13.dylib; sourceTree = ""; }; 86 | CB8E86A41D49B63400884BD7 /* libopencv_calib3d.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_calib3d.2.4.dylib; sourceTree = ""; }; 87 | CB8E86A51D49B63400884BD7 /* libopencv_calib3d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_calib3d.dylib; sourceTree = ""; }; 88 | CB8E86A61D49B63400884BD7 /* libopencv_contrib.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_contrib.2.4.13.dylib; sourceTree = ""; }; 89 | CB8E86A71D49B63400884BD7 /* libopencv_contrib.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_contrib.2.4.dylib; sourceTree = ""; }; 90 | CB8E86A81D49B63400884BD7 /* libopencv_contrib.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_contrib.dylib; sourceTree = ""; }; 91 | CB8E86A91D49B63400884BD7 /* libopencv_core.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_core.2.4.13.dylib; sourceTree = ""; }; 92 | CB8E86AA1D49B63400884BD7 /* libopencv_core.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_core.2.4.dylib; sourceTree = ""; }; 93 | CB8E86AB1D49B63400884BD7 /* libopencv_core.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_core.dylib; sourceTree = ""; }; 94 | CB8E86AC1D49B63400884BD7 /* libopencv_features2d.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_features2d.2.4.13.dylib; sourceTree = ""; }; 95 | CB8E86AD1D49B63400884BD7 /* libopencv_features2d.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_features2d.2.4.dylib; sourceTree = ""; }; 96 | CB8E86AE1D49B63400884BD7 /* libopencv_features2d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_features2d.dylib; sourceTree = ""; }; 97 | CB8E86AF1D49B63400884BD7 /* libopencv_flann.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_flann.2.4.13.dylib; sourceTree = ""; }; 98 | CB8E86B01D49B63400884BD7 /* libopencv_flann.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_flann.2.4.dylib; sourceTree = ""; }; 99 | CB8E86B11D49B63400884BD7 /* libopencv_flann.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_flann.dylib; sourceTree = ""; }; 100 | CB8E86B21D49B63400884BD7 /* libopencv_gpu.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_gpu.2.4.13.dylib; sourceTree = ""; }; 101 | CB8E86B31D49B63400884BD7 /* libopencv_gpu.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_gpu.2.4.dylib; sourceTree = ""; }; 102 | CB8E86B41D49B63400884BD7 /* libopencv_gpu.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_gpu.dylib; sourceTree = ""; }; 103 | CB8E86B51D49B63400884BD7 /* libopencv_highgui.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_highgui.2.4.13.dylib; sourceTree = ""; }; 104 | CB8E86B61D49B63400884BD7 /* libopencv_highgui.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_highgui.2.4.dylib; sourceTree = ""; }; 105 | CB8E86B71D49B63400884BD7 /* libopencv_highgui.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_highgui.dylib; sourceTree = ""; }; 106 | CB8E86B81D49B63400884BD7 /* libopencv_imgproc.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_imgproc.2.4.13.dylib; sourceTree = ""; }; 107 | CB8E86B91D49B63400884BD7 /* libopencv_imgproc.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_imgproc.2.4.dylib; sourceTree = ""; }; 108 | CB8E86BA1D49B63400884BD7 /* libopencv_imgproc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_imgproc.dylib; sourceTree = ""; }; 109 | CB8E86BB1D49B63400884BD7 /* libopencv_legacy.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_legacy.2.4.13.dylib; sourceTree = ""; }; 110 | CB8E86BC1D49B63400884BD7 /* libopencv_legacy.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_legacy.2.4.dylib; sourceTree = ""; }; 111 | CB8E86BD1D49B63400884BD7 /* libopencv_legacy.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_legacy.dylib; sourceTree = ""; }; 112 | CB8E86BE1D49B63400884BD7 /* libopencv_ml.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ml.2.4.13.dylib; sourceTree = ""; }; 113 | CB8E86BF1D49B63400884BD7 /* libopencv_ml.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ml.2.4.dylib; sourceTree = ""; }; 114 | CB8E86C01D49B63400884BD7 /* libopencv_ml.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ml.dylib; sourceTree = ""; }; 115 | CB8E86C11D49B63400884BD7 /* libopencv_nonfree.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_nonfree.2.4.13.dylib; sourceTree = ""; }; 116 | CB8E86C21D49B63400884BD7 /* libopencv_nonfree.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_nonfree.2.4.dylib; sourceTree = ""; }; 117 | CB8E86C31D49B63400884BD7 /* libopencv_nonfree.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_nonfree.dylib; sourceTree = ""; }; 118 | CB8E86C41D49B63400884BD7 /* libopencv_objdetect.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_objdetect.2.4.13.dylib; sourceTree = ""; }; 119 | CB8E86C51D49B63400884BD7 /* libopencv_objdetect.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_objdetect.2.4.dylib; sourceTree = ""; }; 120 | CB8E86C61D49B63400884BD7 /* libopencv_objdetect.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_objdetect.dylib; sourceTree = ""; }; 121 | CB8E86C71D49B63400884BD7 /* libopencv_ocl.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ocl.2.4.13.dylib; sourceTree = ""; }; 122 | CB8E86C81D49B63400884BD7 /* libopencv_ocl.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ocl.2.4.dylib; sourceTree = ""; }; 123 | CB8E86C91D49B63400884BD7 /* libopencv_ocl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_ocl.dylib; sourceTree = ""; }; 124 | CB8E86CA1D49B63400884BD7 /* libopencv_photo.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_photo.2.4.13.dylib; sourceTree = ""; }; 125 | CB8E86CB1D49B63400884BD7 /* libopencv_photo.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_photo.2.4.dylib; sourceTree = ""; }; 126 | CB8E86CC1D49B63400884BD7 /* libopencv_photo.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_photo.dylib; sourceTree = ""; }; 127 | CB8E86CD1D49B63400884BD7 /* libopencv_stitching.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_stitching.2.4.13.dylib; sourceTree = ""; }; 128 | CB8E86CE1D49B63400884BD7 /* libopencv_stitching.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_stitching.2.4.dylib; sourceTree = ""; }; 129 | CB8E86CF1D49B63400884BD7 /* libopencv_stitching.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_stitching.dylib; sourceTree = ""; }; 130 | CB8E86D01D49B63400884BD7 /* libopencv_superres.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_superres.2.4.13.dylib; sourceTree = ""; }; 131 | CB8E86D11D49B63400884BD7 /* libopencv_superres.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_superres.2.4.dylib; sourceTree = ""; }; 132 | CB8E86D21D49B63400884BD7 /* libopencv_superres.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_superres.dylib; sourceTree = ""; }; 133 | CB8E86D31D49B63400884BD7 /* libopencv_ts.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libopencv_ts.a; sourceTree = ""; }; 134 | CB8E86D41D49B63400884BD7 /* libopencv_video.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_video.2.4.13.dylib; sourceTree = ""; }; 135 | CB8E86D51D49B63400884BD7 /* libopencv_video.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_video.2.4.dylib; sourceTree = ""; }; 136 | CB8E86D61D49B63400884BD7 /* libopencv_video.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_video.dylib; sourceTree = ""; }; 137 | CB8E86D71D49B63400884BD7 /* libopencv_videostab.2.4.13.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_videostab.2.4.13.dylib; sourceTree = ""; }; 138 | CB8E86D81D49B63400884BD7 /* libopencv_videostab.2.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_videostab.2.4.dylib; sourceTree = ""; }; 139 | CB8E86D91D49B63400884BD7 /* libopencv_videostab.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libopencv_videostab.dylib; sourceTree = ""; }; 140 | CB96FA0F1D658DEE009760DA /* data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = data; path = ../../../Mac/LearningOpenCV/data; sourceTree = ""; }; 141 | /* End PBXFileReference section */ 142 | 143 | /* Begin PBXFrameworksBuildPhase section */ 144 | CB8E86921D49B50100884BD7 /* Frameworks */ = { 145 | isa = PBXFrameworksBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | CB8E86E11D49B63400884BD7 /* libopencv_calib3d.2.4.dylib in Frameworks */, 149 | CB8E87041D49B63400884BD7 /* libopencv_ocl.2.4.13.dylib in Frameworks */, 150 | CB8E86F31D49B63400884BD7 /* libopencv_highgui.2.4.dylib in Frameworks */, 151 | CB8E86FD1D49B63400884BD7 /* libopencv_ml.dylib in Frameworks */, 152 | CB8E870F1D49B63400884BD7 /* libopencv_superres.dylib in Frameworks */, 153 | CB8E86E41D49B63400884BD7 /* libopencv_contrib.2.4.dylib in Frameworks */, 154 | CB8E86F71D49B63400884BD7 /* libopencv_imgproc.dylib in Frameworks */, 155 | CB8E87061D49B63400884BD7 /* libopencv_ocl.dylib in Frameworks */, 156 | CB8E86E61D49B63400884BD7 /* libopencv_core.2.4.13.dylib in Frameworks */, 157 | CB8E86E21D49B63400884BD7 /* libopencv_calib3d.dylib in Frameworks */, 158 | CB8E87141D49B63400884BD7 /* libopencv_videostab.2.4.13.dylib in Frameworks */, 159 | CB8E86F11D49B63400884BD7 /* libopencv_gpu.dylib in Frameworks */, 160 | CB8E86E81D49B63400884BD7 /* libopencv_core.dylib in Frameworks */, 161 | CB8E86E31D49B63400884BD7 /* libopencv_contrib.2.4.13.dylib in Frameworks */, 162 | CB8E86EC1D49B63400884BD7 /* libopencv_flann.2.4.13.dylib in Frameworks */, 163 | CB8E870A1D49B63400884BD7 /* libopencv_stitching.2.4.13.dylib in Frameworks */, 164 | CB8E87161D49B63400884BD7 /* libopencv_videostab.dylib in Frameworks */, 165 | CB8E86F01D49B63400884BD7 /* libopencv_gpu.2.4.dylib in Frameworks */, 166 | CB8E86F51D49B63400884BD7 /* libopencv_imgproc.2.4.13.dylib in Frameworks */, 167 | CB8E86FF1D49B63400884BD7 /* libopencv_nonfree.2.4.dylib in Frameworks */, 168 | CB8E86ED1D49B63400884BD7 /* libopencv_flann.2.4.dylib in Frameworks */, 169 | CB8E87131D49B63400884BD7 /* libopencv_video.dylib in Frameworks */, 170 | CB8E870C1D49B63400884BD7 /* libopencv_stitching.dylib in Frameworks */, 171 | CB8E86FB1D49B63400884BD7 /* libopencv_ml.2.4.13.dylib in Frameworks */, 172 | CB8E870E1D49B63400884BD7 /* libopencv_superres.2.4.dylib in Frameworks */, 173 | CB8E87121D49B63400884BD7 /* libopencv_video.2.4.dylib in Frameworks */, 174 | CB8E86EE1D49B63400884BD7 /* libopencv_flann.dylib in Frameworks */, 175 | CB8E86FC1D49B63400884BD7 /* libopencv_ml.2.4.dylib in Frameworks */, 176 | CB8E87011D49B63400884BD7 /* libopencv_objdetect.2.4.13.dylib in Frameworks */, 177 | CB8E86E01D49B63400884BD7 /* libopencv_calib3d.2.4.13.dylib in Frameworks */, 178 | CB8E87111D49B63400884BD7 /* libopencv_video.2.4.13.dylib in Frameworks */, 179 | CB8E86F61D49B63400884BD7 /* libopencv_imgproc.2.4.dylib in Frameworks */, 180 | CB8E87101D49B63400884BD7 /* libopencv_ts.a in Frameworks */, 181 | CB8E86EA1D49B63400884BD7 /* libopencv_features2d.2.4.dylib in Frameworks */, 182 | CB8E86F21D49B63400884BD7 /* libopencv_highgui.2.4.13.dylib in Frameworks */, 183 | CB8E86FE1D49B63400884BD7 /* libopencv_nonfree.2.4.13.dylib in Frameworks */, 184 | CB8E86E91D49B63400884BD7 /* libopencv_features2d.2.4.13.dylib in Frameworks */, 185 | CB8E86E71D49B63400884BD7 /* libopencv_core.2.4.dylib in Frameworks */, 186 | CB8E86EF1D49B63400884BD7 /* libopencv_gpu.2.4.13.dylib in Frameworks */, 187 | CB8E87071D49B63400884BD7 /* libopencv_photo.2.4.13.dylib in Frameworks */, 188 | CB8E870B1D49B63400884BD7 /* libopencv_stitching.2.4.dylib in Frameworks */, 189 | CB8E86EB1D49B63400884BD7 /* libopencv_features2d.dylib in Frameworks */, 190 | CB8E87031D49B63400884BD7 /* libopencv_objdetect.dylib in Frameworks */, 191 | CB8E87051D49B63400884BD7 /* libopencv_ocl.2.4.dylib in Frameworks */, 192 | CB8E86FA1D49B63400884BD7 /* libopencv_legacy.dylib in Frameworks */, 193 | CB8E870D1D49B63400884BD7 /* libopencv_superres.2.4.13.dylib in Frameworks */, 194 | CB8E87021D49B63400884BD7 /* libopencv_objdetect.2.4.dylib in Frameworks */, 195 | CB8E86F91D49B63400884BD7 /* libopencv_legacy.2.4.dylib in Frameworks */, 196 | CB8E87151D49B63400884BD7 /* libopencv_videostab.2.4.dylib in Frameworks */, 197 | CB8E86F81D49B63400884BD7 /* libopencv_legacy.2.4.13.dylib in Frameworks */, 198 | CB8E87081D49B63400884BD7 /* libopencv_photo.2.4.dylib in Frameworks */, 199 | CB8E87091D49B63400884BD7 /* libopencv_photo.dylib in Frameworks */, 200 | CB8E86E51D49B63400884BD7 /* libopencv_contrib.dylib in Frameworks */, 201 | CB8E86F41D49B63400884BD7 /* libopencv_highgui.dylib in Frameworks */, 202 | CB8E87001D49B63400884BD7 /* libopencv_nonfree.dylib in Frameworks */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXFrameworksBuildPhase section */ 207 | 208 | /* Begin PBXGroup section */ 209 | CB8E868C1D49B50100884BD7 = { 210 | isa = PBXGroup; 211 | children = ( 212 | CB96FA0F1D658DEE009760DA /* data */, 213 | CB8E86A21D49B63400884BD7 /* lib */, 214 | CB8E869F1D49B58D00884BD7 /* src */, 215 | CB8E86961D49B50100884BD7 /* Products */, 216 | ); 217 | sourceTree = ""; 218 | }; 219 | CB8E86961D49B50100884BD7 /* Products */ = { 220 | isa = PBXGroup; 221 | children = ( 222 | CB8E86951D49B50100884BD7 /* LearningOpenCV */, 223 | ); 224 | name = Products; 225 | sourceTree = ""; 226 | }; 227 | CB8E869F1D49B58D00884BD7 /* src */ = { 228 | isa = PBXGroup; 229 | children = ( 230 | CB8E86A01D49B58D00884BD7 /* main.cpp */, 231 | ); 232 | name = src; 233 | path = ../src; 234 | sourceTree = ""; 235 | }; 236 | CB8E86A21D49B63400884BD7 /* lib */ = { 237 | isa = PBXGroup; 238 | children = ( 239 | CB8E86A31D49B63400884BD7 /* libopencv_calib3d.2.4.13.dylib */, 240 | CB8E86A41D49B63400884BD7 /* libopencv_calib3d.2.4.dylib */, 241 | CB8E86A51D49B63400884BD7 /* libopencv_calib3d.dylib */, 242 | CB8E86A61D49B63400884BD7 /* libopencv_contrib.2.4.13.dylib */, 243 | CB8E86A71D49B63400884BD7 /* libopencv_contrib.2.4.dylib */, 244 | CB8E86A81D49B63400884BD7 /* libopencv_contrib.dylib */, 245 | CB8E86A91D49B63400884BD7 /* libopencv_core.2.4.13.dylib */, 246 | CB8E86AA1D49B63400884BD7 /* libopencv_core.2.4.dylib */, 247 | CB8E86AB1D49B63400884BD7 /* libopencv_core.dylib */, 248 | CB8E86AC1D49B63400884BD7 /* libopencv_features2d.2.4.13.dylib */, 249 | CB8E86AD1D49B63400884BD7 /* libopencv_features2d.2.4.dylib */, 250 | CB8E86AE1D49B63400884BD7 /* libopencv_features2d.dylib */, 251 | CB8E86AF1D49B63400884BD7 /* libopencv_flann.2.4.13.dylib */, 252 | CB8E86B01D49B63400884BD7 /* libopencv_flann.2.4.dylib */, 253 | CB8E86B11D49B63400884BD7 /* libopencv_flann.dylib */, 254 | CB8E86B21D49B63400884BD7 /* libopencv_gpu.2.4.13.dylib */, 255 | CB8E86B31D49B63400884BD7 /* libopencv_gpu.2.4.dylib */, 256 | CB8E86B41D49B63400884BD7 /* libopencv_gpu.dylib */, 257 | CB8E86B51D49B63400884BD7 /* libopencv_highgui.2.4.13.dylib */, 258 | CB8E86B61D49B63400884BD7 /* libopencv_highgui.2.4.dylib */, 259 | CB8E86B71D49B63400884BD7 /* libopencv_highgui.dylib */, 260 | CB8E86B81D49B63400884BD7 /* libopencv_imgproc.2.4.13.dylib */, 261 | CB8E86B91D49B63400884BD7 /* libopencv_imgproc.2.4.dylib */, 262 | CB8E86BA1D49B63400884BD7 /* libopencv_imgproc.dylib */, 263 | CB8E86BB1D49B63400884BD7 /* libopencv_legacy.2.4.13.dylib */, 264 | CB8E86BC1D49B63400884BD7 /* libopencv_legacy.2.4.dylib */, 265 | CB8E86BD1D49B63400884BD7 /* libopencv_legacy.dylib */, 266 | CB8E86BE1D49B63400884BD7 /* libopencv_ml.2.4.13.dylib */, 267 | CB8E86BF1D49B63400884BD7 /* libopencv_ml.2.4.dylib */, 268 | CB8E86C01D49B63400884BD7 /* libopencv_ml.dylib */, 269 | CB8E86C11D49B63400884BD7 /* libopencv_nonfree.2.4.13.dylib */, 270 | CB8E86C21D49B63400884BD7 /* libopencv_nonfree.2.4.dylib */, 271 | CB8E86C31D49B63400884BD7 /* libopencv_nonfree.dylib */, 272 | CB8E86C41D49B63400884BD7 /* libopencv_objdetect.2.4.13.dylib */, 273 | CB8E86C51D49B63400884BD7 /* libopencv_objdetect.2.4.dylib */, 274 | CB8E86C61D49B63400884BD7 /* libopencv_objdetect.dylib */, 275 | CB8E86C71D49B63400884BD7 /* libopencv_ocl.2.4.13.dylib */, 276 | CB8E86C81D49B63400884BD7 /* libopencv_ocl.2.4.dylib */, 277 | CB8E86C91D49B63400884BD7 /* libopencv_ocl.dylib */, 278 | CB8E86CA1D49B63400884BD7 /* libopencv_photo.2.4.13.dylib */, 279 | CB8E86CB1D49B63400884BD7 /* libopencv_photo.2.4.dylib */, 280 | CB8E86CC1D49B63400884BD7 /* libopencv_photo.dylib */, 281 | CB8E86CD1D49B63400884BD7 /* libopencv_stitching.2.4.13.dylib */, 282 | CB8E86CE1D49B63400884BD7 /* libopencv_stitching.2.4.dylib */, 283 | CB8E86CF1D49B63400884BD7 /* libopencv_stitching.dylib */, 284 | CB8E86D01D49B63400884BD7 /* libopencv_superres.2.4.13.dylib */, 285 | CB8E86D11D49B63400884BD7 /* libopencv_superres.2.4.dylib */, 286 | CB8E86D21D49B63400884BD7 /* libopencv_superres.dylib */, 287 | CB8E86D31D49B63400884BD7 /* libopencv_ts.a */, 288 | CB8E86D41D49B63400884BD7 /* libopencv_video.2.4.13.dylib */, 289 | CB8E86D51D49B63400884BD7 /* libopencv_video.2.4.dylib */, 290 | CB8E86D61D49B63400884BD7 /* libopencv_video.dylib */, 291 | CB8E86D71D49B63400884BD7 /* libopencv_videostab.2.4.13.dylib */, 292 | CB8E86D81D49B63400884BD7 /* libopencv_videostab.2.4.dylib */, 293 | CB8E86D91D49B63400884BD7 /* libopencv_videostab.dylib */, 294 | ); 295 | name = lib; 296 | path = ../../../../../../usr/local/Cellar/opencv/2.4.13/lib; 297 | sourceTree = ""; 298 | }; 299 | /* End PBXGroup section */ 300 | 301 | /* Begin PBXNativeTarget section */ 302 | CB8E86941D49B50100884BD7 /* LearningOpenCV */ = { 303 | isa = PBXNativeTarget; 304 | buildConfigurationList = CB8E869C1D49B50100884BD7 /* Build configuration list for PBXNativeTarget "LearningOpenCV" */; 305 | buildPhases = ( 306 | CB8E86911D49B50100884BD7 /* Sources */, 307 | CB8E86921D49B50100884BD7 /* Frameworks */, 308 | CB8E86931D49B50100884BD7 /* CopyFiles */, 309 | ); 310 | buildRules = ( 311 | ); 312 | dependencies = ( 313 | ); 314 | name = LearningOpenCV; 315 | productName = LearningOpenCV; 316 | productReference = CB8E86951D49B50100884BD7 /* LearningOpenCV */; 317 | productType = "com.apple.product-type.tool"; 318 | }; 319 | /* End PBXNativeTarget section */ 320 | 321 | /* Begin PBXProject section */ 322 | CB8E868D1D49B50100884BD7 /* Project object */ = { 323 | isa = PBXProject; 324 | attributes = { 325 | LastUpgradeCheck = 0730; 326 | ORGANIZATIONNAME = Yourtion; 327 | TargetAttributes = { 328 | CB8E86941D49B50100884BD7 = { 329 | CreatedOnToolsVersion = 7.3.1; 330 | }; 331 | }; 332 | }; 333 | buildConfigurationList = CB8E86901D49B50100884BD7 /* Build configuration list for PBXProject "LearningOpenCV" */; 334 | compatibilityVersion = "Xcode 3.2"; 335 | developmentRegion = English; 336 | hasScannedForEncodings = 0; 337 | knownRegions = ( 338 | en, 339 | ); 340 | mainGroup = CB8E868C1D49B50100884BD7; 341 | productRefGroup = CB8E86961D49B50100884BD7 /* Products */; 342 | projectDirPath = ""; 343 | projectRoot = ""; 344 | targets = ( 345 | CB8E86941D49B50100884BD7 /* LearningOpenCV */, 346 | ); 347 | }; 348 | /* End PBXProject section */ 349 | 350 | /* Begin PBXSourcesBuildPhase section */ 351 | CB8E86911D49B50100884BD7 /* Sources */ = { 352 | isa = PBXSourcesBuildPhase; 353 | buildActionMask = 2147483647; 354 | files = ( 355 | CB8E86A11D49B58D00884BD7 /* main.cpp in Sources */, 356 | ); 357 | runOnlyForDeploymentPostprocessing = 0; 358 | }; 359 | /* End PBXSourcesBuildPhase section */ 360 | 361 | /* Begin XCBuildConfiguration section */ 362 | CB8E869A1D49B50100884BD7 /* Debug */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ALWAYS_SEARCH_USER_PATHS = NO; 366 | CLANG_ANALYZER_NONNULL = YES; 367 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 368 | CLANG_CXX_LIBRARY = "libc++"; 369 | CLANG_ENABLE_MODULES = YES; 370 | CLANG_ENABLE_OBJC_ARC = YES; 371 | CLANG_WARN_BOOL_CONVERSION = YES; 372 | CLANG_WARN_CONSTANT_CONVERSION = YES; 373 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 374 | CLANG_WARN_EMPTY_BODY = YES; 375 | CLANG_WARN_ENUM_CONVERSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 378 | CLANG_WARN_UNREACHABLE_CODE = YES; 379 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 380 | CODE_SIGN_IDENTITY = "-"; 381 | COPY_PHASE_STRIP = NO; 382 | DEBUG_INFORMATION_FORMAT = dwarf; 383 | ENABLE_STRICT_OBJC_MSGSEND = YES; 384 | ENABLE_TESTABILITY = YES; 385 | GCC_C_LANGUAGE_STANDARD = gnu99; 386 | GCC_DYNAMIC_NO_PIC = NO; 387 | GCC_NO_COMMON_BLOCKS = YES; 388 | GCC_OPTIMIZATION_LEVEL = 0; 389 | GCC_PREPROCESSOR_DEFINITIONS = ( 390 | "DEBUG=1", 391 | "$(inherited)", 392 | ); 393 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 394 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 395 | GCC_WARN_UNDECLARED_SELECTOR = YES; 396 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 397 | GCC_WARN_UNUSED_FUNCTION = YES; 398 | GCC_WARN_UNUSED_VARIABLE = YES; 399 | MACOSX_DEPLOYMENT_TARGET = 10.11; 400 | MTL_ENABLE_DEBUG_INFO = YES; 401 | ONLY_ACTIVE_ARCH = YES; 402 | SDKROOT = macosx; 403 | }; 404 | name = Debug; 405 | }; 406 | CB8E869B1D49B50100884BD7 /* Release */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | ALWAYS_SEARCH_USER_PATHS = NO; 410 | CLANG_ANALYZER_NONNULL = YES; 411 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 412 | CLANG_CXX_LIBRARY = "libc++"; 413 | CLANG_ENABLE_MODULES = YES; 414 | CLANG_ENABLE_OBJC_ARC = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_CONSTANT_CONVERSION = YES; 417 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 418 | CLANG_WARN_EMPTY_BODY = YES; 419 | CLANG_WARN_ENUM_CONVERSION = YES; 420 | CLANG_WARN_INT_CONVERSION = YES; 421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 422 | CLANG_WARN_UNREACHABLE_CODE = YES; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | CODE_SIGN_IDENTITY = "-"; 425 | COPY_PHASE_STRIP = NO; 426 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 427 | ENABLE_NS_ASSERTIONS = NO; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | GCC_C_LANGUAGE_STANDARD = gnu99; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 432 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 433 | GCC_WARN_UNDECLARED_SELECTOR = YES; 434 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 435 | GCC_WARN_UNUSED_FUNCTION = YES; 436 | GCC_WARN_UNUSED_VARIABLE = YES; 437 | MACOSX_DEPLOYMENT_TARGET = 10.11; 438 | MTL_ENABLE_DEBUG_INFO = NO; 439 | SDKROOT = macosx; 440 | }; 441 | name = Release; 442 | }; 443 | CB8E869D1D49B50100884BD7 /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | FRAMEWORK_SEARCH_PATHS = "/usr/local/Cellar/opencv/2.4.13/lib/**"; 447 | HEADER_SEARCH_PATHS = "/usr/local/Cellar/opencv/2.4.13/include/**"; 448 | LIBRARY_SEARCH_PATHS = ( 449 | "$(inherited)", 450 | /usr/local/Cellar/opencv/2.4.13/lib, 451 | "/usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages", 452 | ); 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | }; 455 | name = Debug; 456 | }; 457 | CB8E869E1D49B50100884BD7 /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | FRAMEWORK_SEARCH_PATHS = "/usr/local/Cellar/opencv/2.4.13/lib/**"; 461 | HEADER_SEARCH_PATHS = "/usr/local/Cellar/opencv/2.4.13/include/**"; 462 | LIBRARY_SEARCH_PATHS = ( 463 | "$(inherited)", 464 | /usr/local/Cellar/opencv/2.4.13/lib, 465 | "/usr/local/Cellar/opencv/2.4.13/lib/python2.7/site-packages", 466 | ); 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | }; 469 | name = Release; 470 | }; 471 | /* End XCBuildConfiguration section */ 472 | 473 | /* Begin XCConfigurationList section */ 474 | CB8E86901D49B50100884BD7 /* Build configuration list for PBXProject "LearningOpenCV" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | CB8E869A1D49B50100884BD7 /* Debug */, 478 | CB8E869B1D49B50100884BD7 /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | CB8E869C1D49B50100884BD7 /* Build configuration list for PBXNativeTarget "LearningOpenCV" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | CB8E869D1D49B50100884BD7 /* Debug */, 487 | CB8E869E1D49B50100884BD7 /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = CB8E868D1D49B50100884BD7 /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /XcodeProject/LearningOpenCV.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XcodeProject/LearningOpenCV.xcodeproj/xcshareddata/xcschemes/LearningOpenCV.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 68 | 69 | 72 | 73 | 76 | 77 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 95 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /data/Distortion.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4 5 | 1 6 |
f
7 | 8 | 1.27418399e-01 -5.63273847e-01 4.61841747e-03 -2.55276146e-03
9 |
10 | -------------------------------------------------------------------------------- /data/Intrinsics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 3 5 | 3 6 |
f
7 | 8 | 1.76565405e+03 0. 8.08267944e+02 0. 1.76637073e+03 6.29673218e+02 0. 9 | 0. 1.
10 |
11 | -------------------------------------------------------------------------------- /data/OpticalFlow0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/OpticalFlow0.jpg -------------------------------------------------------------------------------- /data/OpticalFlow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/OpticalFlow1.jpg -------------------------------------------------------------------------------- /data/baboon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/baboon.jpg -------------------------------------------------------------------------------- /data/birdseye.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0214.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0214.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0214L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0214L.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0215.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0215.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0215L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0215L.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0217.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0217L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0217L.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0218.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0218.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0218L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0218L.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0219.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0219.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0219L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0219L.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0220.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0220.jpg -------------------------------------------------------------------------------- /data/birdseye/IMG_0220L.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/birdseye/IMG_0220L.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0191.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0191.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0192.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0192.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0193.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0193.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0194.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0194.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0195.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0195.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0196.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0196.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0197.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0197.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0198.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0198.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0199.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0199.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0200.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0200.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0201.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0201.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0202.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0202.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0203.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0203.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0204.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0204.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0205.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0205.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0206.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0206.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0207.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0207.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0208.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0208.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0209.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0209.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0210.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0210.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0211.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0211.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0212.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0212.jpg -------------------------------------------------------------------------------- /data/calibration/IMG_0213.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/calibration/IMG_0213.jpg -------------------------------------------------------------------------------- /data/ch12_list.txt: -------------------------------------------------------------------------------- 1 | ./data/stereoData/left01.jpg 2 | ./data/stereoData/right01.jpg 3 | ./data/stereoData/left02.jpg 4 | ./data/stereoData/right02.jpg 5 | ./data/stereoData/left03.jpg 6 | ./data/stereoData/right03.jpg 7 | ./data/stereoData/left04.jpg 8 | ./data/stereoData/right04.jpg 9 | ./data/stereoData/left05.jpg 10 | ./data/stereoData/right05.jpg 11 | ./data/stereoData/left06.jpg 12 | ./data/stereoData/right06.jpg 13 | ./data/stereoData/left07.jpg 14 | ./data/stereoData/right07.jpg 15 | ./data/stereoData/left08.jpg 16 | ./data/stereoData/right08.jpg 17 | ./data/stereoData/left09.jpg 18 | ./data/stereoData/right09.jpg 19 | #./data/stereoData/left10.jpg 20 | #./data/stereoData/right10.jpg 21 | ./data/stereoData/left11.jpg 22 | ./data/stereoData/right11.jpg 23 | ./data/stereoData/left12.jpg 24 | ./data/stereoData/right12.jpg 25 | ./data/stereoData/left13.jpg 26 | ./data/stereoData/right13.jpg 27 | ./data/stereoData/left14.jpg 28 | ./data/stereoData/right14.jpg 29 | -------------------------------------------------------------------------------- /data/chessboards.txt: -------------------------------------------------------------------------------- 1 | ./data/birdseye/IMG_0214L.jpg 2 | ./data/birdseye/IMG_0215L.jpg 3 | ./data/birdseye/IMG_0217L.jpg 4 | ./data/birdseye/IMG_0218L.jpg 5 | ./data/birdseye/IMG_0219L.jpg 6 | ./data/birdseye/IMG_0220L.jpg 7 | ./data/calibration/IMG_0191.jpg 8 | ./data/calibration/IMG_0192.jpg 9 | ./data/calibration/IMG_0193.jpg 10 | ./data/calibration/IMG_0194.jpg 11 | ./data/calibration/IMG_0195.jpg 12 | ./data/calibration/IMG_0196.jpg 13 | ./data/calibration/IMG_0197.jpg 14 | ./data/calibration/IMG_0198.jpg 15 | ./data/calibration/IMG_0199.jpg 16 | ./data/calibration/IMG_0201.jpg 17 | ./data/calibration/IMG_0202.jpg 18 | ./data/calibration/IMG_0203.jpg 19 | ./data/calibration/IMG_0205.jpg 20 | ./data/calibration/IMG_0206.jpg 21 | ./data/calibration/IMG_0208.jpg 22 | ./data/calibration/IMG_0209.jpg 23 | ./data/calibration/IMG_0210.jpg 24 | ./data/calibration/IMG_0211.jpg 25 | ./data/calibration/IMG_0212.jpg 26 | ./data/calibration/IMG_0213.jpg 27 | -------------------------------------------------------------------------------- /data/edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/edge.png -------------------------------------------------------------------------------- /data/faceScene.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/faceScene.jpg -------------------------------------------------------------------------------- /data/faceTemplate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/faceTemplate.jpg -------------------------------------------------------------------------------- /data/fruits.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/fruits.jpg -------------------------------------------------------------------------------- /data/stereoData/left01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left01.jpg -------------------------------------------------------------------------------- /data/stereoData/left02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left02.jpg -------------------------------------------------------------------------------- /data/stereoData/left03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left03.jpg -------------------------------------------------------------------------------- /data/stereoData/left04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left04.jpg -------------------------------------------------------------------------------- /data/stereoData/left05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left05.jpg -------------------------------------------------------------------------------- /data/stereoData/left06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left06.jpg -------------------------------------------------------------------------------- /data/stereoData/left07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left07.jpg -------------------------------------------------------------------------------- /data/stereoData/left08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left08.jpg -------------------------------------------------------------------------------- /data/stereoData/left09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left09.jpg -------------------------------------------------------------------------------- /data/stereoData/left10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left10.jpg -------------------------------------------------------------------------------- /data/stereoData/left11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left11.jpg -------------------------------------------------------------------------------- /data/stereoData/left12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left12.jpg -------------------------------------------------------------------------------- /data/stereoData/left13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left13.jpg -------------------------------------------------------------------------------- /data/stereoData/left14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/left14.jpg -------------------------------------------------------------------------------- /data/stereoData/right01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right01.jpg -------------------------------------------------------------------------------- /data/stereoData/right02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right02.jpg -------------------------------------------------------------------------------- /data/stereoData/right03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right03.jpg -------------------------------------------------------------------------------- /data/stereoData/right04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right04.jpg -------------------------------------------------------------------------------- /data/stereoData/right05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right05.jpg -------------------------------------------------------------------------------- /data/stereoData/right06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right06.jpg -------------------------------------------------------------------------------- /data/stereoData/right07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right07.jpg -------------------------------------------------------------------------------- /data/stereoData/right08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right08.jpg -------------------------------------------------------------------------------- /data/stereoData/right09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right09.jpg -------------------------------------------------------------------------------- /data/stereoData/right10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right10.jpg -------------------------------------------------------------------------------- /data/stereoData/right11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right11.jpg -------------------------------------------------------------------------------- /data/stereoData/right12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right12.jpg -------------------------------------------------------------------------------- /data/stereoData/right13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right13.jpg -------------------------------------------------------------------------------- /data/stereoData/right14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stereoData/right14.jpg -------------------------------------------------------------------------------- /data/stuff.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourtion/LearningOpenCV/f825090058f33a6e4945e9b4dd1fd440b23663ce/data/stuff.jpg -------------------------------------------------------------------------------- /src/Chapter02/Practice5.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int g_slider_size = 2; 14 | 15 | IplImage* doPyrDown (IplImage* in, int filter = IPL_GAUSSIAN_5x5 ) { 16 | assert( in->width%2 == 0 && in->height%2 == 0 ); 17 | IplImage *out = cvCreateImage( cvSize( in->width/2, in->height/2 ), in->depth, in->nChannels); 18 | cvPyrDown( in, out ); 19 | return ( out ); 20 | } 21 | 22 | int main(int argc, const char * argv[]) { 23 | CvCapture* capture = cvCreateCameraCapture(0); 24 | cvNamedWindow("Practice", CV_WINDOW_AUTOSIZE); 25 | cvCreateTrackbar("Position", "Practice", &g_slider_size, 6); 26 | IplImage* frame; 27 | while (1) { 28 | frame = cvQueryFrame( capture ); 29 | if (!frame) break; 30 | for ( int i = 0; i 10 | #include 11 | 12 | int main(int argc, const char * argv[]) { 13 | CvCapture* capture = cvCreateCameraCapture(0); 14 | cvNamedWindow("Example5", CV_WINDOW_AUTOSIZE); 15 | IplImage* frame; 16 | while (1) { 17 | frame = cvQueryFrame( capture ); 18 | if (!frame) break; 19 | cvShowImage( "Example5", frame ); 20 | char c = cvWaitKey(33); 21 | if ( c == 27 ) break; 22 | } 23 | cvReleaseCapture( &capture ); 24 | cvDestroyWindow( "Example5" ); 25 | } 26 | -------------------------------------------------------------------------------- /src/Chapter02/imageCannyAndPyrDown.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // imageCannyAndPyrDown.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | IplImage* doPyrDown (IplImage* in, int filter = IPL_GAUSSIAN_5x5 ) { 14 | assert( in->width%2 == 0 && in->height%2 == 0 ); 15 | IplImage *out = cvCreateImage( cvSize( in->width/2, in->height/2 ), in->depth, in->nChannels); 16 | cvPyrDown( in, out ); 17 | return ( out ); 18 | } 19 | 20 | IplImage* doCanny (IplImage* in, double lowThresh, double highThresh, double aperture ) { 21 | // if (in->nChannels != 1) return (0); 22 | IplImage* out = cvCreateImage(cvGetSize(in), IPL_DEPTH_8U, 1); 23 | cvCanny( in, out, lowThresh, highThresh, aperture); 24 | return ( out ); 25 | } 26 | 27 | 28 | int main(int argc, const char * argv[]) { 29 | 30 | const char* path = argv[1]; 31 | 32 | if (path == NULL) path = "icon2.png"; 33 | 34 | IplImage* image = cvLoadImage( path ); 35 | 36 | cvNamedWindow( "Example4-in" ); 37 | cvNamedWindow( "Example4-out" ); 38 | 39 | cvShowImage( "Example4-in", image); 40 | 41 | IplImage* out = doPyrDown(image); 42 | out = doCanny(out, 10, 100, 3); 43 | 44 | cvShowImage( "Example4-out", out); 45 | 46 | cvReleaseImage( &out ); 47 | cvWaitKey(0); 48 | cvDestroyWindow("Example4-in"); 49 | cvDestroyWindow("Example4-out"); 50 | } 51 | -------------------------------------------------------------------------------- /src/Chapter02/load_image.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // load_image.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | 12 | int main(int argc, const char * argv[]) { 13 | // insert code here... 14 | IplImage* img = cvLoadImage( argv[1] ); 15 | cvNamedWindow( "Example1" , CV_WINDOW_AUTOSIZE); 16 | cvShowImage("Example1", img ); 17 | cvWaitKey(0); 18 | cvReleaseImage( &img ); 19 | cvDestroyWindow( "Example1" ); 20 | } 21 | -------------------------------------------------------------------------------- /src/Chapter02/load_video.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // load_video.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | 12 | int main(int argc, const char * argv[]) { 13 | cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE); 14 | CvCapture* capture = cvCreateFileCapture( argv[1] ); 15 | IplImage* frame; 16 | while (1) { 17 | frame = cvQueryFrame( capture ); 18 | if (!frame) break; 19 | cvShowImage( "Example2", frame ); 20 | char c = cvWaitKey(33); 21 | if ( c == 27 ) break; 22 | } 23 | cvReleaseCapture( &capture ); 24 | cvDestroyWindow( "Example2" ); 25 | } 26 | -------------------------------------------------------------------------------- /src/Chapter02/load_videoTrackbar.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int g_slider_position = 0; 14 | CvCapture* g_capture = NULL; 15 | 16 | void onTrackbarSlide(int pos) { 17 | cvSetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES, pos); 18 | } 19 | 20 | int main(int argc, const char * argv[]) { 21 | cvNamedWindow("Example3", CV_WINDOW_AUTOSIZE ); 22 | g_capture = cvCreateFileCapture( argv[1] ); 23 | int frames = (int) cvGetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_COUNT); 24 | if (frames != 0) { 25 | cvCreateTrackbar("Position", "Example3", &g_slider_position, frames, onTrackbarSlide); 26 | } 27 | IplImage* frame; 28 | while (1) { 29 | frame = cvQueryFrame( g_capture ); 30 | if (!frame) break; 31 | cvShowImage( "Example3", frame ); 32 | char c = cvWaitKey(33); 33 | if ( c == 27 ) break; 34 | } 35 | cvReleaseCapture( &g_capture ); 36 | cvDestroyWindow( "Example2" ); 37 | } 38 | -------------------------------------------------------------------------------- /src/Chapter02/smoothImage.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // smoothImage.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | int main(int argc, const char * argv[]) { 15 | 16 | IplImage* image = cvLoadImage( argv[1] ); 17 | 18 | cvNamedWindow( "Example4-in" ); 19 | cvNamedWindow( "Example4-out" ); 20 | 21 | cvShowImage( "Example4-in", image); 22 | 23 | IplImage* out = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 3); 24 | 25 | cvSmooth(image, out, 3, 3); 26 | 27 | cvShowImage( "Example4-out", out); 28 | 29 | cvReleaseImage( &out ); 30 | cvWaitKey(0); 31 | cvDestroyWindow("Example4-in"); 32 | cvDestroyWindow("Example4-out"); 33 | } 34 | -------------------------------------------------------------------------------- /src/Chapter02/videoConver.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // videoConver.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | CvCapture* capture = cvCreateFileCapture( argv[1] ); 15 | if (!capture) return -1; 16 | 17 | IplImage* bgr_frame = cvQueryFrame( capture ); 18 | double fps = cvGetCaptureProperty( capture , CV_CAP_PROP_FPS ); 19 | CvSize size = cvSize( 20 | (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH), 21 | (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT) 22 | ); 23 | CvVideoWriter* writer = cvCreateVideoWriter( argv[2], CV_FOURCC('M', 'J', 'P', 'G'), fps, size); 24 | IplImage* logpolar_frame = cvCreateImage(size, IPL_DEPTH_8U, 3); 25 | 26 | while ( (bgr_frame = cvQueryFrame(capture)) != NULL ) { 27 | cvLogPolar(bgr_frame, logpolar_frame, 28 | cvPoint2D32f(bgr_frame->width/2, bgr_frame->height/2), 29 | 40, 30 | CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS ); 31 | cvWriteFrame(writer, logpolar_frame); 32 | } 33 | cvReleaseVideoWriter( &writer ); 34 | cvReleaseImage( &logpolar_frame ); 35 | cvReleaseCapture( &capture ); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/Chapter04/AlphaBlend.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // AlphaBlend 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // ./LearningOpenCV 0.jpg 1.jpg 100 100 100 100 0.1 2 14 | 15 | int main(int argc, const char * argv[]) { 16 | IplImage *src1, *src2; 17 | if( argc == 9 && ((src1 = cvLoadImage(argv[1],1)) != 0) && ((src2 = cvLoadImage(argv[2],1)) != 0)) { 18 | int x = atoi(argv[3]); 19 | int y = atoi(argv[4]); 20 | int width = atoi(argv[5]); 21 | int height = atoi(argv[6]); 22 | double alpha = atoi(argv[7]); 23 | double beta = atoi(argv[8]); 24 | 25 | cvSetImageROI(src1, cvRect(x, y, width, height)); 26 | cvSetImageROI(src2, cvRect(0, 0, width, height)); 27 | cvAddWeighted(src1, alpha, src2, beta, 0.0, src1); 28 | cvResetImageROI(src1); 29 | cvNamedWindow( "Alpha_blend", 1 ); 30 | cvShowImage( "Alpha_blend", src1 ); 31 | cvWaitKey(); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/Chapter04/FileStorage.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // FileStorage.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | CvMat *cmatrix = cvCreateMat(5,5,CV_32FC1); 15 | float element_3_2 = 7.7; 16 | *((float*)CV_MAT_ELEM_PTR( *cmatrix, 3,2) ) = element_3_2; 17 | cvmSet(cmatrix,4,4,0.5000); 18 | cvSetReal2D(cmatrix,3,3,0.5000); 19 | 20 | CvFileStorage* fs1 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_WRITE); 21 | cvWriteInt( fs1, "frame_count", 10 ); 22 | cvStartWriteStruct( fs1, "frame_size", CV_NODE_SEQ ); 23 | cvWriteInt( fs1 , 0, 320 ); 24 | cvWriteInt( fs1 , 0, 200 ); 25 | cvEndWriteStruct( fs1 ); 26 | cvWrite( fs1, "color_cvt_matrix", cmatrix ); 27 | cvReleaseFileStorage( &fs1 ); 28 | 29 | CvFileStorage* fs2 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_READ); 30 | int frame_count = cvReadIntByName( fs2 , 0, "frame_count"); 31 | CvSeq* s = cvGetFileNodeByName( fs2,0,"frame_size" )->data.seq; 32 | int frame_width = cvReadInt( (CvFileNode*)cvGetSeqElem(s,0) ); 33 | int frame_height = cvReadInt( (CvFileNode*)cvGetSeqElem(s,1) ); 34 | CvMat* color_cvt_matrix = (CvMat*) cvReadByName( fs2, 0 , "color_cvt_matrix"); 35 | 36 | printf("color_cvt_matrix: width=%d, height=%d\n",color_cvt_matrix->width, color_cvt_matrix->height ); 37 | printf("frame_count=%d, frame_width=%d, frame_height=%d\n",frame_count,frame_width,frame_height); 38 | 39 | cvReleaseFileStorage( &fs2 ); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /src/Chapter04/imageROI.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // imageROI 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // ./LearningOpenCV 0.jpg 10 10 500 300 100 14 | 15 | int main(int argc, const char * argv[]) { 16 | IplImage* src; 17 | if( argc == 7 && ((src = cvLoadImage(argv[1],1)) != 0)) { 18 | int x = atoi(argv[2]); 19 | int y = atoi(argv[3]); 20 | int width = atoi(argv[4]); 21 | int height = atoi(argv[5]); 22 | int add = atoi(argv[6]); 23 | cvSetImageROI(src, cvRect(x, y, width, height)); 24 | cvAddS(src, cvScalar(add), src); 25 | cvResetImageROI(src); 26 | cvNamedWindow( "ROI_Add", 1 ); 27 | cvShowImage( "ROI_Add", src ); 28 | cvWaitKey(); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/Chapter06/AffineTransform.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // AffineTransform.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | 15 | CvPoint2D32f srcTri[3], dstTri[3]; 16 | CvMat* rot_mat = cvCreateMat(2, 3, CV_32FC1); 17 | CvMat* warp_mat = cvCreateMat(2, 3, CV_32FC1); 18 | IplImage *src, *dst; 19 | 20 | if (argc == 2 && ((src = cvLoadImage(argv[1], 1)) != 0)) { 21 | dst = cvCloneImage( src ); 22 | dst->origin = src->origin; 23 | cvZero( dst ); 24 | 25 | // warp matrix 26 | srcTri[0].x = 0; 27 | srcTri[0].y = 0; 28 | srcTri[1].x = src->width -1; 29 | srcTri[1].y = 0; 30 | srcTri[2].x = 0; 31 | srcTri[2].y = src->height -1; 32 | dstTri[0].x = src->width * 0.0; 33 | dstTri[0].y = src->height * 0.33; 34 | dstTri[1].x = src->width * 0.85; 35 | dstTri[1].y = src->height * 0.25; 36 | dstTri[2].x = src->width * 0.15; 37 | dstTri[2].y = src->height * 0.7; 38 | 39 | cvGetAffineTransform( srcTri, dstTri, warp_mat ); 40 | cvWarpAffine( src, dst, warp_mat ); 41 | cvCopy( dst, src ); 42 | 43 | // rotation matrix 44 | CvPoint2D32f center = cvPoint2D32f( src->width/2, src->height/2 ); 45 | double angle = -50.0; 46 | double scale = 0.6; 47 | 48 | cv2DRotationMatrix( center, angle, scale, rot_mat ); 49 | cvWarpAffine( src, dst, rot_mat ); 50 | 51 | cvNamedWindow( "Affine_Transform", 1 ); 52 | cvShowImage( "Affine_Transform" , dst ); 53 | 54 | cvWaitKey(); 55 | 56 | cvReleaseImage( &dst ); 57 | 58 | } 59 | 60 | cvReleaseMat( &rot_mat ); 61 | cvReleaseMat( &warp_mat ); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /src/Chapter06/PerspectiveTransform.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | 15 | CvPoint2D32f srcQuad[4], dstQuad[4]; 16 | CvMat* warp_matrix = cvCreateMat(3, 3, CV_32FC1); 17 | IplImage *src, *dst; 18 | 19 | if (argc == 2 && ((src = cvLoadImage(argv[1], 1)) != 0)) { 20 | dst = cvCloneImage( src ); 21 | dst->origin = src->origin; 22 | cvZero( dst ); 23 | 24 | // warp matrix 25 | srcQuad[0].x = 0; 26 | srcQuad[0].y = 0; 27 | srcQuad[1].x = src->width - 1; 28 | srcQuad[1].y = 0; 29 | srcQuad[2].x = 0; 30 | srcQuad[2].y = src->height - 1; 31 | srcQuad[3].x = src->width - 1; 32 | srcQuad[3].y = src->height - 1; 33 | 34 | dstQuad[0].x = src->width * 0.005; 35 | dstQuad[0].y = src->height * 0.33; 36 | dstQuad[1].x = src->width * 0.9; 37 | dstQuad[1].y = src->height * 0.25; 38 | dstQuad[2].x = src->width * 0.2; 39 | dstQuad[2].y = src->height * 0.7; 40 | dstQuad[3].x = src->width * 0.8; 41 | dstQuad[3].y = src->height * 0.9; 42 | 43 | cvGetPerspectiveTransform( srcQuad, dstQuad, warp_matrix ); 44 | cvWarpPerspective( src, dst, warp_matrix ); 45 | 46 | 47 | cvNamedWindow( "Perspective_Transform", 1 ); 48 | cvShowImage( "Perspective_Transform" , dst ); 49 | 50 | cvWaitKey(); 51 | 52 | cvReleaseImage( &dst ); 53 | 54 | } 55 | 56 | cvReleaseMat( &warp_matrix ); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /src/Chapter06/cvHoughCircles.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // cvHoughCircles.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | 15 | IplImage* image = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE); 16 | 17 | CvMemStorage* storage = cvCreateMemStorage(0); 18 | cvSmooth(image, image, CV_GAUSSIAN, 5, 5); 19 | 20 | CvSeq* results = cvHoughCircles( image, storage, CV_HOUGH_GRADIENT, 2, image->width/10 ); 21 | 22 | for ( int i = 0; i < results->total ; i++ ) { 23 | float* p = (float *) cvGetSeqElem( results, i); 24 | CvPoint pt = cvPoint( cvRound(p[0]), cvRound(p[1]) ); 25 | cvCircle(image, pt, cvRound(p[2]), CV_RGB(0xff, 0xff, 0xff)); 26 | } 27 | cvNamedWindow( "cvHoughCircles", 1 ); 28 | cvShowImage( "cvHoughCircles", image ); 29 | cvWaitKey(0); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/Chapter06/drawBoxs.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // drawBoxs.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void my_mous_callback( int evetnt, int x, int y, int flag, void* param ); 14 | 15 | CvRect box; 16 | bool drawing_box = false; 17 | 18 | void draw_box( IplImage* img, CvRect rect ) { 19 | cvRectangle( 20 | img , 21 | cvPoint(rect.x, rect.y), 22 | cvPoint(rect.x+rect.width, rect.y+rect.height), 23 | cvScalar(0x00, 0x00, 0xff) // Red 24 | ); 25 | } 26 | 27 | int main(int argc, const char * argv[]) { 28 | 29 | box = cvRect(-1, -1, 0, 0); 30 | IplImage* image = cvCreateImage( cvSize(200, 200), IPL_DEPTH_8U, 3 ); 31 | cvZero( image ); 32 | IplImage* temp = cvCloneImage( image ); 33 | 34 | cvNamedWindow( "Box Example" ); 35 | 36 | cvSetMouseCallback( "Box Example", my_mous_callback, (void *) image ); 37 | 38 | while (1) { 39 | cvCopyImage( image, temp ); 40 | 41 | if (drawing_box) draw_box( temp, box ); 42 | cvShowImage( "Box Example", temp ); 43 | 44 | if ( cvWaitKey(15) == 27) break; 45 | 46 | } 47 | 48 | cvReleaseImage( &image ); 49 | cvReleaseImage( &temp ); 50 | cvDestroyWindow( "Box Example" ); 51 | 52 | return 0; 53 | } 54 | 55 | void my_mous_callback( int evetnt, int x, int y, int flag, void* param ) { 56 | 57 | IplImage* image = (IplImage *) param; 58 | 59 | switch (evetnt) { 60 | case CV_EVENT_MOUSEMOVE: 61 | if ( drawing_box ) { 62 | box.width = x-box.x; 63 | box.height = y-box.y; 64 | } 65 | break; 66 | case CV_EVENT_LBUTTONDOWN: 67 | drawing_box = true; 68 | box = cvRect(x, y, 0, 0); 69 | break; 70 | case CV_EVENT_LBUTTONUP: 71 | drawing_box = false; 72 | if (box.width<0) { 73 | box.x += box.width; 74 | box.width *= -1; 75 | } 76 | if (box.height<0) { 77 | box.y += box.height; 78 | box.height *= -1; 79 | } 80 | draw_box(image, box); 81 | break; 82 | default: 83 | break; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/Chapter07/Histogrem-EMD.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Histogrem-EMD.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | 15 | IplImage *src1, *src2; 16 | 17 | if (argc == 3 && ((src1 = cvLoadImage(argv[1], 1)) != 0) && ((src2 = cvLoadImage(argv[2], 1)) != 0)) { 18 | 19 | // HSV image and decompose into separate planes 20 | 21 | IplImage* hsv1 = cvCreateImage( cvGetSize(src1), 8, 3 ); 22 | cvCvtColor( src1, hsv1, CV_BGR2HSV); 23 | 24 | 25 | IplImage* h_plane1 = cvCreateImage( cvGetSize(src1), 8, 1 ); 26 | IplImage* s_plane1 = cvCreateImage( cvGetSize(src1), 8, 1 ); 27 | IplImage* v_plane1 = cvCreateImage( cvGetSize(src1), 8, 1 ); 28 | IplImage* planes1[] = { h_plane1, s_plane1 }; 29 | cvCvtPixToPlane( hsv1, h_plane1, s_plane1, v_plane1, 0 ); 30 | 31 | IplImage* hsv2 = cvCreateImage( cvGetSize(src2), 8, 3 ); 32 | cvCvtColor( src2, hsv2, CV_BGR2HSV); 33 | 34 | 35 | IplImage* h_plane2 = cvCreateImage( cvGetSize(src2), 8, 1 ); 36 | IplImage* s_plane2 = cvCreateImage( cvGetSize(src2), 8, 1 ); 37 | IplImage* v_plane2 = cvCreateImage( cvGetSize(src2), 8, 1 ); 38 | IplImage* planes2[] = { h_plane2, s_plane2 }; 39 | cvCvtPixToPlane( hsv2, h_plane2, s_plane2, v_plane2, 0 ); 40 | 41 | // Build the histogram amd compute 42 | int h_bins = 30, s_bins = 32; 43 | CvHistogram *hist1, *hist2; 44 | { 45 | int hist_size[] = { h_bins, s_bins }; 46 | float h_ranges[] = { 0, 180 }; 47 | float s_ranges[] = { 0, 255 }; 48 | float* ranges[] = { h_ranges, s_ranges }; 49 | hist1 = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 ); 50 | hist2 = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 ); 51 | } 52 | cvCalcHist( planes1, hist1, 0, 0 ); 53 | cvNormalizeHist( hist1, 1.0 ); 54 | 55 | cvCalcHist( planes2, hist2, 0, 0 ); 56 | cvNormalizeHist( hist2, 1.0 ); 57 | 58 | // Get signature using EMD 59 | CvMat *sig1,*sig2; 60 | int numrows = h_bins * s_bins; 61 | 62 | sig1 = cvCreateMat(numrows, 3, CV_32FC1); 63 | sig2 = cvCreateMat(numrows, 3, CV_32FC1); 64 | 65 | // Create image to visualize 66 | int scale = 10; 67 | IplImage* hist_img1 = cvCreateImage( cvSize(h_bins*scale, s_bins*scale), 8, 3); 68 | cvZero( hist_img1 ); 69 | IplImage* hist_img2 = cvCreateImage( cvSize(h_bins*scale, s_bins*scale), 8, 3); 70 | cvZero( hist_img2 ); 71 | 72 | float max_value1 = 0; 73 | cvGetMinMaxHistValue( hist1, 0, &max_value1, 0, 0 ); 74 | float max_value2 = 0; 75 | cvGetMinMaxHistValue( hist2, 0, &max_value2, 0, 0 ); 76 | 77 | // Fill 78 | for ( int h = 0; h < h_bins; h ++ ) { 79 | for ( int s = 0; s < s_bins ; s++ ) { 80 | float bin_val1 = cvQueryHistValue_2D( hist1, h, s ); 81 | float bin_val2 = cvQueryHistValue_2D( hist2, h, s ); 82 | // Image 83 | int intensity1 = cvRound( bin_val1 * 255 / max_value1 ); 84 | cvRectangle(hist_img1, 85 | cvPoint( h*scale, s*scale ), 86 | cvPoint( (h+1)*scale-1, (s+1)*scale-1 ), 87 | CV_RGB(intensity1, intensity1, intensity1), 88 | CV_FILLED 89 | ); 90 | int intensity2 = cvRound( bin_val2 * 255 / max_value2 ); 91 | cvRectangle(hist_img2, 92 | cvPoint( h*scale, s*scale ), 93 | cvPoint( (h+1)*scale-1, (s+1)*scale-1 ), 94 | CV_RGB(intensity2, intensity2, intensity2), 95 | CV_FILLED 96 | ); 97 | 98 | // Signature 99 | cvSet2D(sig1, h*s_bins+s, 0, cvScalar(bin_val1)); // bin value 100 | cvSet2D(sig1, h*s_bins+s, 1, cvScalar(h)); // Coord 1 101 | cvSet2D(sig1, h*s_bins+s, 2, cvScalar(s)); // Coord 2 102 | cvSet2D(sig2, h*s_bins+s, 0, cvScalar(bin_val2)); // bin value 103 | cvSet2D(sig2, h*s_bins+s, 1, cvScalar(h)); // Coord 1 104 | cvSet2D(sig2, h*s_bins+s, 2, cvScalar(s)); // Coord 2 105 | } 106 | } 107 | cvNamedWindow( "Source - 1", 1 ); 108 | cvShowImage( "Source - 1", src1 ); 109 | cvNamedWindow( "H-S Histogrem - 1", 1 ); 110 | cvShowImage( "H-S Histogrem - 1", hist_img1 ); 111 | 112 | cvNamedWindow( "Source - 2", 1 ); 113 | cvShowImage( "Source - 2", src2 ); 114 | cvNamedWindow( "H-S Histogrem - 2", 1 ); 115 | cvShowImage( "H-S Histogrem - 2", hist_img2 ); 116 | 117 | float emd = cvCalcEMD2( sig1, sig2, CV_DIST_L2); 118 | printf("EMD : %f ;", emd); 119 | 120 | cvWaitKey(); 121 | 122 | cvReleaseImage( &src1 ); 123 | cvReleaseImage( &hist_img1 ); 124 | cvReleaseHist( &hist1 ); 125 | cvReleaseMat( &sig1 ); 126 | cvReleaseImage( &src2 ); 127 | cvReleaseImage( &hist_img2 ); 128 | cvReleaseHist( &hist2 ); 129 | cvReleaseMat( &sig2 ); 130 | 131 | } 132 | 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /src/Chapter07/Histogrem.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Histogrem.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, const char * argv[]) { 14 | 15 | IplImage *src; 16 | 17 | if (argc == 2 && ((src = cvLoadImage(argv[1], 1)) != 0)) { 18 | 19 | // HSV image and decompose into separate planes 20 | 21 | IplImage* hsv = cvCreateImage( cvGetSize(src), 8, 3 ); 22 | cvCvtColor( src, hsv, CV_BGR2HSV); 23 | 24 | 25 | IplImage* h_plane = cvCreateImage( cvGetSize(src), 8, 1 ); 26 | IplImage* s_plane = cvCreateImage( cvGetSize(src), 8, 1 ); 27 | IplImage* v_plane = cvCreateImage( cvGetSize(src), 8, 1 ); 28 | IplImage* planes[] = { h_plane, s_plane }; 29 | cvCvtPixToPlane( hsv, h_plane, s_plane, v_plane, 0 ); 30 | 31 | // Build the histogram amd compute 32 | int h_bins = 30, s_bins = 32; 33 | CvHistogram* hist; 34 | { 35 | int hist_size[] = { h_bins, s_bins }; 36 | float h_ranges[] = { 0, 180 }; 37 | float s_ranges[] = { 0, 255 }; 38 | float* ranges[] = { h_ranges, s_ranges }; 39 | hist = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 ); 40 | } 41 | cvCalcHist( planes, hist, 0, 0 ); 42 | cvNormalizeHist( hist, 1.0 ); 43 | 44 | // create image to visualize 45 | int scale = 10; 46 | IplImage* hist_img = cvCreateImage( cvSize(h_bins*scale, s_bins*scale), 8, 3); 47 | cvZero( hist_img ); 48 | 49 | float max_value = 0; 50 | cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 ); 51 | for ( int h = 0; h < h_bins; h ++ ) { 52 | for ( int s = 0; s < s_bins ; s++ ) { 53 | float bin_val = cvQueryHistValue_2D( hist, h, s ); 54 | int intensity = cvRound( bin_val * 255 / max_value ); 55 | cvRectangle(hist_img, 56 | cvPoint( h*scale, s*scale ), 57 | cvPoint( (h+1)*scale-1, (s+1)*scale-1 ), 58 | CV_RGB(intensity, intensity, intensity), 59 | CV_FILLED 60 | ); 61 | } 62 | } 63 | cvNamedWindow( "Source", 1 ); 64 | cvShowImage( "Source", src ); 65 | 66 | cvNamedWindow( "H-S Histogrem", 1 ); 67 | cvShowImage( "H-S Histogrem", hist_img); 68 | 69 | cvWaitKey(); 70 | 71 | cvReleaseImage( &src ); 72 | cvReleaseImage( &hist_img ); 73 | cvReleaseHist( &hist ); 74 | 75 | } 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /src/Chapter07/MatchTemplate.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // MatchTemplate.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int main(int argc, const char * argv[]) { 16 | 17 | IplImage *src, *templ, *ftmp[6]; 18 | int i; 19 | 20 | if (argc == 3 && ((src = cvLoadImage(argv[1], 1)) != 0) && ((templ = cvLoadImage(argv[2], 1)) != 0)) { 21 | // Allocate output images 22 | int i_width = src->width - templ->width + 1; 23 | int i_height = src->height - templ->height + 1; 24 | for ( i = 0; i < 6; i++ ) { 25 | ftmp[i] = cvCreateImage( cvSize(i_width, i_height), 32, 1 ); 26 | } 27 | // Do template matching 28 | for ( i = 0; i < 6; i++) { 29 | cvMatchTemplate( src, templ, ftmp[i], i ); 30 | cvNormalize( ftmp[i], ftmp[i], 1, 0, CV_MINMAX ); 31 | } 32 | 33 | //DISPLAY 34 | cvNamedWindow( "Template", 0 ); 35 | cvShowImage( "Template", templ ); 36 | cvNamedWindow( "Image", 0 ); 37 | cvShowImage( "Image", src ); 38 | 39 | cvNamedWindow( "SQDIFF", 0 ); 40 | cvShowImage( "SQDIFF", ftmp[0] ); 41 | 42 | cvNamedWindow( "SQDIFF_NORMED", 0 ); 43 | cvShowImage( "SQDIFF_NORMED", ftmp[1] ); 44 | 45 | cvNamedWindow( "CCORR", 0 ); 46 | cvShowImage( "CCORR", ftmp[2] ); 47 | 48 | cvNamedWindow( "CCORR_NORMED", 0 ); 49 | cvShowImage( "CCORR_NORMED", ftmp[3] ); 50 | 51 | cvNamedWindow( "CCOEFF", 0 ); 52 | cvShowImage( "CCOEFF", ftmp[4] ); 53 | 54 | cvNamedWindow( "CCOEFF_NORMED", 0 ); 55 | cvShowImage( "CCOEFF_NORMED", ftmp[5] ); 56 | 57 | cvWaitKey(); 58 | 59 | } 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /src/Chapter08/Contours1.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Contours.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | IplImage* g_image = NULL; 14 | IplImage* g_gray = NULL; 15 | int g_thresh = 100; 16 | CvMemStorage* g_storage = NULL; 17 | 18 | void on_trackbar(int) { 19 | if ( g_storage == NULL ) { 20 | g_gray = cvCreateImage( cvGetSize(g_image), 8, 1); 21 | g_storage = cvCreateMemStorage( 0 ); 22 | } else { 23 | cvClearMemStorage( g_storage ); 24 | } 25 | CvSeq* contours = 0; 26 | cvCvtColor( g_image, g_gray, CV_BGR2GRAY ); 27 | cvThreshold( g_gray, g_gray, g_thresh, 255, CV_THRESH_BINARY ); 28 | cvFindContours( g_gray, g_storage, &contours ); 29 | cvSetZero( g_gray ); 30 | if ( contours ) { 31 | cvDrawContours( g_gray, contours, cvScalarAll(255), cvScalarAll(255), 100); 32 | cvShowImage( "Contours", g_gray ); 33 | } 34 | } 35 | 36 | int main(int argc, const char * argv[]) { 37 | 38 | if (argc == 2 && ((g_image = cvLoadImage(argv[1], 1)) != 0)) { 39 | cvNamedWindow( "Contours" ); 40 | cvCreateTrackbar( "Threshold", "Contours", &g_thresh, 100,on_trackbar ); 41 | on_trackbar(0); 42 | 43 | cvWaitKey(); 44 | 45 | cvReleaseImage( &g_image ); 46 | cvReleaseImage( &g_gray ); 47 | cvReleaseMemStorage( &g_storage ); 48 | cvDestroyWindow( "Contours" ); 49 | 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/Chapter08/Contours2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Contours2.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #define CVX_RED CV_RGB( 0xff, 0x00, 0x00 ) 14 | #define CVX_BLUE CV_RGB( 0x00, 0x00, 0xff ) 15 | 16 | int main(int argc, const char * argv[]) { 17 | 18 | cvNamedWindow( "Contours2" ); 19 | 20 | IplImage* img_8uc1 = cvLoadImage( argv[1], CV_LOAD_IMAGE_GRAYSCALE ); 21 | IplImage* img_edge = cvCreateImage( cvGetSize(img_8uc1), 8, 1 ); 22 | IplImage* img_8uc3 = cvCreateImage( cvGetSize(img_8uc1), 8, 3 ); 23 | cvThreshold( img_8uc1, img_edge, 128, 255, CV_THRESH_BINARY ); 24 | 25 | CvMemStorage* storage = cvCreateMemStorage(); 26 | CvSeq* first_contour = NULL; 27 | int Nc = cvFindContours( img_edge, storage, &first_contour, sizeof(CvContour), CV_RETR_LIST ); 28 | int n = 0; 29 | printf( "Total Contours Detected : %d\n", Nc ); 30 | 31 | for ( CvSeq* c = first_contour; c != NULL; c = c->h_next ) { 32 | cvCvtColor( img_8uc1, img_8uc3, CV_GRAY2BGR ); 33 | cvDrawContours( img_8uc3, c, CVX_RED, CVX_BLUE, 0, 2, 8 ); 34 | printf( "Contour #%d\n", n ); 35 | cvShowImage( "Contours2", img_8uc3); 36 | printf( " %d elements:\n", c->total ); 37 | for( int i = 0; i < c -> total; ++i ) 38 | { 39 | CvPoint* p = CV_GET_SEQ_ELEM( CvPoint, c, i ); 40 | printf( " (%d,%d)\n", p -> x, p -> y ); 41 | } 42 | cvWaitKey(0); 43 | n++; 44 | } 45 | 46 | printf( "Finished all contours.\n" ); 47 | cvCvtColor( img_8uc1, img_8uc3, CV_GRAY2BGR ); 48 | cvShowImage( "Contours2", img_8uc3 ); 49 | cvWaitKey(0); 50 | cvDestroyWindow( "Contours2" ); 51 | cvReleaseImage( &img_8uc1 ); 52 | cvReleaseImage( &img_8uc3 ); 53 | cvReleaseImage( &img_edge ); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /src/Chapter10/Kalman.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Kalman.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #define CVX_DONT_CARE -1 14 | 15 | #define CVX_CAMERA 0 16 | #define CVX_AVI 1 17 | 18 | #define CVX_RED CV_RGB(0xff,0x00,0x00) 19 | #define CVX_GREEN CV_RGB(0x00,0xff,0x00) 20 | #define CVX_BLUE CV_RGB(0x00,0x00,0xff) 21 | 22 | #define CVX_CYAN CV_RGB(0x00,0xff,0xff) 23 | #define CVX_MAGENTA CV_RGB(0xff,0x00,0xff) 24 | #define CVX_YELLOW CV_RGB(0xff,0xff,0x00) 25 | 26 | #define CVX_WHITE CV_RGB(0xff,0xff,0xff) 27 | #define CVX_BLACK CV_RGB(0x00,0x00,0x00) 28 | #define CVX_GRAY50 CV_RGB(0x88,0x88,0x88) 29 | 30 | typedef struct { 31 | float x; 32 | float y; 33 | float width; 34 | float height; 35 | } 36 | CvxRect32f; 37 | 38 | CV_INLINE CvxRect32f cvxRect32f(float x, float y, float width, float height) { 39 | CvxRect32f r; 40 | 41 | r.x = x; 42 | r.y = y; 43 | r.width = width; 44 | r.height = height; 45 | 46 | return r; 47 | } 48 | CvScalar cvx_hsv2rgb( CvScalar hsv ) { 49 | 50 | // H is given on [0, 180]. S and V are given on [0, 255]. 51 | // RGB are each returned on [0, 255]. 52 | // 53 | float h = hsv.val[0]/30.0f; 54 | float s = hsv.val[1]/255.0f; 55 | float v = hsv.val[2]/255.0f; 56 | while( h>6.0f ) h-=6.0f; 57 | while( h<0.0f ) h+=6.0f; 58 | float m, n, f; 59 | int i; 60 | 61 | CvScalar rgb; 62 | 63 | i = floor(h); 64 | f = h - i; 65 | if ( !(i&1) ) f = 1 - f; // if i is even 66 | m = v * (1 - s); 67 | n = v * (1 - s * f); 68 | switch (i) { 69 | case 6: 70 | case 0: rgb = CV_RGB(v, n, m); break; 71 | case 1: rgb = CV_RGB(n, v, m); break; 72 | case 2: rgb = CV_RGB(m, v, n); break; 73 | case 3: rgb = CV_RGB(m, n, v); break; 74 | case 4: rgb = CV_RGB(n, m, v); break; 75 | case 5: rgb = CV_RGB(v, m, n); break; 76 | } 77 | 78 | rgb.val[0] *= 255.0f; 79 | rgb.val[1] *= 255.0f; 80 | rgb.val[2] *= 255.0f; 81 | 82 | return rgb; 83 | } 84 | 85 | #define phi2xy(mat) \ 86 | cvPoint( cvRound(img->width/2 + img->width/3*cos(mat->data.fl[0])),\ 87 | cvRound( img->height/2 - img->width/3*sin(mat->data.fl[0])) ) 88 | 89 | int main(int argc, const char * argv[]) { 90 | 91 | cvNamedWindow( "Kalman", 1 ); 92 | CvRandState rng; 93 | cvRandInit( &rng, 0, 1, -1, CV_RAND_UNI ); 94 | 95 | IplImage* img = cvCreateImage( cvSize(500,500), 8, 3 ); 96 | CvKalman* kalman = cvCreateKalman( 2, 1, 0 ); 97 | 98 | CvMat* x_k = cvCreateMat( 2, 1, CV_32FC1 ); 99 | cvRandSetRange( &rng, 0, 0.1, 0 ); 100 | rng.disttype = CV_RAND_NORMAL; 101 | cvRand( &rng, x_k ); 102 | 103 | // process noise 104 | CvMat* w_k = cvCreateMat( 2, 1, CV_32FC1 ); 105 | 106 | // measurements, only one parameter for angle 107 | CvMat* z_k = cvCreateMat( 1, 1, CV_32FC1 ); 108 | cvZero( z_k ); 109 | 110 | const float F[] = { 1, 1, 0, 1 }; 111 | memcpy( kalman->transition_matrix->data.fl, F, sizeof(F)); 112 | // Initialize other Kalman filter parameters. 113 | cvSetIdentity( kalman->measurement_matrix, cvRealScalar(1) ); 114 | cvSetIdentity( kalman->process_noise_cov, cvRealScalar(1e-5) ); 115 | cvSetIdentity( kalman->measurement_noise_cov, cvRealScalar(1e-1) ); 116 | cvSetIdentity( kalman->error_cov_post, cvRealScalar(1)); 117 | 118 | // choose random initial state 119 | cvRand( &rng, kalman->state_post ); 120 | 121 | while( 1 ) { 122 | // predict point position 123 | const CvMat* y_k = cvKalmanPredict( kalman, 0 ); 124 | 125 | // generate measurement (z_k) 126 | cvRandSetRange( &rng, 0, sqrt(kalman->measurement_noise_cov->data.fl[0]), 0 ); 127 | cvRand( &rng, z_k ); 128 | cvMatMulAdd( kalman->measurement_matrix, x_k, z_k, z_k ); 129 | // plot points (eg convert to planar co-ordinates and draw) 130 | cvZero( img ); 131 | cvCircle( img, phi2xy(z_k), 4, CVX_YELLOW ); // observed state 132 | cvCircle( img, phi2xy(y_k), 4, CVX_WHITE, 2 ); // "predicted" state 133 | cvCircle( img, phi2xy(x_k), 4, CVX_RED ); // real state 134 | cvShowImage( "Kalman", img ); 135 | // adjust Kalman filter state 136 | cvKalmanCorrect( kalman, z_k ); 137 | 138 | cvRandSetRange( &rng, 0, sqrt(kalman->process_noise_cov->data.fl[0]), 0 ); 139 | cvRand( &rng, w_k ); 140 | cvMatMulAdd( kalman->transition_matrix, x_k, w_k, x_k ); 141 | 142 | // exit if user hits 'Esc' 143 | if( cvWaitKey( 100 ) == 27 ) break; 144 | } 145 | 146 | return 0; 147 | } 148 | -------------------------------------------------------------------------------- /src/Chapter10/OpticalFlow.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // OpticalFlow.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #define CVX_RED CV_RGB( 0xff, 0x00, 0x00 ) 14 | #define CVX_BLUE CV_RGB( 0x00, 0x00, 0xff ) 15 | #define CVX_GREEN CV_RGB( 0x00, 0xff, 0x00 ) 16 | 17 | const int MAX_CORNERS = 500; 18 | 19 | int main(int argc, const char * argv[]) { 20 | 21 | IplImage* imgA = cvLoadImage( "data/OpticalFlow0.jpg", CV_LOAD_IMAGE_GRAYSCALE ); 22 | IplImage* imgB = cvLoadImage( "data/OpticalFlow1.jpg", CV_LOAD_IMAGE_GRAYSCALE ); 23 | 24 | CvSize img_sz = cvGetSize( imgA ); 25 | int win_size = 10; 26 | 27 | IplImage* imgC = cvLoadImage( "data/OpticalFlow1.jpg", CV_LOAD_IMAGE_UNCHANGED ); 28 | 29 | IplImage* image_eig = cvCreateImage( img_sz, IPL_DEPTH_32F, 1 ); 30 | IplImage* image_tmp = cvCreateImage( img_sz, IPL_DEPTH_32F, 1 ); 31 | 32 | int corner_count = MAX_CORNERS; 33 | CvPoint2D32f* cornersA = new CvPoint2D32f[ MAX_CORNERS ]; 34 | CvPoint2D32f* cornersB = new CvPoint2D32f[ MAX_CORNERS ]; 35 | 36 | cvGoodFeaturesToTrack( imgA, image_eig, image_tmp, cornersA, &corner_count, 0.01, 5.0, 0, 3, 0, 0.04 ); 37 | 38 | cvFindCornerSubPix( 39 | imgA, 40 | cornersA, 41 | corner_count, 42 | cvSize(win_size, win_size), 43 | cvSize(-1, -1), 44 | cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 20.0, 0.03) 45 | ); 46 | 47 | char features_found[ MAX_CORNERS ]; 48 | float feature_errors[ MAX_CORNERS ]; 49 | 50 | CvSize pyr_sz = cvSize( imgA->width+8, imgB->height/3 ); 51 | 52 | IplImage* pyrA = cvCreateImage( pyr_sz, IPL_DEPTH_32F, 1 ); 53 | IplImage* pyrB = cvCreateImage( pyr_sz, IPL_DEPTH_32F, 1 ); 54 | 55 | cvCalcOpticalFlowPyrLK(imgA, 56 | imgB, 57 | pyrA, 58 | pyrB, 59 | cornersA, 60 | cornersB, 61 | corner_count, 62 | cvSize(win_size, win_size), 63 | 5, 64 | features_found, 65 | feature_errors, 66 | cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 20.0, 0.3), 67 | 0 68 | ); 69 | 70 | for( int i=0; i550 ) { 72 | printf("Error is %f\n",feature_errors[i]); 73 | continue; 74 | } 75 | CvPoint p0 = cvPoint( 76 | cvRound( cornersA[i].x ), 77 | cvRound( cornersA[i].y ) 78 | ); 79 | CvPoint p1 = cvPoint( 80 | cvRound( cornersB[i].x ), 81 | cvRound( cornersB[i].y ) 82 | ); 83 | 84 | cvLine( imgC, p0, p1, CV_RGB(255,0,0),2 ); 85 | } 86 | cvNamedWindow("ImageA",0); 87 | cvNamedWindow("ImageB",0); 88 | cvNamedWindow("LKpyr_OpticalFlow",0); 89 | cvShowImage("ImageA",imgA); 90 | cvShowImage("ImageB",imgB); 91 | cvShowImage("LKpyr_OpticalFlow",imgC); 92 | cvWaitKey(0); 93 | 94 | return 0; 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/Chapter11/calib.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // calib.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define CVX_RED CV_RGB(0xff,0x00,0x00) 16 | #define CVX_GREEN CV_RGB(0x00,0xff,0x00) 17 | #define CVX_BLUE CV_RGB(0x00,0x00,0xff) 18 | 19 | #define CVX_CYAN CV_RGB(0x00,0xff,0xff) 20 | #define CVX_MAGENTA CV_RGB(0xff,0x00,0xff) 21 | #define CVX_YELLOW CV_RGB(0xff,0xff,0x00) 22 | 23 | #define CVX_WHITE CV_RGB(0xff,0xff,0xff) 24 | #define CVX_BLACK CV_RGB(0x00,0x00,0x00) 25 | #define CVX_GRAY50 CV_RGB(0x88,0x88,0x88) 26 | 27 | int n_boards = 10; 28 | const int board_dt = 20; 29 | int board_w = 9; 30 | int board_h = 6; 31 | 32 | int main(int argc, const char * argv[]) { 33 | 34 | if(argc == 4){ 35 | board_w = atoi(argv[1]); 36 | board_h = atoi(argv[2]); 37 | n_boards = atoi(argv[3]); 38 | } 39 | int board_n = board_w * board_h; 40 | CvSize board_sz = cvSize( board_w, board_h ); 41 | 42 | CvCapture* capture = cvCreateCameraCapture( 0 ); 43 | assert( capture ); 44 | 45 | cvNamedWindow( "Calibration" ); 46 | 47 | CvMat* image_points = cvCreateMat(n_boards*board_n,2,CV_32FC1); 48 | CvMat* object_points = cvCreateMat(n_boards*board_n,3,CV_32FC1); 49 | CvMat* point_counts = cvCreateMat(n_boards,1,CV_32SC1); 50 | CvMat* intrinsic_matrix = cvCreateMat(3,3,CV_32FC1); 51 | CvMat* distortion_coeffs = cvCreateMat(5,1,CV_32FC1); 52 | 53 | CvPoint2D32f* corners = new CvPoint2D32f[ board_n ]; 54 | int corner_count; 55 | int successes = 0; 56 | int step, frame = 0; 57 | 58 | IplImage* image = cvQueryFrame( capture ); 59 | IplImage* gray_image = cvCreateImage(cvGetSize(image),8,1); 60 | 61 | while ( successes < n_boards ) { 62 | if ( frame++ % board_dt == 0 ) { 63 | int found = cvFindChessboardCorners( image, board_sz, corners, &corner_count, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS ); 64 | cvCvtColor( image, gray_image, CV_BGR2GRAY ); 65 | cvFindCornerSubPix( gray_image, corners, corner_count, cvSize(11, 11), cvSize(-1, -1), cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1) ); 66 | cvDrawChessboardCorners(image, board_sz, corners, corner_count, found); 67 | cvShowImage( "Calibration" , image ); 68 | 69 | if ( corner_count == board_n ) { 70 | step = successes * board_n; 71 | for (int i=step, j=0; j 10 | #include 11 | #include 12 | #include 13 | 14 | int n_boards = 0; //Will be set by input list 15 | const int board_dt = 10; 16 | int board_w; 17 | int board_h; 18 | 19 | int main(int argc, char* argv[]) { 20 | 21 | board_w = 12; 22 | board_h = 12; 23 | int board_n = board_w * board_h; 24 | CvSize board_sz = cvSize( board_w, board_h ); 25 | FILE *fptr = fopen("./data/chessboards.txt","r"); 26 | char names[2048]; 27 | 28 | while(fscanf(fptr,"%s ",names)==1){ 29 | n_boards++; 30 | } 31 | rewind(fptr); 32 | 33 | cvNamedWindow( "Calibration" ); 34 | CvMat* image_points = cvCreateMat(n_boards*board_n,2,CV_32FC1); 35 | CvMat* object_points = cvCreateMat(n_boards*board_n,3,CV_32FC1); 36 | CvMat* point_counts = cvCreateMat(n_boards,1,CV_32SC1); 37 | CvMat* intrinsic_matrix = cvCreateMat(3,3,CV_32FC1); 38 | CvMat* distortion_coeffs = cvCreateMat(4,1,CV_32FC1); 39 | 40 | 41 | IplImage* image = 0;// = cvQueryFrame( capture ); 42 | IplImage* gray_image = 0; //for subpixel 43 | CvPoint2D32f* corners = new CvPoint2D32f[ board_n ]; 44 | int corner_count; 45 | int successes = 0; 46 | int step; 47 | 48 | for( int frame=0; frame 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | int main(int argc, const char * argv[]) { 16 | 17 | IplImage* img = cvCreateImage( cvSize( 500, 500 ), 8, 3 ); 18 | CvRNG rng = cvRNG(-1); 19 | 20 | cvNamedWindow( "fitline", 1 ); 21 | for(;;) { 22 | char key; 23 | int i, count = cvRandInt(&rng) % 100 + 1, outliers = count/5; 24 | float a = cvRandReal(&rng) * 200; 25 | float b = cvRandReal(&rng) * 40; 26 | float angle = cvRandReal(&rng) * CV_PI; 27 | float cos_a = cos(angle), sin_a = sin(angle); 28 | CvPoint pt1, pt2; 29 | CvPoint* points = (CvPoint*)malloc( count * sizeof(points[0])); 30 | CvMat pointMat = cvMat( 1, count, CV_32SC2, points ); 31 | float line[4]; 32 | float d, t; 33 | 34 | b = MIN(a*0.3, b); 35 | 36 | // generate some points that are close to the line 37 | for( i = 0; i < count - outliers; i++ ) { 38 | float x = (cvRandReal(&rng)*2-1)*a; 39 | float y = (cvRandReal(&rng)*2-1)*b; 40 | points[i].x = cvRound(x*cos_a - y*sin_a + img->width/2); 41 | points[i].y = cvRound(x*sin_a + y*cos_a + img->height/2); 42 | } 43 | 44 | // generate "completely off" points 45 | for( ; i < count; i++ ) { 46 | points[i].x = cvRandInt(&rng) % img->width; 47 | points[i].y = cvRandInt(&rng) % img->height; 48 | } 49 | 50 | // find the optimal line 51 | cvFitLine( &pointMat, CV_DIST_L1, 1, 0.001, 0.001, line ); 52 | cvZero( img ); 53 | 54 | // draw the points 55 | for( i = 0; i < count; i++ ) { 56 | cvCircle( img, points[i], 2, i < count - outliers ? CV_RGB(255, 0, 0) : CV_RGB(255,255,0), CV_FILLED, CV_AA, 0 ); 57 | } 58 | 59 | d = sqrt((double)line[0]*line[0] + (double)line[1]*line[1]); 60 | line[0] /= d; 61 | line[1] /= d; 62 | t = (float)(img->width + img->height); 63 | pt1.x = cvRound(line[2] - line[0]*t); 64 | pt1.y = cvRound(line[3] - line[1]*t); 65 | pt2.x = cvRound(line[2] + line[0]*t); 66 | pt2.y = cvRound(line[3] + line[1]*t); 67 | cvLine( img, pt1, pt2, CV_RGB(0,255,0), 3, CV_AA, 0 ); 68 | 69 | cvShowImage( "fitline", img ); 70 | 71 | key = (char) cvWaitKey(0); 72 | if( key == 27 ) break; 73 | free( points ); 74 | } 75 | 76 | cvDestroyWindow( "fitline" ); 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /src/Chapter12/BirdsEye.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BirdsEye.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int main(int argc, const char * argv[]) { 16 | 17 | const char* default_args[] = {"", "12", "12", "./data/Intrinsics.xml", "./data/Distortion.xml", "./data/birdseye.jpg" }; 18 | if (argc != 6) { 19 | argc = 6; 20 | argv = default_args; 21 | } 22 | 23 | int board_w = atoi(argv[1]); 24 | int board_h = atoi(argv[2]); 25 | int board_n = board_w * board_h; 26 | CvSize board_sz = cvSize( board_w, board_h ); 27 | CvMat* intrinsic = (CvMat*)cvLoad(argv[3]); 28 | CvMat* distortion = (CvMat*)cvLoad(argv[4]); 29 | IplImage *image = 0, *gray_image = 0; 30 | if((image = cvLoadImage(argv[5]))== 0){ 31 | printf("Error: Couldn't load %s\n",argv[5]); 32 | return -1; 33 | } 34 | gray_image = cvCreateImage(cvGetSize(image),8,1); 35 | cvCvtColor(image, gray_image, CV_BGR2GRAY); 36 | 37 | //UNDISTORT OUR IMAGE 38 | IplImage* mapx = cvCreateImage( cvGetSize(image), IPL_DEPTH_32F, 1 ); 39 | IplImage* mapy = cvCreateImage( cvGetSize(image), IPL_DEPTH_32F, 1 ); 40 | cvInitUndistortMap( intrinsic, distortion, mapx, mapy ); 41 | IplImage* t = cvCloneImage( image ); 42 | cvRemap( t, image, mapx, mapy ); 43 | 44 | cvNamedWindow("Checkers"); 45 | CvPoint2D32f* corners = new CvPoint2D32f[ board_n ]; 46 | int corner_count = 0; 47 | int found = cvFindChessboardCorners( image, board_sz, corners, &corner_count, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS ); 48 | if(!found){ 49 | printf("Couldn't aquire checkerboard on %s, only found %d of %d corners\n", argv[5],corner_count,board_n); 50 | return -1; 51 | } 52 | cvFindCornerSubPix(gray_image, corners, corner_count, cvSize(11,11),cvSize(-1,-1), cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1) ); 53 | 54 | //GET THE IMAGE AND OBJECT POINTS: 55 | CvPoint2D32f objPts[4], imgPts[4]; 56 | objPts[0].x = 0; 57 | objPts[0].y = 0; 58 | objPts[1].x = board_w-1; 59 | objPts[1].y = 0; 60 | objPts[2].x = 0; 61 | objPts[2].y = board_h-1; 62 | objPts[3].x = board_w-1; 63 | objPts[3].y = board_h-1; 64 | imgPts[0] = corners[0]; 65 | imgPts[1] = corners[board_w-1]; 66 | imgPts[2] = corners[(board_h-1)*board_w]; 67 | imgPts[3] = corners[(board_h-1)*board_w + board_w-1]; 68 | 69 | //DRAW THE POINTS in order: B,G,R,YELLOW 70 | cvCircle(image,cvPointFrom32f(imgPts[0]),9,CV_RGB(0,0,255),3); 71 | cvCircle(image,cvPointFrom32f(imgPts[1]),9,CV_RGB(0,255,0),3); 72 | cvCircle(image,cvPointFrom32f(imgPts[2]),9,CV_RGB(255,0,0),3); 73 | cvCircle(image,cvPointFrom32f(imgPts[3]),9,CV_RGB(255,255,0),3); 74 | 75 | //DRAW THE FOUND CHECKERBOARD 76 | cvDrawChessboardCorners(image, board_sz, corners, corner_count, found); 77 | cvShowImage( "Checkers", image ); 78 | 79 | //FIND THE HOMOGRAPHY 80 | CvMat *H = cvCreateMat( 3, 3, CV_32F); 81 | cvGetPerspectiveTransform(objPts,imgPts,H); 82 | 83 | //LET THE USER ADJUST THE Z HEIGHT OF THE VIEW 84 | float Z = 25; 85 | int key = 0; 86 | IplImage *birds_image = cvCloneImage(image); 87 | cvNamedWindow("Birds_Eye"); 88 | while(key != 27) {//escape key stops 89 | CV_MAT_ELEM(*H,float,2,2) = Z; 90 | //USE HOMOGRAPHY TO REMAP THE VIEW 91 | cvWarpPerspective( image,birds_image, H, CV_INTER_LINEAR+CV_WARP_INVERSE_MAP+CV_WARP_FILL_OUTLIERS ); 92 | cvShowImage("Birds_Eye", birds_image); 93 | key = cvWaitKey(); 94 | if(key == 'u') Z += 0.5; 95 | if(key == 'd') Z -= 0.5; 96 | } 97 | 98 | cvSave("H.xml",H); 99 | 100 | return 0; 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/Chapter12/StereoCalib.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // StereoCalib.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace std; 20 | 21 | static void StereoCalib(const char* imageList, int nx, int ny, int useUncalibrated) 22 | { 23 | int displayCorners = 0; 24 | int showUndistorted = 1; 25 | bool isVerticalStereo = false;//OpenCV can handle left-right 26 | //or up-down camera arrangements 27 | const int maxScale = 1; 28 | const float squareSize = 1.f; //Set this to your actual square size 29 | FILE* f = fopen(imageList, "rt"); 30 | int i, j, lr, nframes, n = nx*ny, N = 0; 31 | vector imageNames[2]; 32 | vector objectPoints; 33 | vector points[2]; 34 | vector npoints; 35 | vector active[2]; 36 | vector temp(n); 37 | CvSize imageSize = {0,0}; 38 | 39 | // ARRAY AND VECTOR STORAGE: 40 | double M1[3][3], M2[3][3], D1[5], D2[5]; 41 | double R[3][3], T[3], E[3][3], F[3][3]; 42 | CvMat _M1 = cvMat(3, 3, CV_64F, M1 ); 43 | CvMat _M2 = cvMat(3, 3, CV_64F, M2 ); 44 | CvMat _D1 = cvMat(1, 5, CV_64F, D1 ); 45 | CvMat _D2 = cvMat(1, 5, CV_64F, D2 ); 46 | CvMat _R = cvMat(3, 3, CV_64F, R ); 47 | CvMat _T = cvMat(3, 1, CV_64F, T ); 48 | CvMat _E = cvMat(3, 3, CV_64F, E ); 49 | CvMat _F = cvMat(3, 3, CV_64F, F ); 50 | if( displayCorners ) cvNamedWindow( "corners", 1 ); 51 | if( !f ) { 52 | fprintf(stderr, "can not open file %s\n", imageList ); 53 | return; 54 | } 55 | for(i=0;;i++) { 56 | char buf[1024]; 57 | int count = 0, result=0; 58 | lr = i % 2; 59 | vector& pts = points[lr]; 60 | if( !fgets( buf, sizeof(buf)-3, f )) break; 61 | size_t len = strlen(buf); 62 | while( len > 0 && isspace(buf[len-1])) { 63 | buf[--len] = '\0'; 64 | } 65 | if( buf[0] == '#') continue; 66 | IplImage* img = cvLoadImage( buf, 0 ); 67 | if( !img ) break; 68 | imageSize = cvGetSize(img); 69 | imageNames[lr].push_back(buf); 70 | //FIND CHESSBOARDS AND CORNERS THEREIN: 71 | for( int s = 1; s <= maxScale; s++ ) { 72 | IplImage* timg = img; 73 | if( s > 1 ) { 74 | timg = cvCreateImage(cvSize(img->width*s,img->height*s), img->depth, img->nChannels ); 75 | cvResize( img, timg, CV_INTER_CUBIC ); 76 | } 77 | result = cvFindChessboardCorners( timg, cvSize(nx, ny), &temp[0], &count, 78 | CV_CALIB_CB_ADAPTIVE_THRESH | 79 | CV_CALIB_CB_NORMALIZE_IMAGE); 80 | if( timg != img ) cvReleaseImage( &timg ); 81 | if( result || s == maxScale ) { 82 | for( j = 0; j < count; j++ ) { 83 | temp[j].x /= s; 84 | temp[j].y /= s; 85 | } 86 | } 87 | if( result ) break; 88 | } 89 | if( displayCorners ) { 90 | printf("%s\n", buf); 91 | IplImage* cimg = cvCreateImage( imageSize, 8, 3 ); 92 | cvCvtColor( img, cimg, CV_GRAY2BGR ); 93 | cvDrawChessboardCorners( cimg, cvSize(nx, ny), &temp[0], count, result ); 94 | cvShowImage( "corners", cimg ); 95 | cvReleaseImage( &cimg ); 96 | 97 | if( cvWaitKey(0) == 27 ) exit(-1); 98 | } 99 | else { 100 | putchar('.'); 101 | } 102 | N = (int)pts.size(); 103 | pts.resize(N + n, cvPoint2D32f(0,0)); 104 | active[lr].push_back((uchar)result); 105 | //assert( result != 0 ); 106 | if( result ) { 107 | cvFindCornerSubPix( img, &temp[0], count, cvSize(11, 11), cvSize(-1,-1), 108 | cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 30, 0.01) ); 109 | copy( temp.begin(), temp.end(), pts.begin() + N ); 110 | } 111 | cvReleaseImage( &img ); 112 | } 113 | fclose(f); 114 | printf("\n"); 115 | nframes = (int)active[0].size();//Number of good chessboads found 116 | objectPoints.resize(nframes*n); 117 | 118 | for( i = 0; i < ny; i++ ) { 119 | for( j = 0; j < nx; j++ ) { 120 | objectPoints[i*nx + j] = cvPoint3D32f(i*squareSize, j*squareSize, 0); 121 | } 122 | } 123 | 124 | for( i = 1; i < nframes; i++ ) { 125 | copy( objectPoints.begin(), objectPoints.begin() + n, objectPoints.begin() + i*n ); 126 | } 127 | 128 | npoints.resize(nframes,n); 129 | N = nframes*n; 130 | CvMat _objectPoints = cvMat(1, N, CV_32FC3, &objectPoints[0] ); 131 | CvMat _imagePoints1 = cvMat(1, N, CV_32FC2, &points[0][0] ); 132 | CvMat _imagePoints2 = cvMat(1, N, CV_32FC2, &points[1][0] ); 133 | CvMat _npoints = cvMat(1, npoints.size(), CV_32S, &npoints[0] ); 134 | cvSetIdentity(&_M1); 135 | cvSetIdentity(&_M2); 136 | cvZero(&_D1); 137 | cvZero(&_D2); 138 | 139 | printf("Running stereo calibration ..."); 140 | fflush(stdout); 141 | cvStereoCalibrate( &_objectPoints, &_imagePoints1, 142 | &_imagePoints2, &_npoints, 143 | &_M1, &_D1, &_M2, &_D2, 144 | imageSize, &_R, &_T, &_E, &_F, 145 | cvTermCriteria(CV_TERMCRIT_ITER+ 146 | CV_TERMCRIT_EPS, 100, 1e-5), 147 | CV_CALIB_FIX_ASPECT_RATIO + 148 | CV_CALIB_ZERO_TANGENT_DIST + 149 | CV_CALIB_SAME_FOCAL_LENGTH ); 150 | printf(" done\n"); 151 | 152 | 153 | vector lines[2]; 154 | points[0].resize(N); 155 | points[1].resize(N); 156 | _imagePoints1 = cvMat(1, N, CV_32FC2, &points[0][0] ); 157 | _imagePoints2 = cvMat(1, N, CV_32FC2, &points[1][0] ); 158 | lines[0].resize(N); 159 | lines[1].resize(N); 160 | CvMat _L1 = cvMat(1, N, CV_32FC3, &lines[0][0]); 161 | CvMat _L2 = cvMat(1, N, CV_32FC3, &lines[1][0]); 162 | //Always work in undistorted space 163 | cvUndistortPoints( &_imagePoints1, &_imagePoints1, &_M1, &_D1, 0, &_M1 ); 164 | cvUndistortPoints( &_imagePoints2, &_imagePoints2, &_M2, &_D2, 0, &_M2 ); 165 | cvComputeCorrespondEpilines( &_imagePoints1, 1, &_F, &_L1 ); 166 | cvComputeCorrespondEpilines( &_imagePoints2, 2, &_F, &_L2 ); 167 | double avgErr = 0; 168 | for( i = 0; i < N; i++ ) { 169 | double err = fabs(points[0][i].x*lines[1][i].x + points[0][i].y*lines[1][i].y + lines[1][i].z) 170 | + fabs(points[1][i].x*lines[0][i].x + points[1][i].y*lines[0][i].y + lines[0][i].z); 171 | avgErr += err; 172 | } 173 | printf( "avg err = %g\n", avgErr/(nframes*n) ); 174 | 175 | if( showUndistorted ) { 176 | CvMat* mx1 = cvCreateMat( imageSize.height, 177 | imageSize.width, CV_32F ); 178 | CvMat* my1 = cvCreateMat( imageSize.height, 179 | imageSize.width, CV_32F ); 180 | CvMat* mx2 = cvCreateMat( imageSize.height, 181 | 182 | imageSize.width, CV_32F ); 183 | CvMat* my2 = cvCreateMat( imageSize.height, 184 | imageSize.width, CV_32F ); 185 | CvMat* img1r = cvCreateMat( imageSize.height, 186 | imageSize.width, CV_8U ); 187 | CvMat* img2r = cvCreateMat( imageSize.height, 188 | imageSize.width, CV_8U ); 189 | CvMat* disp = cvCreateMat( imageSize.height, 190 | imageSize.width, CV_16S ); 191 | CvMat* vdisp = cvCreateMat( imageSize.height, 192 | imageSize.width, CV_8U ); 193 | CvMat* pair; 194 | double R1[3][3], R2[3][3], P1[3][4], P2[3][4]; 195 | CvMat _R1 = cvMat(3, 3, CV_64F, R1); 196 | CvMat _R2 = cvMat(3, 3, CV_64F, R2); 197 | 198 | if( useUncalibrated == 0 ) { 199 | CvMat _P1 = cvMat(3, 4, CV_64F, P1); 200 | CvMat _P2 = cvMat(3, 4, CV_64F, P2); 201 | cvStereoRectify( &_M1, &_M2, &_D1, &_D2, imageSize, 202 | &_R, &_T, 203 | &_R1, &_R2, &_P1, &_P2, 0, 204 | 0/*CV_CALIB_ZERO_DISPARITY*/ ); 205 | isVerticalStereo = fabs(P2[1][3]) > fabs(P2[0][3]); 206 | 207 | cvInitUndistortRectifyMap(&_M1,&_D1,&_R1,&_P1,mx1,my1); 208 | cvInitUndistortRectifyMap(&_M2,&_D2,&_R2,&_P2,mx2,my2); 209 | } 210 | else if( useUncalibrated == 1 || useUncalibrated == 2 ) { 211 | double H1[3][3], H2[3][3], iM[3][3]; 212 | CvMat _H1 = cvMat(3, 3, CV_64F, H1); 213 | CvMat _H2 = cvMat(3, 3, CV_64F, H2); 214 | CvMat _iM = cvMat(3, 3, CV_64F, iM); 215 | //Just to show you could have independently used F 216 | if( useUncalibrated == 2 ) { 217 | cvFindFundamentalMat( &_imagePoints1, &_imagePoints2, &_F); 218 | } 219 | 220 | cvStereoRectifyUncalibrated( &_imagePoints1, &_imagePoints2, &_F, imageSize, &_H1, &_H2, 3); 221 | cvInvert(&_M1, &_iM); 222 | cvMatMul(&_H1, &_M1, &_R1); 223 | cvMatMul(&_iM, &_R1, &_R1); 224 | cvInvert(&_M2, &_iM); 225 | cvMatMul(&_H2, &_M2, &_R2); 226 | cvMatMul(&_iM, &_R2, &_R2); 227 | cvInitUndistortRectifyMap(&_M1,&_D1,&_R1,&_M1,mx1,my1); 228 | cvInitUndistortRectifyMap(&_M2,&_D1,&_R2,&_M2,mx2,my2); 229 | } 230 | else { 231 | assert(0); 232 | } 233 | 234 | cvNamedWindow( "rectified", 1 ); 235 | if( !isVerticalStereo ) { 236 | pair = cvCreateMat( imageSize.height, imageSize.width*2, CV_8UC3 ); 237 | } else { 238 | pair = cvCreateMat( imageSize.height*2, imageSize.width, CV_8UC3 ); 239 | } 240 | 241 | //Setup for finding stereo corrrespondences 242 | CvStereoBMState *BMState = cvCreateStereoBMState(); 243 | assert(BMState != 0); 244 | BMState->preFilterSize=41; 245 | BMState->preFilterCap=31; 246 | BMState->SADWindowSize=41; 247 | BMState->minDisparity=-64; 248 | BMState->numberOfDisparities=128; 249 | BMState->textureThreshold=10; 250 | BMState->uniquenessRatio=15; 251 | for( i = 0; i < nframes; i++ ) { 252 | 253 | IplImage* img1=cvLoadImage(imageNames[0][i].c_str(),0); 254 | IplImage* img2=cvLoadImage(imageNames[1][i].c_str(),0); 255 | if( img1 && img2 ) { 256 | CvMat part; 257 | cvRemap( img1, img1r, mx1, my1 ); 258 | cvRemap( img2, img2r, mx2, my2 ); 259 | if( !isVerticalStereo || useUncalibrated != 0 ) { 260 | cvFindStereoCorrespondenceBM( img1r, img2r, disp, BMState); 261 | cvNormalize( disp, vdisp, 0, 256, CV_MINMAX ); 262 | cvNamedWindow( "disparity" ); 263 | cvShowImage( "disparity", vdisp ); 264 | } 265 | if( !isVerticalStereo ) { 266 | cvGetCols( pair, &part, 0, imageSize.width ); 267 | cvCvtColor( img1r, &part, CV_GRAY2BGR ); 268 | cvGetCols( pair, &part, imageSize.width, imageSize.width*2 ); 269 | cvCvtColor( img2r, &part, CV_GRAY2BGR ); 270 | for( j = 0; j < imageSize.height; j += 16 ) { 271 | cvLine( pair, cvPoint(0,j), cvPoint(imageSize.width*2,j), CV_RGB(0,255,0)); 272 | } 273 | } else { 274 | cvGetRows( pair, &part, 0, imageSize.height ); 275 | cvCvtColor( img1r, &part, CV_GRAY2BGR ); 276 | cvGetRows( pair, &part, imageSize.height, imageSize.height*2 ); 277 | cvCvtColor( img2r, &part, CV_GRAY2BGR ); 278 | for( j = 0; j < imageSize.width; j += 16 ) { 279 | cvLine( pair, cvPoint(j,0), cvPoint(j,imageSize.height*2), CV_RGB(0,255,0)); 280 | } 281 | } 282 | cvShowImage( "rectified", pair ); 283 | if( cvWaitKey() == 27 ) break; 284 | } 285 | cvReleaseImage( &img1 ); 286 | cvReleaseImage( &img2 ); 287 | } 288 | cvReleaseStereoBMState(&BMState); 289 | cvReleaseMat( &mx1 ); 290 | cvReleaseMat( &my1 ); 291 | cvReleaseMat( &mx2 ); 292 | cvReleaseMat( &my2 ); 293 | cvReleaseMat( &img1r ); 294 | cvReleaseMat( &img2r ); 295 | cvReleaseMat( &disp ); 296 | } 297 | } 298 | 299 | int main(int argc, const char * argv[]) { 300 | 301 | StereoCalib("./data/ch12_list.txt", 9, 6, 1); 302 | return 0; 303 | } 304 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // LearningOpenCV 4 | // 5 | // Created by YourtionGuo on 7/28/16. 6 | // Copyright © 2016 Yourtion. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | int main(int argc, const char * argv[]) { 16 | 17 | IplImage* img = cvCreateImage( cvSize( 500, 500 ), 8, 3 ); 18 | CvRNG rng = cvRNG(-1); 19 | 20 | cvNamedWindow( "fitline", 1 ); 21 | for(;;) { 22 | char key; 23 | int i, count = cvRandInt(&rng) % 100 + 1, outliers = count/5; 24 | float a = cvRandReal(&rng) * 200; 25 | float b = cvRandReal(&rng) * 40; 26 | float angle = cvRandReal(&rng) * CV_PI; 27 | float cos_a = cos(angle), sin_a = sin(angle); 28 | CvPoint pt1, pt2; 29 | CvPoint* points = (CvPoint*)malloc( count * sizeof(points[0])); 30 | CvMat pointMat = cvMat( 1, count, CV_32SC2, points ); 31 | float line[4]; 32 | float d, t; 33 | 34 | b = MIN(a*0.3, b); 35 | 36 | // generate some points that are close to the line 37 | for( i = 0; i < count - outliers; i++ ) { 38 | float x = (cvRandReal(&rng)*2-1)*a; 39 | float y = (cvRandReal(&rng)*2-1)*b; 40 | points[i].x = cvRound(x*cos_a - y*sin_a + img->width/2); 41 | points[i].y = cvRound(x*sin_a + y*cos_a + img->height/2); 42 | } 43 | 44 | // generate "completely off" points 45 | for( ; i < count; i++ ) { 46 | points[i].x = cvRandInt(&rng) % img->width; 47 | points[i].y = cvRandInt(&rng) % img->height; 48 | } 49 | 50 | // find the optimal line 51 | cvFitLine( &pointMat, CV_DIST_L1, 1, 0.001, 0.001, line ); 52 | cvZero( img ); 53 | 54 | // draw the points 55 | for( i = 0; i < count; i++ ) { 56 | cvCircle( img, points[i], 2, i < count - outliers ? CV_RGB(255, 0, 0) : CV_RGB(255,255,0), CV_FILLED, CV_AA, 0 ); 57 | } 58 | 59 | d = sqrt((double)line[0]*line[0] + (double)line[1]*line[1]); 60 | line[0] /= d; 61 | line[1] /= d; 62 | t = (float)(img->width + img->height); 63 | pt1.x = cvRound(line[2] - line[0]*t); 64 | pt1.y = cvRound(line[3] - line[1]*t); 65 | pt2.x = cvRound(line[2] + line[0]*t); 66 | pt2.y = cvRound(line[3] + line[1]*t); 67 | cvLine( img, pt1, pt2, CV_RGB(0,255,0), 3, CV_AA, 0 ); 68 | 69 | cvShowImage( "fitline", img ); 70 | 71 | key = (char) cvWaitKey(0); 72 | if( key == 27 ) break; 73 | free( points ); 74 | } 75 | 76 | cvDestroyWindow( "fitline" ); 77 | return 0; 78 | } 79 | --------------------------------------------------------------------------------