Ask Your Question

Kholofelo's profile - activity

2016-07-22 00:03:17 -0600 received badge  Good Question (source)
2016-06-11 15:06:51 -0600 received badge  Famous Question (source)
2015-08-17 08:42:25 -0600 received badge  Notable Question (source)
2015-02-19 07:56:56 -0600 received badge  Popular Question (source)
2013-10-10 17:52:59 -0600 commented answer Best way to apply a function to each element of Mat.

Thanks @Guanta for the suggestion. I wasn't aware of parallel_for_ . Also thanks @maythe4thbewithu for the testing :) made my life easier.

2013-10-10 17:50:25 -0600 commented answer Best way to apply a function to each element of Mat.

Thanks for your answer. However, it seems parallel_for_ is the best. As suggested by Guanta and tested by maythe4thbewithu

2013-10-09 04:05:48 -0600 received badge  Nice Question (source)
2013-10-08 09:28:35 -0600 asked a question Best way to apply a function to each element of Mat.


I need to apply a function to each element of a matrix (in a Mat object). For example, I need to calculate the hyperbolic tangent (tanh) of each value in the Mat.

I know that I can access each element of a Mat M by<T>(i,j) as such I can implement the algorithm (just pseudocode) as follows:

for( i = ... )//through each row in Mat M
    for(j = ...)//through each column<T>(i,j) = tanh(<T>(i,j) );

This works. But it is rather slow as I'm working on a real time system that needs to do the same operation over and over.

Is there is perhaps someway to collectively apply the same function (perhaps by passing a function pointer) to each element in a Mat at the same time? That would be quite helpful.

Thanks in advance :)

2013-10-08 07:52:19 -0600 commented answer Extending Haar features

Hey Steven, thanks a lot for your answer. I ended up needing to make many more changes and it was much better to write my own classifier from scratch.

2013-10-08 07:51:01 -0600 received badge  Scholar (source)
2013-08-12 08:22:33 -0600 commented answer Extending Haar features

So I have narrowed my search down to the class CvHaarEvaluator::Feature::Feature in the file haarfeatures.cpp which is the folder PATH_TO_OPENCVLIB/apps/traincascade. Once I actually get this to work I will update the question with an answer.

2013-08-08 08:04:13 -0600 received badge  Supporter (source)
2013-08-08 08:03:31 -0600 commented answer Extending Haar features

Thanks Steven.

I have noticed that the actual xml file used in the cascade classifier has some defines the rectangles used for the features as well as the threshold for classification. So the classifier has to be trained accordingly and I think the generated xml file would also have the definitions of the features (their respective rectangles and threshold). (So the looking at the classification process alone won't be sufficient).

So I will try your suggested approach but I'll try and find the source used for training and producing the xml file. I will keep you updated. Thanks again.

2013-08-07 23:03:40 -0600 received badge  Student (source)
2013-08-07 20:33:16 -0600 received badge  Editor (source)
2013-08-07 20:30:54 -0600 received badge  Organizer (source)
2013-08-07 20:08:19 -0600 asked a question Extending Haar features

Short question

How can I use custom features in a Haar cascade classifier? Custom feature implies that using features that are not supported by opencv. i.e not one of these:

image description

More details:

I need to implement and train my own custom Haar-cascade classifier in opencv.

There is already an option to train the classifier with my own dataset but I also need to change the basic Haar-features used. All I can do is choose from the given subsets (Edge features,Line features and Center-surround features). I already have a set of Haar-features I need to use which I tested on Matlab.

I am looking of some way to specify my features (for example provide a couple of rects which define my Haar-features).

For example suppose I needed to create this feature:

Custom Haar-feature

It would be helpful if I could specify this feature to be part of the classifier's feature space. Supposing that the square is 20x20. I would like to specify it as follows:

  • rect1 (0, 0, 9 9)
  • rect2 (10, 0,19, 9)
  • rect3 (0, 10,9,19)
  • rect4 (10,10,19,19)

Assuming that the rects are defined by their two corners in the form (xi,yi,xf,yf).

Thanks in advance.