Ask Your Question

Bekhouche's profile - activity

2016-06-28 08:46:53 -0600 asked a question vector Mat crashes

Hello,

I did sample code which add each time Mat to a vector

header :

std::vector<cv::Mat> Histograms

sources

 // hist -> cv::Mat
// each time add new hist
    Histograms.push_back(hist);
    std::cout << hist << std::endl;

//
for(unsigned int i = 0; i < Histograms.size(); i++) {
    std::cout << Histograms[i].cols << std::endl;
    std::cout << Histograms[i] << std::endl;
}

the cout of hist work normaly, but the cout of each Histgrams crashed, the weird thing each time crash in different row?

example of output :

59
[517, 45, 85, 46, 46, 46, 78, 84, 81, 236, 221, 132, 182, 262, 706, 134, 79, 189, 292, 438, 267, 53, 59, 66, 184, 315, 161, 85, 34, 57, 47, 135, 68, 65, 49, 65, 38, 91, 238, 44, 46, 21, 148, 183, 115, 42, 53, 331, 108, 26, 9, 180, 58, 53, 126, 37, 175, 325, 1160]
59
[536, 108, 61, 79, 36, 26, 85, 64, 42, 301, 450, 127, 92, 101, 549, 114, 128, 116, 235, 226, 120, 26, 76, 95, 133, 166, 97, 77, 41, 94, 80, 143, 146, 68, 45, 33, 82, 131, 254, 99, 56, 40, 326, 318, 148, 60, 100, 336, 183, 52, 49, 120, 80, 86, 105, 59, 153, 337, 1126]
59
[454, 95, 59, 94, 73, 72, 97, 72, 65, 127, 259, 100, 87, 100, 350, 119, 67, 96, 244, 332, 119, 66, 83, 92, 139, 318, 158, 68, 39, 93, 122, 260, 386, 140, 41, 72, 106, 102, 287, 203, 70, 31, 146, 210, 174, 90, 81, 330, 133, 84, 57, 162, 70, 90, 107, 39, 129, 334, 1023]
59
[470, 68, 85, 73, 45, 86, 118, 75, 93, 423, 537, 119, 103, 163, 661, 265, 86, 71, 128, 174, 204, 56, 44, 67, 98, 155, 77, 64, 28, 59, 63, 137, 149, 152, 68, 40, 58, 85, 192, 82, 79, 43, 204, 314, 141, 63, 125, 469, 139, 53, 30, 156, 50, 44, 46, 38, 150, 299, 1052]
59
[396, 61, 66, 77, 42, 87, 94, 88, 81, 282, 356, 163, 136, 165, 595, 180, 85, 122, 258, 306, 195, 63, 31, 94, 158, 316, 145, 102, 36, 69, 58, 252, 200, 119, 64, 46, 57, 84, 198, 69, 47, 35, 258, 331, 100, 41, 80, 337, 180, 40, 24, 168, 79, 44, 98, 52, 151, 289, 866]
59
[302, 97, 38, 91, 14, 43, 168, 41, 50, 338, 627, 163, 123, 178, 672, 136, 58, 126, 222, 451, 136, 41, 10, 45, 140, 292, 128, 89, 45, 62, 92, 166, 544, 127, 43, 29, 48, 83, 162, 87, 73, 24, 167, 385, 114, 91, 111, 410, 111, 32, 28, 162, 17, 24, 111, 18, 192, 176, 663]
59
    The program has unexpectedly finished.
2016-04-25 10:05:17 -0600 commented answer SVM model fails to load!

thank you :)

2016-04-25 10:04:59 -0600 received badge  Supporter (source)
2016-04-25 10:04:56 -0600 received badge  Scholar (source)
2016-04-25 09:53:18 -0600 commented answer SVM model fails to load!

I'm working on a framework where I must create the SVM instance in the header ...then load the model in the source, one time in the initializing function

2016-04-25 09:40:55 -0600 commented answer SVM model fails to load!

Thank you :) Is there any way to pass the load after create the instance?

2016-04-25 09:08:18 -0600 asked a question SVM model fails to load!

Hello, I trained an SVM model and save it in xml file, everythink look good. but when I load the model I print the getvar vaule its equal to 0? The model file looks fine to me?

 <?xml version="1.0"?>
<opencv_storage>
<opencv_ml_svm>
  <format>3</format>
  <svmType>C_SVC</svmType>
  <kernel>
    <type>LINEAR</type></kernel>
  <C>1.0000000000000001e-01</C>
  <term_criteria><epsilon>1.1920928955078125e-07</epsilon>
    <iterations>1000</iterations></term_criteria>
  <var_count>4096</var_count>
  <class_count>2</class_count>
  <class_labels type_id="opencv-matrix">
    <rows>2</rows>
    <cols>1</cols>
    <dt>i</dt>
    <data>
      1 2</data></class_labels>
  <sv_total>1</sv_total>
  <support_vectors>
    <_>
      -6.66133815e-15 -4.88498131e-15 -3.33066907e-15 -3.33066907e-15 0.

This is a part of the train code :

Ptr<ml::SVM> Model = ml::SVM::create();
Ptr<ml::TrainData> TrainData = ml::TrainData::create(Data, ml::ROW_SAMPLE, Label);
Model->setType(SVM);
Model->setKernel(Kernel);
Model->trainAuto(TrainData,5);
Model->save((*path));

Test part in other project :

Ptr<ml::SVM> classifier = ml::SVM::create();
classifier->load(*modelPath);
Mat features = (*featuresSptr)[i];
features.convertTo(features, CV_32F);
float label = classifier->predict(features);

error :

OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict

2015-04-11 08:04:10 -0600 asked a question Tracking using optical flow

Hello, I need a simple example of using optical flow for tracking.

2014-03-26 04:17:11 -0600 received badge  Editor (source)
2014-03-26 04:05:49 -0600 asked a question use SVM to class face images

Hello, I need an exemple of using svm to class face images for exemple 2 classes in 100 images ...

int main(array<System::String ^> ^args)

{ IplImage *img;

        img=cvLoadImage("image.jpg");

        // SVM


Console::WriteLine(L"\n Exit ...");
Console::ReadLine();
return 0;

}