Skip to main content

Build and Install OpenCV for Visual Studio 2015

Recently, I did a fresh installation of Windows 10 on my laptop and had to reinstall OpenCV. Since I use OpenCV version 3.0.0 in my office and have the source available, I decided to build it instead of downloading pre-compiled binaries. In this article, I will describe how I build OpenCV 3.0.0 using CMake and Visual Studio and set up my development environment.

Softwares

  • OpenCV 3.0.0
  • Visual Studio 2015 Community Edition
  • CMake 3.9.3

Description

I put the OpenCV source (extracted) in C:\opencv\sources directory. The reason is simply to make it identical to my office PC. Other uses of directories/names in this article is also for the same purpose. I already had Visual Studio 2015 installed. I downloaded and installed CMake and opened the graphical UI application CMake (cmake-gui) from the Start menu.

In CMake, I selected the source folder C:\opencv\sources through Browse Source button. I also selected C:\opencv\sources\build as the directory for building binaries. Then I pressed Configure button. In the pop-up window, I selected Visual Studio 14 2015 as the generator and selected the option Use default native compilers. After configuration was completed, there were several warnings, but I ignored them.

I only changed the option CMAKE_INSTALL_PREFIX to C:\opencv\build. I used default values for all other options. I pressed the Generate button and waited for CMake to generate the project files for building OpenCV. Then I opened the generated projects in VS2015 using the Open Project button.

In VS2015, I build all projects using Build Solution. for both Debug and Release configurations. 54 projects were built succefully, 23 skipped and a 2 failed due to errors. I ignored the failed projects as I don't need those functionalities.

Then I built the INSTALL project (under CMake Targets in Solution Explorer) which was skipped in the last step. This will create three folders in the location C:\opencv\build as directed during CMake configuration step. They are:

  • include: contains header files
  • etc: data files for cascade classifiers
  • x86: binary and library files in separate subdirectories

The final step is to include the location C:\opencv\build2\x86\vc14\bin in system path so that programs using OpenCV library can find the necessary DLLs.

Comments

Popular posts from this blog

DigitalOcean droplet: Repair broken Ubuntu with recovery ISO

Recently, I needed to repair a Ubuntu droplet server that was stuck in a kernel panic. The server maintainer decided to upgrade the OS from Ubuntu 16.04 to 18.04. Everything went well until the final restart after the upgrade when the dorplet was stuck during boot. The maintainer could not SSH into the system and the website was down as well. In the DO control centre, CPU usage of the droplet was showing 100% and the console was showing the kernel panic state and the system calls that caused it. I searched around and found this post that had a similar problem and solved it. Basically, these are the steps: Boot into the recovery ISO Mount and chroot into the existing filesystem Reinstall the kernel From the console commands, it was obvious that the solution was for REHL based distributions and I will need to use ' apt ' instead of ' yum ' for Ubuntu. I found the appropriate command after a bit of digging: apt-get install --reinstall linux-image-generic linux-i

Set up Zotero Attachment File Synchronisation with Google Drive

Background I had a ton of downloaded PDF papers. These files were unorganised and kept in a folder in my Google Drive. I learned about Zotero from a colleague and started using it. I was very impressed at the begining for its convenience and ease of use. Just drag a PDF file into Zotero , and select an option to retreive metadata from the PDF and viola! A proper citation record is ready! I can export it to bibtex format in order to use the citation in Latex, or include it in MS Word in my preferred citation style. The most exciting feature of Zotero for me was the ability to take notes on a paper and keep them organised. I can search for a paper/topic, and open a relevant paper PDF from zotero. I can write comments on that PDF or take notes and everything will be synced to the server. However, soon I began to notice some issues. Zotero didn't use the downloaded PDF files, but included a copy of them instead. These copies were being synced to the Zotero server and soon filled my 3

Finding Optimal PDF Paper Size for Kobo Clara HD Ereader

tl;dr: Optimal page layout for Kobo Clara HD ereader: Width: 9cm, Height: 11.1cm, margins: 0.5cm. **** I have recently bought a Kobo Clara HD ereader. I used to own a Glo HD ereader by the same company, until I accidentally pushed it off the table causing its display to crack. Though I prefer EPUB format for reading on an ereader, there are many cases when a PDF format might be more convenient. However, regular PDF files are difficult to read on the ereader for their large page sizes. The PDF viewer of the device scales a page to fit its display causing tiny texts. I can zoom in a section to read, however I need to swipe and drag around to view other areas which is really not convenient due to slow response time of e-ink display. Worse is when I accidentlly tap the display, causing it  to immediately turn the next page. I need to go back to previous page and go through all the zooming and dragging before I can resume reading. Therefore I always wanted to generate a PDF optimized