Ask Your Question

charge's profile - activity

2017-04-22 08:17:16 -0500 received badge  Enthusiast
2017-04-21 06:13:52 -0500 asked a question opencv 3.1 ANN MLP

I have data of 300 unique object. Each object have 11 unique feature. I will feed this data in to ANN_MLP in teach .

After teaching i will get single object data. Using ANN_MLP predict i would like to know the best match out of 300 taught object.

My code is as follows:

#define UNIQUE_OBJECT 15
#define UNIQUE_FEATURE 11
void Teach()
{
    Mat train_data;
    Mat train_labels = Mat::zeros(UNIQUE_OBJECT, UNIQUE_OBJECT, CV_32F);
    for(int index=0;index<UNIQUE_OBJECT ;index++)
    {
        train_labels.at<float>(index, index) = 1.f;
    }
    for(int index=0;index<UNIQUE_OBJECT ;index++)
    {
        Mat singleRowImage= Mat::zeros(1,UNIQUE_FEATURE,CV_32FC1);
        float floatIndex=(float)(index);
        singleRowImage.setTo(floatIndex);
        singleRowImage.convertTo(singleRowImage,CV_32F);
        train_data.push_back(singleRowImage.reshape(1,1));
    }
    Ptr<ml::ANN_MLP> ann = ml::ANN_MLP::create();
    Mat layersSize = Mat(4, 1, CV_16U);
    layersSize.row(0) = Scalar(train_data.cols);
    layersSize.row(1) = Scalar(15);
    layersSize.row(2) = Scalar(15);
    layersSize.row(3) = Scalar(train_labels.cols);
    ann->setLayerSizes(layersSize);
    ann->setActivationFunction(ml::ANN_MLP::ActivationFunctions::SIGMOID_SYM);
    TermCriteria termCrit = TermCriteria(
                TermCriteria::Type::COUNT + TermCriteria::Type::EPS,
                100000,
                0.0000001
                );
    ann->setTermCriteria(termCrit);
    ann->setTrainMethod(ml::ANN_MLP::TrainingMethods::BACKPROP);
    Ptr<ml::TrainData> trainingData = ml::TrainData::create(
                train_data,
                ml::SampleTypes::ROW_SAMPLE,
                train_labels
                );
    ann->train(trainingData
               );
    cv::FileStorage fs("mlp_NEW.yml", cv::FileStorage::WRITE); // or xml
    ann->write(fs);
}
void Inspect()
{
    //Current sample
    FileStorage ffs("mlp_NEW.yml", FileStorage::READ);
    Ptr<ml::ANN_MLP> ann = Algorithm::read<ml::ANN_MLP>(ffs.root());
        Mat test_data;
        for(int index=0;index<UNIQUE_OBJECT ;index++)
        {
            Rect cropRoi;
            cropRoi.x=0;
            cropRoi.y=index;
            cropRoi.width=UNIQUE_FEATURE;
            cropRoi.height=1;
            Mat singleRowImage= Mat::zeros(1,UNIQUE_FEATURE,CV_32FC1);
            float floatIndex=(float)(index);
            singleRowImage.setTo(floatIndex);
            singleRowImage.convertTo(singleRowImage,CV_32F);
            test_data.push_back(singleRowImage.reshape(1,1));
        }
        for(int i=0; i<test_data.rows; i++) {
            float pred  = ann->predict(test_data.row(i), noArray());
            cerr<<" Predict= "<<pred <<endl;
        }
}

This code is working OK if UNIQUE_OBJECT is equal to 15. I need it to be 300.

2016-02-03 05:53:52 -0500 commented question Linking opencv3.0 with Desktop Qt 5.5.1 MinGW 32 bit

I already used google, but i could not get answer. I done linking & code is compiling , but when i declare Mat object it gives an error. My system is win 7. My opencv3 is for windows(it is working properly with vs express 2012).But i want to run it using QT 5.5.1 MinG 32 bit.

2016-02-03 04:24:41 -0500 asked a question Linking opencv3.0 with Desktop Qt 5.5.1 MinGW 32 bit

How to link opencv3, Qt 5.5.1 MinGW 32 bit.

2015-11-23 06:10:16 -0500 commented question how optimize kaze descriptor

@thdrksdfthmn, image size is 1280x1024. and KAZE takes ard 900ms to execute & my target 100ms.

@Vit: how to create OpenCL version of KAZE? I am using opencv 3.0 on ubuntu 14.04 & using Qt 5.4.1 .

2015-11-17 05:52:44 -0500 received badge  Student (source)
2015-11-17 01:17:47 -0500 asked a question how optimize kaze descriptor

in opencv3 kaze/akaze descriptor is taking large time for execution? how to optimize this & reduce the execution time.

2013-05-24 11:02:01 -0500 answered a question Detecting multiple data matrix codes from high resolution image

sorry i don't have answer, infact i want to know that from where you find these "findDataMatrix function" as i could not found it, after searching a lot. can you help to find this funtion?