Ask Your Question

vidushig2's profile - activity

2017-05-02 00:42:57 -0600 commented question What should be default value of features for classification stored in csv file using svm classifciation

Someone please help in this question

2017-05-01 07:43:24 -0600 commented question What should be default value of features for classification stored in csv file using svm classifciation

Let me explain it again.There are 100 items that need to be classified using svm classification.Each items have some feature value corresponding to them.Now 75 items have 26 features and their corresponding value.Remaining 25 items have only 20 features and their corresponding value.These 100 items with their features are saved in csv file.What should be the default value of remaining 6 features of 25 items.There are 26 columns in csv file and 100 rows.75 items have all the 26 columns filled with values.25 items have 20 columns filled with values.What should be the default value of 6 columns of 25 items which have only 20 features.Should I write default value as 0.000000 or -1.000000 for features that are not part of 25 items.

2017-05-01 07:13:17 -0600 received badge  Editor (source)
2017-05-01 03:04:56 -0600 asked a question What should be default value of features for classification stored in csv file using svm classifciation

Hi, I am writing code in cpp. My task is to classify part of document image belongs to table or not.I have dataset consisting of 80 items.20 items have 20 features each.The value of each feature is stored in csv file.60 items have 26 features and their value is also stored in same csv file.Now 20 items have 20 features corresponding to them,and 60 items have 26 features.What should be the default value of 6 features of 20 items who have 20 .

2017-04-22 12:01:41 -0600 commented answer how to find optimal SVM parameters gamma and cost using grid search with 5-fold cross validation process?

The code is working.But it is not giving right answer

2017-04-22 06:17:56 -0600 commented question how to find optimal SVM parameters gamma and cost using grid search with 5-fold cross validation process?

Is the way i am using trainAuto function correct? I have dataset of 100 images.I need to detect tables from these images.I have divided dataset into two parts one for training and one for testing. For each document image , a component is extracted and features are determined for that component.26 Features are there for each component and i have saved these features in csv file. I just want to know how to optimize parameters gamma and cost using grid search with 5-fold cross-validation process?Or what value should i take for c and gamma to get correct results.

2017-04-22 05:42:01 -0600 asked a question how to find optimal SVM parameters gamma and cost using grid search with 5-fold cross validation process?

I'm using libsvm to classify my dataset but I'm not reaching good results with SVM. I think that it is because the parameters: Gamma and Cost were defined wrongly. I'm training the SVM with C-SVC and RBF Kernel.Please tell how to obtain optimal parameters using a grid-search with 5-fold cross-validation process. My complete code is given below

int main(int,char **)
{
Ptr<ml::TrainData> tdata = ml::TrainData::loadFromCSV("/home/vidushi/Desktop/new/vidtrain.csv",1,-2,0);
Mat data   = tdata->getTrainSamples();
int labels[38] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1};
Mat labelsMat(38, 1, CV_32SC1, labels);
Ptr<cv::ml::SVM> svm = cv::ml::SVM::create();
svm->setType(SVM::C_SVC);
svm->setKernel(SVM::RBF);
svm->setC(1000);
svm->setGamma(100);
Ptr<ml::TrainData> td = ml::TrainData::create(data, ROW_SAMPLE, labelsMat);
svm->trainAuto(td);
 Ptr<ml::TrainData> tdata1 = ml::TrainData::loadFromCSV("/home/vidushi/Desktop/new/vidtest1.csv",1,-2,0);
Mat data1   = tdata1->getTrainSamples();
Mat result;
svm->predict(data1,result);
cout<<result.rows<<" "<<result.cols<<"\n";
cout<<"result = "<< " " <<result<<"\n";
return 0;
}
2017-04-01 03:52:31 -0600 commented question Error while converting csv file into matrices form using CvMLData

That problem is removed.Now the error is coming in this line float res = svm->predict(data1);

OpenCV Error: Assertion failed (nsamples == 1) in predict, file /home/vidushi/Desktop/OpenCV/modules/ml/src/svm.cpp, line 1939 terminate called after throwing an instance of 'cv::Exception' This is the error generated

2017-04-01 01:26:35 -0600 commented question Error while converting csv file into matrices form using CvMLData

No image number is not my class label

2017-04-01 00:54:53 -0600 commented answer Error while converting csv file into matrices form using CvMLData

I wrote the following code int main(int,char **){ Ptr<ml::traindata> tdata = ml::TrainData::loadFromCSV("/home/vidushi/Desktop/new/training.csv",0,-2,0); Mat data = tdata->getTrainSamples(); int labels[11] = {1,1,1,1,1,1,1,1,1,1,1}; Mat labelsMat(11, 1, CV_32SC1, labels); Ptr<svm> svm = SVM::create(); svm->setType(SVM::C_SVC); svm->setKernel(SVM::LINEAR); svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 100, 1e-6)); svm->train(data, ROW_SAMPLE, labelsMat); Ptr<ml::traindata> tdata1 = ml::TrainData::loadFromCSV("/home/vidushi/Desktop/new/testing.csv",0,-2,0); Mat data1 = tdata1->getTrainSamples(); float res = svm->predict(data1); cout<<"result = "<<res&lt;&lt;"\n"; return="" 0;}error="" generated="" is="" :="" opencv="" error:="" assertion="" failed="" (nvars="=" (int)rowvals.size())="" in="" loadcsv,<="" p="">

