Here is a small example on how to set and get environmental variables using getnenv() and putenv() functions defined by C/C++ stdlib.h library. Environmental variable expansion is a great feature of a Linux shell as it enables programmers and users to rely on the environment settings of each user separately. C++ getenv() will read all exported environmental variables and putenv() will set existin...
In attempt to recognize objects by examining images, various Image processing and analysis techniques are applied. This article briefly describes linear stretch algorithm and its use within OpenCV.
Linear stretch technique can be applied to images where substantial lack of contrast can result in false identification of objects, its spacial relationship and significance. Contrast enhancement by ...
Here is a simple example of Binary Search in C++. The example first creates a vector of 4 000 000 numbers and then it makes a function call from main to Binary_Search function.
binary-search.cpp
#include <iostream>
#include <vector>
using namespace std;
void Binary_Search(const vector<int> &numbers, int value);
int main() {
vector <int>my_numbers;
...
Here is a small example of C++ code on how to read a characters from a file as well as to count the number lines of any particular file consist of. The code will check for "\n" the "new line character" and increase the number of lines stored in number_of_lines integer variable. Every iteration will also print single character including "\n" to an output. First create a file called my-input-fil...
This small C++ example program demonstrates an usage of templates within c++. In this example "template class array" can instantiate any type of arrays with single constructor and single setArray member function.
Such a behavior can also be done by overloading a constructors and setArray member function. However, in that case a programmer would need to write a member function declaration and def...
This small OpenCV program demonstrates how to separate RGB image into R, G and B components. The program is written in low level programming as there are build in function in OpenCV which would make this code more efficient. However, this example deepens an understanding on how image is split into matrix of pixels and how can each pixel can be manipulated separately.
WRITE CODE
#include <...
To covert color image to a gray scale has never been easier with OpenCV. Here is a small C++ program that does conversion from color image to a grayscale.
WRITE CODE
#include <iostream> #include "cv.h" #include "highgui.h" using namespace std; int main( int argc, char** argv )
COMPILE
g++ `pkg-config opencv --cflags --libs` convert_grayscale.cpp -o convert_grayscale
USAGE ...
This is a small code to resize an image to a desired percentage from an original. New size of width and height are calculated from a percentage supplied as a 3th argument. Supplying 100% will simply copy the original image to new image.
cvResize also accepts an interpolation argument, however in case of this small program we use the default linear interpolation.
#include <iostream> #incl...
Here is a simple program to display image attributes like width, height, size and etc. This program assumes that you have OpenCV library alredy installed on you system.
#include <iostream>
#include <iomanip>
#include "cv.h"
#include "highgui.h"
using namespace std;
int main( int argc, char** argv )
{
// Create an IplImage object *image
IplImage *image = cvLoadImage( ...
Here is a small program to clalculate Fibonacci numbers using c++ language. No tampering with the code needed ( only iprovements ! ) just copy and compile with g++ FibonacciNumber.cpp -o FibonacciNumber and run ./FibonacciNumber
#include <iostream>
#include <cstdlib>
void HowMany(int *numbers);
void CalculateFibonacci(int *numbers);
int main() {
int numbers = 0;
HowMany...
Recently I was tempted to have a look on OpenCV project and Oreilly’s book “Learning OpenCV” This is a great book and it assumes some basic C programming skills. However, it is not specific to any platform when it comes to compiling and running program examples. Here is a very short start with Ubuntu 9.04
Let’s start with installation of some useful packages into our ubuntu system:
apt...
Author: Lubos Rendek
Abstract
The purpose of this document is to help a reader to get started with Computer Vision library OpenCV on Linux system. OpencCV is a multi-platform library, but this article will be focused only on OpenCV using Linux operating system ( although, just the installation of the OpenCV library and video camera is platform-specific, all examples in this article should c...
Author: Lubos Rendek
Date: 10.09.2009
Update: 04.03.2010 - Section 7.2 created clarify relation between Pointers and Arrays in C++
Introduction
This article is intended to all programing enthusiasts on all levels who do wish to understand pointers in C++ language. All code presented here is not a compiler specific and all examples will be written in plain ANSI C++. Debate about pointe...
|