Skip to content

Commit 6697f0e

Browse files
committed
Merge pull request opencv#17925 from sturkmen72:patch-2
2 parents e935f06 + 7e94380 commit 6697f0e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

samples/cpp/train_HOG.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void load_images( const String & dirname, vector< Mat > & img_lst, bool showImag
7474
for ( size_t i = 0; i < files.size(); ++i )
7575
{
7676
Mat img = imread( files[i] ); // load the image
77-
if ( img.empty() ) // invalid image, skip it.
77+
if ( img.empty() )
7878
{
79-
cout << files[i] << " is invalid!" << endl;
79+
cout << files[i] << " is invalid!" << endl; // invalid image, skip it.
8080
continue;
8181
}
8282

@@ -95,16 +95,13 @@ void sample_neg( const vector< Mat > & full_neg_lst, vector< Mat > & neg_lst, co
9595
box.width = size.width;
9696
box.height = size.height;
9797

98-
const int size_x = box.width;
99-
const int size_y = box.height;
100-
10198
srand( (unsigned int)time( NULL ) );
10299

103100
for ( size_t i = 0; i < full_neg_lst.size(); i++ )
104101
if ( full_neg_lst[i].cols > box.width && full_neg_lst[i].rows > box.height )
105102
{
106-
box.x = rand() % ( full_neg_lst[i].cols - size_x );
107-
box.y = rand() % ( full_neg_lst[i].rows - size_y );
103+
box.x = rand() % ( full_neg_lst[i].cols - box.width );
104+
box.y = rand() % ( full_neg_lst[i].rows - box.height );
108105
Mat roi = full_neg_lst[i]( box );
109106
neg_lst.push_back( roi.clone() );
110107
}
@@ -259,7 +256,7 @@ int main( int argc, char** argv )
259256
load_images( pos_dir, pos_lst, visualization );
260257
if ( pos_lst.size() > 0 )
261258
{
262-
clog << "...[done]" << endl;
259+
clog << "...[done] " << pos_lst.size() << " files." << endl;
263260
}
264261
else
265262
{
@@ -287,22 +284,25 @@ int main( int argc, char** argv )
287284
}
288285

289286
clog << "Negative images are being loaded...";
290-
load_images( neg_dir, full_neg_lst, false );
287+
load_images( neg_dir, full_neg_lst, visualization );
288+
clog << "...[done] " << full_neg_lst.size() << " files." << endl;
289+
290+
clog << "Negative images are being processed...";
291291
sample_neg( full_neg_lst, neg_lst, pos_image_size );
292-
clog << "...[done]" << endl;
292+
clog << "...[done] " << neg_lst.size() << " files." << endl;
293293

294294
clog << "Histogram of Gradients are being calculated for positive images...";
295295
computeHOGs( pos_image_size, pos_lst, gradient_lst, flip_samples );
296296
size_t positive_count = gradient_lst.size();
297297
labels.assign( positive_count, +1 );
298-
clog << "...[done] ( positive count : " << positive_count << " )" << endl;
298+
clog << "...[done] ( positive images count : " << positive_count << " )" << endl;
299299

300300
clog << "Histogram of Gradients are being calculated for negative images...";
301301
computeHOGs( pos_image_size, neg_lst, gradient_lst, flip_samples );
302302
size_t negative_count = gradient_lst.size() - positive_count;
303303
labels.insert( labels.end(), negative_count, -1 );
304304
CV_Assert( positive_count < labels.size() );
305-
clog << "...[done] ( negative count : " << negative_count << " )" << endl;
305+
clog << "...[done] ( negative images count : " << negative_count << " )" << endl;
306306

307307
Mat train_data;
308308
convert_to_ml( gradient_lst, train_data );
@@ -324,7 +324,7 @@ int main( int argc, char** argv )
324324

325325
if ( train_twice )
326326
{
327-
clog << "Testing trained detector on negative images. This may take a few minutes...";
327+
clog << "Testing trained detector on negative images. This might take a few minutes...";
328328
HOGDescriptor my_hog;
329329
my_hog.winSize = pos_image_size;
330330

0 commit comments

Comments
 (0)