Skip to main content

Posts

Opencv with OpenGL (installation and trials)

so i needed to install opengl for a 2D/3D test using opencv since Opengl libraries come preinstalled just needed to download GLUT from: http://www.xmission.com/~nate/glut.html since im running on a 64bit machine i need to place the GLUT32.dll in the C:\Windows\SysWOW64 instead of C:\Windows\System32 i then place the GLUT.h in the: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include and the GLUT32.lib in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib in the visual studio dependencies i just add the following: opengl32.lib glut32.lib glu32.lib and im all set and good to go with the test program /**********************************   Simple.cpp   A simple GLUT program. ****************************************************************************/ #include <string.h> #include <glut.h> void mydisplay( void ) {     glClearColor (0.0, 0.0, 0.0, 0.0);     glClear(GL_COLOR_BUFFER...

Histogram computation on a video

Histograms are collected counts of data organized into a set of predefined bins   refracted class for histogram: given an input image, output the histogram image class atsHistogram { public:     cv::Mat DrawHistogram(Mat src)     {         /// Separate the image in 3 places ( R, G and B )          vector<Mat> rgb_planes;          split( src, rgb_planes );          /// Establish the number of bins          int histSize = 255;          /// Set the ranges ( for R,G,B) )          float range[] = { 0, 255 } ;          const float* histRange = { range };          bool uniform = true; bool accumulate = false;   ...

Nose Tracking using Kalman Filter and Viola and Jones Classifier

class atsKalman { public:     atsKalman()     {         KalmanFilter KF(4, 2, 0);         Mat_<float> state(4, 1); /* (x, y, Vx, Vy) */         Mat processNoise(4, 1, CV_32F);         Mat_<float> measurement(2,1);         measurement.setTo(Scalar(0));         KFs = KF;         measurements = measurement;     }     void setKalman(int x, int y)     {         KFs.statePre.at<float>(0) = x;         KFs.statePre.at<float>(1) = y;         KFs.statePre.at<float>(2) = 0;         KFs.statePre.at<float>(3) = 0;       ...

Artificial Intelligence (K Nearest Neighbor) in OPENCV

In pattern recognition , the k -nearest neighbor algorithm ( k -NN) is a method for classifying objects based on closest training examples in the feature space . k -NN is a type of instance-based learning , or lazy learning where the function is only approximated locally and all computation is deferred until classification. The k -nearest neighbor algorithm is amongst the simplest of all machine learning algorithms: an object is classified by a majority vote of its neighbors, with the object being assigned to the class most common amongst its k nearest neighbors ( k is a positive integer , typically small). If k = 1, then the object is simply assigned to the class of its nearest neighbor. The k -NN algorithm can also be adapted for use in estimating continuous variables. One such implementation uses an inverse distance weighted average of the k -nearest multivariate neighbors. This algorithm functions as follows: Compute Euclidean or Mahalanobis distance from target plo...

Artificial Intelligence (support vector machine (SVM)) in OPENCV

A support vector machine ( SVM ) is a concept in computer science for a set of related supervised learning methods that analyze data and recognize patterns, used for classification and regression analysis . The standard SVM takes a set of input data and predicts, for each given input, which of two possible classes the input is a member of, which makes the SVM a non- probabilistic binary linear classifier . Given a set of training examples, each marked as belonging to one of two categories, an SVM training algorithm builds a model that assigns new examples into one category or the other. An SVM model is a representation of the examples as points in space, mapped so that the examples of the separate categories are divided by a clear gap that is as wide as possible. New examples are then mapped into that same space and predicted to belong to a category based on which side of the gap they fall on. A Support Vector Machine (SVM) performs classification by constructing a...

Artificial Intelligence (Multilayered perceptrons) in OPENCV

Neural networks are models of biological neural structures. The starting point for most neural networks is a model neuron. Each input is modified by a weight , which multiplies with the input value. The neuron will combine these weighted inputs and, with reference to a threshold value and activation function, use these to determine its output. This behavior follows closely our understanding of how real neurons work.  Neural neworks are typically organized in layers. Layers are made up of a number of interconnected 'nodes' which contain an 'activation function'. Patterns are presented to the network via the 'input layer', which communicates to one or more 'hidden layers' where the actual processing is done via a system of weighted 'connections'. The hidden layers then link to an 'output layer' where the answer is output as shown in the graphic below.   Backpropagation is a common method of teaching artificial neural networks ...

OPENCV2 C++ basics (OOP) old style vs new style

Version 2.2 of the opencv library has divided its library into modules. These library modules have their own associated header files which is required therefore any code you see on the internet that looks like this: #include "cv.h" #include <cv.h> and so on is done using the old style, C or C++. However after the restructuring of the opencv library into modules, not all functionality was ported to the new style: #include <opencv2/core/core.hpp> one example of such method is the LOGPOLAR transform. Another thing to take note here is, the old deprecated IplImage is changed to the matrix cv::Mat. therefore you should avoid using such unless your using the old style. For the Log-Polar Transform i will be using this header file: #include <opencv2/imgproc/imgproc_c.h> Also to make things easy, ive created a class to convert between cv::Mat and IplImage class atsoldtonew { public:     IplImage convertOld(cv::Mat MatImage)     { ...