BogoToBogo
  • Home
  • About
  • Big Data
  • Machine Learning
  • AngularJS
  • Python
  • C++
  • go
  • DevOps
  • Kubernetes
  • Algorithms
  • More...
    • Qt 5
    • Linux
    • FFmpeg
    • Matlab
    • Django 1.8
    • Ruby On Rails
    • HTML5 & CSS

Installing on Ubuntu 14

OpenCV_Logo.png  height=




Bookmark and Share





bogotobogo.com site search:






OpenCV - Ubuntu 14.04 64 bit
install required packages

We need the following packages:

$ sudo apt-get update

$ sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg 



Getting OpenCV source code from the Git Repository
$ mkdir OpenCV
$ cd OpenCV
$ git clone https://github.com/Itseez/opencv.git


Building OpenCV
$ cd opencv
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

...
Build files have been written to: ~/OpenCV/opencv/release

We may want to check if the output of cmake includes the following

FFMPEG:     YES
GStreamer:  YES
V4L/V4L2:   Using libv4l (ver 0.8.9)

Now, let's make and install it:

$ make
$ sudo make install

Then, we want to configure the system wide library search path. In the standard Ubuntu install, the opencv.conf file does not exist, so we need to create it. Let's open /etc/ld.so.conf.d/opencv.conf, then type in /usr/local/lib

$ sudo ldconfig

Append the following two lines to the file, /etc/bash.bashrc. We need to adjust the PKG_CONFIG_PATH environment variable since OpenCV libraries are in a nonstandard (/usr/local/lib) prefix so pkg-config can find them:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH




Files - source and CMakeLists.txt

I made my project directory ~/OpenCV/workspace/Display_image, and here is the source file, display_image.cpp, OpenCV's Hello World code:

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui_c.h>

using namespace cv;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
    {
      printf( "No image data \n" );
      return -1;
    }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}

Now we need to make our CMakeLists.txt file in "~/OpenCV/workspace/DisplayImage" and it looks like this:

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage display_image.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )




Run

Let's look at what files do we have now:

$ cd ~/OpenCV/workspace/Display_image
$ ls
display_image.cpp lena.png CMakeLists.txt

Then, run cmake:

$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/khong/OpenCV/workspace/DisplayImage
 
$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  CMakeLists.txt  display_image.cpp  lena.png  Makefile

$ make
$ ls
CMakeCache.txt  cmake_install.cmake  DisplayImage       lena.png
CMakeFiles      CMakeLists.txt       display_image.cpp  Makefile

$ ./DisplayImage lena.png
init done 

Now, we have a window that with an image:

lena_Ubuntu_opencv.png



By the way, what version of OpenCV am I running?

$ pkg-config --modversion opencv
3.0.0







Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization

YouTubeMy YouTube channel

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







OpenCV 3 -

image & video processing



Installing on Ubuntu 13

Mat(rix) object (Image Container)

Creating Mat objects

The core : Image - load, convert, and save

Smoothing Filters A - Average, Gaussian

Smoothing Filters B - Median, Bilateral




Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong








OpenCV 3 image and video processing with Python



OpenCV 3 with Python

Image - OpenCV BGR : Matplotlib RGB

Basic image operations - pixel access

iPython - Signal Processing with NumPy

Signal Processing with NumPy I - FFT and DFT for sine, square waves, unitpulse, and random signal

Signal Processing with NumPy II - Image Fourier Transform : FFT & DFT

Inverse Fourier Transform of an Image with low pass filter: cv2.idft()

Image Histogram

Video Capture and Switching colorspaces - RGB / HSV

Adaptive Thresholding - Otsu's clustering-based image thresholding

Edge Detection - Sobel and Laplacian Kernels

Canny Edge Detection

Hough Transform - Circles

Watershed Algorithm : Marker-based Segmentation I

Watershed Algorithm : Marker-based Segmentation II

Image noise reduction : Non-local Means denoising algorithm

Image object detection : Face detection using Haar Cascade Classifiers

Image segmentation - Foreground extraction Grabcut algorithm based on graph cuts

Image Reconstruction - Inpainting (Interpolation) - Fast Marching Methods

Video : Mean shift object tracking

Machine Learning : Clustering - K-Means clustering I

Machine Learning : Clustering - K-Means clustering II

Machine Learning : Classification - k-nearest neighbors (k-NN) algorithm



Matlab Image and Video Processing



Vectors and Matrices

m-Files (Scripts)

For loop

Indexing and masking

Vectors and arrays with audio files

Manipulating Audio I

Manipulating Audio II

Introduction to FFT & DFT

Discrete Fourier Transform (DFT)



Digital Image Processing 2 - RGB image & indexed image

Digital Image Processing 3 - Grayscale image I

Digital Image Processing 4 - Grayscale image II (image data type and bit-plane)

Digital Image Processing 5 - Histogram equalization

Digital Image Processing 6 - Image Filter (Low pass filters)

Video Processing 1 - Object detection (tagging cars) by thresholding color

Video Processing 2 - Face Detection and CAMShift Tracking












Contact

BogoToBogo
contactus@bogotobogo.com

Follow Bogotobogo

About Us

contactus@bogotobogo.com

YouTubeMy YouTube channel
Pacific Ave, San Francisco, CA 94115

Pacific Ave, San Francisco, CA 94115

Copyright © 2024, bogotobogo
Design: Web Master