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 Ubuntu blog. #559

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
15 changes: 15 additions & 0 deletions Install-OpenCV-4-on-Ubuntu-from-source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.12)

PROJECT(Project)

SET(OpenCV_DIR /path/to/opencv/config)
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-Ubuntu-from-source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Code for Install OpenCV 4 on Ubuntu from source

This repository contains the sample code for [Install OpenCV 4 on Ubuntu from source](https://learnopencv.com/install-opencv-4-on-ubuntu-18-04/)

## Run Code:

### C++
```
mkdir build
cd build
cmake ..
cmake --build . --config Release
cd ..
./build/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-Ubuntu-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-Ubuntu-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-Ubuntu-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 @@ -100,7 +100,7 @@ Want to become an expert in AI? [AI Courses by OpenCV](https://opencv.org/course
|[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) |
|[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) |
|[Install OpenCV 4 on Ubuntu (C++ and Python)](https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/) | [Code](https://github.com/spmallick/learnopencv/blob/master/Install-OpenCV-4-on-Ubuntu-from-source) |
|[Install OpenCV 4 on Ubuntu 16.04 (C++ and Python)](https://www.learnopencv.com/install-opencv-4-on-ubuntu-16-04/) | [Code](https://github.com/spmallick/learnopencv/blob/master/InstallScripts/installOpenCV-4-on-Ubuntu-16-04.sh) |
|[Multi-Person Pose Estimation in OpenCV using OpenPose](https://www.learnopencv.com/multi-person-pose-estimation-in-opencv-using-openpose/) | [Code](https://github.com/spmallick/learnopencv/tree/master/OpenPose-Multi-Person) |
|[Heatmap for Logo Detection using OpenCV (Python)](https://www.learnopencv.com/heatmap-for-logo-detection-using-opencv-python/) | [Code](https://github.com/spmallick/learnopencv/tree/master/heatmap)|
Expand Down