Commit 7f97464c authored by manuele's avatar manuele

logtopolar

parent 77116f35
...@@ -106,7 +106,7 @@ int main(int argc, char *argv[]) ...@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
cerr << "Error reading model size from `" << model_size << "`" << endl; cerr << "Error reading model size from `" << model_size << "`" << endl;
return 1; return 1;
} }
if( params.feature_count <= 0 ) if( params.feature_count <= 0 )
{ {
cerr << "feature_count must be positive number" << endl; cerr << "feature_count must be positive number" << endl;
...@@ -159,15 +159,17 @@ int main(int argc, char *argv[]) ...@@ -159,15 +159,17 @@ int main(int argc, char *argv[])
int features_size = params.feature_count; int features_size = params.feature_count;
int max_features_allowed = (int)(INT_MAX/(sizeof(int)* samples_size)); int max_features_allowed = (int)(INT_MAX/(sizeof(int)* samples_size));
int max_samples_allowed = (int)(INT_MAX/(sizeof(int)* features_size)); int max_samples_allowed = (int)(INT_MAX/(sizeof(int)* features_size));
int total_samples = (int)((params.bg_per_image * bg_filenames.size()) + pos_filenames.size());
if((int)((params.bg_per_image * bg_filenames.size()) + pos_filenames.size()) >max_samples_allowed) if(total_samples >max_samples_allowed)
{ {
CV_Error_(1, ("exceeded maximum number of samples. Maximum number of samples with %d features is %d\n",features_size,max_samples_allowed )); CV_Error_(1, ("exceeded maximum number of samples. Maximum number of samples with %d features is %d, you have %d (%d positive samples + (%d bg * %d bg_per_image))\n",features_size,max_samples_allowed,total_samples,pos_filenames.size(),bg_filenames.size(),params.bg_per_image ));
} }
if(params.feature_count >max_features_allowed) if(params.feature_count >max_features_allowed)
{ {
CV_Error_(1, ("exceeded maximum number of features. Maximum number of features with %d samples is %d\n",samples_size,max_features_allowed )); CV_Error_(1, ("exceeded maximum number of features. Maximum number of features with %d samples is %d, you have %d\n",samples_size,max_features_allowed, features_size ));
} }
std::cout<<pos_filenames.size()<<std::endl; std::cout<<pos_filenames.size()<<std::endl;
......
...@@ -3749,7 +3749,7 @@ void erGroupingNM(InputArray _img, InputArrayOfArrays _src, vector< vector<ERSta ...@@ -3749,7 +3749,7 @@ void erGroupingNM(InputArray _img, InputArrayOfArrays _src, vector< vector<ERSta
_src.getMatVector(src); _src.getMatVector(src);
CV_Assert ( !src.empty() ); CV_Assert ( !src.empty() );
CV_Assert ( src.size() == regions.size() ); //CV_Assert ( src.size() == regions.size() );
size_t num_channels = src.size(); size_t num_channels = src.size();
Mat img = _img.getMat(); Mat img = _img.getMat();
......
...@@ -276,6 +276,7 @@ vector<vector<int> > generateFeatures(Size window_size, const std::string& type, ...@@ -276,6 +276,7 @@ vector<vector<int> > generateFeatures(Size window_size, const std::string& type,
void computeChannels(InputArray image, vector<Mat>& channels) void computeChannels(InputArray image, vector<Mat>& channels)
{ {
Mat_<float> grad; Mat_<float> grad;
Mat_<float> angles;
Mat luv, gray, src; Mat luv, gray, src;
if(image.getMat().channels() > 1) if(image.getMat().channels() > 1)
...@@ -297,13 +298,15 @@ void computeChannels(InputArray image, vector<Mat>& channels) ...@@ -297,13 +298,15 @@ void computeChannels(InputArray image, vector<Mat>& channels)
Sobel(gray, row_der, CV_32F, 0, 1); Sobel(gray, row_der, CV_32F, 0, 1);
Sobel(gray, col_der, CV_32F, 1, 0); Sobel(gray, col_der, CV_32F, 1, 0);
magnitude(row_der, col_der, grad); cartToPolar(col_der, row_der, grad, angles, true);
//magnitude(row_der, col_der, grad);
Mat_<Vec6f> hist = Mat_<Vec6f>::zeros(grad.rows, grad.cols); Mat_<Vec6f> hist = Mat_<Vec6f>::zeros(grad.rows, grad.cols);
const float to_deg = 180 / 3.1415926f; //const float to_deg = 180 / 3.1415926f;
for (int row = 0; row < grad.rows; ++row) { for (int row = 0; row < grad.rows; ++row) {
for (int col = 0; col < grad.cols; ++col) { for (int col = 0; col < grad.cols; ++col) {
float angle = atan2(row_der(row, col), col_der(row, col)) * to_deg; //float angle = atan2(row_der(row, col), col_der(row, col)) * to_deg;
float angle = angles(row, col);
if (angle < 0) if (angle < 0)
angle += 180; angle += 180;
int ind = (int)(angle / 30); int ind = (int)(angle / 30);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment