Hello,

I am trying to build my own filter machine lerning training with a specific 
sampling method. I've tried o start with an example, butI am no able to 
make it work. It is probably just missing one line to set the size of the 
measurement vector of the ListSample, but I don't fin it. Any one has an 
idea ?

Error message (compile is OK)

test 6 on 6
test 0 for 0.04172 on 6
test 1 for 0.0577576 on 6
test 2 for 0.0816327 on 6
test 3 for 0.138198 on 6
test 4 for 0.124274 on 6
test 5 for 0.0801539 on 6
test target on 1
terminate called after throwing an instance of 'itk::ExceptionObject'
  what():  /home/tom/libs/OTB/install/include/ITK-4.8/itkListSample.hxx:56:
itk::ERROR: ListSample(0x16edfb0): MeasurementVectorSize: 0 doesn't match 
input measurement vector length: 6
Aborted


code : 

//vector of floats as input
typedef float InputValueType;
            typedef itk::VariableLengthVector<InputValueType> 
InputSampleType;
            //typedef itk::FixedArray<InputValueType, 6> InputSampleType;
            typedef itk::Statistics::ListSample<InputSampleType> 
InputListSampleType;

            // Target related typedefs
            typedef int TargetValueType;
            typedef itk::FixedArray<TargetValueType, 1> TargetSampleType;
            typedef itk::Statistics::ListSample<TargetSampleType> 
TargetListSampleType;

            InputListSampleType::Pointer InputListSample = 
InputListSampleType::New();
            InputListSample.MeasurementVectorSize = 0;
            TargetListSampleType::Pointer TargetListSample = 
TargetListSampleType::New();

            

            int sizePixel = 
inputReader->GetOutput()->GetNumberOfComponentsPerPixel(); // the vector 
must have the size of the vector image that will be classified

            for (int i(0); i<nbClasses; i++)
            {    
                if (lMatrix[i].rows()>1)
                {
                // Filling the two input training lists
                for (int j = 0; j < lMatrix[i].rows(); ++j)
                {
                    InputSampleType sample;
                    sample.SetSize(sizePixel);

                    TargetValueType label = i + 1;

                    // Multi-component sample filled based on matrix 
                    std::cout<< "test " << lMatrix[i].columns() << " on " 
<< sizePixel << std::endl;
                    for (int k = 0; k < lMatrix[i].columns(); k++)
                    {
                        sample[k] = lMatrix[i].get(j,k);
                        std::cout<< "test " << k << " for " << sample[k] << 
" on " << sizePixel << std::endl;
                    }

                    TargetListSample->PushBack(label);
                    std::cout<< "test target on " << label  << std::endl;
                    InputListSample->PushBack(sample); // THIS IS WHERE I 
GET THE ERROR
                }
                }

            }

std::cout<<" RF learning step"<<std::endl;
            typedef otb::RandomForestsMachineLearningModel<InputValueType, 
TargetValueType> RFType;

            RFType::Pointer RFEstimator = RFType::New();
            RFEstimator->SetInputListSample(InputListSample);
            RFEstimator->SetTargetListSample(TargetListSample);

-- 
-- 
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to