Skip to content

Add flushing to printing number of processed positive/negative samples so that user is informed of updates quicker - #13709

Merged
alalek merged 2 commits into
opencv:3.4from
michal-kowalczyk:flush-processed-samples-number
Apr 12, 2019
Merged

alalek merged 2 commits into
opencv:3.4from
michal-kowalczyk:flush-processed-samples-number

Conversation

@michal-kowalczyk

Copy link
Copy Markdown
Contributor

This pullrequest changes

Add flushing to printing number of processed positive/negative samples so that when running opencv_traincascade, the user is informed of updates quicker.
Without this change I got updates one per half of hour.

@mshabunin

Copy link
Copy Markdown
Contributor

traincascade app is disabled on master branch:

#ocv_add_app(traincascade)

If you use version 3.4.x, you have to rebase this patch to the 3.4 branch (see branches wiki page for instruction).

@vpisarev
vpisarev changed the base branch from master to 3.4 February 19, 2019 12:11
@vpisarev
vpisarev changed the base branch from 3.4 to master February 19, 2019 12:11

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

Comment thread apps/traincascade/cascadeclassifier.cpp Outdated
{
getcount++;
printf("%s current samples: %d\r", isPositive ? "POS":"NEG", getcount);
std::cout << (isPositive ? "POS" : "NEG") << " current samples: " << getcount << "\r" << std::flush;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using this:

printf(...); fflush(stdout);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alalek, I have no opportunity to test that C-style version now. Would you mind keeping C++ version here?
P.S.: thanks for resurrecting this change, I completely forgot about it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, Main concern here is to avoid changing of unrelated code (printf() statement).

These lines should do the same things:

fflush(stdout);
std::cout.flush();
std::cout << std::flush;

fflush(stdout); has been selected because it correlates with printf() (both are C-style).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the change and use fflush as you suggested.

@michal-kowalczyk
michal-kowalczyk changed the base branch from master to 3.4 April 10, 2019 07:54
…s so that user is informed of updates quickly.
@michal-kowalczyk
michal-kowalczyk force-pushed the flush-processed-samples-number branch from d0ba872 to 418eb36 Compare April 10, 2019 10:34

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alalek
alalek merged commit a246d8d into opencv:3.4 Apr 12, 2019
@alalek alalek mentioned this pull request Apr 13, 2019
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
…-samples-number

* Add flushing to printing number of processed positive/negative samples so that user is informed of updates quickly.

* use flush C api instead of C++ api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants