diff --git a/Install-OpenCV-4-on-Windows-from-source/CMakeLists.txt b/Install-OpenCV-4-on-Windows-from-source/CMakeLists.txt new file mode 100755 index 000000000..99fec0674 --- /dev/null +++ b/Install-OpenCV-4-on-Windows-from-source/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8.12) + +PROJECT(Project) + +find_package(OpenCV REQUIRED) + +include_directories(${OpenCV_INCLUDE_DIRS}) + +MACRO(add_example name) + ADD_EXECUTABLE(${name} ${name}.cpp) + TARGET_LINK_LIBRARIES(${name} ${OpenCV_LIBS}) +ENDMACRO() + +add_example(sampleCode) diff --git a/Install-OpenCV-4-on-Windows-from-source/README.md b/Install-OpenCV-4-on-Windows-from-source/README.md new file mode 100755 index 000000000..c033be524 --- /dev/null +++ b/Install-OpenCV-4-on-Windows-from-source/README.md @@ -0,0 +1,30 @@ +# Code for Install OpenCV 4 on Windows from source + +This repository contains the sample code for [Install OpenCV 4 on Windows from source](https://learnopencv.com/install-opencv-4-on-windows/) + +## Run Code: + +### C++ +``` +mkdir build +cd build +cmake -G "Visual Studio 16 2019" .. +cmake --build . --config Release +cd .. +.\build\Release\sampleCode +``` + +### Python +``` +python sampleCode.py +``` + +# AI Courses by OpenCV + +Want to become an expert in AI? [AI Courses by OpenCV](https://opencv.org/courses/) is a great place to start. + + +

+ +

+
diff --git a/Install-OpenCV-4-on-Windows-from-source/boy.jpg b/Install-OpenCV-4-on-Windows-from-source/boy.jpg new file mode 100644 index 000000000..67ef6802c Binary files /dev/null and b/Install-OpenCV-4-on-Windows-from-source/boy.jpg differ diff --git a/Install-OpenCV-4-on-Windows-from-source/sampleCode.cpp b/Install-OpenCV-4-on-Windows-from-source/sampleCode.cpp new file mode 100755 index 000000000..a52d413fe --- /dev/null +++ b/Install-OpenCV-4-on-Windows-from-source/sampleCode.cpp @@ -0,0 +1,26 @@ +#include +#include + +using namespace std; +using namespace cv; + +int main(int argc, char **argv) +{ + // Print OpenCV Version + cout << CV_VERSION << endl; + + // Read image + Mat image = imread("boy.jpg", 1); + + // Convert image to grayscale + cvtColor(image, image, COLOR_BGR2GRAY); + + // Display image + imshow("Display", image); + waitKey(0); + + // Save grayscale image + imwrite("boyGray.jpg",image); + + return 0; +} diff --git a/Install-OpenCV-4-on-Windows-from-source/sampleCode.py b/Install-OpenCV-4-on-Windows-from-source/sampleCode.py new file mode 100755 index 000000000..75b81216e --- /dev/null +++ b/Install-OpenCV-4-on-Windows-from-source/sampleCode.py @@ -0,0 +1,17 @@ +import cv2 as cv + +# Print OpenCV Version +print(cv.__version__) + +# Read image +image = cv.imread("boy.jpg", 1) + +# Convert image to grayscale +image = cv.cvtColor(image, cv.COLOR_BGR2GRAY) + +# Display image +cv.imshow("Display", image) +cv.waitKey(0) + +# Save grayscale image +cv.imwrite("boyGray.jpg",image) diff --git a/README.md b/README.md index 7c33dc275..03447651a 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Want to become an expert in AI? [AI Courses by OpenCV](https://opencv.org/course |[Install OpenCV 3.4.4 on Ubuntu 18.04 (C++ and Python)](https://www.learnopencv.com/install-opencv-3-4-4-on-ubuntu-18-04/) | [Code](https://github.com/spmallick/learnopencv/blob/master/InstallScripts/installOpenCV-3-on-Ubuntu-18-04.sh) | |[Universal Sentence Encoder](https://www.learnopencv.com/universal-sentence-encoder) | [Code](https://github.com/spmallick/learnopencv/blob/master/Universal-Sentence-Encoder) | |[Install OpenCV 4 on Raspberry Pi](https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/) | [Code](https://github.com/spmallick/learnopencv/blob/master/InstallScripts/installOpenCV-4-raspberry-pi.sh) | -|[Install OpenCV 4 on Windows (C++ and Python)](https://www.learnopencv.com/install-opencv-4-on-windows/) | [Code](https://github.com/spmallick/learnopencv/tree/master/InstallScripts/Windows-4) | +|[Install OpenCV 4 on Windows (C++ and Python)](https://www.learnopencv.com/install-opencv-4-on-windows/) | [Code](https://github.com/spmallick/learnopencv/tree/master/Install-OpenCV-4-on-Windows-from-source) | |[Hand Keypoint Detection using Deep Learning and OpenCV](https://www.learnopencv.com/hand-keypoint-detection-using-deep-learning-and-opencv/) | [Code](https://github.com/spmallick/learnopencv/tree/master/HandPose)| |[Deep learning based Object Detection and Instance Segmentation using Mask R-CNN in OpenCV (Python / C++)](https://www.learnopencv.com/deep-learning-based-object-detection-and-instance-segmentation-using-mask-r-cnn-in-opencv-python-c/) | [Code](https://github.com/spmallick/learnopencv/tree/master/Mask-RCNN) | |[Install OpenCV 4 on Ubuntu 18.04 (C++ and Python)](https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/) | [Code](https://github.com/spmallick/learnopencv/blob/master/InstallScripts/installOpenCV-4-on-Ubuntu-18-04.sh) |