Tuesday, December 17, 2013

Installing OpenCV 2.4.6 in Visual Studio 2012



Step 1
Download OpenCV from here
unzip and change the name of opencv to OpenCV2.4.6

add to system path:

C:\OpenCV2.4.6\build\x64\vc10\bin

Step 2:
Open Visual Studio 2012 and create a new console win32 application preferrebly uncheck the precomplied hadear and security options
Go to BUILD -> Configuration Manager
Click on Win32 and create a new x64


Step 3:
Go to Project properties and add the following :
C/C++ -> Additional Include Directories

C:\OpenCV2.4.6\build\include\opencv;C:\OpenCV2.4.6\build\include;


Linker-> General -> Additional Library Dependencies

C:\OpenCV2.4.6\build\x64\vc10\lib



Linker->Input-> Additional Dependencies
Release mode:

opencv_core246.lib
opencv_imgproc246.lib
opencv_highgui246.lib
opencv_ml246.lib
opencv_video246.lib
opencv_features2d246.lib
opencv_calib3d246.lib
opencv_objdetect246.lib
opencv_contrib246.lib
opencv_legacy246.lib
opencv_flann246.lib

for Debug mode:

opencv_core246d.lib
opencv_imgproc246d.lib
opencv_highgui246d.lib
opencv_ml246d.lib
opencv_video246d.lib
opencv_features2d246d.lib
opencv_calib3d246d.lib
opencv_objdetect246d.lib
opencv_contrib246d.lib
opencv_legacy246d.lib
opencv_flann246d.lib

Step 4
Run this small snippet

#include "stdafx.h"

#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
        IplImage *img = cvLoadImage("image.jpg");
        cvNamedWindow("Image:",1);
        cvShowImage("image:",img);

        cvWaitKey();
        cvDestroyWindow("Image:");
        cvReleaseImage(&img);

        return 0;
}

Wednesday, October 23, 2013

Installing Opencv Python Bindings on Ubuntu

Installing OpenCV python binding on Ubuntu is easier using the software center. You don't have to compile the source code. You can just type
aptitude search opencv
in the command prompt to find which version you would like and then call apt-get
For instance on my computer I did:
sudo apt-get install opencv2.7-opencv

Tuesday, October 1, 2013

How to install Opencv 2.4.2 with ffmpeg 0.11.1 on Ubuntu 12.04

After dealing a lot of headache with trying to install Opencv to work with videos I came up with this tutorial:
http://www.ozbotz.org/opencv-installation/

I was able to confirm it works for the versions mentioned in this post. The installation of opencv with ffmpeg is so brittle and sensitive that any slight variation on the versions on either software and you will have to deal with bugs that you may or may not be able to fix. So make sure that if you follow a tutorial, that the versions you are installing are the ones on the tutorial. Good luck


Monday, September 23, 2013

Convnet issue: got nan or inf!

I was able to install the convnet library and  trying to replicate the 13% accuracy on the CIFAR10 dataset claimed. but my implementation would run a few epochs and then give me a message such as " got nan or inf" and the process would die. 
I would get a message such as  : 

5.1... logprob:  1.224800, 0.430300 (2.227 sec)
5.2... logprob:  1.251499, 0.436500 (2.165 sec)
5.3... logprob:     nan, 1.000000 ^ got nan or inf!


Sometimes it would run for 5 epochs and die other times would be 40. 

After emailing Alex Krizhevsky the author of the library, he said, "it can happen if the optimization becomes numerically unstable, but it can also be caused by a faulty GPU"

So I swtiched my GPU for a different one and it worked!
So if you see this problem, something simple you can do is just try a different GPU. Good luck

Thursday, February 28, 2013

prereq-opencv-linux


#!/bin/bash
echo ""
echo "starting installation of essential packages for opencv..."

apt-get install build-essential
apt-get install cmake
apt-get install pkg-config
apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3
apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2
apt-get install zlib1g-dbg zlib1g zlib1g-dev
apt-get install libjasper-dev libjasper-runtime libjasper1
apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog
apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev
apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin
apt-get install libunicap2 libunicap2-dev
apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
apt-get install swig
apt-get install libv4l-0 libv4l-dev
apt-get install python-numpy
apt-get install git