├── .clang-format ├── .gitattributes ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── Docker ├── Dockerfile ├── build.sh └── run.sh ├── LICENSE ├── LectureSlides ├── 10A_The_Retina │ └── 10A-L1.pdf ├── 10B_Vision_in_the_Brain │ └── 10B-L1.pdf ├── 1A_Introduction │ └── 1A-L1.pdf ├── 2A_Linear_Image_Processing │ ├── 2A-L1.pdf │ ├── 2A-L2.pdf │ ├── 2A-L3.pdf │ ├── 2A-L4.pdf │ ├── 2A-L5.pdf │ └── 2A-L6.pdf ├── 2B_Model_Fitting │ ├── 2B-L1.pdf │ ├── 2B-L2.pdf │ └── 2B-L3.pdf ├── 2C_Frequency_Domain_Analysis │ ├── 2C-L1.pdf │ ├── 2C-L2.pdf │ └── 2C-L3.pdf ├── 3A_Camera_Models │ ├── 3A-L1.pdf │ └── 3A-L2.pdf ├── 3B_Stereo_Geometry │ ├── 3B-L1.pdf │ ├── 3B-L2.pdf │ └── 3B-L3.pdf ├── 3C_Camera_Calibration │ ├── 3C-L1.pdf │ ├── 3C-L2.pdf │ └── 3C-L3.pdf ├── 3D_Multiple_Views │ ├── 3D-L1.pdf │ ├── 3D-L2.pdf │ ├── 3D-L3.pdf │ ├── 3D-L4.pdf │ └── 3D-L5.pdf ├── 4A_Feature_Detection │ ├── 4A-L1.pdf │ ├── 4A-L2.pdf │ └── 4A-L3.pdf ├── 4B_Feature_Descriptors │ ├── 4B-L1.pdf │ └── 4B-L2.pdf ├── 4C_Model_Fitting │ ├── 4C-L1.pdf │ └── 4C-L2.pdf ├── 5A_Photometry │ └── 5A-L1.pdf ├── 5B_Lightness │ └── 5B-L1.pdf ├── 5C_Shape_From_Shading │ └── 5C-L1.pdf ├── 6A_Introduction_To_Motion │ └── 6A-L1.pdf ├── 6B_Optical_Flow │ ├── 6B-L1.pdf │ ├── 6B-L2.pdf │ ├── 6B-L3.pdf │ └── 6B-L4.pdf ├── 7A_Introduction_To_Tracking │ └── 7A-L1.pdf ├── 7B_Parametric_Models │ ├── 7B-L1.pdf │ └── 7B-L2.pdf ├── 7C_Non-Parametric_Models │ ├── 7C-L1.pdf │ ├── 7C-L2.pdf │ ├── 7C-L3.pdf │ └── 7C-L4.pdf ├── 7D_Tracking_Considerations │ └── 7D-L1.pdf ├── 8A_Introduction_To_Recognition │ └── 8A-L1.pdf ├── 8B_Classification_Generative_Models │ ├── 8B-L1.pdf │ ├── 8B-L2.pdf │ └── 8B-L3.pdf ├── 8C_Classification_Discriminative_Models │ ├── 8C-L1.pdf │ ├── 8C-L2.pdf │ ├── 8C-L3.pdf │ └── 8C-L4.pdf ├── 8D_Action_Recognition │ ├── 8D-L1.pdf │ ├── 8D-L2.pdf │ └── 8D-L3.pdf ├── 9A_Color_Spaces_and_Segmentation │ ├── 9A-L1.pdf │ ├── 9A-L2.pdf │ ├── 9A-L3.pdf │ └── 9A-L4.pdf ├── 9B_Binary_Morphology │ └── 9B-L1.pdf ├── 9C_3D_Perception │ └── 9C-L1.pdf ├── CS4495 Spring 2015 Study Guide.pdf └── Extra │ ├── 19-cameracalibration.pdf │ ├── Burt-Adelson1983Laplacian-Pyramid.pdf │ ├── MIT_Least_Squares.pdf │ └── least-squares_slides.pdf ├── ProblemSets ├── CMakeLists.txt ├── ps0_cpp │ ├── CMakeLists.txt │ ├── main.cpp │ └── ps0.md ├── ps1_cpp │ ├── CMakeLists.txt │ ├── ps1.md │ └── src │ │ ├── Config.cpp │ │ ├── Config.h │ │ ├── Hough.cu │ │ ├── Hough.h │ │ ├── Solution.cpp │ │ ├── Solution.h │ │ └── main.cpp ├── ps2_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ ├── Config.h │ │ ├── DisparityNCorr.h │ │ └── DisparitySSD.h │ ├── lib │ │ ├── Config.cpp │ │ ├── DisparityNCorr.cpp │ │ ├── DisparityNCorr.cu │ │ ├── DisparitySSD.cpp │ │ └── DisparitySSD.cu │ ├── output │ │ ├── ps2-1-a-1.png │ │ ├── ps2-1-a-2.png │ │ ├── ps2-2-a-1-inverted.png │ │ ├── ps2-2-a-1.png │ │ ├── ps2-2-a-2.png │ │ ├── ps2-3-a-1-inverted.png │ │ ├── ps2-3-a-1.png │ │ ├── ps2-3-a-2.png │ │ ├── ps2-3-b-1-inverted.png │ │ ├── ps2-3-b-1.png │ │ ├── ps2-3-b-2.png │ │ ├── ps2-4-a-1-inverted.png │ │ ├── ps2-4-a-1.png │ │ ├── ps2-4-a-2.png │ │ ├── ps2-4-b-1-inverted.png │ │ ├── ps2-4-b-1.png │ │ ├── ps2-4-b-2.png │ │ ├── ps2-4-c-1-inverted.png │ │ ├── ps2-4-c-1.png │ │ ├── ps2-4-c-2.png │ │ ├── ps2-5-a-1-inverted.png │ │ ├── ps2-5-a-1.png │ │ ├── ps2-5-a-2.png │ │ ├── ps2_cpu.log │ │ └── ps2_gpu.log │ └── src │ │ └── main.cpp ├── ps3_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ ├── Calibration.h │ │ ├── Config.h │ │ ├── FParse.h │ │ └── Fundamental.h │ ├── lib │ │ ├── Calibration.cpp │ │ ├── Config.cpp │ │ ├── FParse.cpp │ │ └── Fundamental.cpp │ ├── output │ │ ├── ps3-2-c-1.png │ │ ├── ps3-2-c-2.png │ │ ├── ps3-2-e-1.png │ │ ├── ps3-2-e-2.png │ │ └── ps3.log │ └── src │ │ ├── Solution.cpp │ │ ├── Solution.h │ │ └── main.cpp ├── ps4_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ ├── Config.h │ │ ├── Descriptors.h │ │ ├── Harris.h │ │ └── RANSAC.h │ ├── lib │ │ ├── Config.cpp │ │ ├── Descriptors.cpp │ │ ├── Harris.cpp │ │ ├── Harris.cu │ │ └── RANSAC.cpp │ ├── output │ │ ├── ps4-1-a-1.png │ │ ├── ps4-1-a-2.png │ │ ├── ps4-1-a-3.png │ │ ├── ps4-1-a-4.png │ │ ├── ps4-1-b-1.png │ │ ├── ps4-1-b-2.png │ │ ├── ps4-1-b-3.png │ │ ├── ps4-1-b-4.png │ │ ├── ps4-1-c-1.png │ │ ├── ps4-1-c-2.png │ │ ├── ps4-1-c-3.png │ │ ├── ps4-1-c-4.png │ │ ├── ps4-2-a-1.png │ │ ├── ps4-2-a-2.png │ │ ├── ps4-2-b-1.png │ │ ├── ps4-2-b-2.png │ │ ├── ps4-3-a-1.png │ │ ├── ps4-3-b-1.png │ │ ├── ps4-3-c-1.png │ │ ├── ps4-3-d-1.png │ │ ├── ps4-3-e-1.png │ │ └── ps4.log │ └── src │ │ ├── Solution.cpp │ │ ├── Solution.h │ │ └── main.cpp ├── ps5_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ ├── Config.h │ │ ├── OpticalFlow.h │ │ └── Pyramids.h │ ├── lib │ │ ├── Config.cpp │ │ ├── OpticalFlow.cpp │ │ ├── Pyramids.cpp │ │ └── Pyramids.cu │ ├── output │ │ ├── ps5-1-a-1-uColorMap.png │ │ ├── ps5-1-a-1-vColorMap.png │ │ ├── ps5-1-a-1.png │ │ ├── ps5-1-a-2-uColorMap.png │ │ ├── ps5-1-a-2-vColorMap.png │ │ ├── ps5-1-a-2.png │ │ ├── ps5-1-b-1-uColorMap.png │ │ ├── ps5-1-b-1-vColorMap.png │ │ ├── ps5-1-b-1.png │ │ ├── ps5-1-b-2-uColorMap.png │ │ ├── ps5-1-b-2-vColorMap.png │ │ ├── ps5-1-b-2.png │ │ ├── ps5-1-b-3-uColorMap.png │ │ ├── ps5-1-b-3-vColorMap.png │ │ ├── ps5-1-b-3.png │ │ ├── ps5-2-a-1.png │ │ ├── ps5-2-b-1.png │ │ ├── ps5-3-a-1-1-uColorMap.png │ │ ├── ps5-3-a-1-1-vColorMap.png │ │ ├── ps5-3-a-1-1-warped-diff.png │ │ ├── ps5-3-a-1-1.png │ │ ├── ps5-3-a-1-2-uColorMap.png │ │ ├── ps5-3-a-1-2-vColorMap.png │ │ ├── ps5-3-a-1-2-warped-diff.png │ │ ├── ps5-3-a-1-2.png │ │ ├── ps5-3-a-2-1-uColorMap.png │ │ ├── ps5-3-a-2-1-vColorMap.png │ │ ├── ps5-3-a-2-1-warped-diff.png │ │ ├── ps5-3-a-2-1.png │ │ ├── ps5-3-a-2-2-uColorMap.png │ │ ├── ps5-3-a-2-2-vColorMap.png │ │ ├── ps5-3-a-2-2-warped-diff.png │ │ ├── ps5-3-a-2-2.png │ │ ├── ps5-4-a-1-uColorMap.png │ │ ├── ps5-4-a-1-vColorMap.png │ │ ├── ps5-4-a-1.png │ │ ├── ps5-4-a-2-uColorMap.png │ │ ├── ps5-4-a-2-vColorMap.png │ │ ├── ps5-4-a-2.png │ │ ├── ps5-4-b-1-uColorMap.png │ │ ├── ps5-4-b-1-vColorMap.png │ │ ├── ps5-4-b-1.png │ │ ├── ps5-4-b-2-uColorMap.png │ │ ├── ps5-4-b-2-vColorMap.png │ │ └── ps5-4-b-2.png │ └── src │ │ ├── Solution.cpp │ │ ├── Solution.h │ │ └── main.cpp ├── ps6_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ │ ├── Config.h │ │ └── ParticleFilter.h │ ├── lib │ │ ├── Config.cpp │ │ └── ParticleFilter.cpp │ ├── output │ │ ├── ps6-1-a-f144.png │ │ ├── ps6-1-a-f28.png │ │ ├── ps6-1-a-f84.png │ │ ├── ps6-1-e-f14.png │ │ ├── ps6-1-e-f32.png │ │ ├── ps6-1-e-f46.png │ │ ├── ps6-2-a-f15.png │ │ ├── ps6-2-a-f150.png │ │ ├── ps6-2-a-f50.png │ │ ├── ps6-2-b-f15.png │ │ ├── ps6-2-b-f150.png │ │ ├── ps6-2-b-f50.png │ │ ├── ps6-3-a-f144.png │ │ ├── ps6-3-a-f28.png │ │ ├── ps6-3-a-f84.png │ │ ├── ps6-3-b-f140.png │ │ ├── ps6-3-b-f15.png │ │ ├── ps6-3-b-f50.png │ │ └── ps6.log │ └── src │ │ ├── Solution.cpp │ │ ├── Solution.h │ │ └── main.cpp └── ps7_cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── include │ ├── Config.h │ ├── Matching.h │ ├── Moments.h │ └── MotionHistory.h │ ├── lib │ ├── Config.cpp │ ├── Matching.cpp │ ├── Moments.cpp │ ├── MotionHistory.cpp │ └── MotionHistory.cu │ ├── output │ ├── ps7-1-a-1.png │ ├── ps7-1-a-2.png │ ├── ps7-1-a-3.png │ ├── ps7-1-b-1.png │ ├── ps7-1-b-2.png │ ├── ps7-1-b-3.png │ ├── ps7-2-a-1.png │ ├── ps7-2-a-2.png │ ├── ps7-2-b-1.png │ ├── ps7-2-b-2.png │ ├── ps7-2-b-3.png │ ├── ps7-2-b-4.png │ └── ps7.log │ └── src │ ├── Solution.cpp │ ├── Solution.h │ └── main.cpp ├── README.md ├── Resources ├── ProblemSet1 │ ├── ps1-input0-noise.png │ ├── ps1-input0.png │ ├── ps1-input1.png │ ├── ps1-input2.png │ └── ps1-input3.png ├── ProblemSet2 │ ├── pair0-L.png │ ├── pair0-R.png │ ├── pair1-D_L.png │ ├── pair1-D_R.png │ ├── pair1-L.png │ ├── pair1-R.png │ ├── pair2-D_L.png │ ├── pair2-D_R.png │ ├── pair2-L.png │ └── pair2-R.png ├── ProblemSet3 │ ├── pic_a.jpg │ ├── pic_b.jpg │ ├── pts2d-norm-pic_a.txt │ ├── pts2d-pic_a.txt │ ├── pts2d-pic_b.txt │ ├── pts3d-norm.txt │ └── pts3d.txt ├── ProblemSet4 │ ├── check.bmp │ ├── check_rot.bmp │ ├── simA.jpg │ ├── simB.jpg │ ├── transA.jpg │ └── transB.jpg ├── ProblemSet5 │ ├── DataSeq1 │ │ ├── yos_img_01.jpg │ │ ├── yos_img_02.jpg │ │ └── yos_img_03.jpg │ ├── DataSeq2 │ │ ├── 0.png │ │ ├── 1.png │ │ └── 2.png │ ├── Juggle │ │ ├── 0.png │ │ ├── 1.png │ │ └── 2.png │ └── TestSeq │ │ ├── Shift0.png │ │ ├── ShiftR10.png │ │ ├── ShiftR2.png │ │ ├── ShiftR20.png │ │ ├── ShiftR40.png │ │ └── ShiftR5U5.png ├── ProblemSet6 │ ├── noisy_debate.avi │ ├── noisy_debate.txt │ ├── pedestrians.avi │ ├── pedestrians.txt │ ├── pres_debate.avi │ └── pres_debate.txt ├── ProblemSet7 │ ├── PS7A1P1T1.avi │ ├── PS7A1P1T2.avi │ ├── PS7A1P1T3.avi │ ├── PS7A1P2T1.avi │ ├── PS7A1P2T2.avi │ ├── PS7A1P2T3.avi │ ├── PS7A1P3T1.avi │ ├── PS7A1P3T2.avi │ ├── PS7A1P3T3.avi │ ├── PS7A2P1T1.avi │ ├── PS7A2P1T2.avi │ ├── PS7A2P1T3.avi │ ├── PS7A2P2T1.avi │ ├── PS7A2P2T2.avi │ ├── PS7A2P2T3.avi │ ├── PS7A2P3T1.avi │ ├── PS7A2P3T2.avi │ ├── PS7A2P3T3.avi │ ├── PS7A3P1T1.avi │ ├── PS7A3P1T2.avi │ ├── PS7A3P1T3.avi │ ├── PS7A3P2T1.avi │ ├── PS7A3P2T2.avi │ ├── PS7A3P2T3.avi │ ├── PS7A3P3T1.avi │ ├── PS7A3P3T2.avi │ ├── PS7A3P3T3.avi │ ├── TestLabel1.avi │ └── TestLabel2.avi └── USC_Misc │ ├── 4.1.01.png │ ├── 4.1.02.png │ ├── 4.1.03.png │ ├── 4.1.04.png │ ├── 4.1.05.png │ ├── 4.1.06.png │ ├── 4.1.07.png │ ├── 4.1.08.png │ ├── 4.2.01.png │ ├── 4.2.03.png │ ├── 4.2.05.png │ ├── 4.2.06.png │ ├── 4.2.07.png │ ├── 5.1.09.png │ ├── 5.1.10.png │ ├── 5.1.11.png │ ├── 5.1.12.png │ ├── 5.1.13.png │ ├── 5.1.14.png │ ├── 5.2.08.png │ ├── 5.2.09.png │ ├── 5.2.10.png │ ├── 5.3.01.png │ ├── 5.3.02.png │ ├── 7.1.01.png │ ├── 7.1.02.png │ ├── 7.1.03.png │ ├── 7.1.04.png │ ├── 7.1.05.png │ ├── 7.1.06.png │ ├── 7.1.07.png │ ├── 7.1.08.png │ ├── 7.1.09.png │ ├── 7.1.10.png │ ├── 7.2.01.png │ ├── boat.512.png │ ├── gray21.512.png │ ├── house.png │ └── ruler.512.png ├── common ├── CMakeLists.txt ├── include │ └── common │ │ ├── BasicConfig.h │ │ ├── CudaCommon.cuh │ │ ├── CudaWarmup.h │ │ ├── GpuTimer.h │ │ ├── OpenCVThrustInterop.h │ │ ├── Utils.h │ │ └── make_unique.h └── src │ ├── CudaWarmup.cu │ ├── GpuTimer.cpp │ └── Utils.cpp ├── config ├── ps0.yaml ├── ps1.yaml ├── ps2.yaml ├── ps3.yaml ├── ps4.yaml ├── ps5.yaml ├── ps6.yaml └── ps7.yaml └── external └── CMakeLists.txt /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | AccessModifierOffset: -4 3 | AlignAfterOpenBracket: Align 4 | AlignEscapedNewlinesLeft: false 5 | AlignOperands: true 6 | AlignTrailingComments: true 7 | AllowAllParametersOfDeclarationOnNextLine: false 8 | AllowShortBlocksOnASingleLine: false 9 | AllowShortCaseLabelsOnASingleLine: false 10 | AllowShortFunctionsOnASingleLine: true 11 | AllowShortIfStatementsOnASingleLine: true 12 | AllowShortLoopsOnASingleLine: false 13 | AlwaysBreakAfterDefinitionReturnType: false 14 | AlwaysBreakBeforeMultilineStrings: false 15 | AlwaysBreakTemplateDeclarations: true 16 | BinPackArguments: false 17 | BinPackParameters: false 18 | BreakBeforeBinaryOperators: None 19 | BreakBeforeBraces: Attach 20 | BreakBeforeTernaryOperators: true 21 | BreakConstructorInitializersBeforeComma: false 22 | ColumnLimit: 100 23 | CommentPragmas: '^ IWYU pragma:' 24 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 25 | ConstructorInitializerIndentWidth: 4 26 | ContinuationIndentWidth: 4 27 | Cpp11BracedListStyle: true 28 | DerivePointerAlignment: false 29 | DisableFormat: false 30 | ExperimentalAutoDetectBinPacking: false 31 | IndentCaseLabels: false 32 | IndentWidth: 4 33 | IndentWrappedFunctionNames: true 34 | KeepEmptyLinesAtTheStartOfBlocks: true 35 | Language: Cpp 36 | MaxEmptyLinesToKeep: 1 37 | NamespaceIndentation: None 38 | ObjCBlockIndentWidth: 2 39 | ObjCSpaceAfterProperty: false 40 | ObjCSpaceBeforeProtocolList: true 41 | PenaltyBreakBeforeFirstCallParameter: 19 42 | PenaltyBreakComment: 300 43 | PenaltyBreakFirstLessLess: 120 44 | PenaltyBreakString: 1000 45 | PenaltyExcessCharacter: 1000000 46 | PenaltyReturnTypeOnItsOwnLine: 60 47 | PointerAlignment: Left 48 | SpaceAfterCStyleCast: false 49 | SpaceBeforeAssignmentOperators: true 50 | SpaceBeforeParens: ControlStatements 51 | SpaceInEmptyParentheses: false 52 | SpacesBeforeTrailingComments: 1 53 | SpacesInAngles: false 54 | SpacesInCStyleCastParentheses: false 55 | SpacesInContainerLiterals: true 56 | SpacesInParentheses: false 57 | SpacesInSquareBrackets: false 58 | Standard: Cpp11 59 | TabWidth: 4 60 | UseTab: Never 61 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | **/*.pdf filter=lfs diff=lfs merge=lfs -text 2 | **/*.png filter=lfs diff=lfs merge=lfs -text 3 | **/*.jpg filter=lfs diff=lfs merge=lfs -text 4 | **/*.avi filter=lfs diff=lfs merge=lfs -text 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | 4 | # Libraries 5 | *.lib 6 | *.a 7 | 8 | # Shared objects (inc. Windows DLLs) 9 | *.dll 10 | *.so 11 | *.so.* 12 | *.dylib 13 | 14 | # Executables 15 | *.exe 16 | *.out 17 | *.app 18 | 19 | # OS X stuff 20 | .DS_Store 21 | 22 | build 23 | bin 24 | .vscode 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/spdlog"] 2 | path = external/spdlog 3 | url = https://github.com/gabime/spdlog.git 4 | [submodule "external/yaml-cpp"] 5 | path = external/yaml-cpp 6 | url = https://github.com/jbeder/yaml-cpp.git 7 | [submodule "external/gnuplot-iostream"] 8 | path = external/gnuplot-iostream 9 | url = https://github.com/dstahlke/gnuplot-iostream.git 10 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################ 2 | # Modified from Udacity's CS344 repository: 3 | # https://github.com/udacity/cs344 4 | ############################################################################ 5 | 6 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 7 | project(IntroToComputerVision) 8 | 9 | find_package(OpenCV REQUIRED core imgproc imgcodecs highgui cudafilters cudaimgproc features2d 10 | xfeatures2d videoio) 11 | find_package(Eigen3 3.3 REQUIRED NO_MODULE) 12 | find_package(Boost REQUIRED) 13 | find_package(CUDA REQUIRED) 14 | 15 | link_libraries(${OpenCV_LIBS} ) 16 | 17 | set (EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin/") 18 | 19 | ####################################### 20 | # Externally-sourced libraries 21 | ####################################### 22 | add_subdirectory(external) 23 | 24 | include_directories(external/yaml-cpp/include) 25 | include_directories(external/spdlog/include) 26 | include_directories(external/gnuplot-iostream) 27 | 28 | ####################################### 29 | # Look for CUDA 30 | ####################################### 31 | 32 | if(CUDA_FOUND) 33 | set(CUDA_NVCC_FLAGS " 34 | -ccbin g++; 35 | -gencode;arch=compute_50,code=sm_50; 36 | -gencode;arch=compute_52,code=sm_52; 37 | -gencode;arch=compute_60,code=sm_60; 38 | -gencode;arch=compute_61,code=sm_61; 39 | -gencode;arch=compute_62,code=sm_62") 40 | 41 | # add -Wextra compiler flag for gcc compilations 42 | if (UNIX) 43 | set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -Wextra") 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") 45 | endif (UNIX) 46 | 47 | # Support g++ versions less than 6.0 48 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 49 | if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) 50 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 51 | set (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11") 52 | set (CUDA_PROPAGATE_HOST_FLAGS OFF) 53 | endif() 54 | endif() 55 | 56 | if(CMAKE_BUILD_TYPE MATCHES Debug) 57 | # add debugging to CUDA NVCC flags. For NVidia's NSight tools. 58 | set(CUDA_NVCC_FLAGS_DEBUG ${CUDA_NVCC_FLAGS_DEBUG} "-G") 59 | endif() 60 | 61 | ####################################### 62 | # Utility library 63 | ####################################### 64 | add_subdirectory(common) 65 | include_directories(common/include) 66 | 67 | add_subdirectory (ProblemSets) 68 | 69 | else(CUDA_FOUND) 70 | message("CUDA is not installed on this system.") 71 | endif() 72 | -------------------------------------------------------------------------------- /Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Docker container for running my solutions to Udacity UD810 - Intro to Computer Vision code. 2 | 3 | FROM tanmaniac/opencv3-cudagl:latest 4 | LABEL maintainers="Tanmay Bangalore " 5 | 6 | RUN apt-get update && apt-get install -y tmux libboost-all-dev gnuplot &&\ 7 | rm -rf /var/lib/apt/lists/* 8 | 9 | # Install Eigen for linear algebra 10 | RUN cd /tmp &&\ 11 | wget http://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz -O Eigen.tar.gz &&\ 12 | mkdir Eigen && tar -xf Eigen.tar.gz -C Eigen --strip-components=1 &&\ 13 | cd Eigen && mkdir build && cd build && cmake .. && sudo make install &&\ 14 | cd /tmp && rm -rf Eigen* 15 | 16 | # Make a home directory so everything isn't just owned by root 17 | ARG UID=1000 18 | ARG GID=1000 19 | ARG UNAME="opencv" 20 | 21 | RUN mkdir -p /home/${UNAME} &&\ 22 | echo "${UNAME}:x:${UID}:${GID}:${UNAME},,,:/home/${UNAME}:/bin/bash" >> /etc/passwd &&\ 23 | echo "${UNAME}:x:${UID}:" >> /etc/group &&\ 24 | echo "${UNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${UNAME} &&\ 25 | chmod 0440 /etc/sudoers.d/${UNAME} &&\ 26 | chown ${UID}:${GID} -R /home/${UNAME} 27 | 28 | USER ${UNAME} 29 | ENV HOME /home/${UNAME} -------------------------------------------------------------------------------- /Docker/build.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | REPO="tanmaniac" 4 | IMAGE="opencv3-cudagl" 5 | TAG="ud810" 6 | 7 | docker build --build-arg UID=$(id -u) \ 8 | --build-arg GID=$(id -g) \ 9 | --build-arg UNAME=$(id -un) \ 10 | --tag ${REPO}/${IMAGE}:${TAG} . -------------------------------------------------------------------------------- /Docker/run.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | REPO="tanmaniac" 4 | IMAGE="opencv3-cudagl" 5 | TAG="ud810" 6 | 7 | if [ ! "$(docker ps -q -f name=${TAG})" ]; then 8 | if [ "$(docker ps -aq -f status=exited -f name=${TAG})" ]; then 9 | # cleanup 10 | docker rm ${TAG} 11 | fi 12 | docker run -it \ 13 | --runtime=nvidia \ 14 | --privileged \ 15 | --name ${TAG} \ 16 | -e DISPLAY=$DISPLAY \ 17 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 18 | -v $(pwd)/../../IntroToComputerVision:/home/$(id -un)/IntroToComputerVision \ 19 | ${REPO}/${IMAGE}:${TAG} \ 20 | /bin/bash 21 | fi 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 tanmaniac 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LectureSlides/10A_The_Retina/10A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b7fd5925e047bd5d2c594970404501491926b60e3948b586970984643175bc21 3 | size 1972887 4 | -------------------------------------------------------------------------------- /LectureSlides/10B_Vision_in_the_Brain/10B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:88143d59b1ef48afca5c8ab5a20b1566867a1e584e772022ac20f0437a67d6b5 3 | size 1842275 4 | -------------------------------------------------------------------------------- /LectureSlides/1A_Introduction/1A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:faeb991f8376543513e06461157074a9c74b5b61921f0d90ba5d7db8ce6a1291 3 | size 2391876 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c44b36cc0e5a90f17c33482007da773e45e1582de738967b2c3c0fda7f5e17db 3 | size 1389627 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:386c1395225745c1e79891eb86bad0cda4da3ac27ea1526972c6d2e81056bbae 3 | size 1603573 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9870d36235ab557c2a363b5143bc1e0ca611c68dec98ed21475d007d00585046 3 | size 1647726 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1afbfa56a9f4358c5b3afd708c373e2b070d44803e56ca6a88eb91190b4ab0ae 3 | size 1262463 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L5.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9bee64f715430ad4f46145bbc47fcdf71f4644d0b07f010e66197d70dcdf50f8 3 | size 1395113 4 | -------------------------------------------------------------------------------- /LectureSlides/2A_Linear_Image_Processing/2A-L6.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:78d594830a10724485e561812d9f3e8acbabb0a46dda6e615fdb853e1e7841b5 3 | size 1775928 4 | -------------------------------------------------------------------------------- /LectureSlides/2B_Model_Fitting/2B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9b750a8e383298b8cf97343347f99ce29a7d1ff820f45ad623b73894ac512d0d 3 | size 1301216 4 | -------------------------------------------------------------------------------- /LectureSlides/2B_Model_Fitting/2B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2e121347120c68b2ac656309a5161a8e67fa1d53f76ae7718583e6215f3ed34b 3 | size 665575 4 | -------------------------------------------------------------------------------- /LectureSlides/2B_Model_Fitting/2B-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:eea96cea0214f5ed51e8632a0341ce4202c1b0fbf843c9bcc9874dd6bb70f4ef 3 | size 654329 4 | -------------------------------------------------------------------------------- /LectureSlides/2C_Frequency_Domain_Analysis/2C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5e6c3af0abc25e4dacceb0fe00ea3708ae004901e08f30b1b063f23da4966a9d 3 | size 1644700 4 | -------------------------------------------------------------------------------- /LectureSlides/2C_Frequency_Domain_Analysis/2C-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:383df0bc395eec997b9d9098444eb09c832c7db2e41d40545dadbe5c8b7a3fa2 3 | size 842200 4 | -------------------------------------------------------------------------------- /LectureSlides/2C_Frequency_Domain_Analysis/2C-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2deab86ea036e54a45946224515fcba28eb111be5b2a38b22a0effe58f1f603e 3 | size 1460018 4 | -------------------------------------------------------------------------------- /LectureSlides/3A_Camera_Models/3A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:50080fdaddeef43aa48a161513ccc420011ab71deb7d2e621b2795f85772d629 3 | size 1817154 4 | -------------------------------------------------------------------------------- /LectureSlides/3A_Camera_Models/3A-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:81801662580b44746556de89266172d1ef59c72af0755a915b75b4266e7aa63e 3 | size 1055827 4 | -------------------------------------------------------------------------------- /LectureSlides/3B_Stereo_Geometry/3B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:320426bfff99d93763f693414f8b736bba44aecfd5c0f4405e1ffd42487ee747 3 | size 2094788 4 | -------------------------------------------------------------------------------- /LectureSlides/3B_Stereo_Geometry/3B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9e4352cd6f5ed2a4ef494e85ba3de04bc9c7b72fb6ee43b183183b8650d94d8d 3 | size 803789 4 | -------------------------------------------------------------------------------- /LectureSlides/3B_Stereo_Geometry/3B-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:742da715e6c22d23522ac508396d1336a327b95632a42fef44fa62d65359bb6f 3 | size 1549885 4 | -------------------------------------------------------------------------------- /LectureSlides/3C_Camera_Calibration/3C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:38298421d2e9d350655e0382c6379caa3f972dbc789e9cc2cef1f0768e690a65 3 | size 840140 4 | -------------------------------------------------------------------------------- /LectureSlides/3C_Camera_Calibration/3C-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1b116aace342925392845746750532c74ff4ae133058e418bddbae8c16a07b0d 3 | size 1076368 4 | -------------------------------------------------------------------------------- /LectureSlides/3C_Camera_Calibration/3C-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7835c42ee3818c9a6bec254fce9a054c4ac9f8508b9c2bbf493d09e2f29b5f03 3 | size 1058162 4 | -------------------------------------------------------------------------------- /LectureSlides/3D_Multiple_Views/3D-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5c2272a249347fc930b5653afa9036a83644b356aacdbacdd00bbe05be76ecb7 3 | size 547880 4 | -------------------------------------------------------------------------------- /LectureSlides/3D_Multiple_Views/3D-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:24b7aba3d06e0ab8c2be2505c5256481bddc5df5f9d48fce9eb441caaa420099 3 | size 1733030 4 | -------------------------------------------------------------------------------- /LectureSlides/3D_Multiple_Views/3D-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b8cdab8f758bcf4a37b91a658976c72cd3b953575101003b9d5a6a6f09bc0aa 3 | size 620960 4 | -------------------------------------------------------------------------------- /LectureSlides/3D_Multiple_Views/3D-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b2555f9bf72795f1e17a14cca63765a1e6310861c746c4c5a6235a62bbcd1422 3 | size 1077824 4 | -------------------------------------------------------------------------------- /LectureSlides/3D_Multiple_Views/3D-L5.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c44a85e4947139f8660bcfd366449bc2c504734899b69d86765bd3fbea1bd7a2 3 | size 1454308 4 | -------------------------------------------------------------------------------- /LectureSlides/4A_Feature_Detection/4A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c86104332253586ea0ae8590c3a18f7e9de86f4b884da625f6e9a1bb2ea7a4af 3 | size 1516086 4 | -------------------------------------------------------------------------------- /LectureSlides/4A_Feature_Detection/4A-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:02df3448d6cc8a3f39779690f16972e2ee612b2699a58c867c5bc09264964ca7 3 | size 1439965 4 | -------------------------------------------------------------------------------- /LectureSlides/4A_Feature_Detection/4A-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:21a0d69060a4cddd53db3f3e667960c20a4adf5804746ee99b1120d39e686983 3 | size 1985065 4 | -------------------------------------------------------------------------------- /LectureSlides/4B_Feature_Descriptors/4B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d8a80ee322c952de2c389c66a140e77f394b44ed0f617ec7c01f17647a0c8526 3 | size 1657467 4 | -------------------------------------------------------------------------------- /LectureSlides/4B_Feature_Descriptors/4B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a14f898621b90e1a96a4f9dcfa500774ee73caadc441c79d982f210935a4f468 3 | size 1032582 4 | -------------------------------------------------------------------------------- /LectureSlides/4C_Model_Fitting/4C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:047cd4655d36c028bf8f4fef91276b418a7dc11991eafbfc84affa045e710b8f 3 | size 1222580 4 | -------------------------------------------------------------------------------- /LectureSlides/4C_Model_Fitting/4C-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cb63ce37e8214a66a3127027fde85831f8e1b377445703032a8a3a677c16198d 3 | size 1320775 4 | -------------------------------------------------------------------------------- /LectureSlides/5A_Photometry/5A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cc415965d62a6b9e57030b0fd764bb79238db1730f50c4437d19fce2cf562689 3 | size 1601441 4 | -------------------------------------------------------------------------------- /LectureSlides/5B_Lightness/5B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aa9feafe5a045ac489ef29ff3d2b8446edda61778e8a0ca3e92cd62b1fb20b81 3 | size 817162 4 | -------------------------------------------------------------------------------- /LectureSlides/5C_Shape_From_Shading/5C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2015ca5aeab5ac76d02f881b8733810a6ed596961747907532e894279e54b2b3 3 | size 1761950 4 | -------------------------------------------------------------------------------- /LectureSlides/6A_Introduction_To_Motion/6A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4dd2d902f62bd0601dd09b0f717457ece3a3ccac4e2aedbd01b8fd53aa59304b 3 | size 1237626 4 | -------------------------------------------------------------------------------- /LectureSlides/6B_Optical_Flow/6B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1d72df8d5eaf061d9d36e97ea2fc08a64bf60858b8648eab7133f89b43d8a210 3 | size 904092 4 | -------------------------------------------------------------------------------- /LectureSlides/6B_Optical_Flow/6B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8e74855cffdfde2f30d9fd5f44b9e85933de30b1ac0e631a1866671bf2f05245 3 | size 1220645 4 | -------------------------------------------------------------------------------- /LectureSlides/6B_Optical_Flow/6B-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6a7e0b8478e5f096d98d50fda52d86b88dcae5547026af15e9f894501b5cd19a 3 | size 1551722 4 | -------------------------------------------------------------------------------- /LectureSlides/6B_Optical_Flow/6B-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b8d4f1a1022bbf282683a1bb6db07fd42f96681269265137bafd5681d6f4d40d 3 | size 1114652 4 | -------------------------------------------------------------------------------- /LectureSlides/7A_Introduction_To_Tracking/7A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bde06a7512a7d1c54e5189f902ecf53a611a3c1853be9a7771e3338abd9c8c05 3 | size 712523 4 | -------------------------------------------------------------------------------- /LectureSlides/7B_Parametric_Models/7B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:73a654e4c2cf39f6e2b716beb4db3c37fbe9d5694bc125044c120604015f810f 3 | size 1090160 4 | -------------------------------------------------------------------------------- /LectureSlides/7B_Parametric_Models/7B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:616ec09410d5f66bac04425dc68259703f099403e4741e22bffbb2e4d089c306 3 | size 1108127 4 | -------------------------------------------------------------------------------- /LectureSlides/7C_Non-Parametric_Models/7C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e993f173d9105483c57737447fd6111fbc5c5ce028880ebcda7729fdf9147280 3 | size 1002603 4 | -------------------------------------------------------------------------------- /LectureSlides/7C_Non-Parametric_Models/7C-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0e9c9df3c5e872b5cc5366a52f0251dc8686b2c162bfb6a48744d47d6187f419 3 | size 974640 4 | -------------------------------------------------------------------------------- /LectureSlides/7C_Non-Parametric_Models/7C-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b87b127f6b72db12653f66975b69543f73ab808765963ca912eb46178af9fa6a 3 | size 1521200 4 | -------------------------------------------------------------------------------- /LectureSlides/7C_Non-Parametric_Models/7C-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7e3e41f4c4a209b3ed4409343d2ed0b7458e8938e883a15a0a9da6d88281baf8 3 | size 1145015 4 | -------------------------------------------------------------------------------- /LectureSlides/7D_Tracking_Considerations/7D-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:30b48b329e3f6b9b319ac81e0f5aca4accc7f807797e149536272cfb1cdd3b2a 3 | size 1808384 4 | -------------------------------------------------------------------------------- /LectureSlides/8A_Introduction_To_Recognition/8A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f672b63f41b01edaa68d3bb8b1dbe06889ddc065d344bb576e83b759f2fb6519 3 | size 2709468 4 | -------------------------------------------------------------------------------- /LectureSlides/8B_Classification_Generative_Models/8B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e25befef79f2e794fd17b9bea9ec2be2c484bc2ebadcc29ce89c675a5a43adba 3 | size 1115959 4 | -------------------------------------------------------------------------------- /LectureSlides/8B_Classification_Generative_Models/8B-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e3f315a1b8dc29bfc650d945e4d3cc8b5caac4f88fd3de7bd2e1d1b677fdebbf 3 | size 1837636 4 | -------------------------------------------------------------------------------- /LectureSlides/8B_Classification_Generative_Models/8B-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fd8267caa4bfd96601770e6329fcf100619e06efbae5f71e704cc21a05e5be2a 3 | size 878736 4 | -------------------------------------------------------------------------------- /LectureSlides/8C_Classification_Discriminative_Models/8C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e363b55f80ab050b92b7707cd721b1cc215a36fc4dbc5ca4fbbb2fc83781019a 3 | size 1728816 4 | -------------------------------------------------------------------------------- /LectureSlides/8C_Classification_Discriminative_Models/8C-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f66934ea3c72194e3ec28ff1a25ba554e48dbeb3930b6306e52e2c1dbb515f5 3 | size 1359219 4 | -------------------------------------------------------------------------------- /LectureSlides/8C_Classification_Discriminative_Models/8C-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dca24bd25330df91ecc58fe5048e8df86f6d382876ec834d26587f8a50d6c999 3 | size 1360221 4 | -------------------------------------------------------------------------------- /LectureSlides/8C_Classification_Discriminative_Models/8C-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a3270a10333b13b88958cec0bd23934af9538026dd757031c5b70186e0e8f682 3 | size 1339117 4 | -------------------------------------------------------------------------------- /LectureSlides/8D_Action_Recognition/8D-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9393d97d543ae804adfbd39747327b5af734c2f14391ccb55951f64d5d591373 3 | size 1975970 4 | -------------------------------------------------------------------------------- /LectureSlides/8D_Action_Recognition/8D-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4df66624f26ff4d2186f0a6f53e5c5f9519c0702ca6d237bb87bc0223f447a4a 3 | size 1343032 4 | -------------------------------------------------------------------------------- /LectureSlides/8D_Action_Recognition/8D-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:476419a44965a8c70a4666dda5d1ceed6f543e12de0467934af26ce5098568ad 3 | size 1967725 4 | -------------------------------------------------------------------------------- /LectureSlides/9A_Color_Spaces_and_Segmentation/9A-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bfb967b0f52e722f37d110dd410d349b0bddc17adc515e1d6a51d2d406697ec0 3 | size 3278443 4 | -------------------------------------------------------------------------------- /LectureSlides/9A_Color_Spaces_and_Segmentation/9A-L2.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6a1fb12f6b6a0a80e9e685257ffa13d3cce106978bf3761644780028a9c8a123 3 | size 1810480 4 | -------------------------------------------------------------------------------- /LectureSlides/9A_Color_Spaces_and_Segmentation/9A-L3.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7775b140e5fba732f397962cf471024edbcb4e6e1c2149cfa6969e84516ff30d 3 | size 1986887 4 | -------------------------------------------------------------------------------- /LectureSlides/9A_Color_Spaces_and_Segmentation/9A-L4.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:983f5133ad56ebaf4fee8b52fd19304111a09a0b56968e008f73aa24acd05df9 3 | size 848726 4 | -------------------------------------------------------------------------------- /LectureSlides/9B_Binary_Morphology/9B-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:288625d74a238b94def4433fe4ebbc81b44d0d22773a0792ffd204b581dfb567 3 | size 1597132 4 | -------------------------------------------------------------------------------- /LectureSlides/9C_3D_Perception/9C-L1.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4547969c87fe4f29092d6555a4a9f2d301201f54e2c7121ceab75ebb82fefcde 3 | size 3983557 4 | -------------------------------------------------------------------------------- /LectureSlides/CS4495 Spring 2015 Study Guide.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:07a5041bdfb9d74506f05e5d2b5053cadf4df6e9131bd5c34696c8c19510ee56 3 | size 291889 4 | -------------------------------------------------------------------------------- /LectureSlides/Extra/19-cameracalibration.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:70d52400e4a1734e6c65834f141625e2eb3fb2256a54351d461e75685dcc10b6 3 | size 67457 4 | -------------------------------------------------------------------------------- /LectureSlides/Extra/Burt-Adelson1983Laplacian-Pyramid.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:940d602d3927dcdcf2a38a9b30e7e6d49967484416cd1eda2e837f013d35058f 3 | size 832070 4 | -------------------------------------------------------------------------------- /LectureSlides/Extra/MIT_Least_Squares.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ee5202e8e9eb49fa620606413dc6f660927af041739865563e56b509e77f5d5d 3 | size 138565 4 | -------------------------------------------------------------------------------- /LectureSlides/Extra/least-squares_slides.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:240bc709cc9104cfcab9f521a179ed1eddc5f6eef4a0b5df9cbc81ebfde053ee 3 | size 193040 4 | -------------------------------------------------------------------------------- /ProblemSets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(ps0_cpp) 2 | add_subdirectory(ps1_cpp) 3 | add_subdirectory(ps2_cpp) 4 | add_subdirectory(ps3_cpp) 5 | add_subdirectory(ps4_cpp) 6 | add_subdirectory(ps5_cpp) 7 | add_subdirectory(ps6_cpp) 8 | add_subdirectory(ps7_cpp) -------------------------------------------------------------------------------- /ProblemSets/ps0_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB hdr *.h *.hpp *.cuh) 2 | file(GLOB src *.cpp *.cu) 3 | 4 | add_executable(ps0 ${hdr} ${src}) 5 | 6 | target_link_libraries(ps0 yaml-cpp) 7 | 8 | #set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/ps0") -------------------------------------------------------------------------------- /ProblemSets/ps1_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB hdr src/*.h src/*.hpp) 2 | file(GLOB src src/*.cpp) 3 | file(GLOB cu src/*.cu src/*.cuh) 4 | 5 | cuda_add_executable(ps1 ${hdr} ${cu} ${src}) 6 | 7 | target_link_libraries(ps1 yaml-cpp cv_common) -------------------------------------------------------------------------------- /ProblemSets/ps1_cpp/src/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include "spdlog/spdlog.h" 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace config { 16 | static constexpr char FILE_LOGGER[] = "file_logger"; 17 | static constexpr char STDOUT_LOGGER[] = "logger"; 18 | }; // namespace config 19 | 20 | class Config { 21 | private: 22 | std::shared_ptr _logger; 23 | 24 | public: 25 | // Structures 26 | struct Images : BasicConfig { 27 | cv::Mat _input0, _input0Noise, _input1, _input2, _input3; 28 | 29 | Images() = default; 30 | Images(const YAML::Node& imagesNode); 31 | }; 32 | 33 | struct EdgeDetect : BasicConfig { 34 | size_t _gaussianSize; 35 | float _gaussianSigma; 36 | double _lowerThreshold, _upperThreshold; 37 | int _sobelApertureSize; 38 | 39 | EdgeDetect() = default; 40 | EdgeDetect(const YAML::Node& edgeDetectNode); 41 | }; 42 | 43 | struct Hough : BasicConfig { 44 | unsigned int _numPeaks; 45 | int _threshold; 46 | }; 47 | 48 | struct HoughLines : Hough { 49 | unsigned int _rhoBinSize, _thetaBinSize; 50 | HoughLines() = default; 51 | HoughLines(const YAML::Node& houghNode); 52 | }; 53 | 54 | struct HoughCircles : Hough { 55 | unsigned int _minRadius, _maxRadius; 56 | HoughCircles() = default; 57 | HoughCircles(const YAML::Node& houghNode); 58 | }; 59 | 60 | Images _images; 61 | EdgeDetect _p2Edge, _p3Edge, _p4Edge, _p5Edge, _p6Edge, _p7Edge, _p8Edge; 62 | HoughLines _p2Hough, _p3Hough, _p4Hough, _p6Hough, _p8HoughLines; 63 | HoughCircles _p5Hough, _p7Hough, _p8HoughCircles; 64 | 65 | std::string _outputPathPrefix; 66 | 67 | bool _configDone = false; 68 | 69 | Config(const std::string& configFilePath); 70 | 71 | bool loadConfig(const YAML::Node& config); 72 | }; -------------------------------------------------------------------------------- /ProblemSets/ps1_cpp/src/Hough.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define MIN_THETA -90.f 7 | #define MAX_THETA 90.f 8 | #define THETA_WIDTH (MAX_THETA - MIN_THETA) 9 | 10 | // C++ wrappers around CUDA kernels 11 | 12 | namespace cuda { 13 | 14 | /** 15 | * \brief Create Hough lines accumulation matrix. 16 | * 17 | * \param edgemask input matrix of edges 18 | * \param rhoBinSize rho resolution 19 | * \param thetaBinSize theta resolution 20 | * \pararm accumulator output matrix of accumulated votes 21 | */ 22 | void houghLinesAccumulate(const cv::cuda::GpuMat& edgeMask, 23 | const unsigned int rhoBinSize, 24 | const unsigned int thetaBinSize, 25 | cv::cuda::GpuMat& accumulator); 26 | 27 | /** 28 | * \brief Create Hough lines accumulation matrix. 29 | * 30 | * \param edgemask input matrix of edges 31 | * \param rhoBinSize rho resolution 32 | * \param thetaBinSize theta resolution 33 | * \pararm accumulator output matrix of accumulated votes 34 | */ 35 | void houghLinesAccumulate(const cv::Mat& edgeMask, 36 | const unsigned int rhoBinSize, 37 | const unsigned int thetaBinSize, 38 | cv::Mat& accumulator); 39 | 40 | /** 41 | * \brief Locates peaks in the Hough transform matrix. 42 | * \param accumulator Hough transform accumulator 43 | * \param numPeaks maximum number of peaks to detect 44 | * \param threshold minimum number of votes required to be considered a peak 45 | * \param localMaxima output vector of pairs, where the first value is the row and second value is 46 | * the column in which the peak was found 47 | */ 48 | void findLocalMaxima(const cv::cuda::GpuMat& accumulator, 49 | const unsigned int numPeaks, 50 | const int threshold, 51 | std::vector>& localMaxima); 52 | 53 | /** 54 | * \brief Locates peaks in the Hough transform matrix. 55 | * \param accumulator Hough transform accumulator 56 | * \param numPeaks maximum number of peaks to detect 57 | * \param threshold minimum number of votes required to be considered a peak 58 | * \param localMaxima output vector of pairs, where the first value is the row and second value is 59 | * the column in which the peak was found 60 | */ 61 | void findLocalMaxima(const cv::Mat& accumulator, 62 | const unsigned int numPeaks, 63 | const int threshold, 64 | std::vector>& localMaxima); 65 | 66 | /** 67 | * \brief Create Hough circles accumulation matrix 68 | * 69 | * \param edgeMask input matrix of edges 70 | * \param radius radius to which the Hough transform is computed 71 | * \param accumulator output matrix of accumulated votes 72 | */ 73 | void houghCirclesAccumulate(const cv::cuda::GpuMat& edgeMask, 74 | const size_t radius, 75 | cv::cuda::GpuMat& accumulator); 76 | 77 | /** 78 | * \brief Create Hough circles accumulation matrix 79 | * 80 | * \param edgeMask input matrix of edges 81 | * \param radius radius to which the Hough transform is computed 82 | * \param accumulator output matrix of accumulated votes 83 | */ 84 | void houghCirclesAccumulate(const cv::Mat& edgeMask, const size_t radius, cv::Mat& accumulator); 85 | }; // namespace cuda 86 | -------------------------------------------------------------------------------- /ProblemSets/ps1_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Definitions for solution class that runs all the solutions 4 | #include 5 | #include "Config.h" 6 | 7 | #include 8 | 9 | namespace sol { 10 | /** 11 | * Problem 1.a. 12 | * Load the input grayscale image (input/ps1-input0.png) as img and generate an edge image – 13 | * which is a binary image with white pixels (1) on the edges and black pixels (0) elsewhere. 14 | * 15 | * For reference, do “doc edge” in Matlab and read about edge operators. Use one operator of 16 | * your choosing – for this image it probably won’t matter much. If your edge operator uses 17 | * parameters (like ‘canny’) play with those until you get the edges you would expect to see. 18 | */ 19 | void generateEdge(const cv::Mat& input, const Config::EdgeDetect& config, cv::Mat& output); 20 | // Using my separable convolution implementation 21 | void gaussianBlur(const cv::Mat& input, const Config::EdgeDetect& config, cv::Mat& output); 22 | 23 | /** 24 | * Computes the Hough Transform for lines and produces an accumulator array. 25 | */ 26 | void houghLinesAccumulate(const cv::Mat& edgeMask, 27 | const Config::HoughLines& config, 28 | cv::Mat& accumulator); 29 | 30 | void houghCirclesAccumulate(const cv::Mat& edgeMask, const size_t radius, cv::Mat& accumulator); 31 | 32 | /** 33 | * Problem 2.b. 34 | * Write a function hough_lines_draw to draw color lines that correspond to peaks found in the 35 | * accumulator array. This means you need to look up rho, theta values using the peak indices, 36 | * and then convert them (back) to line parameters in cartesian coordinates (you can then use 37 | * regular line-drawing functions). 38 | */ 39 | void findLocalMaxima(const cv::Mat& accumulator, 40 | const Config::Hough& config, 41 | std::vector>& localMaxima); 42 | 43 | /** 44 | * Problem 2.c. 45 | * Write a function hough_lines_draw to draw color lines that correspond to peaks found in the 46 | * accumulator array. This means you need to look up rho, theta values using the peak indices, 47 | * and then convert them (back) to line parameters in cartesian coordinates (you can then use 48 | * regular line-drawing functions). 49 | * 50 | * Use this to draw lines on the original grayscale (not edge) image. The lines should extend to 51 | * the edges of the image (aka infinite lines) 52 | */ 53 | // Convert a row x column value computed by findLocalMaxima to a rho x theta value. This just 54 | // adjusts the row, column value to account for the bin sizes and the diagonal size of the 55 | // image. 56 | std::pair rowColToRhoTheta(const std::pair& coordinates, 57 | const cv::Mat& inputImage, 58 | const Config::HoughLines& config); 59 | void drawLineParametric(cv::Mat& image, const float rho, const float theta, const cv::Scalar color); 60 | 61 | // Draw all the lines in a vector of (rho, theta) pairs. 62 | void drawLinesParametric(cv::Mat& image, 63 | const std::vector>& rhoTheta, 64 | const cv::Scalar color); 65 | 66 | // Draw all the circles in a vector of (y, x) pairs. 67 | void drawCircles(cv::Mat& image, 68 | const std::vector>& center, 69 | const size_t radius, 70 | const cv::Scalar color); 71 | 72 | void findParallelLines(const std::vector>& rhoTheta, 73 | const size_t deltaTheta, 74 | const size_t deltaRho, 75 | std::vector>& parallelRhoThetas); 76 | }; // namespace sol -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | file(GLOB lib_cu lib/*.cu lib/*.cuh) 4 | 5 | file(GLOB exe_hdr src/*.h src/*.hpp) 6 | file(GLOB exe_src src/*.cpp) 7 | 8 | cuda_add_library(ps2sol ${lib_hdr} ${lib_cu} ${lib_src}) 9 | 10 | cuda_add_executable(ps2 ${exe_hdr} ${exe_src}) 11 | 12 | target_link_libraries(ps2sol yaml-cpp cv_common) 13 | target_link_libraries(ps2 ps2sol) -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/README.md: -------------------------------------------------------------------------------- 1 | # Problem Set 2: Window-based Stereo Matching 2 | 3 | All output images are originally generated in the `bin/ps2_output` directory at the root of this repository. Additionally, program logfiles are generated in `bin`. For convenience, I have copied these outputs to the `output` directory here. 4 | 5 | CUDA kernel execution times are listed in `output/ps2_gpu.log`. 6 | 7 | Left-hand side disparity maps computed stereo correspondence from left to right; right-hand side computed it from right to left. 8 | 9 | ## Problem 1: Basic stereo with sum of squared differences 10 | 11 | Input images: 12 | 13 | 14 | 15 | Disparity maps with SSD: 16 | 17 | 18 | 19 | - Runtime with CPU: 366.367 ms 20 | - Runtime with GPU (CUDA): 7.18332 ms 21 | 22 | **Speedup with GPU: 51x** 23 | 24 | ## Problem 2: More realistic images 25 | 26 | Input images: 27 | 28 | 29 | 30 | Ground truths: 31 | 32 | 33 | 34 | Disparity maps with SSD: 35 | 36 | 37 | 38 | - Runtime with CPU: 161714 ms 39 | - Runtime with GPU (CUDA): 56.5523 ms 40 | 41 | **Speedup with GPU: 2859.55x** 42 | 43 | ## Problem 3: Adding noise and contrast to the previous image 44 | 45 | With added Gaussian noise (mean = 0, sigma = 10) 46 | 47 | 48 | 49 | With boosted contrast (10% increase) 50 | 51 | 52 | 53 | - Runtime with CPU: 373934 ms 54 | - Runtime with GPU (CUDA): 118.377 ms 55 | 56 | **Speedup with GPU: 3158.84x** 57 | 58 | ## Problem 4: Implementing stereo correspondence with normalized cross-correlation 59 | 60 | Note: I used the built-in OpenCV `cv::matchTemplate` function to run the CPU version of the normalized cross-correlation matcher, but there is no fast parallelized implementation in OpenCV that would work for computing a full disparity map. I wrote another kernel similar to the sum of squared differences kernel in Problem 1 to handle normalized cross-correlation on the GPU. 61 | 62 | Window matching with the images from Problem 2: 63 | 64 | 65 | 66 | With increased Gaussian noise (mean = 0, sigma = 10) 67 | 68 | 69 | 70 | With a 10% increase in contrast 71 | 72 | 73 | 74 | - Runtime with CPU: 49778.3 ms 75 | - Runtime with GPU: 215.4 ms 76 | 77 | **Speedup with GPU: 231.10x** 78 | 79 | ## Problem 5: Normalized cross-correlation on a different pair of images 80 | 81 | Input images: 82 | 83 | 84 | 85 | Ground truths: 86 | 87 | 88 | 89 | Output using normalized cross correlation: 90 | 91 | 92 | 93 | - Runtime with CPU: 16845.6 ms 94 | - Runtime with GPU: 61.6843 ms 95 | 96 | **Speedup with GPU: 273.09x** -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace config { 16 | static constexpr char FILE_LOGGER[] = "file_logger"; 17 | static constexpr char STDOUT_LOGGER[] = "logger"; 18 | }; // namespace config 19 | 20 | class Config { 21 | private: 22 | std::shared_ptr _logger; 23 | 24 | public: 25 | // Structures 26 | struct Images : BasicConfig { 27 | std::pair _pair0, _pair1, _pair2, _pair1GT, _pair2GT; 28 | 29 | Images() = default; 30 | Images(const YAML::Node& imagesNode); 31 | 32 | private: 33 | // Load an left-right image pair from a YAML file and return whether or not it succeeded. 34 | bool loadImgPair(const YAML::Node& node, 35 | const std::string& keyLeft, 36 | const std::string& keyRight, 37 | std::pair& imgs); 38 | }; 39 | 40 | struct DisparitySSD : BasicConfig { 41 | size_t _windowRadius; 42 | size_t _disparityRange; 43 | 44 | DisparitySSD() = default; 45 | DisparitySSD(const YAML::Node& ssdNode); 46 | }; 47 | 48 | Images _images; 49 | bool _useGpuDisparity = false; 50 | DisparitySSD _p1disp, _p2disp, _p3disp, _p4disp, _p5disp; 51 | 52 | std::string _outputPathPrefix; 53 | 54 | bool _configDone = false; 55 | 56 | Config(const std::string& configFilePath); 57 | 58 | bool loadConfig(const YAML::Node& config); 59 | }; -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/include/DisparityNCorr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Functions for computing disparity using normalized correlation 6 | 7 | namespace cuda { 8 | /** 9 | * \brief Computes disparity between two images using normalized correlation. 10 | * \param left "reference" image 11 | * \param right target image to compare against 12 | * \param windowRad Radius of the summing window, e.g. 5 = 11x11 window 13 | * \param minDisparity Minimum disparity value. Should be negative if a left side image is used as 14 | * a reference image. 15 | * \param maxDisparity Maximum disparity value. Should be positive if a right side image is used as 16 | * a reference image. 17 | * \param disparity Output disparity matrix. 18 | */ 19 | void disparityNCorr(const cv::Mat& left, 20 | const cv::Mat& right, 21 | const size_t windowRad, 22 | const int minDisparity, 23 | const int maxDisparity, 24 | cv::Mat& disparity); 25 | }; // namespace cuda 26 | 27 | namespace serial { 28 | /** 29 | * \brief Computes disparity between two images using normalized correlation. 30 | * \param left "reference" image 31 | * \param right target image to compare against 32 | * \param windowRad Radius of the summing window, e.g. 5 = 11x11 window 33 | * \param minDisparity Minimum disparity value. Should be negative if a left side image is used as 34 | * a reference image. 35 | * \param maxDisparity Maximum disparity value. Should be positive if a right side image is used as 36 | * a reference image. 37 | * \param disparity Output disparity matrix. 38 | */ 39 | void disparityNCorr(const cv::Mat& left, 40 | const cv::Mat& right, 41 | const size_t windowRad, 42 | const int minDisparity, 43 | const int maxDisparity, 44 | cv::Mat& disparity); 45 | }; // namespace serial -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/include/DisparitySSD.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // Parallelized implementation of disparity using sum-of-squared-differences. 6 | namespace cuda { 7 | /** 8 | * \brief Compute disparity on GPU with sum-of-squared-differences. 9 | * \param left "reference" image 10 | * \param right target image to compare against 11 | * \param windowRad Radius of the summing window, e.g. 5 = 11x11 window 12 | * \param minDisparity Minimum disparity value. Should be negative if a left side image is used as 13 | * a reference image. 14 | * \param maxDisparity Maximum disparity value. Should be positive if a right side image is used as 15 | * a reference image. 16 | * \param disparity Output disparity matrix. 17 | */ 18 | void disparitySSD(const cv::Mat& left, 19 | const cv::Mat& right, 20 | const size_t windowRad, 21 | const int minDisparity, 22 | const int maxDisparity, 23 | cv::Mat& disparity); 24 | }; // namespace cuda 25 | 26 | namespace serial { 27 | /** 28 | * \brief Compute disparity on CPU with sum-of-squared-differences. 29 | * \param left "reference" image 30 | * \param right target image to compare against 31 | * \param windowRad Radius of the summing window, e.g. 5 = 11x11 window 32 | * \param minDisparity Minimum disparity value. Should be negative if a left side image is used as 33 | * a reference image. 34 | * \param maxDisparity Maximum disparity value. Should be positive if a right side image is used as 35 | * a reference image. 36 | * \param disparity Output disparity matrix. 37 | */ 38 | void disparitySSD(const cv::Mat& left, 39 | const cv::Mat& right, 40 | const size_t windowRad, 41 | const int minDisparity, 42 | const int maxDisparity, 43 | cv::Mat& disparity); 44 | }; // namespace serial -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/lib/DisparityNCorr.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/DisparityNCorr.h" 2 | #include "../include/Config.h" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | void serial::disparityNCorr(const cv::Mat& left, 13 | const cv::Mat& right, 14 | const size_t windowRad, 15 | const int minDisparity, 16 | const int maxDisparity, 17 | cv::Mat& disparity) { 18 | assert(left.type() == CV_32FC1 && right.type() == CV_32FC1); 19 | // Set up file loggers 20 | auto logger = spdlog::get(config::FILE_LOGGER); 21 | logger->info("DisparityNCorr: windowRad={}, minDisparity={}, maxDisparity={}", 22 | windowRad, 23 | minDisparity, 24 | maxDisparity); 25 | // Pad input images with replicated borders so we can do the edge pixels 26 | logger->info("DisparityNCorr: padding input images with {} pixels", windowRad); 27 | cv::Mat leftPadded, rightPadded; 28 | cv::copyMakeBorder( 29 | left, leftPadded, windowRad, windowRad, windowRad, windowRad, cv::BORDER_REPLICATE); 30 | cv::copyMakeBorder( 31 | right, rightPadded, windowRad, windowRad, windowRad, windowRad, cv::BORDER_REPLICATE); 32 | 33 | logger->info("DisparityNCorr: original image: rows={} cols={}; new image: rows={} cols={}", 34 | left.rows, 35 | left.cols, 36 | leftPadded.rows, 37 | leftPadded.cols); 38 | 39 | disparity.create(left.rows, left.cols, CV_8SC1); 40 | 41 | size_t windowSize = 2 * windowRad + 1; 42 | 43 | // Iterate over the image 44 | for (int y = windowRad; y < leftPadded.rows - windowRad; y++) { 45 | for (int x = windowRad; x < leftPadded.cols - windowRad; x++) { 46 | // Get the template around this pixel that we'll use for the block matcher 47 | cv::Rect bbox(x - windowRad, y - windowRad, windowSize, windowSize); 48 | cv::Mat templ = leftPadded(bbox).clone(); 49 | // Get the search window. 50 | int startX = std::max(0, x + minDisparity - int(windowRad)); 51 | int endX = std::min(int(leftPadded.cols), x + maxDisparity + 1 + int(windowRad)); 52 | bbox = cv::Rect(startX, y - windowRad, endX - startX, windowSize); 53 | cv::Mat search = rightPadded(bbox).clone(); 54 | // Result of template matching is stored in a matrix of size (W - w + 1 * H - h + 1), 55 | // where W,H = width and height of the search image, w,h = width and height of the 56 | // template 57 | cv::Mat result(search.rows - windowSize + 1, search.cols - windowSize + 1, CV_32FC1); 58 | 59 | // Match templates 60 | cv::matchTemplate(search, templ, result, cv::TM_CCORR_NORMED); 61 | // Find maxima 62 | double minVal, maxVal; 63 | cv::Point minLoc, maxLoc; 64 | cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc); 65 | 66 | // Get disparity value 67 | int disp = maxLoc.x - (minDisparity <= 0 && maxDisparity <= 0 ? result.cols - 1 : 0); 68 | disparity.at(y - windowRad, x - windowRad) = disp; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/lib/DisparitySSD.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/DisparitySSD.h" 2 | #include "../include/Config.h" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | void serial::disparitySSD(const cv::Mat& left, 10 | const cv::Mat& right, 11 | const size_t windowRad, 12 | const int minDisparity, 13 | const int maxDisparity, 14 | cv::Mat& disparity) { 15 | assert(left.type() == CV_32FC1 && right.type() == CV_32FC1); 16 | // Set up file loggers 17 | auto logger = spdlog::get(config::FILE_LOGGER); 18 | logger->info("disparitySSD (CPU): Padding input images with {} pixels", windowRad); 19 | cv::Mat leftPadded, rightPadded; 20 | cv::copyMakeBorder( 21 | left, leftPadded, windowRad, windowRad, windowRad, windowRad, cv::BORDER_REPLICATE); 22 | cv::copyMakeBorder( 23 | right, rightPadded, windowRad, windowRad, windowRad, windowRad, cv::BORDER_REPLICATE); 24 | 25 | logger->info( 26 | "disparitySSD (CPU): Original image: rows={} cols={}; padded image: rows={} cols={}", 27 | left.rows, 28 | left.cols, 29 | leftPadded.rows, 30 | leftPadded.cols); 31 | 32 | disparity.create(left.rows, left.cols, CV_8SC1); 33 | 34 | // iterate over every pixel in the left image 35 | for (int y = windowRad; y < leftPadded.rows - windowRad; y++) { 36 | for (int x = windowRad; x < leftPadded.cols - windowRad; x++) { 37 | int bestCost = 99999999; 38 | int bestDisparity = 0; 39 | // Iterate over the row to search for a matching window. If the reference frame is the 40 | // left image, then we search to the left; if it's the right image, then we search to 41 | // the right 42 | int searchIndex = fmax(0, x + minDisparity); 43 | int maxSearchIndex = fmin(leftPadded.cols - 1, x + maxDisparity); 44 | for (searchIndex; searchIndex <= maxSearchIndex; searchIndex++) { 45 | int sum = 0; 46 | // Iterate over the window and compute sum of squared differences 47 | for (int winY = -1 * int(windowRad); winY <= int(windowRad); winY++) { 48 | for (int winX = -1 * int(windowRad); winX <= int(windowRad); winX++) { 49 | float rawCost = leftPadded.at(y + winY, x + winX) - 50 | rightPadded.at(y + winY, searchIndex + winX); 51 | sum += round(rawCost * rawCost); 52 | } 53 | } 54 | if (sum < bestCost) { 55 | bestCost = sum; 56 | bestDisparity = searchIndex - x; 57 | } 58 | } 59 | disparity.at(y - windowRad, x - windowRad) = bestDisparity; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-1-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b755de16b2186a939159082058de5c3086b4943f3ea4513a9122584cc6cc8db3 3 | size 493 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-1-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cb05ae17a0758b297dd3c52d4f3e42513837b29a2cbc4a9bcc1e27805bcc0f68 3 | size 453 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-2-a-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:526e9c948197abd03a0da0ac4c3508a2b0e9cd8a7e5402c76256c0453ab3bf89 3 | size 84335 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-2-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:610906eb637add1fd078826ea21c515e263fd443f912cea008aa4f0d8899fdb5 3 | size 84435 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-2-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1fd9117a629e5fda0cf76e71fb7e7be673f19880d319f169c2c1bb86ab7e11e0 3 | size 83763 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-a-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d291288c3dd72974d9f11e5f50d9f953473d2226d8178694d4b3d96d25ff8f90 3 | size 119203 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:46af215f9849d14c4d6d68fa34e485ea9a020f1e83b7541b202f16270674820c 3 | size 119340 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5f7c005356c769c96571c79ffe04f81617c43e6da6469cf1e7703449310c070c 3 | size 116586 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-b-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7e2db3c0a4e9d1b6923a205e91d9234dd554fc2c985a4707fc21fdde6058eca8 3 | size 84333 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f940963c23e13b2a207ea4d2e5c0adcf52fc84f79596dc9d42b9a90b840c27d4 3 | size 84433 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-3-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5955945e9d87144456952561320a418e9d539e036684ec1d10e7b7a350a2942b 3 | size 83761 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-a-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7f6f26a6a5102f1828befb1d7de975f7b96aa52b2aca48887a6f44a640ff5766 3 | size 85788 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:29351b3eb827b818cb076642c020d6d60d088999a08ebe4d23718319bea79da7 3 | size 85681 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:21e5e938e84a18d1dad8c38d73af2ec9bc15ace2c29e469479df45bc39901d32 3 | size 84999 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-b-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3f70d59c5dcf2737421ce72e14d023c66878edc05afec795393d05f7fbc70bbf 3 | size 130209 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:18fb75d73609907776c52902fcd6fc8c1f1607142466e1f22723768d9e92f517 3 | size 130287 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c5eaf49c9dbac36245e39e73fbb5f31f54d1b443efebccc044c92bb3d1298f95 3 | size 129669 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-c-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0d3d80bdc74c95616c42afded1f9577ddccea5871074b8370bb76f4ba93d7dc8 3 | size 85790 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-c-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4a7103b1f43ee0cb3e48a7b67ad268643ee1d45deb710ddfe692fa2ae3859304 3 | size 85681 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-4-c-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d1eb8e647fba6c8be2156657bc0996162886ec038d6913c6578f8c3d9a4e707d 3 | size 85007 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-5-a-1-inverted.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:db45d9f56ab900be144a80149ed6d210134018e265f07229fc2275a3c63ebddd 3 | size 77932 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-5-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a082d3b0955d326ea720eead54dc8d50196351814ffad771c2fd17fa54423881 3 | size 77988 4 | -------------------------------------------------------------------------------- /ProblemSets/ps2_cpp/output/ps2-5-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:54b94319ada237e4d3b5f6aca9fed2e8c8d66192ac047474cb95eefa9635c516 3 | size 80095 4 | -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | 4 | file(GLOB exe_hdr src/*.h src/*.hpp) 5 | file(GLOB exe_src src/*.cpp) 6 | 7 | add_library(ps3sol ${lib_hdr} ${lib_src}) 8 | 9 | add_executable(ps3 ${exe_hdr} ${exe_src}) 10 | 11 | target_link_libraries(ps3sol yaml-cpp cv_common Eigen3::Eigen) 12 | target_link_libraries(ps3 ps3sol) -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/include/Calibration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace calib { 7 | // Solve system of linear equations using least squares normal equations 8 | Eigen::MatrixXf solveLeastSquares(const Eigen::MatrixXf& pts2d, const Eigen::MatrixXf& pts3d); 9 | 10 | // Overload of the above function using cv::Mat instead of Eigen 11 | cv::Mat solveLeastSquares(const cv::Mat& pts2d, const cv::Mat& pts3d); 12 | 13 | // Solve system of linear equations using singular value decomposition 14 | Eigen::MatrixXf solveSVD(const Eigen::MatrixXf& pts2d, const Eigen::MatrixXf& pts3d); 15 | 16 | // Overload of the above function using cv::Mat instead of Eigen 17 | cv::Mat solveSVD(const cv::Mat& pts2d, const cv::Mat& pts3d); 18 | }; // namespace calib -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include "FParse.h" 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace config { 18 | static constexpr char FILE_LOGGER[] = "file_logger"; 19 | static constexpr char STDOUT_LOGGER[] = "logger"; 20 | }; // namespace config 21 | 22 | class Config { 23 | private: 24 | std::shared_ptr _logger, _fileLogger; 25 | 26 | public: 27 | // Structures 28 | struct Images : BasicConfig { 29 | cv::Mat _picA, _picB; 30 | 31 | Images() = default; 32 | Images(const YAML::Node& imagesNode); 33 | }; 34 | 35 | struct Points : BasicConfig { 36 | // Vectors of column-vectors for each of the point sets 37 | cv::Mat _picA, _picB, _picANorm, _pts3D, _pts3DNorm; 38 | 39 | Points() = default; 40 | Points(const YAML::Node& node); 41 | 42 | private: 43 | // Load points from a text file 44 | template 45 | bool loadPoints(const YAML::Node& node, const std::string& key, cv::Mat& points) { 46 | auto logger = spdlog::get(config::STDOUT_LOGGER); 47 | auto flogger = spdlog::get(config::FILE_LOGGER); 48 | if (node[key]) { 49 | std::string path = node[key].as(); 50 | points = FParse::parseAs(path); 51 | if (!points.empty()) { 52 | flogger->info("Loaded points from {}", path); 53 | return true; 54 | } 55 | } 56 | 57 | logger->error("Could not load points from param \"{}\"", key); 58 | return false; 59 | } 60 | }; 61 | 62 | Images _images; 63 | Points _points; 64 | 65 | // Path to which output images will be written 66 | std::string _outputPathPrefix; 67 | // Seed for mersenne twister engine 68 | std::unique_ptr _mersenneSeed; 69 | 70 | bool _configDone = false; 71 | 72 | Config(const std::string& configFilePath); 73 | 74 | bool loadConfig(const YAML::Node& config); 75 | }; -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/include/Fundamental.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace fundamental { 7 | /** 8 | * \brief Compute the fundamental matrix estimating the mapping between points in two cameras, 9 | * solving the linear system with normal equations. 10 | * 11 | * \param pts2dA 2D points from camera A 12 | * \param pts2dB 2D points from camera B 13 | */ 14 | Eigen::MatrixXf solveLeastSquares(const Eigen::MatrixXf& pts2dA, const Eigen::MatrixXf& pts2d); 15 | 16 | // Overload of the above function using cv::Mat instead of Eigen 17 | cv::Mat solveLeastSquares(const cv::Mat& pts2dA, const cv::Mat& pts2dB); 18 | 19 | /** 20 | * \brief Reduce rank of fundamental matrix from 3 to 2 21 | * 22 | * \param fMat input matrix 23 | */ 24 | Eigen::MatrixXf rankReduce(const Eigen::MatrixXf& fMat); 25 | 26 | cv::Mat rankReduce(const cv::Mat& fMat); 27 | }; // namespace fundamental -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/lib/Calibration.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Calibration.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | Eigen::MatrixXf calib::solveLeastSquares(const Eigen::MatrixXf& pts2d, 8 | const Eigen::MatrixXf& pts3d) { 9 | assert(pts2d.cols() == pts3d.cols() && pts2d.rows() == 2 && pts3d.rows() == 3); 10 | // Set up A and b matrices. 11 | const size_t rows = pts3d.cols() * 2; 12 | const size_t cols = 11; 13 | Eigen::MatrixXf A(rows, cols); 14 | Eigen::MatrixXf b(rows, 1); 15 | 16 | // Build A and b matrices 17 | for (int i = 0; i < rows; i += 2) { 18 | float X = pts3d(0, i / 2); 19 | float Y = pts3d(1, i / 2); 20 | float Z = pts3d(2, i / 2); 21 | float x = pts2d(0, i / 2); 22 | float y = pts2d(1, i / 2); 23 | A.row(i) << X, Y, Z, 1, Eigen::MatrixXf::Zero(1, 4), -x * X, -x * Y, -x * Z; 24 | A.row(i + 1) << Eigen::MatrixXf::Zero(1, 4), X, Y, Z, 1, -y * X, -y * Y, -y * Z; 25 | b.row(i) << x; 26 | b.row(i + 1) << y; 27 | } 28 | 29 | // Solve least squares 30 | Eigen::MatrixXf sol = (A.transpose() * A).ldlt().solve(A.transpose() * b); 31 | // Append a 1 to the end since scale is constant 32 | sol.conservativeResize(sol.rows() + 1, sol.cols()); 33 | sol(sol.rows() - 1, 0) = 1; 34 | return sol; 35 | } 36 | 37 | cv::Mat calib::solveLeastSquares(const cv::Mat& pts2d, const cv::Mat& pts3d) { 38 | // Wrap OpenCV matrices in Eigen::Map 39 | Eigen::MatrixXf eigenPts2d, eigenPts3d; 40 | cv::cv2eigen(pts2d, eigenPts2d); 41 | cv::cv2eigen(pts3d, eigenPts3d); 42 | 43 | auto eigenSol = solveLeastSquares(eigenPts2d, eigenPts3d); 44 | cv::Mat cvSol; 45 | cv::eigen2cv(eigenSol, cvSol); 46 | return cvSol; 47 | } 48 | 49 | Eigen::MatrixXf calib::solveSVD(const Eigen::MatrixXf& pts2d, const Eigen::MatrixXf& pts3d) { 50 | assert(pts2d.cols() == pts3d.cols() && pts2d.rows() == 2 && pts3d.rows() == 3); 51 | // Set up A and b matrices. 52 | const size_t rows = pts3d.cols() * 2; 53 | const size_t cols = 12; 54 | Eigen::MatrixXf A(rows, cols); 55 | 56 | // Build A and b matrices 57 | for (int i = 0; i < rows; i += 2) { 58 | float X = pts3d(0, i / 2); 59 | float Y = pts3d(1, i / 2); 60 | float Z = pts3d(2, i / 2); 61 | float x = pts2d(0, i / 2); 62 | float y = pts2d(1, i / 2); 63 | A.row(i) << X, Y, Z, 1, Eigen::MatrixXf::Zero(1, 4), -x * X, -x * Y, -x * Z, -x; 64 | A.row(i + 1) << Eigen::MatrixXf::Zero(1, 4), X, Y, Z, 1, -y * X, -y * Y, -y * Z, -y; 65 | } 66 | 67 | // Compute the orthogonal matrix of eigenvectors of A_T*A 68 | Eigen::MatrixXf eigenvectors = A.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).matrixV(); 69 | // Get the eigenvector with the smallest eigenvalue (the last column of the V matrix) 70 | Eigen::MatrixXf smallest = eigenvectors.col(eigenvectors.cols() - 1); 71 | // std::cout << "sol = \n" << smallest << std::endl; 72 | return smallest; 73 | } 74 | 75 | cv::Mat calib::solveSVD(const cv::Mat& pts2d, const cv::Mat& pts3d) { 76 | // Convert OpenCV matrices to Eigen matrices 77 | Eigen::MatrixXf eigenPts2d, eigenPts3d; 78 | cv::cv2eigen(pts2d, eigenPts2d); 79 | cv::cv2eigen(pts3d, eigenPts3d); 80 | 81 | auto eigenSol = solveSVD(eigenPts2d, eigenPts3d); 82 | cv::Mat cvSol; 83 | cv::eigen2cv(eigenSol, cvSol); 84 | return cvSol; 85 | } -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/lib/FParse.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/FParse.h" 2 | 3 | cv::Mat FParse::parse(const std::string& filePath) { 4 | return parseAs(filePath); 5 | } 6 | 7 | cv::Mat FParse::parse(const std::string& filePath, const char delim) { 8 | return parseAs(filePath, delim); 9 | } 10 | 11 | cv::Mat FParse::parse(const std::string& filePath, const std::string& delim) { 12 | return parseAs(filePath, delim); 13 | } -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/lib/Fundamental.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Fundamental.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | Eigen::MatrixXf fundamental::solveLeastSquares(const Eigen::MatrixXf& pts2dA, 8 | const Eigen::MatrixXf& pts2dB) { 9 | assert(pts2dA.cols() == pts2dB.cols() && pts2dA.rows() == pts2dB.rows() && pts2dA.rows() == 2); 10 | // Set up A and b matrices. 11 | const size_t rows = pts2dB.cols(); 12 | const size_t cols = 8; 13 | Eigen::MatrixXf A(rows, cols); 14 | Eigen::MatrixXf b = Eigen::MatrixXf::Constant(rows, 1, -1); 15 | 16 | // Build A and b matrices 17 | for (int i = 0; i < rows; i++) { 18 | float u = pts2dA(0, i); 19 | float v = pts2dA(1, i); 20 | float u_p = pts2dB(0, i); 21 | float v_p = pts2dB(1, i); 22 | A.row(i) << u * u_p, v * u_p, u_p, u * v_p, v * v_p, v_p, u, v; 23 | } 24 | 25 | // Solve least squares 26 | Eigen::MatrixXf sol = (A.transpose() * A).ldlt().solve(A.transpose() * b); 27 | // Append a 1 to the end since scale is constant 28 | sol.conservativeResize(sol.rows() + 1, sol.cols()); 29 | sol(sol.rows() - 1, 0) = 1; 30 | return sol; 31 | } 32 | 33 | cv::Mat fundamental::solveLeastSquares(const cv::Mat& pts2dA, const cv::Mat& pts2dB) { 34 | // Wrap OpenCV matrices in Eigen::Map 35 | Eigen::MatrixXf eigenPts2dA, eigenPts2dB; 36 | cv::cv2eigen(pts2dA, eigenPts2dA); 37 | cv::cv2eigen(pts2dB, eigenPts2dB); 38 | 39 | auto eigenSol = solveLeastSquares(eigenPts2dA, eigenPts2dB); 40 | cv::Mat cvSol; 41 | cv::eigen2cv(eigenSol, cvSol); 42 | return cvSol; 43 | } 44 | 45 | Eigen::MatrixXf fundamental::rankReduce(const Eigen::MatrixXf& fMat) { 46 | // Make sure this is a valid input matrix 47 | assert(fMat.cols() == 3 && fMat.rows() == 3); 48 | 49 | // Compute SVD of fundamental matrix 50 | auto svd = fMat.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV); 51 | 52 | // Set smallest singular value to zero 53 | auto sigma2 = svd.singularValues(); 54 | sigma2(sigma2.rows() - 1, sigma2.cols() - 1) = 0; 55 | 56 | Eigen::MatrixXf r2FMat = svd.matrixU() * sigma2.asDiagonal() * svd.matrixV().transpose(); 57 | 58 | return r2FMat; 59 | } 60 | 61 | cv::Mat fundamental::rankReduce(const cv::Mat& fMat) { 62 | // Convert OpenCV matrix to Eigen 63 | Eigen::MatrixXf eigenFMat; 64 | cv::cv2eigen(fMat, eigenFMat); 65 | 66 | auto eigenSol = rankReduce(eigenFMat); 67 | cv::Mat cvSol; 68 | cv::eigen2cv(eigenSol, cvSol); 69 | return cvSol; 70 | } -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/output/ps3-2-c-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a00e90da3cf1dd3dd47d5b9c9d58e7bf873edc1167e9eede7eba662c836a6d7e 3 | size 971278 4 | -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/output/ps3-2-c-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3c34034d8e75cf019e884fc4862cb26e2d3400c25309f9ae0d325c43199d63f4 3 | size 1075006 4 | -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/output/ps3-2-e-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:64899378f94ef6dc242837a1d877d3ff4e7af99388cd99921b6cbcab8cee991f 3 | size 969398 4 | -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/output/ps3-2-e-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:da42fdf0b2645fdd1aa15885995cac114a9bf043000a9a900bcf048eb323f621 3 | size 1076229 4 | -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../include/Config.h" 4 | 5 | // General Solution namespace to for functions that involve running the problem set. 6 | 7 | namespace solution { 8 | /** 9 | * \brief Solves problem 1.a, which computes the matrix of calibration parameters M that describes 10 | * the mapping between 3D world points and 2D camera points. 11 | * 12 | * \param config Configuration settings as loaded from a YAML file. 13 | */ 14 | void runProblem1a(const Config& config); 15 | 16 | /** 17 | * \brief Solves problems 1.b. and 1.c. First we compute the camera projection matrix with different 18 | * constraint sizes (8, 12, and 16 points), and picks the best projection by selecting the lowest 19 | * residual. Then, the camera center in the world frame is computed. 20 | * 21 | * \param config Configuration settings as loaded from a YAML file. 22 | */ 23 | void runProblem1bc(const Config& config); 24 | 25 | /** 26 | * \brief Solves problem 2 (parts a, b, and c). This estimates the fundamental matrix F mapping 27 | * corresponding points between an image A and an image B. First, a least-squares estimate of F is 28 | * computed, which is then decomposed from rank 3 to rank 2. Finally, this matrix is used to compute 29 | * epipolar lines from the input points, and these lines are drawn on the input images. 30 | * 31 | * \param config Configuration settings as loaded from a YAML file. 32 | */ 33 | void runProblem2(const Config& config); 34 | 35 | /** 36 | * \brief Solves the extra credit (problem 2, parts d and e). This computes fundamental matrix F by 37 | * first normalizing the input points, then draws the epipolar lines computed by this more accurate 38 | * F on the input images. 39 | * 40 | * \param config Configuration settings as loaded from a YAML file. 41 | */ 42 | void runExtraCredit(const Config& config); 43 | }; // namespace solution -------------------------------------------------------------------------------- /ProblemSets/ps3_cpp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Config.h" 2 | #include "Solution.h" 3 | 4 | #include 5 | 6 | // YAML file containing input parameters 7 | static constexpr char CONFIG_FILE_PATH[] = "../config/ps3.yaml"; 8 | 9 | std::shared_ptr _logger, _fileLogger; 10 | 11 | int main() { 12 | // Set up loggers 13 | std::vector sinks; 14 | auto colorStdoutSink = std::make_shared(); 15 | auto fileSink = std::make_shared("ps3.log"); 16 | sinks.push_back(colorStdoutSink); 17 | sinks.push_back(fileSink); 18 | _logger = std::make_shared("logger", begin(sinks), end(sinks)); 19 | // File logger is just for CUDA kernel outputs 20 | _fileLogger = std::make_shared("file_logger", fileSink); 21 | spdlog::register_logger(_logger); 22 | spdlog::register_logger(_fileLogger); 23 | 24 | Config config(CONFIG_FILE_PATH); 25 | solution::runProblem1a(config); 26 | solution::runProblem1bc(config); 27 | solution::runProblem2(config); 28 | solution::runExtraCredit(config); 29 | } -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | file(GLOB lib_cu lib/*.cu lib/*.cuh) 4 | 5 | file(GLOB exe_hdr src/*.h src/*.hpp) 6 | file(GLOB exe_src src/*.cpp) 7 | 8 | cuda_add_library(ps4sol ${lib_hdr} ${lib_cu} ${lib_src}) 9 | 10 | cuda_add_executable(ps4 ${exe_hdr} ${exe_src}) 11 | 12 | target_link_libraries(ps4sol yaml-cpp cv_common) 13 | target_link_libraries(ps4 ps4sol) -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/README.md: -------------------------------------------------------------------------------- 1 | # Problem Set 4: Harris, SIFT, and RANSAC 2 | 3 | All program outputs are logged; a copy is placed in the `output` directory of this directory. Additionally, all images generated are copied to the `output` directory. 4 | 5 | ## Problem 1: Harris Corners 6 | 7 | ### Part a 8 | Computing X and Y gradients for transA/B and simA/B images. 9 | 10 | transA and transB: 11 |
12 | 13 |
14 | 15 | simA and simB: 16 |
17 | 18 |
19 | 20 | 21 | ### Part b 22 | Harris values (corner responses) for the transA/B and simA/B image pairs. Very dark sections correspond to areas with one high and one low eigenvalue, i.e. they indicate lines. Medium grey areas are flat regions; whiter areas have strong corner responses. 23 | 24 | transA | transB 25 | --- | --- 26 | | 27 | 28 | simA | simB 29 | --- | --- 30 | | 31 | 32 | ### Part c 33 | Corner points found in the image after thresholding and non-maximum suppression. 34 | 35 | transA | transB 36 | --- | --- 37 | | 38 | 39 | simA | simB 40 | --- | --- 41 | | 42 | 43 | ## Problem 2: SIFT Features 44 | 45 | ### Part a 46 | Angles computed from the gradients of each image at each corner point. 47 | 48 | transA and transB: 49 |
50 | 51 |
52 | 53 | simA and simB: 54 |
55 | 56 |
57 | 58 | ### Part b 59 | SIFT descriptors are computed matched between images. Putative matches are drawn on the below image pairs. 60 | 61 | transA and transB: 62 |
63 | 64 |
65 | 66 | simA and simB: 67 |
68 | 69 |
70 | 71 | ## Problem 3: RANSAC 72 | 73 | In all of these problems, "Best transform" refers to the transformation from the "A" image to the "B" image. 74 | 75 | ### Part a 76 | RANSAC is used to find the best translation transformation in the transA/B image pair. The consensus set for this translation is drawn on the images. 77 | 78 | 79 | 80 | ``` 81 | Best transform = 82 | [1, 0, -134; 83 | 0, 1, -78] 84 | with consensus ratio 0.213675 85 | ``` 86 | 87 | ### Part b 88 | The same process as above was done to compute the similarity transformation in the simA/B image pair. 89 | 90 | 91 | 92 | ``` 93 | Best transform = 94 | [0.97133934, -0.28252175, 38.384468; 95 | 0.28252175, 0.97133934, -58.787109] 96 | with consensus ratio 0.628205 97 | ``` 98 | 99 | ## Extra credit problems 100 | A continuation of problem 3. 101 | 102 | ### Part c 103 | Assuming instead that the transformation between simA and simB is affine (instead of similar): 104 | 105 | 106 | 107 | ``` 108 | Best transform = 109 | [0.95664239, -0.26735318, 39.611755; 110 | 0.28754473, 0.99733996, -65.212708] 111 | with consensus ratio 0.602564 112 | ``` 113 | 114 | ### Part d 115 | Warping simB back to simA is done by computing the affine warp of the image using the inverse of the **similarity** transformation computed in part b. 116 | 117 | 118 | 119 | ### Part e 120 | Warping simB back to simA is done by computing the affine warp of the image using the inverse of the **affine** transformation computed in part b. 121 | 122 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace config { 18 | static constexpr char FILE_LOGGER[] = "file_logger"; 19 | static constexpr char STDOUT_LOGGER[] = "logger"; 20 | }; // namespace config 21 | 22 | class Config { 23 | private: 24 | std::shared_ptr _logger, _fileLogger; 25 | 26 | public: 27 | // Structures 28 | struct Images : BasicConfig { 29 | // Input images 30 | cv::Mat _transA, _transB, _simA, _simB, _check, _checkRot; 31 | 32 | Images() = default; 33 | Images(const YAML::Node& imagesNode); 34 | }; 35 | 36 | struct Harris : BasicConfig { 37 | int _sobelKernelSize; 38 | size_t _windowSize, _minDistance; 39 | float _gaussianSigma, _alpha, _responseThresh; 40 | 41 | Harris() = default; 42 | Harris(const YAML::Node& harrisNode); 43 | }; 44 | 45 | struct RANSAC : BasicConfig { 46 | int _reprojThresh, _maxIters; 47 | double _minConsensusRatio; 48 | 49 | RANSAC() = default; 50 | RANSAC(const YAML::Node& ransacNode); 51 | }; 52 | 53 | Images _images; 54 | bool _useGpu = false; 55 | // Settings for Harris operator for the transA and simA images, respectively 56 | Harris _harrisTrans, _harrisSim; 57 | // Settings for RANSAC when searching for translation, similarity, and affine transformations 58 | RANSAC _trans, _sim, _affine; 59 | 60 | // Path to which output images will be written 61 | std::string _outputPathPrefix; 62 | // Seed for mersenne twister engine 63 | std::shared_ptr _mersenneSeed; 64 | 65 | bool _configDone = false; 66 | 67 | Config(const std::string& configFilePath); 68 | 69 | bool loadConfig(const YAML::Node& config); 70 | }; -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/include/Descriptors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace sift { 7 | // Create an "angle" image from X and Y gradients of an input image 8 | void getAnglesFromGradients(const cv::Mat& gradX, const cv::Mat& gradY, cv::Mat& angles); 9 | 10 | /** 11 | * \brief getKeypoints Computes gradient angles for a set of points in an image 12 | * 13 | * \param gradX Gradient in the x-direction of an image 14 | * \param gradY Gradient in the y-direction of an image 15 | * \param cornerLocs Set of (y, x) coordinates of points in the image to treat as keypoints 16 | * \param size Keypoint size 17 | * \param keypoints output vector of cv::KeyPoint objects 18 | */ 19 | void getKeypoints(const cv::Mat& gradX, 20 | const cv::Mat& gradY, 21 | const std::vector>& cornerLocs, 22 | const size_t size, 23 | std::vector& keypoints); 24 | }; // namespace sift -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/include/RANSAC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ransac { 10 | enum class TransformType { TRANSLATION = 1, SIMILARITY = 2, AFFINE = 3 }; 11 | /** 12 | * \brief Gets translation between a set of source points and destination points. Returns a pair 13 | * where the first element is the similarity transformation matrix and the second element is a 14 | * vector of indices indicating the largest consensus set between the two point sets. 15 | * 16 | */ 17 | std::tuple, double> solve(const std::vector& srcPts, 18 | const std::vector& destPts, 19 | const TransformType whichTransform, 20 | const int ransacReprojThresh = 3, 21 | const int maxIters = 2000, 22 | const double minConsensusRatio = 0.75); 23 | 24 | // Seeds the random number generator used by RANSAC 25 | void seed(std::shared_ptr seq); 26 | } // namespace ransac -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/lib/Descriptors.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Descriptors.h" 2 | 3 | #include 4 | 5 | static constexpr float PI = 3.1415921636; 6 | 7 | void sift::getAnglesFromGradients(const cv::Mat& gradX, const cv::Mat& gradY, cv::Mat& angles) { 8 | // Make sure our input images are the right size, then resize the output to the correct size 9 | assert(gradX.rows == gradY.rows && gradX.cols == gradY.cols && gradX.type() == gradY.type() && 10 | gradX.type() == CV_32F); 11 | 12 | // Each angle will be represented in degrees 13 | angles.create(gradX.rows, gradX.cols, CV_32F); 14 | 15 | // Iterate over the input matrices and compute the angle 16 | float Ix, Iy; 17 | for (int y = 0; y < gradX.rows; y++) { 18 | for (int x = 0; x < gradX.cols; x++) { 19 | Ix = gradX.at(y, x); 20 | Iy = gradY.at(y, x); 21 | 22 | angles.at(y, x) = std::atan2(Iy, Ix); 23 | } 24 | } 25 | } 26 | 27 | void sift::getKeypoints(const cv::Mat& gradX, 28 | const cv::Mat& gradY, 29 | const std::vector>& cornerLocs, 30 | const size_t size, 31 | std::vector& keypoints) { 32 | // Make sure our input images are the right size, then resize the output to the correct size 33 | assert(gradX.rows == gradY.rows && gradX.cols == gradY.cols && gradX.type() == gradY.type() && 34 | gradX.type() == CV_32F); 35 | 36 | keypoints.clear(); 37 | 38 | // Iterate over corners and create keypoints 39 | for (const auto& corner : cornerLocs) { 40 | float Ix = gradX.at(corner.first, corner.second); 41 | float Iy = gradY.at(corner.first, corner.second); 42 | 43 | float angle = std::atan2(Iy, Ix) * 180.f / PI; 44 | 45 | keypoints.emplace_back(corner.second, corner.first, size, angle, 0); 46 | } 47 | } -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ac98ae7e988f418a52411372713b0f3ee5db486fd4c82488c043212e3a059106 3 | size 329135 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5e1f33318b16e2efc346248a10f000a53bf16d493eaa2d12bdac51767c5d5d24 3 | size 292502 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-a-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0cb3b38409709825c01d63474dfdec48954658243d35ea56523cc8edb3f2cc07 3 | size 309397 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-a-4.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dcc33edb186b81d5fedf492d98ce2a9dca344c75e03fa17ffa62d7d2c6000c21 3 | size 329443 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:77583f944a72c0d406cf56dd8c8aa3f4899e7b3241fdcc4c0cf962a4ea2d9b15 3 | size 44748 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0d3114b22b2fcaac24131d7e8ada87a0855873ab8491903c7b62833614700961 3 | size 39215 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-b-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ed6cb447b34075aeae8605156c51c5c53673f04dd1bf2d1d3aa53eaa652a6525 3 | size 27974 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-b-4.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1dddbc2b32a33800a0a6ad801b04cd1626ddee501089bd39afd8c1f4ff9b6c0a 3 | size 27627 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-c-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e26040b45b25e4d76aad65a2b9a561278d0d4eabb3a72402d60c296cb2267f18 3 | size 586377 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-c-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5821304a2f709466ca9de8a9030a9ebb4fd5b8dc82d7021c131fa7acac4f45e9 3 | size 558164 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-c-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fa15218bd4d1a99e6295f0da3fa429ba0d11e14d1632835d48bc6981e23c2f34 3 | size 511885 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-1-c-4.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fd18ebf3a2c2b0141293c51738c4c021709f9cb1de4d3de7ec26fc8da72b00e2 3 | size 550229 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-2-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8e650a05731fef96ee83062e754687df80b3d9d00e55ac116d6bed89e06b9ad1 3 | size 1206288 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-2-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ac2d2b8d129a00f0dfe7d49234f9723c523a5aeef97d40641214ee243ba76bae 3 | size 1097778 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-2-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2483e886acccbb605ee1ce9fd9c13f2bae9874f5626697f9c096fd9db5194af9 3 | size 1154062 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-2-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f167bc1b7cc5d7368e402f4d70731075493803f03bcd28a29dded4c2733bbe27 3 | size 1028160 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-3-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e02bef61e42872743bf005091d5a89bc51ff57518a14916e07b1c5c756a1e729 3 | size 1140397 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-3-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bc280c84f394566447966675e1e5a68997d18ab2d22ecf88b57c38ae164aa009 3 | size 1023446 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-3-c-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:62c22077312089058d294d696c50c95954106733b00da0693f133488447ea3e5 3 | size 1023753 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-3-d-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:100a1330bd8dc68fd1f950f117ca58e197d66b2a095a9e42814e87e7ad64d39e 3 | size 160787 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/output/ps4-3-e-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3f480e56a6493003296efc5b81276b224a698aa179d7dc35ccf07d540d039bee 3 | size 160516 4 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../include/Config.h" 4 | #include "../include/RANSAC.h" 5 | 6 | #include 7 | #include 8 | 9 | class Solution { 10 | public: 11 | Solution(const Config& config); 12 | 13 | void runProblem1(); 14 | void runProblem2(); 15 | void runProblem3(); 16 | 17 | private: 18 | // Helpful struct to hold problem set configurations for Harris corners problems, so that we 19 | // don't have to copy/paste a bunch of code 20 | struct FeaturesContainer { 21 | // Reference to input image 22 | const cv::Mat& _input; 23 | // Reference to runtime configuration for a Harris corner detector 24 | const Config::Harris& _config; 25 | // Flags to use CUDA for computation 26 | const bool _useGpu; 27 | const std::string _outPrefix, _gradImgPath, _crImgPath, _cornersImgPath, _keypointsImgPath, 28 | _matchesImgPath; 29 | 30 | // Filled when Harris functions are run 31 | cv::Mat _gradientX, _gradientY, _cornerResponse, _corners, _angles, _drawnKeypoints; 32 | std::vector> _cornerLocs; 33 | std::vector _keypoints; 34 | std::vector _goodMatches; 35 | 36 | FeaturesContainer(const cv::Mat& input, 37 | const Config::Harris& config, 38 | const bool useGpu, 39 | const std::string& outPrefix, 40 | const std::string& gradImgPath, 41 | const std::string& crImgPath, 42 | const std::string& cornersImgPath, 43 | const std::string& keypointsImgPath, 44 | const std::string& matchesImgPath) 45 | : _input(input), _config(config), _useGpu(useGpu), _outPrefix(outPrefix), 46 | _gradImgPath(gradImgPath), _crImgPath(crImgPath), _cornersImgPath(cornersImgPath), 47 | _keypointsImgPath(keypointsImgPath), _matchesImgPath(matchesImgPath) {} 48 | }; 49 | 50 | const Config& _config; 51 | 52 | std::vector _featConts; 53 | 54 | // Draw dots given by an input mask onto an image 55 | void drawDots(const cv::Mat& mask, const cv::Mat& img, cv::Mat& dottedImg); 56 | 57 | // Compute Harris corners 58 | void harrisHelper(FeaturesContainer& conf); 59 | 60 | // Find SIFT descriptors 61 | void siftHelper(FeaturesContainer& img1, FeaturesContainer& img2); 62 | 63 | // Compute best fit model 64 | std::tuple, double> ransacHelper(FeaturesContainer& img1, 65 | FeaturesContainer& img2, 66 | ransac::TransformType whichRansac, 67 | const Config::RANSAC& settings, 68 | const std::string& outputPath); 69 | }; 70 | -------------------------------------------------------------------------------- /ProblemSets/ps4_cpp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../include/Config.h" 3 | #include "Solution.h" 4 | 5 | #include 6 | 7 | // YAML file containing input parameters 8 | static constexpr char CONFIG_FILE_PATH[] = "../config/ps4.yaml"; 9 | 10 | std::shared_ptr _logger, _fileLogger; 11 | 12 | int main() { 13 | // Set up loggers 14 | std::vector sinks; 15 | auto colorStdoutSink = std::make_shared(); 16 | auto fileSink = std::make_shared("ps4.log"); 17 | sinks.push_back(colorStdoutSink); 18 | sinks.push_back(fileSink); 19 | _logger = std::make_shared("logger", begin(sinks), end(sinks)); 20 | // File logger is just for CUDA kernel outputs 21 | _fileLogger = std::make_shared("file_logger", fileSink); 22 | spdlog::register_logger(_logger); 23 | spdlog::register_logger(_fileLogger); 24 | 25 | common::warmup(); 26 | _fileLogger->info("GPU warmup done"); 27 | 28 | Config config(CONFIG_FILE_PATH); 29 | Solution sol(config); 30 | sol.runProblem1(); 31 | sol.runProblem2(); 32 | sol.runProblem3(); 33 | } -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | file(GLOB lib_cu lib/*.cu lib/*.cuh) 4 | 5 | file(GLOB exe_hdr src/*.h src/*.hpp) 6 | file(GLOB exe_src src/*.cpp) 7 | 8 | cuda_add_library(ps5sol ${lib_hdr} ${lib_cu} ${lib_src}) 9 | 10 | cuda_add_executable(ps5 ${exe_hdr} ${exe_src}) 11 | 12 | target_link_libraries(ps5sol yaml-cpp cv_common boost_system boost_filesystem) 13 | target_link_libraries(ps5 ps5sol) -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace config { 18 | static constexpr char FILE_LOGGER[] = "file_logger"; 19 | static constexpr char STDOUT_LOGGER[] = "logger"; 20 | }; // namespace config 21 | 22 | class Config { 23 | private: 24 | std::shared_ptr _logger, _fileLogger; 25 | 26 | public: 27 | // Structures 28 | struct ImageSet : BasicConfig { 29 | private: 30 | // Input images 31 | std::vector _pics; 32 | 33 | public: 34 | ImageSet() = default; 35 | ImageSet(const YAML::Node& node, const std::string& dirKey); 36 | using iterator = std::vector::iterator; 37 | using const_iterator = std::vector::const_iterator; 38 | 39 | // Loads a set of images in alphabetical order into a vector of cv::Mats 40 | bool loadImFromDir(const std::string& dir); 41 | 42 | // Indexing operator so that we don't have to access _pics directly 43 | cv::Mat& operator[](int idx) { return _pics[idx]; } 44 | 45 | const cv::Mat& operator[](int idx) const { return _pics[idx]; } 46 | 47 | inline iterator begin() noexcept { return _pics.begin(); } 48 | inline const_iterator begin() const noexcept { return _pics.cbegin(); } 49 | inline iterator end() noexcept { return _pics.end(); } 50 | inline const_iterator end() const noexcept { return _pics.end(); } 51 | }; 52 | 53 | ImageSet _yosemite, _pupper, _juggle, _shift; 54 | bool _useGpu = false; 55 | size_t _lkWinSize1, _lkWinSize3, _lkWinSize4, _pyrLevel3a, _pyrLevel3b; 56 | 57 | // Path to which output images will be written 58 | std::string _outputPathPrefix; 59 | 60 | bool _configDone = false; 61 | 62 | Config(const std::string& configFilePath); 63 | 64 | bool loadConfig(const YAML::Node& config); 65 | }; -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/include/OpticalFlow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace lk { 6 | void calcOpticalFlow(const cv::Mat& prevImg, 7 | const cv::Mat& nextImg, 8 | cv::Mat& u, 9 | cv::Mat& v, 10 | const size_t winSize = 21); 11 | 12 | void warp(const cv::Mat& src, const cv::Mat& du, const cv::Mat& dv, cv::Mat& dst); 13 | 14 | void calcOpticalFlowPyr(const cv::Mat& prevImg, 15 | const cv::Mat& nextImg, 16 | cv::Mat& u, 17 | cv::Mat& v, 18 | const size_t winSize = 21); 19 | } // namespace lk 20 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/include/Pyramids.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace pyr { 8 | void pyrDown(const cv::Mat& src, cv::Mat& dst); 9 | void pyrUp(const cv::Mat& src, cv::Mat& dst); 10 | 11 | std::vector makeGaussianPyramid(const cv::Mat& src, const size_t levels); 12 | } // namespace pyr -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/lib/Pyramids.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Pyramids.h" 2 | 3 | #include 4 | 5 | std::vector pyr::makeGaussianPyramid(const cv::Mat& src, const size_t levels) { 6 | std::vector pyramid; 7 | 8 | // PyrUp/down only supports CV_32F since I'm too lazy to support anything else 9 | cv::Mat grey = src.clone(); 10 | if (grey.channels() > 1) { 11 | cv::cvtColor(grey, grey, cv::COLOR_RGB2GRAY); 12 | } 13 | if (grey.type() != CV_32F) { 14 | grey.convertTo(grey, CV_32F); 15 | } 16 | 17 | // Build Gaussian pyramid. The first image in the pyramid is the original image 18 | pyramid.push_back(grey); 19 | for (int i = 1; i < levels; i++) { 20 | cv::Mat down; 21 | pyr::pyrDown(pyramid[i - 1], down); 22 | pyramid.push_back(down); 23 | } 24 | 25 | return pyramid; 26 | } -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:736edea10d651f9ccc84d1b29fe0f3cca649c519e04aeff1f332987ce9524633 3 | size 34508 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d7154cbdca71b8e985aed3849cf6226bb20cd8cd4c166d69791fa8277d3838b2 3 | size 34534 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:775c7fde0a54e762ee7a5a6a33cba6344e23d20990f5a3da6f9e3bd3e0930780 3 | size 157582 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e835eb48c42e81c512a71403e47f000a9bcbc106dddc8db2124c3baf2ab390a3 3 | size 43706 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6853ce75c53717d9239b17058b2c8cd2a1614098222e96dd5afe819729187987 3 | size 41361 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0ed4490426766ce3a8c071fb03d64b13d94ac3617ead41fe09541c3ada61ed04 3 | size 162888 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:54a9793777ecfbc18dddc3efd5ace67e11f4b9e60fb4185640b8938b80b2f3fd 3 | size 41962 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a0c383701bbf44cdd18ee16f582783fb2297b68c2f3f976646c0043d283153bf 3 | size 45878 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e98123ac87068241d12eab38d920313880e148ea89f57bdf270629b784e391f4 3 | size 159330 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6948c3d5ca0423f26cbf0acee65bdc78f1162d378756d818dc62c4e7c5947df8 3 | size 41768 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7439518c2a309ec8d716c8780ad26c2b07da2a13a1e7a41bd1c8f46ce8511c11 3 | size 45304 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d5ac7446c5d8b6bac904654b8473cdac5344cf09257f76774cf841f6b767c08 3 | size 159727 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-3-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f049c5c2dfb899a2bf2e799065f789aeab8cdff1f5582a55335ae9cf5b1b2ab9 3 | size 50518 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-3-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a198a6da7a11b2eace327f9932a12a1b865fd509b8caa2e7d900ab9bca5aa73e 3 | size 48098 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-1-b-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7ed6e6929ce5837436f80d86e6b721e9a8de7835a33b07f96c511afd296f48dc 3 | size 160291 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-2-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:45fc70a5b0ae8b229af95659ed3a098706b05964ae2a7f054bfdbf0eba2e1dcb 3 | size 116721 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-2-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f49bbd18281a307429133fb5c487235dfa6227f0acab0e6b245de798350911ad 3 | size 89530 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d0c78db96cba63877b55e107857cd8e03939175f439f07a2c8c1f8d4e816cc44 3 | size 21163 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e6e4e1f27e822415702d74aceda5b7ce4fde31dbd2a4a8947717bd07f612403d 3 | size 20024 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-1-warped-diff.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:27c7dd1c1de60456fe8fe1286a12a1dda7fbe313a1b2f7abd40eb5f4bb5e9bb6 3 | size 12152 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5c18b0a3150edbf2cc9bfa90cd0468ede5ee10f57c1c00061391d5112b9949e8 3 | size 41122 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:469723dd495900b019161e77077266c35eca74f5b4090746d13a5b25ab82f359 3 | size 23228 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3779082ed9a6097480aa341b79351e67b9db81fd2a473e156cd7bd141f825c16 3 | size 21267 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-2-warped-diff.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:735c9f6656f9e1db9a71d403eef9a9e0c6c1ad001f05df75effb0b839db7323a 3 | size 12128 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-1-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2590056b000fe95da151beaae8b594883102f0bc8a6c75631ce1d79b11d74e7e 3 | size 41174 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:768d19ca94b5a939a60cb3eb5c3b950fb2ca1faa7f8e81336ce5c81d69ca10f5 3 | size 26427 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ae8c0bdcb2570c30b7a31e6dc9a20efe4330b49fe6bf7ca386a9ef16734daf60 3 | size 21404 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-1-warped-diff.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:064b4a6c00fe55a1f52b47750cc9ddfc221b1a3d38fa78f3b999bfd5ccbb3f7a 3 | size 12566 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:35a28366ae0862f9c1f154c734c86cbcdffb86c3abe70e84c937d8b1651fa87b 3 | size 44530 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ca321c09d2902fa53daf5d1edc331e254fe200710ee483c068177c08fb4f53ac 3 | size 25668 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aa3e372646692b7b6cd034dfe1e36fd204ad54a0b0561fe938325a657f82c797 3 | size 23132 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-2-warped-diff.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cf9e05354cfbf87ceb689288aa3b8a65bdb86b12a257b01f06c0ba0fb856701f 3 | size 12873 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-3-a-2-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:67969cd9fd3eb43cd194f026c955e587d5a79a577d8bb8f8755483ca6dd305bb 3 | size 44753 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8b4f12fcce37f2cdaec64ace2fdcc99e1fcc43d7e76e14d51eff625c95579d5c 3 | size 66658 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f6770d8edaaaf7241acb50aa0038e4a4b79b0cdf97cfa39bccee7e19cefe20f6 3 | size 41429 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6427b2562ce5d6747a7943795cc60d509a53e04d6e139ce3f1a0d5d61e8458c7 3 | size 140909 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ad507b9fb56e16178446df5142bd1aee43ed469b2b02034dc1f0eec93b3cef25 3 | size 56412 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:27c5775a5afe23a5deeae9384b8487ef8490b3f882461b409d8eff9d021ac7cb 3 | size 37747 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c5c5c0cb83d830127e917821ded2a79606dce1e5c9e8c8d95c9aabec088f4110 3 | size 141230 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-1-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:309dc89f6f86c043f48ce4d1615b6534dba7e8553071aa4e26d74a45a35a6e96 3 | size 171118 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-1-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d5c1dff96f463007c57e379a383ffb9a0f814e35242d14a17ffdb1ab00682450 3 | size 196967 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22ea05487f7ad39360e244d721ff49531e453c45ba0fc90e72c98d45c47edba9 3 | size 479955 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-2-uColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cb0e693fcfd38f7be63a96ca98661175824f10af21d3e383073dbeb3a02b02ec 3 | size 150177 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-2-vColorMap.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1c8aa5235b5f48082d70a2c4320c05c646758a9f9aa22ac0893c1244ac174577 3 | size 191456 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/output/ps5-4-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4f37daf2000bd1974ef5ceaa332f6bf432254ac3469751a191bf9d39f8e5f745 3 | size 481419 4 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../include/Config.h" 3 | 4 | namespace sol { 5 | void runProblem1(const Config& config); 6 | void runProblem2(const Config& config); 7 | void runProblem3(const Config& config); 8 | void runProblem4(const Config& config); 9 | } // namespace sol 10 | -------------------------------------------------------------------------------- /ProblemSets/ps5_cpp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../include/Config.h" 3 | #include "Solution.h" 4 | 5 | #include 6 | 7 | // YAML file containing input parameters 8 | static constexpr char CONFIG_FILE_PATH[] = "../config/ps5.yaml"; 9 | static constexpr char LOG_FILE_PATH[] = "ps5.log"; 10 | 11 | std::shared_ptr _logger, _fileLogger; 12 | 13 | int main() { 14 | // Set up loggers 15 | std::vector sinks; 16 | auto colorStdoutSink = std::make_shared(); 17 | auto fileSink = std::make_shared(LOG_FILE_PATH); 18 | sinks.push_back(colorStdoutSink); 19 | sinks.push_back(fileSink); 20 | _logger = std::make_shared("logger", begin(sinks), end(sinks)); 21 | _fileLogger = std::make_shared("file_logger", fileSink); 22 | spdlog::register_logger(_logger); 23 | spdlog::register_logger(_fileLogger); 24 | 25 | common::warmup(); 26 | _fileLogger->info("GPU warmup done"); 27 | 28 | Config config(CONFIG_FILE_PATH); 29 | 30 | sol::runProblem1(config); 31 | sol::runProblem2(config); 32 | sol::runProblem3(config); 33 | sol::runProblem4(config); 34 | } -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | file(GLOB lib_cu lib/*.cu lib/*.cuh) 4 | 5 | file(GLOB exe_hdr src/*.h src/*.hpp) 6 | file(GLOB exe_src src/*.cpp) 7 | 8 | add_library(ps6sol ${lib_hdr} ${lib_cu} ${lib_src}) 9 | 10 | add_executable(ps6 ${exe_hdr} ${exe_src}) 11 | 12 | target_link_libraries(ps6sol yaml-cpp cv_common) 13 | target_link_libraries(ps6 ps6sol) -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/README.md: -------------------------------------------------------------------------------- 1 | # Problem Set 6: Particle Tracking 2 | 3 | ## Problem 1: Particle Filter Tracking 4 | 5 | ### Part a 6 | Particle filter using mean squared error as a measure of similarity. 7 | 8 | Frame 28 9 |
10 | 11 | 12 | Frame 84 13 |
14 | 15 | 16 | Frame 144 17 |
18 | 19 | 20 | ### Part e 21 | Particle filter being run on a noisy video stream. 22 | 23 | Frame 14 24 |
25 | 26 | 27 | Frame 32 28 |
29 | 30 | 31 | Frame 46 32 |
33 | 34 | 35 | ## Problem 2: Appearance Model Update 36 | 37 | ### Part a 38 | The same particle filter as before, but the appearance model is updated between frames to be a blended version of the previous model and the current best estimate of the tracked object's position. 39 | 40 | Frame 15 41 |
42 | 43 | 44 | Frame 50 45 |
46 | 47 | 48 | Frame 150 49 |
50 | 51 | 52 | ### Part b 53 | The same particle filter as in part a, but being run on a noisy video stream. 54 | 55 | Frame 15 56 |
57 | 58 | 59 | Frame 50 60 |
61 | 62 | 63 | Frame 150 64 |
65 | 66 | 67 | ## Problem 3: Mean Shift Lite 68 | 69 | ### Part a 70 | Using a histogram with 32 bins as the appearance model instead of a copy of the image patch. Similarity is measured by chi-squared error. 71 | 72 | Frame 28 73 |
74 | 75 | 76 | Frame 84 77 |
78 | 79 | 80 | Frame 144 81 |
82 | 83 | 84 | ### Part b 85 | Attempting to track Romney's hand using the histogram as the appearance model. This did not work. 86 | 87 | Frame 15 88 |
89 | 90 | 91 | Frame 50 92 |
93 | 94 | 95 | Frame 140 96 |
97 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace config { 19 | static constexpr char FILE_LOGGER[] = "file_logger"; 20 | static constexpr char STDOUT_LOGGER[] = "logger"; 21 | }; // namespace config 22 | 23 | class Config { 24 | private: 25 | std::shared_ptr _logger, _fileLogger; 26 | 27 | public: 28 | // Structures 29 | struct Tracking : BasicConfig { 30 | cv::VideoCapture _cap; // Video capture stream 31 | cv::Point2f _bbox; // (x, y) coordinates of the initial bounding box 32 | cv::Size2f _bboxSize; // width and height of the initial bounding box 33 | 34 | Tracking() = default; 35 | Tracking(const YAML::Node& node); 36 | 37 | private: 38 | // Load bounding box (x, y) coordinates and width/height from a text file 39 | bool loadBBox(const std::string& filename); 40 | }; 41 | 42 | struct PFConf : BasicConfig { 43 | double _mseSigma, _dynamicsSigma, _alpha; 44 | size_t _numParticles; 45 | 46 | PFConf() = default; 47 | PFConf(const YAML::Node& node); 48 | }; 49 | 50 | Tracking _debate, _noisyDebate, _pedestrians; 51 | PFConf _pfConf1, _pfConf1Noisy, _pfConf2, _pfConf2Noisy, _pfConf3Head, _pfConf3Hand; 52 | bool _useGpu = false; 53 | 54 | // Path to which output images will be written 55 | std::string _outputPathPrefix; 56 | 57 | bool _configDone = false; 58 | 59 | Config(const std::string& configFilePath); 60 | 61 | bool loadConfig(const YAML::Node& config); 62 | }; -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-a-f144.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f3f24ea0c86b2ba5422eb2a831a2cb21bee04a7aeb5f80c8c19859b5954a3fa7 3 | size 639871 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-a-f28.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:577d75968c57bfbb606a48b65bfd14f3fddb44fb6a94d637951e9991f244eac9 3 | size 634453 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-a-f84.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e78bba525c8274d4493917b8c0e0892ee538382a9823833c83201e842f2c1187 3 | size 665191 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-e-f14.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a14124fc5b49116bd9ecd8d36c853013e3bb065a80143dee3868f2cd81c9f13f 3 | size 2599225 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-e-f32.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f11fd6c2b84f967cae5efd296f5fc1c60f85fc360eb70da6a3d90a6ffc8f68bf 3 | size 888294 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-1-e-f46.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:39067848d04b6bdf4b2b435d470cd74ccfc3383eb9262947ab043762a48b1899 3 | size 2600646 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-a-f15.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:475b3df04911cfacde3b7778808739bcaf59aa23e624f1858d13e9308dee0ed4 3 | size 630353 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-a-f150.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:89b3195ff55a8d6aa095cffcb1282634a8385155ff2863e0460a114f5015b049 3 | size 644147 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-a-f50.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:128ba3b1d327d82aa17d419397d442e22fcc435e1c731f061560ef74396dff8d 3 | size 649189 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-b-f15.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:42cc4f31b9b4261359f87685f03979ee25370a89a411c0ae71883325c3b23f6a 3 | size 2606115 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-b-f150.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d6bc63b835a73887d1d24e8c21f56874b59fb15918442867bbb14fd1c4a69497 3 | size 2197382 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-2-b-f50.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8d63bfc9a53c60ccc560005052871e54048c7fa68ae174a718197c5a26803613 3 | size 2565380 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-a-f144.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d59fb79afb47cf02fa157a02da232b77ef9f820322d492f7071c156c78d0353e 3 | size 640697 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-a-f28.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:46be7b9e1dd5971042b5c0f095f13d58fc9948d06274865ce5674cda6a30c510 3 | size 635226 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-a-f84.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b75c6be502290cb9ecfae3f92988df140c449ec63a1016c3f88f13cc1a2175e 3 | size 666254 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-b-f140.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5d5d17d27cc625b05879fd7b078e06a021afcebeed429b24c890524e02a2bcb2 3 | size 643276 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-b-f15.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:eba72b84f121e0bb6e146e98ffd266fe10d1361e02420bd1c804bf7e6d62636d 3 | size 633435 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6-3-b-f50.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:59dd9a27907aafc6513327c052eb567917e89b2b5a975272e0d6cd89bb0a5d35 3 | size 652032 4 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/output/ps6.log: -------------------------------------------------------------------------------- 1 | [2018-05-18 16:14:16.833] [file_logger] [info] GPU warmup done 2 | [2018-05-18 16:14:16.881] [file_logger] [info] Loaded bounding box with coordinates (320.875, 175.178); width=103.54; height=129.05 3 | [2018-05-18 16:14:16.922] [file_logger] [info] Loaded bounding box with coordinates (320.875, 175.178); width=103.54; height=129.05 4 | [2018-05-18 16:14:16.961] [file_logger] [info] Loaded bounding box with coordinates (211, 36); width=100; height=293 5 | [2018-05-18 16:14:16.962] [logger] [info] Created output directory at "./ps6_output" 6 | [2018-05-18 16:14:16.962] [logger] [info] Loaded runtime configuration from "../config/ps6.yaml" 7 | [2018-05-18 16:14:16.962] [logger] [info] Problem 1 begins 8 | [2018-05-18 16:14:16.985] [logger] [info] Initialized particle filter 9 | [2018-05-18 16:14:21.586] [logger] [info] Average tick time was 3.209 ms (311.623 fps) 10 | [2018-05-18 16:14:21.611] [logger] [info] Initialized particle filter 11 | [2018-05-18 16:14:31.283] [logger] [info] Average tick time was 3.04322 ms (328.6 fps) 12 | [2018-05-18 16:14:31.283] [logger] [info] Problem 1 runtime = 14321.2 ms 13 | [2018-05-18 16:14:31.283] [logger] [info] Problem 2 begins 14 | [2018-05-18 16:14:31.293] [logger] [info] Initialized particle filter 15 | [2018-05-18 16:14:37.591] [logger] [info] Average tick time was 4.17584 ms (239.473 fps) 16 | [2018-05-18 16:14:37.609] [logger] [info] Initialized particle filter 17 | [2018-05-18 16:14:48.140] [logger] [info] Average tick time was 4.21075 ms (237.488 fps) 18 | [2018-05-18 16:14:48.140] [logger] [info] Problem 2 runtime = 16856.9 ms 19 | [2018-05-18 16:14:48.140] [logger] [info] Problem 3 begins 20 | [2018-05-18 16:14:48.150] [logger] [info] Initialized particle filter 21 | [2018-05-18 16:14:58.031] [logger] [info] Average tick time was 16.8773 ms (59.2513 fps) 22 | [2018-05-18 16:14:58.042] [logger] [info] Initialized particle filter 23 | [2018-05-18 16:15:07.124] [logger] [info] Average tick time was 13.8011 ms (72.4582 fps) 24 | [2018-05-18 16:15:07.124] [logger] [info] Problem 3 runtime = 18984 ms 25 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../include/Config.h" 3 | 4 | namespace sol { 5 | void runProblem1(Config& config); 6 | void runProblem2(Config& config); 7 | void runProblem3(Config& config); 8 | } // namespace sol 9 | -------------------------------------------------------------------------------- /ProblemSets/ps6_cpp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../include/Config.h" 3 | #include "Solution.h" 4 | 5 | #include 6 | 7 | // YAML file containing input parameters 8 | static constexpr char CONFIG_FILE_PATH[] = "../config/ps6.yaml"; 9 | static constexpr char LOG_FILE_PATH[] = "ps6.log"; 10 | 11 | std::shared_ptr _logger, _fileLogger; 12 | 13 | int main() { 14 | // Set up loggers 15 | std::vector sinks; 16 | auto colorStdoutSink = std::make_shared(); 17 | auto fileSink = std::make_shared(LOG_FILE_PATH); 18 | sinks.push_back(colorStdoutSink); 19 | sinks.push_back(fileSink); 20 | _logger = std::make_shared("logger", begin(sinks), end(sinks)); 21 | _fileLogger = std::make_shared("file_logger", fileSink); 22 | spdlog::register_logger(_logger); 23 | spdlog::register_logger(_fileLogger); 24 | 25 | common::warmup(); 26 | _fileLogger->info("GPU warmup done"); 27 | 28 | Config config(CONFIG_FILE_PATH); 29 | 30 | sol::runProblem1(config); 31 | sol::runProblem2(config); 32 | sol::runProblem3(config); 33 | } -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB lib_hdr include/*.h include/*.hpp) 2 | file(GLOB lib_src lib/*.cpp) 3 | file(GLOB lib_cu lib/*.cu lib/*.cuh) 4 | 5 | file(GLOB exe_hdr src/*.h src/*.hpp) 6 | file(GLOB exe_src src/*.cpp) 7 | 8 | cuda_add_library(ps7sol ${lib_hdr} ${lib_cu} ${lib_src}) 9 | 10 | cuda_add_executable(ps7 ${exe_hdr} ${exe_src}) 11 | 12 | target_link_libraries(ps7sol yaml-cpp cv_common boost_system boost_filesystem boost_iostreams) 13 | target_link_libraries(ps7 ps7sol) -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/README.md: -------------------------------------------------------------------------------- 1 | # Problem Set 7: Motion History Images 2 | 3 | ## Problem 1: Frame-differenced MHI 4 | 5 | ### Part a 6 | Binary sequences computed at each frame of the `PS7A1P1T1.avi` video. These are masks where if motion is greater than a given threshold, the pixel's value is set to 1; otherwise it is set to 0. 7 | 8 | Frame 10 | Frame 20 | Frame 30 9 | ---|---|--- 10 | | | 11 | 12 | 13 | ### Part b 14 | Motion history images computed from the binary frames. See [the config file](../../config/ps7.yaml) for the values of tau and the "last frame" of each sequence. 15 | 16 | Action 1 | Action 2 | Action 3 17 | ---|---|--- 18 | | | 19 | 20 | 21 | ## Problem 2: Recognition using MHIs 22 | 23 | ### Part a 24 | Confusion matrices for the central and scale-invariant moments. The image moments are used as features for a KNN classifier and the action number (1/2/3) is used as the label. For each input, that feature and label is removed from the dataset and tested against the remaining data in the set. 25 | 26 | Mu | Eta 27 | ---|--- 28 | | 29 | 30 | ### Part b 31 | "Non-cheating" way, where each person is removed from the training data and is instead used as testing data. 32 | 33 | Person 1 | Person 2 | Person 3 | Average of all 34 | ---|---|---|--- 35 | | | | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/include/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Structures to hold runtime configurations. 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace config { 20 | static constexpr char FILE_LOGGER[] = "file_logger"; 21 | static constexpr char STDOUT_LOGGER[] = "logger"; 22 | }; // namespace config 23 | 24 | class Config { 25 | public: 26 | Config(const std::string& configFilePath); 27 | 28 | bool loadConfig(const YAML::Node& config); 29 | 30 | // Expects short names, e.g. "PS7A1P1T1" 31 | cv::VideoCapture openVid(const std::string& name); 32 | 33 | // Expects short names, e.g. "PS7A1P1T1" 34 | size_t lastFrameOfAction(const std::string& name); 35 | 36 | // Path to which output images will be written 37 | std::string _outputPathPrefix; 38 | 39 | struct MHI : BasicConfig { 40 | double _threshold, _preBlurSigma; 41 | cv::Size _preBlurSize; 42 | int _tau; 43 | 44 | MHI() = default; 45 | MHI(const YAML::Node& node); 46 | }; 47 | 48 | MHI _mhiAction1, _mhiAction2, _mhiAction3; 49 | 50 | private: 51 | std::shared_ptr _logger, _fileLogger; 52 | 53 | // Get the full paths for all the video files in a directory and place them in the map of video 54 | // files 55 | bool getVidFilesFromDir(const std::string& dir); 56 | 57 | // Load actions lengths for each sequence into a map 58 | bool loadActionLengths(const YAML::Node& actions); 59 | 60 | // Map matching file names with absolute file paths 61 | std::unordered_map _vidMap; 62 | // Map matching file names with final frames of each action 63 | std::unordered_map _lastFrames; 64 | // Set as true when configuration is done 65 | bool _configDone = false; 66 | }; -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/include/Matching.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace matching { 6 | // Computes confusion matrix by training KNN classifier from the given features and labels, removing 7 | // one pair each iteration as a cross-validation sample. 8 | void naiveConfusionMatrix(const cv::Mat& features, const cv::Mat& labels, cv::Mat& confusion); 9 | 10 | // More "correct" confusion matrix. Builds a training sets by removing each person from the feature 11 | // data and using that for cross validation. Returns a vector of N mats, where mats 0 through N-1 12 | // are the confusion matrices for persons 1 through N; mat N is the average of mats 0 through N-1. 13 | void confusionMatrix(const cv::Mat& features, 14 | const cv::Mat& labels, 15 | const cv::Mat& people, 16 | const size_t numPeople, 17 | std::vector& confusions); 18 | 19 | // Plots confusion matrix. fileName is an optional parameter; if it is set, then the plot will be 20 | // saved to that file. 21 | void plotConfusionMatrix(const cv::Mat& confusion, 22 | const std::string& title, 23 | const std::string& fileName = ""); 24 | } // namespace matching -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/include/Moments.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace moments { 9 | // Compute the central moments of an image given the input image and a vector of pairs describing 10 | // the desired orders of the central moments 11 | std::vector> 12 | centralMoment(const cv::Mat& img, const std::vector>& momentOrders); 13 | } // namespace moments -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/include/MotionHistory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace mhi { 8 | // Compute difference between two frames. Returns a binary image with a value of 1 where the 9 | // difference between the two frames is greater than the given threshold, and 0 if not. 10 | void frameDifference(const cv::Mat& f1, 11 | const cv::Mat& f2, 12 | const double thresh, 13 | cv::Mat& diff, 14 | const cv::Size& blurSize = cv::Size(3, 3), 15 | const double blurSigma = 1.0); 16 | 17 | // Build a motion history image from the current motion history image, tau, and a binary mask 18 | // representing pixels that have moved in this frame (see frameDifference) 19 | void calcMotionHistory(cv::Mat& history, const cv::Mat& binaryMask, const int tau); 20 | 21 | // Compute motion energy images (MEIs) from a motion history image. This thresholds the MHIs such 22 | // that any nonzero value is set to 1. 23 | void energyFromHistory(const cv::Mat& mhi, cv::Mat& mei); 24 | 25 | // This is an overloaded namespace function provided for convenience. It differs from the above 26 | // function only in what arguments it accepts. 27 | void energyFromHistory(const std::vector& mhis, std::vector& meis); 28 | } // namespace mhi -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/lib/Moments.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/Moments.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | std::vector> 8 | moments::centralMoment(const cv::Mat& img, 9 | const std::vector>& momentOrders) { 10 | assert(img.channels() == 1); 11 | // Compute the image moments of the input image 12 | cv::Mat x_i, y_j; 13 | cv::Mat fltImg; 14 | img.convertTo(fltImg, CV_32FC1); 15 | 16 | size_t numRows = fltImg.rows; 17 | size_t numCols = fltImg.cols; 18 | std::vector rows(numRows); 19 | std::vector cols(numCols); 20 | std::iota(rows.begin(), rows.end(), 0); 21 | std::iota(cols.begin(), cols.end(), 0); 22 | 23 | x_i = cv::Mat(cols); // Nx1 matrix 24 | cv::transpose(x_i, x_i); // 1xN matrix 25 | y_j = cv::Mat(rows); // Mx1 matrix 26 | 27 | // Build up x and y matrices so that we can multiply them 28 | cv::Mat xFull = x_i.clone(); 29 | cv::Mat yFull = y_j.clone(); 30 | 31 | for (int r = 1; r < numRows; r++) { 32 | xFull.push_back(x_i); 33 | } 34 | for (int c = 1; c < numCols; c++) { 35 | // yFull.push_back(y_j); 36 | cv::hconcat(yFull, y_j, yFull); 37 | } 38 | 39 | // std::cout << "xFull is " << xFull.rows << "x" << xFull.cols << "; yFull is " << yFull.rows 40 | // << "x" << yFull.cols << "; fltImg is " << fltImg.rows << "x" << fltImg.cols 41 | // << std::endl; 42 | 43 | // Calculate image moments 44 | float M00 = cv::sum(fltImg)[0]; 45 | float M01 = cv::sum(yFull.mul(fltImg))[0]; 46 | float M10 = cv::sum(xFull.mul(fltImg))[0]; 47 | 48 | float xBar = M10 / M00; 49 | float yBar = M01 / M00; 50 | 51 | // Iterate over desired moment orders and compute central moments 52 | std::vector> centralMoments; 53 | for (const auto& order : momentOrders) { 54 | int p = order.first; 55 | int q = order.second; 56 | 57 | cv::Mat xPow, yPow; 58 | cv::pow(xFull - xBar, p, xPow); 59 | cv::pow(xFull - yBar, q, yPow); 60 | 61 | float mu = cv::sum(yPow.mul(xPow.mul(fltImg)))[0]; 62 | float eta = mu / (std::pow(M00, 1.0 + float(p + q) / 2.0)); 63 | // float eta = std::pow(M00, 1.0 + float(p + q) / 2.0); 64 | centralMoments.emplace_back(mu, eta); 65 | } 66 | 67 | return centralMoments; 68 | } -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/lib/MotionHistory.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | template 17 | struct AbsThreshold : public thrust::unary_function { 18 | const double _threshold; 19 | 20 | AbsThreshold(const double threshold) : _threshold(threshold) {} 21 | 22 | __host__ __device__ T operator()(T val) { 23 | return ((val >= _threshold || -val >= _threshold) ? 1 : 0); 24 | } 25 | }; 26 | 27 | void thresholdDifference(const cv::cuda::GpuMat& src, 28 | const double thresh, 29 | cv::cuda::GpuMat& dst, 30 | cv::cuda::Stream& stream) { 31 | // Only support single-channel uint8_t 32 | assert(src.type() == CV_8UC1 && dst.type() == src.type() && src.rows == dst.rows && 33 | src.cols == dst.cols); 34 | 35 | // Wrap input matrices in thrust iterators 36 | auto srcBegin = GpuMatBeginItr(src); 37 | auto srcEnd = GpuMatEndItr(src); 38 | 39 | auto dstBegin = GpuMatBeginItr(dst); 40 | 41 | // Threshold and push to output 42 | AbsThreshold thresholdOp(thresh); 43 | thrust::transform(thrust::system::cuda::par.on(cv::cuda::StreamAccessor::getStream(stream)), 44 | srcBegin, 45 | srcEnd, 46 | dstBegin, 47 | thresholdOp); 48 | } 49 | 50 | // Functions for computing motion history 51 | 52 | template 53 | __global__ void motionHistoryKernel(cv::cuda::PtrStepSz history, 54 | const cv::cuda::PtrStepSz binaryMask, 55 | const int tau) { 56 | const uint2 gThreadPos = getPosition(); 57 | 58 | if (gThreadPos.x >= history.cols || gThreadPos.y >= history.rows) { 59 | return; 60 | } 61 | 62 | // Update history 63 | T historyVal = history(gThreadPos.y, gThreadPos.x); 64 | history(gThreadPos.y, gThreadPos.x) = 65 | (binaryMask(gThreadPos.y, gThreadPos.x) == 1) ? tau : max(historyVal - 1, 0); 66 | } 67 | 68 | void motionHistoryKernelCall(cv::cuda::GpuMat& history, 69 | const cv::cuda::GpuMat& binaryMask, 70 | const int tau) { 71 | // 16 x 16 thread blocks 72 | static constexpr size_t TILE_SIZE = 16; 73 | 74 | dim3 blocks(common::divRoundUp(history.cols, TILE_SIZE), 75 | common::divRoundUp(history.rows, TILE_SIZE)); 76 | dim3 threads(TILE_SIZE, TILE_SIZE); 77 | 78 | // auto flogger->info("Launching motionHistoryKernel"); 79 | 80 | motionHistoryKernel<<>>(history, binaryMask, tau); 81 | cudaDeviceSynchronize(); 82 | checkCudaErrors(cudaGetLastError()); 83 | } -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bd3e6bce7314d94290bd68e3b75a4666713e0851ad94d2a8067e6d38bc37c34b 3 | size 2120 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3f2609cc72ea99a9f7fa4c843e411293ae6f171a64bcaf97a50a4e9ceba19e4f 3 | size 2815 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-a-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:77c6f0fea06bb79d68588f23c449e1c48989468f9010607058e238383c45139b 3 | size 1944 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e7cdbcc2822dbc7610a7f02417db26b72ace9ffd6e7ab5805303f19343251383 3 | size 21113 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7d80c14c183d290a3d6a229f669683d39328dc0113ebc1e805549179a5ffc3b1 3 | size 8929 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-1-b-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3b3773bce1a317562d4338368b52dad633955b9ca9976004bdf39b28d7769c8f 3 | size 18592 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-a-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cfa075472f7a9b6c8dd49d7482ccc20f428c272ab36d8df47f23425e15ea95a0 3 | size 25577 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-a-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:74ba209b7217ff019d971767a8410270222fb5eac2846d270d6a7c5e9be2193c 3 | size 27323 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-b-1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9b32fe5ce3c3d8264d70c50169581757f2e0a881375fca4ad628bedb9f30c1fc 3 | size 24969 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-b-2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:702ae48e4b8d008db3ef70d037db08b460b8ce73b1b3ca9f00355f15e4806592 3 | size 23615 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-b-3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22c7fc0d65399cfd973dcd706a725e3317964eeb74d16b66854f32cbb1ca1b1c 3 | size 23676 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/output/ps7-2-b-4.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aa90199b422aff0490ad0b24ea0861505c872d26a0791789f93df8fb71fdc203 3 | size 25176 4 | -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/src/Solution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../include/Config.h" 4 | 5 | namespace sol { 6 | void runProblem1(Config& config); 7 | void runProblem2(Config& config); 8 | } // namespace sol -------------------------------------------------------------------------------- /ProblemSets/ps7_cpp/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../include/Config.h" 3 | #include "Solution.h" 4 | 5 | #include 6 | 7 | // YAML file containing input parameters 8 | static constexpr char CONFIG_FILE_PATH[] = "../config/ps7.yaml"; 9 | static constexpr char LOG_FILE_PATH[] = "ps7.log"; 10 | 11 | std::shared_ptr _logger, _fileLogger; 12 | 13 | int main() { 14 | // Set up loggers 15 | std::vector sinks; 16 | auto colorStdoutSink = std::make_shared(); 17 | auto fileSink = std::make_shared(LOG_FILE_PATH); 18 | sinks.push_back(colorStdoutSink); 19 | sinks.push_back(fileSink); 20 | _logger = std::make_shared("logger", begin(sinks), end(sinks)); 21 | _fileLogger = std::make_shared("file_logger", fileSink); 22 | spdlog::register_logger(_logger); 23 | spdlog::register_logger(_fileLogger); 24 | 25 | common::warmup(); 26 | _fileLogger->info("GPU warmup done"); 27 | 28 | Config config(CONFIG_FILE_PATH); 29 | 30 | sol::runProblem1(config); 31 | sol::runProblem2(config); 32 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intro to Computer Vision (Udacity UD810) 2 | 3 | Lecture slides, problem sets, and C++ solutions to UD810. 4 | 5 | - [Original Google Doc](https://docs.google.com/spreadsheets/d/1ecUGIyhYOfQPi3HPXb-7NndrLgpX_zgkwsqzfqHPaus/pubhtml) with problem sets and slides 6 | - [Miscellaneous images](http://sipi.usc.edu/database/database.php?volume=misc) from USC 7 | - [Computer vision image database](http://homepages.inf.ed.ac.uk/rbf/CVonline/Imagedbase.htm) from the University of Edinburgh 8 | 9 | ## Prerequisites 10 | 11 | I try to accelerate all of the assignments with CUDA, so you will need an Nvidia GPU along with CUDA toolkit installed. This repository is developed on: 12 | - Ubuntu 17.10 + CUDA 9.1; Intel Core i7 6800k + GeForce GTX 1080 13 | 14 | #### You will need: 15 | - CUDA: Follow [Nvidia's CUDA installation instructions](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) to install. 16 | - [Git LFS](https://git-lfs.github.com/) is required to clone the images and lecture slides. 17 | 18 | From here, there are two options: building in **Docker** or just building locally on a host machine. 19 | 20 | ### Containerized Build in Docker *(Recommended!)* 21 | This is the suggested approach to building this project since all of the dependencies are included in the Docker image. 22 | 23 | - Install Docker-CE as described for your distribution on the [Docker docs](https://docs.docker.com/install/). 24 | - Follow the [Optional Linux post-installation](https://docs.docker.com/install/linux/linux-postinstall/) steps to run Docker without `sudo`. 25 | - Install nvidia-docker2 as described in the [`nvidia-docker` docs](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)). The container provided in this repo needs the `nvidia` Docker runtime to run. 26 | - Clone this repo and build/run the Docker container: 27 | 28 | ```bash 29 | git clone --recursive https://github.com/tanmaniac/IntroToComputerVision.git 30 | cd IntroToComputerVision/Docker 31 | # Build the Docker container 32 | ./build.sh 33 | # Run the container 34 | ./run.sh 35 | ``` 36 | 37 | This will drop you into a shell where you can follow the build steps below. The `IntroToComputerVision` directory (this one) is mapped to `${HOME}/IntroToComputerVision` in the Docker container. 38 | 39 | ### Build on host 40 | 41 | - Build OpenCV 3.4.1 as directed in the OpenCV documentation. Make sure to add the `-DWITH_CUDA=ON` CMake flag to compile CUDA features. 42 | - Install [Eigen](http://eigen.tuxfamily.org/) as described in its documentation. 43 | - `gnuplot`, which you can install from your distro repository. On Ubuntu: 44 | ```bash 45 | sudo apt install gnuplot 46 | ``` 47 | 48 | ## Building 49 | 50 | ```bash 51 | # Navigate to wherever you cloned this repo first 52 | mkdir build && cd build 53 | cmake .. 54 | make -j 55 | ``` 56 | 57 | If you want to use NVIDIA debugging tools, like `cuda-memcheck` or the NVIDIA Visual Profiler, compile with Debug flags: 58 | ```bash 59 | mkdir build && cd build 60 | cmake -DCMAKE_BUILD_TYPE=Debug .. 61 | make -j 62 | ``` 63 | Note that this increases runtime of some kernels by around 100x, so only compile in debug mode if you need it. 64 | 65 | 66 | ## Running 67 | 68 | Build outputs are placed in the `bin` directory. All of the executables are configured with YAML files in the `config` directory. You can edit these to change the input parameters to each of the assignments. For example, with Problem Set 0, all you need to do (after building) is: 69 | 70 | ```bash 71 | cd bin 72 | ./ps0 73 | ``` 74 | -------------------------------------------------------------------------------- /Resources/ProblemSet1/ps1-input0-noise.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7c3815383054c20b822e16c9a2ea70dc7761e570e7c48b5ee60ac634cdce7378 3 | size 56648 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet1/ps1-input0.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c64b32b7a141a7804248307b1897e051b380ef8b4e90147be55e4c09567d9ee7 3 | size 632 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet1/ps1-input1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9f74dbb86b80d5edfcdcb18a5f77ca061b5749549b16a730f78ffa031a98e4bd 3 | size 591656 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet1/ps1-input2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7dc83d77f109ca358f59dc6ed10f93f337c0efd15a680d35953ca91e5f278e6d 3 | size 546740 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet1/ps1-input3.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b25b7bc2396c0f8125946631f706299d07ce07b9a3eccbedd5d975611b44340 3 | size 466849 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair0-L.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:28af07bc6fc62b0e4f5217e67855b4541eb2a64a7f3ffecb6989ab6da99c9483 3 | size 8426 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair0-R.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:467dd79b2c55e4a0aba782a4ed0e0904d027af1aa93d4bbf726a30f64ee95105 3 | size 8469 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair1-D_L.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:84a0a302cf12ed2f2325a44c882b24baca4b08d58412ab410dc8ae2834be811f 3 | size 55281 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair1-D_R.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:081754140b2e998a91ca440a7ef44b005291b5306e393f447f82d1b451eb621f 3 | size 56793 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair1-L.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:454fe4bfa4abe35c1997c858f2dc28a2371bd1fba1403af0282f30a2032ceea7 3 | size 505758 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair1-R.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:82dd658e2feea39a18630ed7c9150118d13de17f2987e77b2e2104f9b64fb834 3 | size 503015 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair2-D_L.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1f32a272b20965cd3400fcfff01e2c34ed2e7e00594afcf89daf3f9fc290d8b5 3 | size 45177 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair2-D_R.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:57732c29c8ea61c3593f27455fc19bd4d801ced53d08eebf8b02b37440f1f603 3 | size 42338 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair2-L.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b74e93b52fb48cbaf6edd60520c4d543a768db1f490f7165fec72033db523cf6 3 | size 469431 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet2/pair2-R.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fdb0d591d63477de6c38536230e3b95d7781fe8392068a0d80a819d5125fb88a 3 | size 465167 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pic_a.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:31c2a55937ccb5b674b8be59f6a3d60f3f3669776a302e46376712d848b0f6db 3 | size 93853 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pic_b.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d1d631432271a8c5d8a79c582a890d7d0f3c734a43a55441aad9303ce5222b39 3 | size 107642 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pts2d-norm-pic_a.txt: -------------------------------------------------------------------------------- 1 | 1.0486 -0.3645 2 | -1.6851 -0.4004 3 | -0.9437 -0.4200 4 | 1.0682 0.0699 5 | 0.6077 -0.0771 6 | 1.2543 -0.6454 7 | -0.2709 0.8635 8 | -0.4571 -0.3645 9 | -0.7902 0.0307 10 | 0.7318 0.6382 11 | -1.0580 0.3312 12 | 0.3464 0.3377 13 | 0.3137 0.1189 14 | -0.4310 0.0242 15 | -0.4799 0.2920 16 | 0.6109 0.0830 17 | -0.4081 0.2920 18 | -0.1109 -0.2992 19 | 0.5129 -0.0575 20 | 0.1406 -0.4527 21 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pts2d-pic_a.txt: -------------------------------------------------------------------------------- 1 | 880 214 2 | 43 203 3 | 270 197 4 | 886 347 5 | 745 302 6 | 943 128 7 | 476 590 8 | 419 214 9 | 317 335 10 | 783 521 11 | 235 427 12 | 665 429 13 | 655 362 14 | 427 333 15 | 412 415 16 | 746 351 17 | 434 415 18 | 525 234 19 | 716 308 20 | 602 187 21 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pts2d-pic_b.txt: -------------------------------------------------------------------------------- 1 | 731 238 2 | 22 248 3 | 204 230 4 | 903 342 5 | 635 316 6 | 867 177 7 | 958 572 8 | 328 244 9 | 426 386 10 | 1064 470 11 | 480 495 12 | 964 419 13 | 695 374 14 | 505 372 15 | 645 452 16 | 692 359 17 | 712 444 18 | 465 263 19 | 591 324 20 | 447 213 21 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pts3d-norm.txt: -------------------------------------------------------------------------------- 1 | 1.5706 -0.1490 0.2598 2 | -1.5282 0.9695 0.3802 3 | -0.6821 1.2856 0.4078 4 | 0.4124 -1.0201 -0.0915 5 | 1.2095 0.2812 -0.1280 6 | 0.8819 -0.8481 0.5255 7 | -0.9442 -1.1583 -0.3759 8 | 0.0415 1.3445 0.3240 9 | -0.7975 0.3017 -0.0826 10 | -0.4329 -1.4151 -0.2774 11 | -1.1475 -0.0772 -0.2667 12 | -0.5149 -1.1784 -0.1401 13 | 0.1993 -0.2854 -0.2114 14 | -0.4320 0.2143 -0.1053 15 | -0.7481 -0.3840 -0.2408 16 | 0.8078 -0.1196 -0.2631 17 | -0.7605 -0.5792 -0.1936 18 | 0.3237 0.7970 0.2170 19 | 1.3089 0.5786 -0.1887 20 | 1.2323 1.4421 0.4506 21 | -------------------------------------------------------------------------------- /Resources/ProblemSet3/pts3d.txt: -------------------------------------------------------------------------------- 1 | 312.747 309.140 30.086 2 | 305.796 311.649 30.356 3 | 307.694 312.358 30.418 4 | 310.149 307.186 29.298 5 | 311.937 310.105 29.216 6 | 311.202 307.572 30.682 7 | 307.106 306.876 28.660 8 | 309.317 312.490 30.230 9 | 307.435 310.151 29.318 10 | 308.253 306.300 28.881 11 | 306.650 309.301 28.905 12 | 308.069 306.831 29.189 13 | 309.671 308.834 29.029 14 | 308.255 309.955 29.267 15 | 307.546 308.613 28.963 16 | 311.036 309.206 28.913 17 | 307.518 308.175 29.069 18 | 309.950 311.262 29.990 19 | 312.160 310.772 29.080 20 | 311.988 312.709 30.514 21 | -------------------------------------------------------------------------------- /Resources/ProblemSet4/check.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanmaniac/IntroToComputerVision/dcb4628c49e216203c1a86fbe3695e98a1bb87ac/Resources/ProblemSet4/check.bmp -------------------------------------------------------------------------------- /Resources/ProblemSet4/check_rot.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanmaniac/IntroToComputerVision/dcb4628c49e216203c1a86fbe3695e98a1bb87ac/Resources/ProblemSet4/check_rot.bmp -------------------------------------------------------------------------------- /Resources/ProblemSet4/simA.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b33b333488f138a186b5211fcfc70f9cb026b371ba86a2d49fd70259f912a1db 3 | size 196628 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet4/simB.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e487388da91cfec3862345d740b2de50190d1dab6fd72787e62aefb35487193e 3 | size 204352 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet4/transA.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:386304a3a8ac9587fff1fb2f760debdfe9ee44defeaa2863b4deafa8a8560e6a 3 | size 218084 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet4/transB.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ae814a4629224555a1a0c402aac11f617081c3d7f48571dcc88dfab1354eb228 3 | size 211030 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq1/yos_img_01.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c67ad557afc9922f614ae38faa41475092f199d733fc108848608acf289905fd 3 | size 65868 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq1/yos_img_02.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e353e6145cb97a1b513c09a63e5c37d8b67def128dd7dc5c36eb99ca1efb7412 3 | size 65938 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq1/yos_img_03.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1d8a6eae10337717c96436f475ed91790eb735c91e3e9e3f0fe1f6f0a56120d0 3 | size 65739 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq2/0.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e61be5be0b3fe1b31ce048c8a6bcfc5ff6cb589560f25c654b4c248fdf97cc12 3 | size 382681 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq2/1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:44f4f4ce3f5ce7ad2b96a6f7f6ae6d2b9f2c45ddbf322368fa6f505dd3e0bd9b 3 | size 381839 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/DataSeq2/2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4b5f43f75b03763d4fcd6fbaa2317b7ab4d099ab1ca961ef9e0c3612db2eaa8f 3 | size 381170 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/Juggle/0.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:431521d9dda3ecb648dadf67a528b17cf67957bcbffc6edf8800c3f07bd10321 3 | size 333296 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/Juggle/1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2997379324ea61b2594148e990d04fd1e7470b49a75e6b456a420578ef8b714b 3 | size 333402 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/Juggle/2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bc62e15a5b52b1c0f874cebba42ca5c3d7883cb69875608a35c4bf7d25e52f4c 3 | size 333659 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/Shift0.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c8256034efaaf61a89857b40b7499701194d62f3e47a212ac7f9951981d005d4 3 | size 34508 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/ShiftR10.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4f60f3add78fd8c6760a3eb29c853ad52bf4c0f61eeb8f7c5fbc15c4a82b3d65 3 | size 34389 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/ShiftR2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c794adff4a81dc5117e2e38f7a003ec2cada291ed4da599f95a2fbb427476bde 3 | size 34434 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/ShiftR20.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cee03514ddfafe09c4ffc9c44ef65469ad4c42d2bbce51d615a701504ff4b602 3 | size 34353 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/ShiftR40.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:44c602fd5e6931e131dd048f3f4908271b88c46f36a6054c9ceea914291b4c22 3 | size 34379 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet5/TestSeq/ShiftR5U5.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ea1340480276537e8217116122f7cffe1867fc8a301c0ef158156dce07db5e6a 3 | size 34357 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/noisy_debate.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2c7e45e5c33520cc4f8d1939b433d400a0cdc1b524b2ff900aa51b21cd8c632c 3 | size 47157208 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/noisy_debate.txt: -------------------------------------------------------------------------------- 1 | 320.8751 175.1776 2 | 103.5404 129.0504 3 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/pedestrians.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d0a023756f18ca4b0880508b5b16e2bf73ab5415cdf0bc3978d13738a8f61c1a 3 | size 2938204 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/pedestrians.txt: -------------------------------------------------------------------------------- 1 | 211.0000 36.0000 2 | 100.0000 293.0000 3 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/pres_debate.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:585ee4935d8b973cd55d64b7682b128314dc312e7cc0d26f670d69b6c8249209 3 | size 1298206 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet6/pres_debate.txt: -------------------------------------------------------------------------------- 1 | 320.8751 175.1776 2 | 103.5404 129.0504 3 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P1T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6e6f7ce02cb5e660001643851d15c9862a9d45e3213b28db844007cc713c76ef 3 | size 381058 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P1T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2bd6c84ab1b6ff8cf6399552e22443ccd7f8080fff28af245dabb7ed3811d3c7 3 | size 349368 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P1T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8c4bcb71baf752206d61d737890ef03b8451386745ff5ef78a6c6595db70a197 3 | size 392078 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P2T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5032d110881018304d37339c9b73a161ee8e36ad1f00366b73335fe15f4f6ccc 3 | size 242168 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P2T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:43891f6ce82c556831965955ba73ad7236ef5be15646ca2cc2ce398d6c50f42d 3 | size 217468 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P2T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2809129d5ca8c74a500f4f4451007034f026b5b2beefbbee9b540f7d12711fe6 3 | size 220112 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P3T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:16cefe3f63367cda79502168ff53f014c113d2cf0c0fe4508b8b87e234a69b8a 3 | size 279620 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P3T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0ff5d2e34fff3af8a4b5c6b83fc646266b914fa7a9f88e2d19996bc0ccb0c445 3 | size 281310 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A1P3T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:730af35298889f1d582f3c8da78572c190c416cbe9348e697101447db40c539b 3 | size 265206 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P1T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:303093b854dfddd49cdedc5ca2a6dcae8b9609db66b264edb68cf5b81bd90307 3 | size 231612 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P1T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fb4d582cfb45842e21eb80259421b9c98ac98d9cb28e80c8cd508bcb5b5b9c8b 3 | size 249460 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P1T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cdba3fdb3264fae7f07a573c4194694f852516a970bfae9584d931b8ac3c63b8 3 | size 253524 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P2T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d60775dd9674d3754ade6ef1d96e005d7cfa31c5ad4f7f666c2fd5c2b9855ab5 3 | size 134800 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P2T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ad9811396b6174708bd07f3c14030a91f7d316ba85c4ae8e07003857c0771ebb 3 | size 135886 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P2T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d723dcbbb1c4658b6d2b53c65886046fda2c86847a49d679d65a27b206a8c5df 3 | size 148622 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P3T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:af3ef7cb9462c8d789e78b07830ec68d2d7b6e9757ee0a2d080172e3f13a6aa9 3 | size 170210 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P3T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4bb96e8f2f326f9a91a710851ced7c77cd564da398f457b180d957f3dc09f432 3 | size 164044 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A2P3T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0d56f16908be46793f2d3b7df3d630c580803505fb9b12c1e7ebc89f94d1240a 3 | size 168782 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P1T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fe5564c01dcdb6780d5a65df36ac831ccaa2087c6f47653e67f617c98ac67dd8 3 | size 391156 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P1T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:77a4f5974dd9f46dd5ae312ecdcb3c5c9772b2bf6d339831260a827736324544 3 | size 360086 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P1T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b9e877ee1ac1d3d686826f32a5dd2e427e39034d343db2a982047bba7501afd7 3 | size 344714 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P2T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6ebf2909afc887f1a7a6914c57d0e99edbb19aefffc7b6b7773cd723463d0b2f 3 | size 207442 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P2T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2a73de7a9cc90c1bb2ae9283a086288a783fb960023b510e1240e1a85883f501 3 | size 213502 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P2T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:27ec3a7cc6e3ce6f3c874a7cdcdce68930eb432b4d968520101c2502c381cc43 3 | size 219190 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P3T1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4a5ab3a610b13e8b0a0e837a5dcb317be859f9c810849cfdedfe3296fe1c167b 3 | size 241586 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P3T2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e77c4644da1c08068fb7750719edb103349371d2ba4e23820db09cd8394b9e2b 3 | size 288282 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/PS7A3P3T3.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5b02870593ae665701bf7e31ec751fe8c1b7d3ebda71be663cd2adfb0c27c81e 3 | size 307568 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/TestLabel1.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b1ab9d649b8de2dac7bb51966f2685a67a07e288743ef5b310a72f101c07e5f0 3 | size 13943174 4 | -------------------------------------------------------------------------------- /Resources/ProblemSet7/TestLabel2.avi: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1a55c9089f92425de6ac1888bf2ba6740ec17d4822ab197e6a0e82dc698a9dd4 3 | size 18051264 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.01.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:330bbf20f7d083b2c3273e0882a8005586bd78ea21e5396aa7037fcd8c95d48a 3 | size 118838 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.02.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:602b2edf755e197e19ae13aa014cf48671f2f5693d23331f003aecb8224e84da 3 | size 108208 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.03.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0f1ea09cf6b863f8f4394f0852cfa946c330cb358088a7e907cd36ece55e5ccd 3 | size 94370 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.04.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b7685d9be966dbfef9480cd289cd586742f631cd513991741a60d6e202a85b36 3 | size 105128 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.05.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:708f17ed8d4792daaf7e05792f069ac830cf1e4e605018080439753733b64558 3 | size 111217 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.06.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c99d882132b20a33f25c440d2e611d2b66ad08e779fcdf89d1d76f1da9245d91 3 | size 133123 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.07.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:074b7d32f84b3749efc458a6ead818de51d6a7d1fda399fddc2d207d7c93993c 3 | size 77023 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.1.08.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f1f9ccdc2fd26ba9c0506d53a6601029aa638f71999df272d1b11067e846d2b9 3 | size 86417 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.2.01.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4a46f36e247166499216379927a5631a08c8f9fdcfdbd93623d9d367243d8992 3 | size 393024 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.2.03.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1b5ecf4c9a875c21d7df766b1cecaa6da73fb7ab833543afe546070b360dc5a2 3 | size 626299 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.2.05.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f592748eec4d3d1ed4249d0a965fad9904ac91f2e33fe4efbe0924b678d38a7b 3 | size 424170 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.2.06.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:384b6a0ce7d1ac5f1204d3029d243d3d7c19493125ad6c4a7150d39f5f5d1b85 3 | size 546672 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/4.2.07.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:01f34896176c8bb0800e2b0f80986192fddeac0b0d04d8f05af47b7b31344301 3 | size 506084 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.09.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7b576b6501db197cc5d751a62794024f86f216fab719076cd8bb8ce5592da8fd 3 | size 54317 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.10.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a4acbbf857901a7d4afe6997fbaf93664ec823ffaa1d81ff6628a88580cb3788 3 | size 59807 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.11.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d58b905daaaa9c8fd4c3b3b6029d3a3580c0c2b59dcf7a8f944beecbfd26959b 3 | size 42165 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.12.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e2e7fa1bb6de03891fc86db6f39480a4c058687fe44890645f6697ff3d9965d7 3 | size 45682 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.13.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:76a666c271ff20a1241898423e68d87656eaf7cc75eecec01e395cbb41ce145b 3 | size 10884 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.1.14.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6cb0108cedfefb8c9390fa184b70448127841fe563b60b74f7d0f17a2846abb7 3 | size 58232 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.2.08.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:91bfebb3133134b754d6453a6a80578446b270cc0d6dbab610d527bb10aa8c39 3 | size 211843 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.2.09.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d2df0f43d739c2656fac3d41288429e65797820a7f039ec9bcb964de7525e97b 3 | size 218337 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.2.10.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:126eb6525f4511ad040af57b75bd8b3cd5b239d049e68427f887eaa6e694d171 3 | size 157384 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.3.01.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b9d988b772cf572fd97306506faf59f586b25d9caa3e3cdb39f9c3cb75ef08ae 3 | size 928997 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/5.3.02.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d10d269d908ddc53be610e335da1318b1ca7bbb7bc431bf5fe8503db8730f1b7 3 | size 885642 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.01.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f3a5de538668ad784c4710d9b483f5839847459315a2317ac711b5c47193725b 3 | size 174237 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.02.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cf382c5baed8ad5af607baff7e93ed8e2e3641e7acd59c3192d1fa641bab2440 3 | size 94427 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.03.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:96d46e7cd222a37b66e586991fdac556751f3bd230ba77fb4d0ec02505a71e1b 3 | size 170087 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.04.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1660515fce78db178ffc43266f04b0b2a2c47740c15ab0529f6a44bea9c1c678 3 | size 176733 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.05.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e79056a26d6ea8630b56b00ce5ebd2929fc20f03544cd48012311c4ea0865432 3 | size 203241 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.06.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e979fce4186b39eb10912758b73fc79fd7fb6055b936313a4ae892341e9e335b 3 | size 209548 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.07.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d8c56431f9223386b5f1aa35029cb3140bf70dd59f7822d74484658d0f7d5adc 3 | size 193846 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.08.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cd0e1c5e93eb89088720eb12b8bf9f799c24bb976d714630929f13493d26aa36 3 | size 148918 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.09.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:58f6fb51074befe124c5fb441fd8f1fde728e9d69e7b849eb9b51ae8af51d390 3 | size 179041 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.1.10.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cc90fd893d9aecfebd8949a2d7c8ea53161aea33b9e82793b959dd6f86310e4d 3 | size 177461 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/7.2.01.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:dc5a25fbca9dea6c764bfa481af6724be43f23b632d0851d7531aace27e9a2a5 3 | size 718111 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/boat.512.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d08d089335fee222ce4f96ca7dc4daf039e9682163693213153514a581b7b327 3 | size 218832 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/gray21.512.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d8baa8732dd813918580ccf0e225f6cbaedf2d6197a48849e63519fd5fb74d25 3 | size 1734 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/house.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6a7dae60e36a8d9e8a684428b6bcc33cac5f1a7e7bcc9647d1651c3964d52968 3 | size 457214 4 | -------------------------------------------------------------------------------- /Resources/USC_Misc/ruler.512.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:47891449e61e2ca7e1e48603694374ba731ac29fa91ad489d8b5ec9fefca56f6 3 | size 1601 4 | -------------------------------------------------------------------------------- /common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB cuda_hdr include/common/*.cuh) 2 | file(GLOB cpp_hdr include/common/*.h include/common/*.hpp) 3 | file(GLOB cuda_src src/*.cu) 4 | file(GLOB cpp_src src/*.cpp) 5 | 6 | include_directories("${CUDA_INCLUDE_DIRS}") 7 | 8 | cuda_add_library(cv_common ${cpp_hdr} ${cuda_hdr} ${cpp_src} ${cuda_src}) 9 | -------------------------------------------------------------------------------- /common/include/common/BasicConfig.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | // Basic configuration container to load runtime parameters from YAML files 12 | 13 | struct BasicConfig { 14 | protected: 15 | bool _configDone = false; 16 | 17 | public: 18 | bool configDone() { 19 | return _configDone; 20 | } 21 | 22 | /** 23 | * \brief loadParam Loads a parameter from a YAML node and optionally logs if it was successful. 24 | * 25 | * \param node Input YAML-CPP node 26 | * \param key Key in YAML file from which the parameter should be loaded 27 | * \param val Var to which the value should be loaded 28 | * \param logger Shared pointer to a spdlog logger 29 | */ 30 | template 31 | bool loadParam(const YAML::Node& node, 32 | const std::string& key, 33 | T& val, 34 | std::shared_ptr logger = nullptr) { 35 | if (node[key]) { 36 | val = node[key].as(); 37 | return true; 38 | } 39 | if (logger) { 40 | logger->error("Could not load param \"{}\"", key); 41 | } 42 | return false; 43 | } 44 | 45 | /** 46 | * \brief loadImg Loads an image from a path defined in a YAML file. Images are loaded 47 | * unchanged. 48 | * 49 | * \param node Input YAML-CPP node 50 | * \param key Key in YAML file from which the image path is loaded 51 | * \param img OpenCV matrix to which the image is loaded 52 | * \param logger Optional shared pointer to a spdlog logger 53 | */ 54 | bool loadImg(const YAML::Node& node, 55 | const std::string& key, 56 | cv::Mat& img, 57 | std::shared_ptr logger = nullptr) { 58 | bool loadSuccess = false; 59 | std::string imgPath; 60 | if (loadParam(node, key, imgPath, logger)) { 61 | img = cv::imread(imgPath, cv::IMREAD_UNCHANGED); 62 | if (!img.empty()) { 63 | loadSuccess = true; 64 | } else { 65 | if (logger) logger->error("Could not load image \"{}\"", imgPath); 66 | } 67 | } else { 68 | if (logger) logger->error("Could not find YAML key \"{}\"", key); 69 | } 70 | if (logger) logger->info("Loaded image from {}", imgPath); 71 | return loadSuccess; 72 | } 73 | }; -------------------------------------------------------------------------------- /common/include/common/CudaCommon.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Common functions between all CUDA kernels 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | // For checking CUDA errors 11 | #define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__) 12 | 13 | inline void __checkCudaErrors(cudaError_t err, const char* file, const int line) { 14 | if (cudaSuccess != err) { 15 | fprintf(stderr, 16 | "CUDA Driver API error: %s at file <%s>, line %i.\n", 17 | cudaGetErrorString(err), 18 | file, 19 | line); 20 | exit(-1); 21 | } 22 | } 23 | 24 | __device__ inline uint2 getPosition() { 25 | return make_uint2(blockIdx.x * blockDim.x + threadIdx.x, blockIdx.y * blockDim.y + threadIdx.y); 26 | } 27 | 28 | __device__ inline unsigned int convert2dTo1d(const uint2 loc, const size_t numCols) { 29 | return loc.y * numCols + loc.x; 30 | } 31 | -------------------------------------------------------------------------------- /common/include/common/CudaWarmup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace common { 4 | 5 | // Simple warmup kernel to bring the GPU out of a low-power state 6 | void warmup(); 7 | 8 | }; // namespace common -------------------------------------------------------------------------------- /common/include/common/GpuTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class GpuTimer { 6 | private: 7 | float _runtimeMs; 8 | cudaEvent_t _start, _stop; 9 | 10 | public: 11 | GpuTimer(); 12 | ~GpuTimer(); 13 | 14 | // Start timing GPU execution 15 | void start(); 16 | 17 | // Stop timing GPU execution 18 | void stop(); 19 | 20 | // Get runtime 21 | float getTime(); 22 | }; -------------------------------------------------------------------------------- /common/include/common/OpenCVThrustInterop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * Enables interoperability between OpenCV and Thrust. 5 | * Source: 6 | * https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/gpu/gpu-thrust-interop 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* 17 | @Brief step_functor is an object to correctly step a thrust iterator according to the stride of 18 | a matrix 19 | */ 20 | //! [step_functor] 21 | template 22 | struct step_functor : public thrust::unary_function { 23 | int columns; 24 | int step; 25 | int channels; 26 | __host__ __device__ step_functor(int columns_, int step_, int channels_ = 1) 27 | : columns(columns_), step(step_), channels(channels_){}; 28 | __host__ step_functor(cv::cuda::GpuMat& mat) { 29 | CV_Assert(mat.depth() == cv::DataType::depth); 30 | columns = mat.cols; 31 | step = mat.step / sizeof(T); 32 | channels = mat.channels(); 33 | } 34 | __host__ __device__ int operator()(int x) const { 35 | int row = x / columns; 36 | int idx = (row * step) + (x % columns) * channels; 37 | return idx; 38 | } 39 | }; 40 | //! [step_functor] 41 | //! [begin_itr] 42 | /* 43 | @Brief GpuMatBeginItr returns a thrust compatible iterator to the beginning of a GPU mat's 44 | memory. 45 | @Param mat is the input matrix 46 | @Param channel is the channel of the matrix that the iterator is accessing. If set to -1, the 47 | iterator will access every element in sequential order 48 | */ 49 | template 50 | thrust::permutation_iterator< 51 | thrust::device_ptr, 52 | thrust::transform_iterator, thrust::counting_iterator>> 53 | GpuMatBeginItr(cv::cuda::GpuMat mat, int channel = 0) { 54 | if (channel == -1) { 55 | mat = mat.reshape(1); 56 | channel = 0; 57 | } 58 | CV_Assert(mat.depth() == cv::DataType::depth); 59 | CV_Assert(channel < mat.channels()); 60 | return thrust::make_permutation_iterator( 61 | thrust::device_pointer_cast(mat.ptr(0) + channel), 62 | thrust::make_transform_iterator( 63 | thrust::make_counting_iterator(0), 64 | step_functor(mat.cols, mat.step / sizeof(T), mat.channels()))); 65 | } 66 | //! [begin_itr] 67 | //! [end_itr] 68 | /* 69 | @Brief GpuMatEndItr returns a thrust compatible iterator to the end of a GPU mat's memory. 70 | @Param mat is the input matrix 71 | @Param channel is the channel of the matrix that the iterator is accessing. If set to -1, the 72 | iterator will access every element in sequential order 73 | */ 74 | template 75 | thrust::permutation_iterator< 76 | thrust::device_ptr, 77 | thrust::transform_iterator, thrust::counting_iterator>> 78 | GpuMatEndItr(cv::cuda::GpuMat mat, int channel = 0) { 79 | if (channel == -1) { 80 | mat = mat.reshape(1); 81 | channel = 0; 82 | } 83 | CV_Assert(mat.depth() == cv::DataType::depth); 84 | CV_Assert(channel < mat.channels()); 85 | return thrust::make_permutation_iterator( 86 | thrust::device_pointer_cast(mat.ptr(0) + channel), 87 | thrust::make_transform_iterator( 88 | thrust::make_counting_iterator(mat.rows * mat.cols), 89 | step_functor(mat.cols, mat.step / sizeof(T), mat.channels()))); 90 | } 91 | //! [end_itr] -------------------------------------------------------------------------------- /common/include/common/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // Useful utilities that can be used for both CUDA and CPU code 8 | 9 | namespace common { 10 | 11 | // Compute block size by dividing two numbers and round up, clipping the minimum output to 1. 12 | template 13 | std::size_t divRoundUp(const numType num, const denomType denom) { 14 | return std::max(std::size_t(1), std::size_t(ceil(float(num) / float(denom)))); 15 | } 16 | 17 | // CUDA stream callback 18 | void checkCopySuccess(int status, void* userData); 19 | 20 | bool makeDir(const std::string& dirPath); 21 | 22 | }; // namespace common -------------------------------------------------------------------------------- /common/include/common/make_unique.h: -------------------------------------------------------------------------------- 1 | // Ripped from https://stackoverflow.com/a/17902439 2 | // Allows for make_unique in C++11 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace cpp_upstream { 10 | template 11 | struct _Unique_if { 12 | typedef std::unique_ptr _Single_object; 13 | }; 14 | 15 | template 16 | struct _Unique_if { 17 | typedef std::unique_ptr _Unknown_bound; 18 | }; 19 | 20 | template 21 | struct _Unique_if { 22 | typedef void _Known_bound; 23 | }; 24 | 25 | template 26 | typename _Unique_if::_Single_object make_unique(Args&&... args) { 27 | return std::unique_ptr(new T(std::forward(args)...)); 28 | } 29 | 30 | template 31 | typename _Unique_if::_Unknown_bound make_unique(size_t n) { 32 | typedef typename std::remove_extent::type U; 33 | return std::unique_ptr(new U[n]()); 34 | } 35 | 36 | template 37 | typename _Unique_if::_Known_bound make_unique(Args&&...) = delete; 38 | } // namespace cpp_upstream 39 | -------------------------------------------------------------------------------- /common/src/CudaWarmup.cu: -------------------------------------------------------------------------------- 1 | #include "../include/common/CudaWarmup.h" 2 | #include "../include/common/CudaCommon.cuh" 3 | 4 | // Simple kernel to warm up the GPU before doing a timed kernel launch 5 | __global__ void warmupKernel() { 6 | int threadId = blockIdx.x * blockDim.x + threadIdx.x; 7 | float a = 1.f; 8 | float b = 2.f; 9 | 10 | a = a * threadId; 11 | b = b * threadId; 12 | } 13 | 14 | void common::warmup() { 15 | dim3 blocks(10, 1, 1); 16 | dim3 threads(64, 1, 1); 17 | 18 | warmupKernel<<>>(); 19 | } -------------------------------------------------------------------------------- /common/src/GpuTimer.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/common/GpuTimer.h" 2 | 3 | GpuTimer::GpuTimer() { 4 | cudaEventCreate(&_start); 5 | cudaEventCreate(&_stop); 6 | } 7 | 8 | GpuTimer::~GpuTimer() { 9 | cudaEventSynchronize(_stop); 10 | } 11 | 12 | void GpuTimer::start() { 13 | cudaEventRecord(_start); 14 | } 15 | 16 | void GpuTimer::stop() { 17 | cudaEventRecord(_stop); 18 | cudaEventSynchronize(_stop); 19 | } 20 | 21 | float GpuTimer::getTime() { 22 | cudaEventElapsedTime(&_runtimeMs, _start, _stop); 23 | return _runtimeMs; 24 | } -------------------------------------------------------------------------------- /common/src/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/common/Utils.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | // CUDA stream callback 8 | void common::checkCopySuccess(int status, void* userData) { 9 | auto logger = spdlog::get("file_logger"); 10 | if (status == cudaSuccess) { 11 | logger->info("Stream successfully copied data to GPU"); 12 | } else { 13 | logger->error("Stream copy failed!"); 14 | } 15 | } 16 | 17 | bool common::makeDir(const std::string& dirPath) { 18 | const int dirErr = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 19 | if (dirErr == -1) { 20 | // The directory already exists, so there's nothing to do anyway. Return true 21 | return errno == EEXIST; 22 | } 23 | return true; 24 | } -------------------------------------------------------------------------------- /config/ps0.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Configuration for Problem Set 0 3 | images: 4 | image1: ../Resources/USC_Misc/4.1.03.png 5 | image2: ../Resources/USC_Misc/4.1.06.png 6 | ... -------------------------------------------------------------------------------- /config/ps1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Problem set 1 configuration 3 | images: 4 | input0: ../Resources/ProblemSet1/ps1-input0.png 5 | input0_noise: ../Resources/ProblemSet1/ps1-input0-noise.png 6 | input1: ../Resources/ProblemSet1/ps1-input1.png 7 | input2: ../Resources/ProblemSet1/ps1-input2.png 8 | input3: ../Resources/ProblemSet1/ps1-input3.png 9 | output_dir: ./ps1_output 10 | 11 | # Problem 2 configuration 12 | # Edge detector options 13 | edge_detector_p2: 14 | gaussian_size: 1 15 | gaussian_sigma: 0.0001 16 | lower_threshold: 1 17 | upper_threshold: 3 18 | sobel_aperture_size: 3 19 | 20 | hough_transform_p2: 21 | rho_bin_size: 1 22 | theta_bin_size: 1 23 | num_peaks: 6 24 | threshold: 200 25 | 26 | # Problem 3 configuration 27 | edge_detector_p3: 28 | gaussian_size: 19 29 | gaussian_sigma: 4 30 | lower_threshold: 10 31 | upper_threshold: 50 32 | sobel_aperture_size: 3 33 | 34 | hough_transform_p3: 35 | rho_bin_size: 2 36 | theta_bin_size: 2 37 | num_peaks: 6 38 | threshold: 5 39 | 40 | # Problem 4 configuration 41 | edge_detector_p4: 42 | gaussian_size: 13 43 | gaussian_sigma: 4 44 | lower_threshold: 20 45 | upper_threshold: 80 46 | sobel_aperture_size: 3 47 | 48 | hough_transform_p4: 49 | rho_bin_size: 1 50 | theta_bin_size: 1 51 | num_peaks: 10 52 | threshold: 130 53 | 54 | # Problem 5 configuration 55 | edge_detector_p5: 56 | gaussian_size: 13 57 | gaussian_sigma: 4 58 | lower_threshold: 10 59 | upper_threshold: 70 60 | sobel_aperture_size: 3 61 | 62 | hough_circle_transform_p5: 63 | min_radius: 20 64 | max_radius: 50 65 | num_peaks: 10 66 | threshold: 130 67 | 68 | # Problem 6 configuration 69 | edge_detector_p6: 70 | gaussian_size: 7 71 | gaussian_sigma: 5 72 | lower_threshold: 50 73 | upper_threshold: 140 74 | sobel_aperture_size: 3 75 | 76 | hough_transform_p6: 77 | rho_bin_size: 2 78 | theta_bin_size: 3 79 | num_peaks: 10 80 | threshold: 80 81 | 82 | # Problem 7 configuration 83 | edge_detector_p7: 84 | gaussian_size: 3 85 | gaussian_sigma: 1 86 | lower_threshold: 35 87 | upper_threshold: 130 88 | sobel_aperture_size: 3 89 | 90 | hough_circle_transform_p7: 91 | min_radius: 20 92 | max_radius: 40 93 | num_peaks: 10 94 | threshold: 135 95 | 96 | # Problem 8 configuration 97 | edge_detector_p8: 98 | gaussian_size: 3 99 | gaussian_sigma: 2 100 | lower_threshold: 40 101 | upper_threshold: 90 102 | sobel_aperture_size: 3 103 | 104 | hough_line_transform_p8: 105 | rho_bin_size: 1 106 | theta_bin_size: 1 107 | num_peaks: 10 108 | threshold: 105 109 | 110 | hough_circle_transform_p8: 111 | min_radius: 20 112 | max_radius: 40 113 | num_peaks: 5 114 | threshold: 110 115 | ... -------------------------------------------------------------------------------- /config/ps2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Problem Set 2 configuration 3 | images: 4 | pair0-L: ../Resources/ProblemSet2/pair0-L.png 5 | pair0-R: ../Resources/ProblemSet2/pair0-R.png 6 | pair1-L: ../Resources/ProblemSet2/pair1-L.png 7 | pair1-R: ../Resources/ProblemSet2/pair1-R.png 8 | pair2-L: ../Resources/ProblemSet2/pair2-L.png 9 | pair2-R: ../Resources/ProblemSet2/pair2-R.png 10 | pair1-GT-L: ../Resources/ProblemSet2/pair1-D_L.png 11 | pair1-GT-R: ../Resources/ProblemSet2/pair1-D_R.png 12 | pair2-GT-L: ../Resources/ProblemSet2/pair2-D_L.png 13 | pair2-GT-R: ../Resources/ProblemSet2/pair2-D_R.png 14 | 15 | output_dir: ./ps2_output 16 | use_gpu_disparity: true 17 | 18 | # Problem 1 settings 19 | problem_1_ssd: 20 | window_radius: 6 21 | disparity_range: 3 22 | 23 | # Problem 2 settings 24 | problem_2_ssd: 25 | window_radius: 7 26 | disparity_range: 95 27 | 28 | # Problem 3 settings 29 | problem_3_ssd: 30 | window_radius: 7 31 | disparity_range: 95 32 | 33 | # Problem 4 settings 34 | problem_4_ncorr: 35 | window_radius: 7 36 | disparity_range: 95 37 | 38 | # Problem 5 settings 39 | problem_5_ncorr: 40 | window_radius: 7 41 | disparity_range: 80 42 | ... -------------------------------------------------------------------------------- /config/ps3.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Problem Set 3 configuration 3 | images: 4 | pic_a: ../Resources/ProblemSet3/pic_a.jpg 5 | pic_b: ../Resources/ProblemSet3/pic_b.jpg 6 | 7 | points: 8 | pts2d_pic_a: ../Resources/ProblemSet3/pts2d-pic_a.txt 9 | pts2d_pic_b: ../Resources/ProblemSet3/pts2d-pic_b.txt 10 | pts2d_norm_pic_a: ../Resources/ProblemSet3/pts2d-norm-pic_a.txt 11 | pts3d: ../Resources/ProblemSet3/pts3d.txt 12 | pts3d_norm: ../Resources/ProblemSet3/pts3d-norm.txt 13 | 14 | output_dir: ./ps3_output 15 | 16 | # Seed for Mersenne Twister Engine used in Problem 1b 17 | mersenne_seed: 16 38 c7 e4 6a a2 d8 cc 96 f6 fe f1 4b 7d a7 25 18 | ... -------------------------------------------------------------------------------- /config/ps4.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Problem Set 4 configuration 3 | images: 4 | transA.jpg: ../Resources/ProblemSet4/transA.jpg 5 | transB.jpg: ../Resources/ProblemSet4/transB.jpg 6 | simA.jpg: ../Resources/ProblemSet4/simA.jpg 7 | simB.jpg: ../Resources/ProblemSet4/simB.jpg 8 | check.bmp: ../Resources/ProblemSet4/check.bmp 9 | check_rot.bmp: ../Resources/ProblemSet4/check_rot.bmp 10 | 11 | output_dir: ./ps4_output 12 | 13 | # Seed for Mersenne Twister Engine 14 | mersenne_seed: 16 38 c7 e4 6a a2 d8 cc 96 f6 fe f1 4b 7d a7 25 15 | 16 | use_gpu: true 17 | 18 | harris_trans: 19 | sobel_kernel_size: 3 20 | window_size: 5 21 | gaussian_sigma: 1.5 22 | alpha: 0.04 23 | response_threshold: 500000000 24 | min_distance: 5 25 | 26 | harris_sim: 27 | sobel_kernel_size: 3 28 | window_size: 5 29 | gaussian_sigma: 1.5 30 | alpha: 0.04 31 | response_threshold: 500000000 32 | min_distance: 5 33 | 34 | ransac_trans: 35 | reprojection_threshold: 10 36 | max_iterations: 2000 37 | consensus_ratio: 0.2 38 | 39 | ransac_sim: 40 | reprojection_threshold: 6 41 | max_iterations: 2000 42 | consensus_ratio: 0.6 43 | 44 | ransac_affine: 45 | reprojection_threshold: 6 46 | max_iterations: 2000 47 | consensus_ratio: 0.6 48 | ... -------------------------------------------------------------------------------- /config/ps5.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Problem Set 5 image sets 3 | image_sets: 4 | yosemite: ../Resources/ProblemSet5/DataSeq1 5 | pupper: ../Resources/ProblemSet5/DataSeq2 6 | juggle: ../Resources/ProblemSet5/Juggle 7 | shift: ../Resources/ProblemSet5/TestSeq 8 | 9 | output_dir: ./ps5_output 10 | 11 | lk_window_size_1: 43 12 | 13 | lk_window_size_3: 7 14 | pyr_level_3-a: 1 15 | pyr_level_3-b: 2 16 | 17 | lk_window_size_4: 15 18 | ... -------------------------------------------------------------------------------- /config/ps6.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Input videos and initial bounding boxes 3 | pres_debate: 4 | video: ../Resources/ProblemSet6/pres_debate.avi 5 | bounding_box: ../Resources/ProblemSet6/pres_debate.txt 6 | 7 | noisy_debate: 8 | video: ../Resources/ProblemSet6/noisy_debate.avi 9 | bounding_box: ../Resources/ProblemSet6/noisy_debate.txt 10 | 11 | pedestrians: 12 | video: ../Resources/ProblemSet6/pedestrians.avi 13 | bounding_box: ../Resources/ProblemSet6/pedestrians.txt 14 | 15 | output_dir: ./ps6_output 16 | 17 | pfconf1: 18 | num_particles: 300 19 | mse_sigma: 3 20 | dynamics_sigma: 6.5 21 | alpha: 0.1 22 | 23 | pfconf1_noisy: 24 | num_particles: 300 25 | mse_sigma: 3 26 | dynamics_sigma: 6.5 27 | alpha: 0.1 28 | 29 | pfconf2: 30 | num_particles: 700 31 | mse_sigma: 1.5 32 | dynamics_sigma: 28 33 | alpha: 0.15 34 | 35 | pfconf2_noisy: 36 | num_particles: 700 37 | mse_sigma: 1.5 38 | dynamics_sigma: 26 39 | alpha: 0.15 40 | 41 | pfconf3_head: 42 | num_particles: 300 43 | mse_sigma: 0 44 | dynamics_sigma: 4.7 45 | alpha: 0.15 46 | 47 | pfconf3_hand: 48 | num_particles: 300 49 | mse_sigma: 0 50 | dynamics_sigma: 28 51 | alpha: 0.15 52 | ... -------------------------------------------------------------------------------- /config/ps7.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Directory of input videos 3 | input_dir: ../Resources/ProblemSet7 4 | 5 | output_dir: ./ps7_output 6 | 7 | last_frame_of_action: 8 | action1: 9 | person1: 10 | - 50 # Trial 1 11 | - 39 # Trial 2 12 | - 41 # Trial 3 13 | person2: 14 | - 30 15 | - 30 16 | - 32 17 | person3: 18 | - 36 19 | - 31 20 | - 32 21 | action2: 22 | person1: 23 | - 30 24 | - 30 25 | - 30 26 | person2: 27 | - 23 28 | - 23 29 | - 23 30 | person3: 31 | - 30 32 | - 30 33 | - 30 34 | action3: 35 | person1: 36 | - 42 37 | - 38 38 | - 38 39 | person2: 40 | - 38 41 | - 36 42 | - 38 43 | person3: 44 | - 38 45 | - 38 46 | - 19 47 | 48 | mhi_action1: 49 | diff_threshold: 1.7 50 | pre_blur_size: 31 51 | pre_blur_sigma: 10 52 | tau: 25 53 | last_frame: 30 54 | 55 | mhi_action2: 56 | diff_threshold: 1.7 57 | pre_blur_size: 31 58 | pre_blur_sigma: 10 59 | tau: 25 60 | last_frame: 30 61 | 62 | mhi_action3: 63 | diff_threshold: 1.7 64 | pre_blur_size: 31 65 | pre_blur_sigma: 10 66 | tau: 34 67 | last_frame: 38 68 | ... -------------------------------------------------------------------------------- /external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "disable yaml tests") 2 | set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "disable yaml tools") 3 | set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "disable yaml contrib") 4 | 5 | add_subdirectory(yaml-cpp) --------------------------------------------------------------------------------