2017-03-31 03:43:29 -0600 commented question Error while converting csv file into matrices form using CvMLData

It is comma seperated csv file and contains 10 decimal values in one row of csv file.The first column contains image number.Remaining 9 column contains features of the image in decimal form.Features could be like number of pixels in image,number of horizontal line in image. I tried using TrainData also but than also error was generated.I would be highly obliged if you could tell me how to use TrainData.

2017-03-31 03:18:50 -0600 asked a question Error while converting csv file into matrices form using CvMLData

I need to convert csv file into matrices.I wrote the following code.

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include "opencv2/imgcodecs.hpp"
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/ml.hpp>
#include <cstdlib>
#include<algorithm>
#include<fstream>
#include<string>
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace cv;
using namespace cv::ml;
using namespace std;
int main(int, char**){



    const char *CSV_FILE = "/home/vidushi/Desktop/new/training.csv";
    const char *CSV_FILE1 = "/home/vidushi/Desktop/new/testing.csv";
    CvMLData dataFile;
    CvMLData dataFile1;
    // Load matrix data in csv format
    if (dataFile.read_csv(CSV_FILE) != 0)
    {
        fprintf(stderr, "Can't read csv file %s\n", CSV_FILE);
        return -1;
    }
    Mat dataMat(dataFile.get_values()); // Default data type is float
    int labels[11] = {1,1,1,1,1,1,1,1,1,1,1};
    Mat labelsMat(11, 1, CV_32SC1, labels);

    CvMLData dataFile1;
    // Load matrix data in csv format
    if (dataFile1.read_csv(CSV_FILE1) != 0)
    {
        fprintf(stderr, "Can't read csv file %s\n", CSV_FILE1);
        return -1;
    }
    Mat dataMat1(dataFile1.get_values()); // Default data type is float


    Ptr<SVM> svm = SVM::create();
    svm->setType(SVM::C_SVC);
    svm->setKernel(SVM::LINEAR);
    svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 100, 1e-6));
    svm->train(dataMat, ROW_SAMPLE, labelsMat);


    float res = svm->predict(dataMat1);

    cout << "- Result of prediction:" << res;



    return 0;
}
When i try to compile this code.Error is generated - 
/home/vidushi/Desktop/new/svm_class.cpp:29:5: error: ‘CvMLData’ was not declared in this scope
     CvMLData dataFile;
     ^
/home/vidushi/Desktop/new/svm_class.cpp:30:14: error: expected ‘;’ before ‘dataFile1’
     CvMLData dataFile1;
              ^
/home/vidushi/Desktop/new/svm_class.cpp:32:9: error: ‘dataFile’ was not declared in this scope
     if (dataFile.read_csv(CSV_FILE) != 0)
         ^
/home/vidushi/Desktop/new/svm_class.cpp:37:17: error: ‘dataFile’ was not declared in this scope
     Mat dataMat(dataFile.get_values()); // Default data type is float
                 ^
/home/vidushi/Desktop/new/svm_class.cpp:41:14: error: expected ‘;’ before ‘dataFile1’
     CvMLData dataFile1;
              ^
/home/vidushi/Desktop/new/svm_class.cpp:43:9: error: ‘dataFile1’ was not declared in this scope
     if (dataFile1.read_csv(CSV_FILE1) != 0)
         ^
/home/vidushi/Desktop/new/svm_class.cpp:48:18: error: ‘dataFile1’ was not declared in this scope

Please tell how to resolve this error. I am using opencv 3.2.0, ubuntu 16.04 LTS.

2017-03-20 00:14:15 -0600 received badge  Enthusiast
2017-03-18 09:38:57 -0600 commented answer Convexity Defects in OpenCV 2.4.2

I need to find number of convex deficient region in image..following error is coming error: no match for call to ‘(std::vector<std::vector<cv::vec<int, 4=""> > >) (std::vector<cv::point_<int> >&, std::vector<int>&, std::vector<std::vector<cv::vec<int, 4=""> > >&)’ convexityDefects(contours[i], hullIndices, convexityDefects);

Please suggest how to resolve this error.

2017-03-15 04:39:07 -0600 commented question Find number of open horizontal line in image

I need to find open horizontal lines in an image.

2017-03-15 01:31:41 -0600 asked a question Find number of open horizontal line in image

I have an image consisting of text,tables and images. I need to extract tables from an image.Now tables are normally composed of both horizontal and vertical line sides.Whereas graphic objects , boundary of images tend to have 'open' lines that do not intersect other lines at one of its end. I want to find number of such horizontal and vertical lines.Is there an inbuilt method available in opencv.