merged all the latest changes from 2.4 to trunk

This commit is contained in:
Vadim Pisarevsky
2012-04-13 21:50:59 +00:00
parent 020f9a6047
commit 2fd1e2ea57
416 changed files with 12852 additions and 6070 deletions

View File

@@ -66,7 +66,6 @@ struct CV_EXPORTS CvMotionModel
}
float low_pass_gain; // low pass gain
CvEMParams em_params; // EM parameters
};
// Mean Shift Tracker parameters for specifying use of HSV channel and CamShift parameters.
@@ -109,7 +108,6 @@ struct CV_EXPORTS CvHybridTrackerParams
float ms_tracker_weight;
CvFeatureTrackerParams ft_params;
CvMeanShiftTrackerParams ms_params;
CvEMParams em_params;
int motion_model;
float low_pass_gain;
};
@@ -182,7 +180,6 @@ private:
CvMat* samples;
CvMat* labels;
CvEM em_model;
Rect prev_window;
Point2f prev_center;

View File

@@ -47,7 +47,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output
Mat dst = _dst.getMat();
for(size_t idx = 0; idx < indices.size(); idx++) {
Mat originalRow = src.row(indices[idx]);
Mat sortedRow = dst.row(idx);
Mat sortedRow = dst.row((int)idx);
originalRow.copyTo(sortedRow);
}
}
@@ -127,8 +127,9 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi)
case CV_32SC1: return interp1_<int>(x,Y,xi); break;
case CV_32FC1: return interp1_<float>(x,Y,xi); break;
case CV_64FC1: return interp1_<double>(x,Y,xi); break;
default: CV_Error(CV_StsUnsupportedFormat, ""); return Mat();
default: CV_Error(CV_StsUnsupportedFormat, ""); break;
}
return Mat();
}
namespace colormap
@@ -166,7 +167,7 @@ namespace colormap
static Mat linear_colormap(InputArray X,
InputArray r, InputArray g, InputArray b,
float begin, float end, float n) {
return linear_colormap(X,r,g,b,linspace(begin,end,n));
return linear_colormap(X,r,g,b,linspace(begin,end, cvRound(n)));
}
// Interpolates from a base colormap.

View File

