Fangyijie Wang


  • Home

  • Archives

  • Tags
Fangyijie Wang

Issues found during OpenCV Python installation

Posted on 2018-03-27

In last article, I’ve shared my story about how to install OpenCV 3.1.0 associated with Python 3.5 on Ubuntu system. Continue with it, I’m going to share some issues I found during installation of OpenCV and Python.

Details of my local environment:

  • ubuntu 16.04 LTS
  • Python 3.5.2
  • OpenCV 3.1.0

Anaconda installed before virtual environment setup

As my last article mentions, it’s highly recommended to create virtual environment to install and use Python. However on my local machine, I installed Ananconda which includes many useful Python libs. If you are familiar with Anaconda, it is a very handy software for Python development.

As I already have Anaconda (Python 3.5) on my machine, When I want to install OpenCV, I found and installed a OpenCV library associated with Anaconda. You could follow installation instructions on my last article, but skip the part of creating virtual environment. Please note you will need to change CMake commands like below:

1
2
3
4
5
6
7
8
9
10
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=~/anaconda3/envs/py35/bin \
-D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
-D PYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
-D PYTHON3_NUMPY_INCLUDE_DIRS=~/anaconda3/envs/py35/site-packages \
-D BUILD_EXAMPLES=ON ..

You need to point PYTHON_EXECUTABLE and PYTHON3_NUMPY_INCLUDE_DIRS to location of Python 3.5 and Numpy respectively. I believe they are all in Anaconda folder. Then you can build OpenCV with CMake. I guess the output would be like below screenshot:
cmake anaconda py35

In my case, the output says OpenCV is associated with Python 3.5 (from Anaconda). But when I try to import cv2 in Python environment, below error shown up:
cmake error

I googled lots of docs related with this error, but no luck… No solution is working for me unless I deleted Anaconda completely, create virtual environment and install everything from scratch.

Permission issue

Also, I found another permission issue maybe caused by Anaconda on my local machine. The error is shown up during CMake build:
permission error

After I did lots of research on this issue, again my final stupid solution is deleteing Anaconda and start everything from scratch.

Currently I only have above two issues when I was installing OpenCV and Python on Ubuntu. If you know the better solutions to solve them, please let me know ! Thanks a mil.

Fangyijie Wang

Ubuntu Install OpenCV 3.0 And Python 3

Posted on 2018-03-26

A few days ago, I was playing around with some interesting object detection projects using OpenCV and Python3. In this blog, I’d like to share some issues I found during installation and development environment setup.

Details of my dev environment:

  • ubuntu 16.04 LTS
  • Python 3.5.2
  • OpenCV 3.1.0

Now, I’ll show you how to install them and set up a dev environment probably.

Install dependencies

First there are lots of libs and dependencies before you start installing Python or OpenCV. Please see below lists of commands. It’s better to follow them step and step to install all of them.

Upgrade any pre-installed packages:

1
2
sudo apt-get update
sudo apt-get upgrade

Install tools to compile OpenCV 3.1.0:

1
sudo apt-get install build-essential cmake git pkg-config

If you are going to develop object detection functionalities on images, then below libraries and packages are needed:

1
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev

Also, if you need to work on videos, below libraries are needed as well:

1
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

Install packages that are used to optimize various functions inside OpenCV, such as matrix operations:

1
sudo apt-get install libatlas-base-dev gfortran

After you run above commands to install all libraries and packages without errors, you are ready to go next step - setting up Python environment.

Read more »
Fangyijie Wang

Fix black screen issue - Ubuntu

Posted on 2018-03-02

If you are using Ubuntu and recently you just updated Ubuntu system, you may face black screen issue when the system is rebooted. The situation looks like that after entering the username and password in the login screen, you are able to login but the screen is black. Then you cannot see any icons or menus. It never goes back to normal screen.

One probable reason is that the system update packages are not installed cleanly and the graphical desktop environment is set to a broken state. There is a easy and quick way to fix this issue.

Read more »
Fangyijie Wang

How to install python2 & 3 together in Windows

Posted on 2017-06-20

This post will introduce how to install Python 2 and Python 3 together in Windows 7 on the same PC.

Read more »
Fangyijie Wang

Git error - current branch is behind its remote counterpart

Posted on 2017-01-31

It’s been a long time since I started playing with Github, but today I was facing a really wired git error when I tried to push my changes to origin/master branch. Because I’m not a professional guy in terms of git, I spent some time to figure it out and fix it. Here is the git error I met.

The error is below
error: faild to push some refs to ‘[my-github-repository]’

git error I had when push codes

Read more »
Fangyijie Wang

Configure custom DNS with Hexo

Posted on 2016-12-13

While using Hexo to set up a github.io blog, the default domain name is [your-github-username].github.io. To use a custom DNS for your personal blog, Github requires you to create a file named CNAME in master branch of your repository. Since Hexo3, if you simply added the CNAME file manually it would be overwritten at deployment time. So you could use Hexo plugin: hexo-generator-cname.

Read more »
Fangyijie Wang

How to use Hexo

Posted on 2016-11-19

Hexo is a fast, simple and powerful blog framework! Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask questions on GitHub.

Read more »
Fangyijie Wang

Fangyijie Wang

7 posts
15 tags
Github Linkedin
© 2016 - 2018 Fangyijie Wang
Powered by Hexo
Theme - NexT.Mist