Ask Your Question

alexMm1's profile - activity

2020-04-18 08:28:29 -0600 received badge  Popular Question (source)
2020-01-14 09:56:04 -0600 received badge  Famous Question (source)
2019-05-20 15:11:35 -0600 received badge  Notable Question (source)
2018-12-10 21:01:27 -0600 received badge  Popular Question (source)
2018-01-09 03:24:51 -0600 commented question Open usb camera using name instead of index in openCV3.2

mmm...@kbarni, in this way I have to know the cam id...by the way, it does not work

2018-01-08 10:58:11 -0600 commented question Open usb camera using name instead of index in openCV3.2

videoMine is the name of the device I re-mapped.... suppose /dev/video0 in /dev/videoMine

2018-01-08 05:07:01 -0600 asked a question Open usb camera using name instead of index in openCV3.2

Open usb camera using name instead of index in openCV3.2 Hi all, I have an issue with my USB camera. When I plug it int

2017-05-24 10:30:41 -0600 asked a question Set multiple rows and single column at the same time in Matrix

Hi,

i'd like to know how to set multiple rows and single column at the same time in Matrix.

Ex:

Mat my_matrix = Mat::zeros(100, 4, CV_32S);

suppose that I want to set:

  • rows 0-24 column 1 as 1;
  • rows 25-49 column 2 as 1;
  • rows 50-74 column 3 as 1;
  • rows 75-99 column 4 as 1;
2017-05-24 08:29:56 -0600 received badge  Necromancer (source)
2017-05-24 08:28:29 -0600 answered a question Meaning of Output of Artificial Neural Network

The out value 2 means that the highest value in your output is output(2).....for this reason, your testdata is classified as class 3

2017-05-24 04:23:17 -0600 commented answer ANN in opencv 3

ok. thanks a lot....you are always "enlightening" in your answers ;)

2017-05-24 04:09:13 -0600 commented answer ANN in opencv 3

ok great....got the point. thanks! Last question (:P): do you know how to compute a confidence of the output label?

2017-05-24 04:05:12 -0600 commented answer How to get the confidence value of detections got through ANN_MLP?

yes, but sometimes the logit output is greater than 1...How you can determine a sort of confidence?

2017-05-24 03:55:00 -0600 commented answer ANN in opencv 3

no no...my question is: in the example above the labels are putted in the first two position of my feature vector: position 0 and position 1 of data matrix represent the label of the two classes

for (int i = 0; i<data.rows; ++i)
    {
        if (i < data.rows/2)
        {
            data(i, 0) = 1;
            data(i, 1) = 0;
        }
        else
        {
            data(i, 0) = 0;
            data(i, 1) = 1;
        }
    }

This is not correct in my opinion, isn't it? It shoud be responses instead of data

My second question was: how to choose the numbers of hidden layers? how many neurons I have to put?

2017-05-24 03:07:49 -0600 commented answer ANN in opencv 3

is it correct that my feature data should have in the first and second position the label of the class and the features themselves in the rest? as data matrix in the example above. furthermore, having a feature vector of 200 elements with 160 training samples (4 classes 40 elements per class), which should be the correct number of layerSize?

2017-05-23 05:44:09 -0600 commented answer ANN in opencv 3

what do you mean with "larger"? for example...having [-3.7452435, -4.7302642] is 1 the prediction label, isn't it?

2017-05-23 05:37:07 -0600 commented answer ANN in opencv 3

so, in my case, considering only two classes, it means that the prediction label is 0? (ps in case of two negative numbers is the max abs?)

2017-05-23 05:25:33 -0600 commented answer Loading a pre-trained KNN classifier - python

I got the point.....i tought that the method were the same. thanks for your clarification

2017-05-23 05:12:38 -0600 commented answer Loading a pre-trained KNN classifier - python

@berak....oops sorry

2017-05-23 05:09:05 -0600 answered a question Loading a pre-trained KNN classifier - python

This code save an img as xml but should be similar in your case:

import cv2
import numpy as np

img = cv2.cv.LoadImage('0.jpg',0)
cv2.cv.Save('sof.xml',img)
e=cv2.cv.Load("sof.xml")

print e
2017-05-23 05:05:15 -0600 asked a question ANN in opencv 3

Hi,

I was trying to run this example found in this forum:

#include <opencv2/ml/ml.hpp>

using namespace std;
using namespace cv;
using namespace cv::ml;

int main(int argc, char* argv[])
{
    //create random training data
    Mat_<float> data(100, 100);
    randn(data, Mat::zeros(1, 1, data.type()), Mat::ones(1, 1, data.type()));

    //half of the samples for each class
    Mat_<float> responses(data.rows, 2);
    for (int i = 0; i<data.rows; ++i)
    {
        if (i < data.rows/2)
        {
            data(i, 0) = 1;
            data(i, 1) = 0;
        }
        else
        {
            data(i, 0) = 0;
            data(i, 1) = 1;
        }
    }

    /*
    Mat_<float> responses(data.rows, 1);
    for (int i=0; i<responses.rows; ++i)
        responses(i, 0) = i < responses.rows / 2 ? 0 : 1;
    */

    //create the neural network
    Mat_<int> layerSizes(1, 3);
    layerSizes(0, 0) = data.cols;
    layerSizes(0, 1) = 100;
    layerSizes(0, 2) = responses.cols;

    Ptr<ANN_MLP> network = ANN_MLP::create();
    network->setLayerSizes(layerSizes);
    network->setActivationFunction(ANN_MLP::SIGMOID_SYM, 0.1, 0.1);
    network->setTrainMethod(ANN_MLP::BACKPROP, 0.1, 0.1);
    Ptr<TrainData> trainData = TrainData::create(data, ROW_SAMPLE, responses);

    network->train(trainData);
    if (network->isTrained())
    {
        printf("Predict one-vector:\n");
        Mat result;
        network->predict(Mat::ones(1, data.cols, data.type()), result);
        cout << result << endl;

        printf("Predict training data:\n");
        for (int i=0; i<data.rows; ++i)
        {
            network->predict(data.row(i), result);
            cout << result << endl;
        }
    }

    return 0;
}

Unfortunately, I'm not able to understand the meaning of the output: im my case, considering my test data, I obtain something like: [0.20409864, -0.15044725]

what does it mean? should I obtain a label class, isn't it? Am I doind something wrong?

2017-04-20 03:42:02 -0600 received badge  Enthusiast
2017-04-19 08:54:16 -0600 commented answer LibSVM and OpenCV 3.1

Thanks @StevenPuttemans ... one more question: if I have a cv::Mat structure instead of a file? all my features are in a Mat structure (as asked from the openCV SVM implementation)

2017-04-19 04:48:59 -0600 asked a question LibSVM and OpenCV 3.1

Hi Guys,

someone of you knows how to include LibSVM (http://www.csie.ntu.edu.tw/~cjlin/lib...) in OpenCV ? I would like to use LibSVM instead of OpenCV SVM that is less powerfull (i.e. no probability is given in multi-class problem).

I have an example with the predict function (http://kuantinglai.blogspot.it/2013/0...) but I don't know how to create the model.

Thanks in advance

M.

2017-04-19 03:31:04 -0600 commented question CHI2 response in opencv SVM

ok thanks @berak, understood

2017-04-14 08:03:36 -0600 commented question CHI2 response in opencv SVM

Linux ubuntu 16.04 and opencv3.0

2017-04-14 07:56:35 -0600 commented question CHI2 response in opencv SVM

the problem is in the use of ml::SVM::EPS_SVR instead of ml::SVM::C_SVC