mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge remote-tracking branch 'upstream/master' into svm_hog
This commit is contained in:
@@ -2122,9 +2122,14 @@ CvBoost::train( const Mat& _train_data, int _tflag,
|
||||
const Mat& _missing_mask,
|
||||
CvBoostParams _params, bool _update )
|
||||
{
|
||||
CvMat tdata = _train_data, responses = _responses, vidx = _var_idx,
|
||||
sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
return train(&tdata, _tflag, &responses, vidx.data.ptr ? &vidx : 0,
|
||||
train_data_hdr = _train_data;
|
||||
train_data_mat = _train_data;
|
||||
responses_hdr = _responses;
|
||||
responses_mat = _responses;
|
||||
|
||||
CvMat vidx = _var_idx, sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
|
||||
return train(&train_data_hdr, _tflag, &responses_hdr, vidx.data.ptr ? &vidx : 0,
|
||||
sidx.data.ptr ? &sidx : 0, vtype.data.ptr ? &vtype : 0,
|
||||
mmask.data.ptr ? &mmask : 0, _params, _update);
|
||||
}
|
||||
|
||||
@@ -1844,12 +1844,16 @@ bool CvERTrees::train( const Mat& _train_data, int _tflag,
|
||||
const Mat& _sample_idx, const Mat& _var_type,
|
||||
const Mat& _missing_mask, CvRTParams params )
|
||||
{
|
||||
CvMat tdata = _train_data, responses = _responses, vidx = _var_idx,
|
||||
sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
return train(&tdata, _tflag, &responses, vidx.data.ptr ? &vidx : 0,
|
||||
train_data_hdr = _train_data;
|
||||
train_data_mat = _train_data;
|
||||
responses_hdr = _responses;
|
||||
responses_mat = _responses;
|
||||
|
||||
CvMat vidx = _var_idx, sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
|
||||
return train(&train_data_hdr, _tflag, &responses_hdr, vidx.data.ptr ? &vidx : 0,
|
||||
sidx.data.ptr ? &sidx : 0, vtype.data.ptr ? &vtype : 0,
|
||||
mmask.data.ptr ? &mmask : 0, params);
|
||||
}
|
||||
|
||||
// End of file.
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ bool CvKNearest::train( const CvMat* _train_data, const CvMat* _responses,
|
||||
|
||||
if( !responses )
|
||||
CV_ERROR( CV_StsNoMem, "Could not allocate memory for responses" );
|
||||
|
||||
|
||||
if( _update_base && _dims != var_count )
|
||||
CV_ERROR( CV_StsBadArg, "The newly added data have different dimensionality" );
|
||||
|
||||
@@ -480,4 +480,3 @@ float CvKNearest::find_nearest( const cv::Mat& _samples, int k, CV_OUT cv::Mat&
|
||||
}
|
||||
|
||||
/* End of file */
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ CV_INIT_ALGORITHM(EM, "StatModel.EM",
|
||||
|
||||
bool initModule_ml(void)
|
||||
{
|
||||
Ptr<Algorithm> em = createEM_hidden();
|
||||
Ptr<Algorithm> em = createEM_ptr_hidden();
|
||||
return em->info() != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@ bool CvNormalBayesClassifier::train( const CvMat* _train_data, const CvMat* _res
|
||||
prod_data[c2] += train_vec[c2]*val1;
|
||||
}
|
||||
}
|
||||
cvReleaseMat( &responses );
|
||||
responses = 0;
|
||||
|
||||
/* calculate avg, covariance matrix, c */
|
||||
for( cls = 0; cls < nclasses; cls++ )
|
||||
@@ -623,4 +625,3 @@ float CvNormalBayesClassifier::predict( const Mat& _samples, Mat* _results ) con
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
/* End of file. */
|
||||
@@ -41,7 +41,6 @@
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/ml.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
@@ -126,7 +126,7 @@ void ForestTreeBestSplitFinder::operator()(const BlockedRange& range)
|
||||
}
|
||||
|
||||
if( res && bestSplit->quality < split->quality )
|
||||
memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)split, splitSize );
|
||||
memcpy( bestSplit.get(), split.get(), splitSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -839,9 +839,14 @@ bool CvRTrees::train( const Mat& _train_data, int _tflag,
|
||||
const Mat& _sample_idx, const Mat& _var_type,
|
||||
const Mat& _missing_mask, CvRTParams _params )
|
||||
{
|
||||
CvMat tdata = _train_data, responses = _responses, vidx = _var_idx,
|
||||
sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
return train(&tdata, _tflag, &responses, vidx.data.ptr ? &vidx : 0,
|
||||
train_data_hdr = _train_data;
|
||||
train_data_mat = _train_data;
|
||||
responses_hdr = _responses;
|
||||
responses_mat = _responses;
|
||||
|
||||
CvMat vidx = _var_idx, sidx = _sample_idx, vtype = _var_type, mmask = _missing_mask;
|
||||
|
||||
return train(&train_data_hdr, _tflag, &responses_hdr, vidx.data.ptr ? &vidx : 0,
|
||||
sidx.data.ptr ? &sidx : 0, vtype.data.ptr ? &vtype : 0,
|
||||
mmask.data.ptr ? &mmask : 0, _params);
|
||||
}
|
||||
|
||||
@@ -1391,6 +1391,8 @@ bool CvSVM::do_train( int svm_type, int sample_count, int var_count, const float
|
||||
for( i = 0; i < sample_count; i++ )
|
||||
sv_count += fabs(alpha[i]) > 0;
|
||||
|
||||
CV_Assert(sv_count != 0);
|
||||
|
||||
sv_total = df->sv_count = sv_count;
|
||||
CV_CALL( df->alpha = (double*)cvMemStorageAlloc( storage, sv_count*sizeof(df->alpha[0])) );
|
||||
CV_CALL( sv = (float**)cvMemStorageAlloc( storage, sv_count*sizeof(sv[0])));
|
||||
@@ -2997,4 +2999,3 @@ cvTrainSVM_CrossValidation( const CvMat* train_data, int tflag,
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
|
||||
|
||||
+19
-14
@@ -1594,9 +1594,14 @@ bool CvDTree::train( const Mat& _train_data, int _tflag,
|
||||
const Mat& _sample_idx, const Mat& _var_type,
|
||||
const Mat& _missing_mask, CvDTreeParams _params )
|
||||
{
|
||||
CvMat tdata = _train_data, responses = _responses, vidx=_var_idx,
|
||||
sidx=_sample_idx, vtype=_var_type, mmask=_missing_mask;
|
||||
return train(&tdata, _tflag, &responses, vidx.data.ptr ? &vidx : 0, sidx.data.ptr ? &sidx : 0,
|
||||
train_data_hdr = _train_data;
|
||||
train_data_mat = _train_data;
|
||||
responses_hdr = _responses;
|
||||
responses_mat = _responses;
|
||||
|
||||
CvMat vidx=_var_idx, sidx=_sample_idx, vtype=_var_type, mmask=_missing_mask;
|
||||
|
||||
return train(&train_data_hdr, _tflag, &responses_hdr, vidx.data.ptr ? &vidx : 0, sidx.data.ptr ? &sidx : 0,
|
||||
vtype.data.ptr ? &vtype : 0, mmask.data.ptr ? &mmask : 0, _params);
|
||||
}
|
||||
|
||||
@@ -1877,7 +1882,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
|
||||
namespace cv
|
||||
{
|
||||
|
||||
template<> CV_EXPORTS void Ptr<CvDTreeSplit>::delete_obj()
|
||||
template<> CV_EXPORTS void DefaultDeleter<CvDTreeSplit>::operator ()(CvDTreeSplit* obj) const
|
||||
{
|
||||
fastFree(obj);
|
||||
}
|
||||
@@ -1888,12 +1893,12 @@ DTreeBestSplitFinder::DTreeBestSplitFinder( CvDTree* _tree, CvDTreeNode* _node)
|
||||
node = _node;
|
||||
splitSize = tree->get_data()->split_heap->elem_size;
|
||||
|
||||
bestSplit = (CvDTreeSplit*)fastMalloc(splitSize);
|
||||
memset((CvDTreeSplit*)bestSplit, 0, splitSize);
|
||||
bestSplit.reset((CvDTreeSplit*)fastMalloc(splitSize));
|
||||
memset(bestSplit.get(), 0, splitSize);
|
||||
bestSplit->quality = -1;
|
||||
bestSplit->condensed_idx = INT_MIN;
|
||||
split = (CvDTreeSplit*)fastMalloc(splitSize);
|
||||
memset((CvDTreeSplit*)split, 0, splitSize);
|
||||
split.reset((CvDTreeSplit*)fastMalloc(splitSize));
|
||||
memset(split.get(), 0, splitSize);
|
||||
//haveSplit = false;
|
||||
}
|
||||
|
||||
@@ -1903,10 +1908,10 @@ DTreeBestSplitFinder::DTreeBestSplitFinder( const DTreeBestSplitFinder& finder,
|
||||
node = finder.node;
|
||||
splitSize = tree->get_data()->split_heap->elem_size;
|
||||
|
||||
bestSplit = (CvDTreeSplit*)fastMalloc(splitSize);
|
||||
memcpy((CvDTreeSplit*)(bestSplit), (const CvDTreeSplit*)finder.bestSplit, splitSize);
|
||||
split = (CvDTreeSplit*)fastMalloc(splitSize);
|
||||
memset((CvDTreeSplit*)split, 0, splitSize);
|
||||
bestSplit.reset((CvDTreeSplit*)fastMalloc(splitSize));
|
||||
memcpy(bestSplit.get(), finder.bestSplit.get(), splitSize);
|
||||
split.reset((CvDTreeSplit*)fastMalloc(splitSize));
|
||||
memset(split.get(), 0, splitSize);
|
||||
}
|
||||
|
||||
void DTreeBestSplitFinder::operator()(const BlockedRange& range)
|
||||
@@ -1939,14 +1944,14 @@ void DTreeBestSplitFinder::operator()(const BlockedRange& range)
|
||||
}
|
||||
|
||||
if( res && bestSplit->quality < split->quality )
|
||||
memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)split, splitSize );
|
||||
memcpy( bestSplit.get(), split.get(), splitSize );
|
||||
}
|
||||
}
|
||||
|
||||
void DTreeBestSplitFinder::join( DTreeBestSplitFinder& rhs )
|
||||
{
|
||||
if( bestSplit->quality < rhs.bestSplit->quality )
|
||||
memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)rhs.bestSplit, splitSize );
|
||||
memcpy( bestSplit.get(), rhs.bestSplit.get(), splitSize );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user