I need to implement a software for tracking of moving objects in image streams using the condensation algorithm and the OpenCV library. I have read that OpenCV includes an implementation of this algorithm, but I did not find examples or tutorials that explain how to use the corresponding functions available in OpenCV.
The cvCreateConDensation function allocates the CvConDensation structure and requires the dimension of the state vector (dynam_params), the dimension of the measurement vector (measure_params) and the number of samples (sample_count).
The dimension of the state vector should refer to the object state: for example, if the state could be the center point of the tracked object, then the state vector should contain the two coordinates of the center of the object, so the dimension of the state vector should be 2 in this case; in a similar manner, if the state of an object is formed by S points belonging to its shape, then I will specify 2*S as dynam_params value (ie the number of coordinates is equal to 2*S). Is this correct?
The number of samples is the number of particles, therefore the parameter sample_count must be set with the number of particles to be used for the tracking of the object.
What about the dimension of the measurement vector? What is the purpose the measure_params parameter?
The cvConDensInitSampleSet function initializes the sample set for the condensation algorithm. Which rule is used to initialize the sample set? Which distribution is used to initialize the sample set? Given the starting position and the bounding box of the object to be tracked, how does this function initialize the sample set?
What is the function that performs a complete interaction (select, predict and measure) of the algorithm? How do the samples are updated?
Is there any tutorial that explains in detail how to use the functions available in OpenCV?
A working example of condensation algorithm can be found in the Q&A of opencv and ross (same author):
http://answers.ros.org/question/55316/using-the-opencv-particle-filter-condensation/
and
http://answers.opencv.org/question/6985/syntax-for-particle-filter-in-opencv-243/
Here is another implementation of a particle filter, and the OpenCV and GSL libraries were used. The source code provided by the author is easy to read. Maybe you can learn something from it.
Related
I have a project where CGAL::Exact_predicates_exact_constructions_kernel is used for CGAL::Arrangement_with_history_2. Now there is a task to add a property to each point which should not affect point operations (just extra data providing). I read tutorial from CGAL Extensible Kernel guide, but it looks strange and difficult to override all geometric operations and classes for all geometric traits. Also, it is not very clear how to support lazy operations and Interval arithmetic, how is it works in CGAL::Epeck.
Edit: Vertex record in the DCEL can't be used because not every point has DCEL vertex (CGAL vertices is the edge ends, but the edges have intermediate points |Points| >= |Vertices|)
I found Weighted_point_2.h, which define Weighted_pointC2 class with scalar field. Can this type of point be used for CGAL::Epeck kernel? Maybe there is a example?
Maybe there is an example code where the code for creating a Epeck-like kernel for a custom point?
This is my first image processing application, so please be kind with this filthy peasant.
THE APPLICATION:
I want to implement a fast application (performance are crucial even over accuracy) where given a photo (taken by mobile phone) containing a movie poster finds the most similar photo in a given dataset and return a similarity score. The dataset is composed by similar pictures (taken by mobile phone, containing a movie poster). The images can be of different size, resolutions and can be taken from different viewpoints (but there is no rotation, since the posters are supposed to always be right-oriented).
Any suggestion on how to implement such an application is well accepted.
FEATURE DESCRIPTIONS IN OPENCV:
I've never used OpenCV and I've read this tutorial about Feature Detection and Description by OpenCV.
From what I've understood, these algorithms are supposed to find keypoints (usually corners) and eventually define descriptors (which describe each keypoint and are used for matching two different images). I used "eventually" since some of them (eg FAST) provides only keypoints.
MOST SIMILAR IMAGE PROBLEM AND LSH:
The problems above doesn't solve the problem "given an image, how to find the most similar one in a dataset in a fast way". In order to do that, we can both use the keypoints and descriptors obtained by any of the previous algorithms. The problem stated above seems like a nearest neighbor problem and Locality Sensitive Hashing is a fast and popular solution for find an approximate solution for this problem in high-dimensionality spaces.
THE QUESTION:
What I don't understand is how to use the result of any of the previous algorithms (i.e. keypoints and descriptors) in LSH.
Is there any implementation for this problem?
I will provide a general answer, going beyond the scope of OpenCV library.
Quoting this answer:
descriptors: they are the way to compare the keypoints. They
summarize, in vector format (of constant length) some characteristics
about the keypoints.
With that said, we can imagine/treat (geometrically) a descriptor as point in a D dimensional space. So in total, all the descriptors are points in a D dimensional space. For example, for GIST, D = 960.
So actually descriptors describe the image, using less information that the whole image (because when you have 1 billion images, the size matters). They serve as the image's representatives, so we are processing them on behalf of the image (since they are easier/smaller to treat).
The problem you are mentioning is the Nearest Neighbor problem. Notice that an approximate version of this problem can lead to significant speed ups, when D is big (since the curse of dimensionality will make the traditional approaches, such as a kd-tree very slow, almost linear in N (number of points)).
Algorithms that solve the NN problem, which is a problem of optimization, are usually generic. They may not care if the data are images, molecules, etc., I for example have used my kd-GeRaF for both. As a result, the algorithms expect N points in a D dimensional space, so N descriptors you might want to say.
Check my answer for LSH here (which points to a nice implementation).
Edit:
LSH expects as input N vectors of D dimension and given a query vector (in D) and a range R, will find the vectors that lie within this range from the query vector.
As a result, we can say that every image is represented by just one vector, in SIFT format for example.
You see, LSH doesn't actually solve the k-NN problem directly, but it searches within a range (and can give you the k-NNs, if they are withing the range). Read more about R, in the Experiments section, High-dimensional approximate nearest neighbo. kd-GeRaF and FLANN solve directly the k-NN problem.
I have a dataset from custom abstract objects and a custom distance function. Is there any good SVM libraries that allows me to train on my custom objects (not 2d points) and my custom distance function?
I searched the answers in this similar stackoverflow question, but none of them allows me to use custom objects and distance functions.
First things first.
SVM does not work on distance functions, it only accepts dot products. So your distance function (actually similarity, but usually 1-distance is similarity) has to:
be symmetric s(a,b)=s(b,a)
be positive definite s(a,a)>=0, s(a,a)=0 <=> a=0
be linear in first argument s(ka, b) = k s(a,b) and s(a+b,c) = s(a,c) + s(b,c)
This can be tricky to check, as you actually ask "is there a function from my objects to some vector space, phi such that s(phi(x), phi(y))" is a dot-product, thus leading to definition of so called kernel, K(x,y)=s(phi(x), phi(y)). If your objects are themselves elements of vector space, then sometimes it is enough to put phi(x)=x thus K=s, but it is not true in general.
Once you have this kind of similarity nearly any SVM library (for example libSVM) works with providing Gram matrix. Which is simply defined as
G_ij = K(x_i, x_j)
Thus requiring O(N^2) memory and time. Consequently it does not matter what are your objects, as SVM only works on pairwise dot-products, nothing more.
If you look appropriate mathematical tools to show this property, what can be done is to look for kernel learning from similarity. These methods are able to create valid kernel which behaves similarly to your similarity.
Check out the following:
MLPack: a lightweight library that provides lots of functionality.
DLib: a very popular toolkit that is used both in industry and academia.
Apart from these, you can also use Python packages, but import them from C++.
Anyone can help me to understand the difference among itk 4.8 data object. What are the difference between Vector Image, CovariantVector Image and Spatial Objects?
The itk::VectorImage class is merely an image where each image pixel has a list of values associated with it rather than a single intensity value.
I am not aware of any itk::CovariantVectorImage class or a similar class.
The itk::Vector class represents a mathematical vector with magnitude and direction with operators and methods for vector addition, scalar multiplication, the inner product of two vectors, getting a vector's norm, and so forth. You can also perform linear transformations on them using methods in the itk::AffineTransform, mainly the TransformVector() method. This is not related to C++'s std::vector container object, which is really a dynamic array data structure.
The itk::CovariantVector class is similar to itk::Vector, except it represents a covector rather than a vector. Covectors represent n-1-dimensional hyperplanes, (2D planes in the case of 3D space), and so their components transform in the opposite way that a vector's components do. itk::AffineTransform's TransformCovariantVector() method will transform a itk::CovariantVector object according to covariant transformation laws.
The itk::SpatialObject class allows you to create objects that exist in physical n-dimension space such as boxes, ellipses, tubes, planes, and cylinders, and relate these objects through parent-child relationships. You can read Chapter 5 of the ITK software manual for more information on this topic.
I am implementing the Good Features To Track/Shi-Tomasi corner detection algorithm on CUDA and need to find a way to parallelize the following part of the algorithm:
I start with an array of points obtained from an image sorted according to a certain intensity value (an eigenvalue of a previous calculation).
Starting with the first point of the array, I remove any point in the array that is within a certain physical distance of the first point. (This distance is calculated on the image plane, not on the array).
On the resulting array, we repeat step two for the remaining points.
Is this somehow parallelizable, specifically on CUDA? I'm suspecting not, since there will obviously be dependencies across the image.
I think the article Accelerated Corner-Detector Algorithms describes the way to solve this problem.