diff --git a/Capstone_Design.sln b/Capstone_Design.sln index 0c47250..cc8f0ad 100644 --- a/Capstone_Design.sln +++ b/Capstone_Design.sln @@ -17,6 +17,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\He EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatOp", "MatOp\MatOp.vcxproj", "{284ABC4B-82D9-4808-8E18-E6F7A1D05563}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ch04", "ch04", "{6AD5DB3F-FAAC-4D79-9B5C-52AF61E2E052}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Video", "Video\Video.vcxproj", "{67BA8C21-12CB-440F-998D-E0DFF7B04DDF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Drawing", "Drawing\Drawing.vcxproj", "{27CCD2CA-F740-43F5-8740-B30E3A2840C1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -57,6 +63,22 @@ Global {284ABC4B-82D9-4808-8E18-E6F7A1D05563}.Release|x64.Build.0 = Release|x64 {284ABC4B-82D9-4808-8E18-E6F7A1D05563}.Release|x86.ActiveCfg = Release|Win32 {284ABC4B-82D9-4808-8E18-E6F7A1D05563}.Release|x86.Build.0 = Release|Win32 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Debug|x64.ActiveCfg = Debug|x64 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Debug|x64.Build.0 = Debug|x64 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Debug|x86.ActiveCfg = Debug|Win32 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Debug|x86.Build.0 = Debug|Win32 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Release|x64.ActiveCfg = Release|x64 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Release|x64.Build.0 = Release|x64 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Release|x86.ActiveCfg = Release|Win32 + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF}.Release|x86.Build.0 = Release|Win32 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Debug|x64.ActiveCfg = Debug|x64 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Debug|x64.Build.0 = Debug|x64 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Debug|x86.ActiveCfg = Debug|Win32 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Debug|x86.Build.0 = Debug|Win32 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Release|x64.ActiveCfg = Release|x64 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Release|x64.Build.0 = Release|x64 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Release|x86.ActiveCfg = Release|Win32 + {27CCD2CA-F740-43F5-8740-B30E3A2840C1}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -66,6 +88,8 @@ Global {9466991C-83CD-4753-90EB-A20C12368EAC} = {C8D5274F-AC00-46C7-1F8D-E88E81087A52} {682942EC-3BD1-4759-A9A4-3089C2EEC799} = {C8D5274F-AC00-46C7-1F8D-E88E81087A52} {284ABC4B-82D9-4808-8E18-E6F7A1D05563} = {5A922B9F-8CAA-418C-9D2A-C2F26CCF7059} + {67BA8C21-12CB-440F-998D-E0DFF7B04DDF} = {6AD5DB3F-FAAC-4D79-9B5C-52AF61E2E052} + {27CCD2CA-F740-43F5-8740-B30E3A2840C1} = {6AD5DB3F-FAAC-4D79-9B5C-52AF61E2E052} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E1A0C3F4-F16D-4626-86CE-D8484C0C776D} diff --git a/Drawing/Drawing.vcxproj b/Drawing/Drawing.vcxproj new file mode 100644 index 0000000..6ad2af6 --- /dev/null +++ b/Drawing/Drawing.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {27ccd2ca-f740-43f5-8740-b30e3a2840c1} + Drawing + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Drawing/Drawing.vcxproj.filters b/Drawing/Drawing.vcxproj.filters new file mode 100644 index 0000000..2c1b3dc --- /dev/null +++ b/Drawing/Drawing.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 소스 파일 + + + \ No newline at end of file diff --git a/Drawing/Drawing.zip b/Drawing/Drawing.zip new file mode 100644 index 0000000..51c5768 Binary files /dev/null and b/Drawing/Drawing.zip differ diff --git a/Drawing/main.cpp b/Drawing/main.cpp new file mode 100644 index 0000000..3ffb591 --- /dev/null +++ b/Drawing/main.cpp @@ -0,0 +1,66 @@ +#include +#include "opencv2/opencv.hpp" + +int drawLines(); +int drawPolys(); + +int main() { + return drawPolys(); +} + +int drawLines() { + cv::Mat img(400, 400, CV_8UC3, cv::Scalar(255, 255, 255)); + + cv::line(img, cv::Point(50, 50), cv::Point(200, 50), cv::Scalar(0, 0, 255)); + cv::line(img, cv::Point(50, 100), cv::Point(200, 100), cv::Scalar(255, 0, 255), 3); + cv::line(img, cv::Point(50, 150), cv::Point(200, 150), cv::Scalar(255, 0, 0), 10); + + cv::line(img, cv::Point(250, 50), cv::Point(350, 100), cv::Scalar(0, 0, 255), 1, cv::LINE_4); + cv::line(img, cv::Point(250, 70), cv::Point(350, 120), cv::Scalar(255, 0, 255), 1, cv::LINE_8); + cv::line(img, cv::Point(250, 90), cv::Point(350, 140), cv::Scalar(255, 0, 0), 1, cv::LINE_AA); + + cv::arrowedLine(img, cv::Point(50, 200), cv::Point(150, 200), cv::Scalar(0, 0, 255), 1); + cv::arrowedLine(img, cv::Point(50, 250), cv::Point(350, 250), cv::Scalar(255, 0, 255), 1); + cv::arrowedLine(img, cv::Point(50, 300), cv::Point(350, 300), cv::Scalar(255, 0, 0), 1, cv::LINE_8, 0, 0.05); + + cv::drawMarker(img, cv::Point(50, 350), cv::Scalar(0, 0, 255), cv::MARKER_CROSS); + cv::drawMarker(img, cv::Point(100, 350), cv::Scalar(0, 0, 255), cv::MARKER_TILTED_CROSS); + cv::drawMarker(img, cv::Point(150, 350), cv::Scalar(0, 0, 255), cv::MARKER_STAR); + cv::drawMarker(img, cv::Point(200, 350), cv::Scalar(0, 0, 255), cv::MARKER_DIAMOND); + cv::drawMarker(img, cv::Point(250, 350), cv::Scalar(0, 0, 255), cv::MARKER_SQUARE); + cv::drawMarker(img, cv::Point(300, 350), cv::Scalar(0, 0, 255), cv::MARKER_TRIANGLE_UP); + cv::drawMarker(img, cv::Point(350, 350), cv::Scalar(0, 0, 255), cv::MARKER_TRIANGLE_DOWN); + + cv::imshow("img", img); + cv::waitKey(0); + + cv::destroyAllWindows(); + return 0; +} + +int drawPolys() { + cv::Mat img(400, 400, CV_8UC3, cv::Scalar(255, 255, 255)); + + cv::rectangle(img, cv::Rect(50, 50, 100, 50), cv::Scalar(0, 0, 255), 2); + cv::rectangle(img, cv::Rect(50, 150, 100, 50), cv::Scalar(0, 0, 128), -1); + + cv::circle(img, cv::Point(300, 120), 30, cv::Scalar(255, 255, 0), -1, cv::LINE_AA); + cv::circle(img, cv::Point(300, 120), 60, cv::Scalar(255, 0, 0), 3, cv::LINE_AA); + + cv::ellipse(img, cv::Point(120, 300), cv::Size(60, 30), 20, 0, 270, cv::Scalar(255, 255, 0), -1, cv::LINE_AA); + cv::ellipse(img, cv::Point(120, 300), cv::Size(100, 50), 20, 0, 360, cv::Scalar(0, 255, 0), 2, cv::LINE_AA); + + std::vector pts; + pts.push_back(cv::Point(250, 250)); pts.push_back(cv::Point(300, 250)); + pts.push_back(cv::Point(300, 300)); pts.push_back(cv::Point(350, 300)); + pts.push_back(cv::Point(350, 350)); pts.push_back(cv::Point(250, 350)); + cv::polylines(img, pts, true, cv::Scalar(255, 0, 255), 2); + + cv::putText(img, "KimMinSu 20518009", cv::Point(50, 30), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(255, 0, 255), 2, cv::LINE_AA); + + cv::imshow("img", img); + cv::waitKey(0); + + cv::destroyAllWindows(); + return 0; +} \ No newline at end of file diff --git a/HelloCV/HelloCV.vcxproj b/HelloCV/HelloCV.vcxproj index 9d1dc11..799d0a2 100644 --- a/HelloCV/HelloCV.vcxproj +++ b/HelloCV/HelloCV.vcxproj @@ -59,15 +59,19 @@ + + + + @@ -106,13 +110,10 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(OPENCV_DIR)\include Console true - opencv_world4110d.lib;%(AdditionalDependencies) - $(OPENCV_DIR)\x64\vc16\lib;%(AdditionalLibraryDirectories) @@ -137,6 +138,9 @@ + + + diff --git a/HelloCV/HelloCV.vcxproj.filters b/HelloCV/HelloCV.vcxproj.filters index 2c1b3dc..1d6af50 100644 --- a/HelloCV/HelloCV.vcxproj.filters +++ b/HelloCV/HelloCV.vcxproj.filters @@ -19,4 +19,9 @@ 소스 파일 + + + 리소스 파일 + + \ No newline at end of file diff --git a/HelloCV/main.cpp b/HelloCV/main.cpp index e96a248..a34d6cd 100644 --- a/HelloCV/main.cpp +++ b/HelloCV/main.cpp @@ -5,7 +5,7 @@ int main(int argv, char* argc[]) { std::cout << "Hello, OpenCV " << CV_VERSION << std::endl; cv::Mat img; - img = cv::imread("c:\\coding\\images\\lenna.bmp"); + img = cv::imread("..\\resources\\images\\lenna.bmp"); if (img.empty()) { std::cerr << "Image load failed!" << std::endl; diff --git a/MatOp/MatOp.vcxproj b/MatOp/MatOp.vcxproj index 7e09d89..cd537bd 100644 --- a/MatOp/MatOp.vcxproj +++ b/MatOp/MatOp.vcxproj @@ -59,15 +59,19 @@ + + + + diff --git a/OPENCV4110_debug.props b/OPENCV4110_debug.props new file mode 100644 index 0000000..7fab32a --- /dev/null +++ b/OPENCV4110_debug.props @@ -0,0 +1,18 @@ + + + + + + <_PropertySheetDisplayName>OPENCV4110_debug + + + + $(OPENCV_DIR)\include;%(AdditionalIncludeDirectories) + + + $(OPENCV_DIR)\x64\vc16\lib;%(AdditionalLibraryDirectories) + opencv_world4110d.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/OPENCV4110_release.props b/OPENCV4110_release.props new file mode 100644 index 0000000..1cf6f71 --- /dev/null +++ b/OPENCV4110_release.props @@ -0,0 +1,18 @@ + + + + + + <_PropertySheetDisplayName>OPENCV4110_release + + + + $(OPENCV_DIR)\include;%(AdditionalIncludeDirectories) + + + $(OPENCV_DIR)\x64\vc16\lib;%(AdditionalLibraryDirectories) + opencv_world4110.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/Point_Class/Point_Class.vcxproj b/Point_Class/Point_Class.vcxproj index 50c26f1..249d574 100644 --- a/Point_Class/Point_Class.vcxproj +++ b/Point_Class/Point_Class.vcxproj @@ -59,15 +59,19 @@ + + + + @@ -104,13 +108,10 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(OPENCV_DIR)\include Console true - $(OPENCV_DIR)\x64\vc16\lib;%(AdditionalLibraryDirectories) - opencv_world4110d.lib;%(AdditionalDependencies) diff --git a/Video/Video.vcxproj b/Video/Video.vcxproj new file mode 100644 index 0000000..68f6839 --- /dev/null +++ b/Video/Video.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {67ba8c21-12cb-440f-998d-e0dff7b04ddf} + Video + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Video/Video.vcxproj.filters b/Video/Video.vcxproj.filters new file mode 100644 index 0000000..2c1b3dc --- /dev/null +++ b/Video/Video.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 소스 파일 + + + \ No newline at end of file diff --git a/Video/main.cpp b/Video/main.cpp new file mode 100644 index 0000000..cea6ee0 --- /dev/null +++ b/Video/main.cpp @@ -0,0 +1,58 @@ +#include +#include "opencv2/opencv.hpp" + +int camera_in(); +int camera_in_video_out(); + +int main() { + return camera_in_video_out(); +} + +int camera_in() { + cv::VideoCapture camera(0); + if (!camera.isOpened()) { + std::cerr << "camera.isopened()" << std::endl; + return 1; + } + cv::Mat img; + double fps = 1000 / camera.get(cv::VideoCaptureProperties::CAP_PROP_FPS); + std::cout << "\n\n" << fps << "\n\n"; + while (true) { + camera >> img; + if (img.empty()) { + std::cerr << "img.empty()" << std::endl; + return 1; + } + cv::imshow("img", img); + if (cv::waitKey(fps) == 27) + break; + } + return 0; +} + +int camera_in_video_out() { + cv::VideoCapture camera(0); + if (!camera.isOpened()) { + std::cerr << "camera.isopened()" << std::endl; + return 1; + } + cv::Mat img; + int w = cvRound(camera.get(cv::VideoCaptureProperties::CAP_PROP_FRAME_WIDTH)); + int h = cvRound(camera.get(cv::VideoCaptureProperties::CAP_PROP_FRAME_HEIGHT)); + double fps = camera.get(cv::VideoCaptureProperties::CAP_PROP_FPS); + + cv::VideoWriter outputVideo("output.avi", cv::VideoWriter::fourcc('D', 'I', 'V', 'X'), fps, cv::Size(w, h)); + + while (true) { + camera >> img; + if (img.empty()) { + std::cerr << "img.empty()" << std::endl; + return 1; + } + outputVideo << ~img; + cv::imshow("img", img); + if (cv::waitKey(fps) == 27) + break; + } + return 0; +} \ No newline at end of file