Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OpenCV 4 source installation Windows blog. #560

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Install-OpenCV-4-on-Windows-from-source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
30 changes: 30 additions & 0 deletions Install-OpenCV-4-on-Windows-from-source/README.md
Original file line number Diff line number Diff line change
@@ -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.

<a href="https://opencv.org/courses/">
<p align="center">
<img src="https://www.learnopencv.com/wp-content/uploads/2020/04/AI-Courses-By-OpenCV-Github.png">
</p>
</a>
Binary file added Install-OpenCV-4-on-Windows-from-source/boy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Install-OpenCV-4-on-Windows-from-source/sampleCode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <opencv2/opencv.hpp>
#include <iostream>

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;
}
17 changes: 17 additions & 0 deletions Install-OpenCV-4-on-Windows-from-source/sampleCode.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down