Skip to content

Commit

Permalink
CPU works less if queues are full or empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gineshidalgo99 committed Jul 5, 2018
1 parent 92cdcad commit 7c21e0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ OpenPose Library - Release Notes
18. Speed up of cvMatToOpOutput and opOutputToCvMat: op::Datum::outputData is now H x W x C instead of C x H x W, making it much faster to be copied to/from op::Datum::cvOutputData.
19. Much faster GUI display by adding the `WITH_OPENCV_WITH_OPENGL` flag to tell whether to use OpenGL support for OpenCV.
20. Turned security check error into warning when using dynamic `net_resolution` for `image_dir` in CPU/OpenCL versions.
21. Minimized CPU usage when queues are empty or full, in order to prevent problems such as general computer slow down, overheating, or excesive power usage.
2. Functions or parameters renamed:
1. Removed scale parameter from hand and face rectangle extractor (causing wrong results if custom `--output_resolution`).
2. Functions `scaleKeypoints`, other than `scaleKeypoints(Array<float>& keypoints, const float scale)`, renamed as `scaleKeypoints2d`.
Expand Down
5 changes: 4 additions & 1 deletion include/openpose/thread/subThreadQueueIn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace op
namespace op
{
template<typename TDatums, typename TWorker, typename TQueue>
SubThreadQueueIn<TDatums, TWorker, TQueue>::SubThreadQueueIn(const std::vector<TWorker>& tWorkers, const std::shared_ptr<TQueue>& tQueueIn) :
SubThreadQueueIn<TDatums, TWorker, TQueue>::SubThreadQueueIn(const std::vector<TWorker>& tWorkers,
const std::shared_ptr<TQueue>& tQueueIn) :
SubThread<TDatums, TWorker>{tWorkers},
spTQueueIn{tQueueIn}
{
Expand All @@ -44,6 +45,8 @@ namespace op
try
{
// Pop TDatums
if (spTQueueIn->empty())
std::this_thread::sleep_for(std::chrono::microseconds{100});
TDatums tDatums;
bool queueIsRunning = spTQueueIn->tryPop(tDatums);
// Check queue not empty
Expand Down
5 changes: 5 additions & 0 deletions include/openpose/thread/subThreadQueueInOut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace op
if (!spTQueueOut->isFull())
{
// Pop TDatums
if (spTQueueIn->empty())
std::this_thread::sleep_for(std::chrono::microseconds{100});
TDatums tDatums;
bool workersAreRunning = spTQueueIn->tryPop(tDatums);
// Check queue not stopped
Expand All @@ -83,7 +85,10 @@ namespace op
return workersAreRunning;
}
else
{
std::this_thread::sleep_for(std::chrono::microseconds{100});
return true;
}
}
}
catch (const std::exception& e)
Expand Down
3 changes: 3 additions & 0 deletions include/openpose/thread/subThreadQueueOut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ namespace op
return workersAreRunning;
}
else
{
std::this_thread::sleep_for(std::chrono::microseconds{100});
return true;
}
}
}
catch (const std::exception& e)
Expand Down

0 comments on commit 7c21e0b

Please sign in to comment.