Ask Your Question

JNB's profile - activity

2018-05-07 08:06:33 -0600 received badge  Popular Question (source)
2013-12-03 10:19:23 -0600 answered a question Convert between depth values and depth types

I have the same question, but I'd like to do this all at runtime, since the depth of my matrix depends on the user input. Maybe what I want to do is clearly impossible, but I just don't have a clue...

So is it possible to use Adi's code but instead of having a myTemplateFunc<cv_8u>() or so, having a myTemplateFunc<mymat.depth()&gt;();< p="">

I know this is not possible as is, my compiler keeps on complaining about it, but is there another way to achieve that ?

2013-11-20 08:36:57 -0600 received badge  Supporter (source)
2013-11-14 09:55:58 -0600 answered a question cv::format does not format the way it should.

I finally got into the code to understand why this bug occurred, and I think I figured it out, finally. But I don't know how to submit it so everybody's opencv is fixed in next release.

The problem was in file /ROOT/modules/core/src/out.cpp, at lines 151, 168, 190, 207, and 226, when calling the writeMat() method. The last parameter called singleLine is a Boolean which is true if the data matrix has only one line, so as not to print the final \n if it is the case.

But each time this function is called, the number of colons is given instead of the number of lines !

therefore the correction of the code would be changing writeMat(out, m, ';', ' ', m.cols == 1); into writeMat(out, m, ';', ' ', m.rows == 1); or similar process at each of the lines given above.

I tested it and it works fine !

2013-11-04 09:39:35 -0600 commented question cv::KNearest : change distance used

Right, I did not look at it, and it will be helpful to understand which measure is used for now. But does this mean that there is nothing already built in to change the distance used ? Changing OpenCV does not seem like a good option to me, since my code is a small part of a big framework which should be easy to install on other machines. Changing the libraries make it less portable and I would have to find another knn implementation or implement one myself.

2013-11-04 06:14:14 -0600 asked a question cv::KNearest : change distance used

I am currently using cv::KNearest to classify some images and it works fine, but I can't seem to find which distance is used to find out "how near" are the train samples. My guess would be Euclidean but I didn't find any clue to confirm that.

Moreover I'd like to try several distance measures to compare their efficiency, as I was told that chi-square performs best in my application. Is it possible to do so with this implementation of the KNN algorithm?

thanks by advance for your answers !

2013-09-24 03:07:51 -0600 commented question cv::format does not format the way it should.

I can't seem to make your method work... OpenCV won't recognize FMT_CSV constant... (my version is 2.4.1)

2013-09-23 06:40:41 -0600 received badge  Editor (source)
2013-09-23 06:37:30 -0600 asked a question cv::format does not format the way it should.

I started to use cv::format() a while ago to format my data in a CSV like text stream, and noticed it worked oddely : no problem of importance when used on a N * P cv::Mat where P is greater or equal to 2. The only matter then would be the useless spaces before each row but the first, but we can trim them afterwards easily.

But when P is equal to 1 (the matrix is a column), cv::format() does not seem to add the end of line signals between lines and I end up with a single line full of characters with no separation in between.

Here is an exemple, where I fill up two matrices and display them before and after using cv::format() :

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;

int main()
{
  int dimensions = 5;
  int sampleCount = 4;

  cv::Mat points(sampleCount,dimensions, CV_32F,cv::Scalar(10));
  cout<<points<<endl;
  cout<<cv::format(points,"csv")<<endl;

  cv::Mat points2(sampleCount,1, CV_32F,cv::Scalar(10));
  cout<<points2<<endl;
  cout<<cv::format(points2,"csv")<<endl;

  return 0;
}

The output given is :

[10, 10, 10, 10, 10;
  10, 10, 10, 10, 10;
  10, 10, 10, 10, 10;
  10, 10, 10, 10, 10]
10, 10, 10, 10, 10
  10, 10, 10, 10, 10
  10, 10, 10, 10, 10
  10, 10, 10, 10, 10

[10; 10; 10; 10]
10101010

The extra spaces in the first case seem to come from the << operator which gives a nicer display since it displays a bracket on first line.

As for the second and most important case, I don't know where it comes from but I think this should be fixed.

Note the "csv" format seems not to be the only one with this kind of output, I tried with "python" and got a similar [10101010] output.