@@ -117,7 +117,7 @@ public:
void train(InputArray src, InputArray labels);
// Predicts the label of a query image in src.
int predict(const InputArray src) const;
int predict(InputArray src) const;
// See FaceRecognizer::load.
void load(const FileStorage& fs);
@@ -384,7 +384,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
if(labels.size() != (size_t)N)
CV_Error(CV_StsUnsupportedFormat, "Labels must be given as integer (CV_32SC1).");
// compute the Fisherfaces
int C = remove_dups(labels).size(); // number of unique classes
int C = (int)remove_dups(labels).size(); // number of unique classes
// clip number of components to be a valid number
if((_num_components <= 0) || (_num_components > (C-1)))
_num_components = (C-1);
@@ -495,8 +495,8 @@ inline void elbp_(InputArray _src, OutputArray _dst, int radius, int neighbors)
dst.setTo(0);
for(int n=0; n<neighbors; n++) {
// sample points
float x = static_cast<float>(-radius) * sin(2.0*CV_PI*n/static_cast<float>(neighbors));
float y = static_cast<float>(radius) * cos(2.0*CV_PI*n/static_cast<float>(neighbors));
float x = static_cast<float>(-radius * sin(2.0*CV_PI*n/static_cast<float>(neighbors)));
float y = static_cast<float>(radius * cos(2.0*CV_PI*n/static_cast<float>(neighbors)));
// relative indices
int fx = static_cast<int>(floor(x));
int fy = static_cast<int>(floor(y));
@@ -514,7 +514,7 @@ inline void elbp_(InputArray _src, OutputArray _dst, int radius, int neighbors)
for(int i=radius; i < src.rows-radius;i++) {
for(int j=radius;j < src.cols-radius;j++) {
// calculate interpolated value
float t = w1*src.at<_Tp>(i+fy,j+fx) + w2*src.at<_Tp>(i+fy,j+cx) + w3*src.at<_Tp>(i+cy,j+fx) + w4*src.at<_Tp>(i+cy,j+cx);
float t = static_cast<float>(w1*src.at<_Tp>(i+fy,j+fx) + w2*src.at<_Tp>(i+fy,j+cx) + w3*src.at<_Tp>(i+cy,j+fx) + w4*src.at<_Tp>(i+cy,j+cx));
// floating point precision, so check some machine-dependent epsilon
dst.at<int>(i-radius,j-radius) += ((t > src.at<_Tp>(i,j)) || (std::abs(t-src.at<_Tp>(i,j)) < std::numeric_limits<float>::epsilon())) << n;
}
@@ -543,13 +543,13 @@ histc_(const Mat& src, int minVal=0, int maxVal=255, bool normed=false)
// Establish the number of bins.
int histSize = maxVal-minVal+1;
// Set the ranges.
float range[] = { minVal, maxVal } ;
float range[] = { static_cast<float>(minVal), static_cast<float>(maxVal) };
const float* histRange = { range };
// calc histogram
calcHist(&src, 1, 0, Mat(), result, 1, &histSize, &histRange, true, false);
// normalize
if(normed) {
result /= src.total();
result /= (int)src.total();
}
return result.reshape(1,1);
}

View File

@@ -132,17 +132,6 @@ void CvHybridTracker::newTracker(Mat image, Rect selection) {
mstracker->newTrackingWindow(image, selection);
fttracker->newTrackingWindow(image, selection);
params.em_params.covs = NULL;
params.em_params.means = NULL;
params.em_params.probs = NULL;
params.em_params.nclusters = 1;
params.em_params.weights = NULL;
params.em_params.cov_mat_type = CvEM::COV_MAT_SPHERICAL;
params.em_params.start_step = CvEM::START_AUTO_STEP;
params.em_params.term_crit.max_iter = 10000;
params.em_params.term_crit.epsilon = 0.001;
params.em_params.term_crit.type = CV_TERMCRIT_ITER | CV_TERMCRIT_EPS;
samples = cvCreateMat(2, 1, CV_32FC1);
labels = cvCreateMat(2, 1, CV_32SC1);
@@ -221,10 +210,16 @@ void CvHybridTracker::updateTrackerWithEM(Mat image) {
count++;
}
em_model.train(samples, 0, params.em_params, labels);
cv::Mat lbls;
EM em_model(1, EM::COV_MAT_SPHERICAL, TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 10000, 0.001));
em_model.train(cvarrToMat(samples), lbls);
if(labels)
lbls.copyTo(cvarrToMat(labels));
curr_center.x = (float)em_model.getMeans().at<double> (0, 0);
curr_center.y = (float)em_model.getMeans().at<double> (0, 1);
Mat em_means = em_model.get<Mat>("means");
curr_center.x = (float)em_means.at<float>(0, 0);
curr_center.y = (float)em_means.at<float>(0, 1);
}
void CvHybridTracker::updateTrackerWithLowPassFilter(Mat image) {

View File

@@ -62,7 +62,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
if(n == 0)
return Mat();
// dimensionality of samples
int d = src.getMat(0).total();
int d = (int)src.getMat(0).total();
// create data matrix
Mat data(n, d, rtype);
// copy data
@@ -82,7 +82,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra
Mat dst = _dst.getMat();
for(size_t idx = 0; idx < indices.size(); idx++) {
Mat originalCol = src.col(indices[idx]);
Mat sortedCol = dst.col(idx);
Mat sortedCol = dst.col((int)idx);
originalCol.copyTo(sortedCol);
}
}
@@ -947,14 +947,14 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
vector<int> num2label = remove_dups(labels);
map<int, int> label2num;
for (size_t i = 0; i < num2label.size(); i++)
label2num[num2label[i]] = i;
label2num[num2label[i]] = (int)i;
for (size_t i = 0; i < labels.size(); i++)
mapped_labels[i] = label2num[labels[i]];
// get sample size, dimension
int N = data.rows;
int D = data.cols;
// number of unique labels
int C = num2label.size();
int C = (int)num2label.size();
// throw error if less labels, than samples
if (labels.size() != (size_t)N)
CV_Error(CV_StsBadArg, "Error: The number of samples must equal the number of labels.");

View File

@@ -440,9 +440,9 @@ cv::Mesh3D::~Mesh3D() {}
void cv::Mesh3D::buildOctree() { if (octree.getNodes().empty()) octree.buildTree(vtx); }
void cv::Mesh3D::clearOctree(){ octree = Octree(); }
float cv::Mesh3D::estimateResolution(float tryRatio)
float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
{
#if 0
#if 0
const int neighbors = 3;
const int minReasonable = 10;
@@ -476,10 +476,10 @@ float cv::Mesh3D::estimateResolution(float tryRatio)
sort(dist, less<double>());
return resolution = (float)dist[ dist.size() / 2 ];
#else
#else
CV_Error(CV_StsNotImplemented, "");
return 1.f;
#endif
#endif
}
@@ -1171,7 +1171,7 @@ private:
break;
std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat));
int minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg;
size_t minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg;
if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */
{
@@ -1182,14 +1182,14 @@ private:
left.erase(pos);
}
else
break;
break;
}
if (group.size() >= 4)
groups.push_back(group);
groups.push_back(group);
}
/* converting the data to final result */
/* converting the data to final result */
for(size_t i = 0; i < groups.size(); ++i)
{
const group_t& group = groups[i];
@@ -1197,7 +1197,7 @@ private:
vector< Vec2i > outgrp;
for(citer pos = group.begin(); pos != group.end(); ++pos)
{
const Match& m = allMatches[*pos];
const Match& m = allMatches[*pos];
outgrp.push_back(Vec2i(subset[m.modelInd], scene.subset[m.sceneInd]));
}
result.push_back(outgrp);