Skip to content

Commit

Permalink
Merge pull request #5 from Cupello5/master
Browse files Browse the repository at this point in the history
Fixed camera-resolution independent
  • Loading branch information
pbosetti authored May 3, 2024
2 parents dbbc05f + 2c05d29 commit 427fb6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion params.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"camera_device": 0,
"azure_device": 0,
"model_file": "models/human-pose-estimation-0001.xml",
"resolution_rgb": "1280x720",
"resolution_rgb": "",
"fps": 25,
"dummy": false,
"debug": {
Expand Down
9 changes: 7 additions & 2 deletions src/plugin/skeletonizer3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,28 @@ class Skeletonizer3D : public Source<json> {
if (!_cap.isOpened()) {
throw invalid_argument("ERROR: Cannot open the video camera");
}

_cap >> _rgb;
cv::Size resolution = _rgb.size();
size_t found = _resolution_rgb.find("x");
if (found != string::npos) {
resolution = cv::Size{
stoi(_resolution_rgb.substr(0, found)),
stoi(_resolution_rgb.substr(found + 1, _resolution_rgb.length()))};

_output_transform = OutputTransform(_rgb.size(), resolution);
resolution = _output_transform.computeResolution();

cv::resize(_rgb, _rgb, cv::Size(resolution.width, resolution.height));
}
// cout << "Resolution: " << resolution << endl;

_rgb_height = resolution.height; //_rgb.rows;
_rgb_width = resolution.width; //_rgb.cols;
}

void setup_OpenPoseModel() {
// setup inference model
data_t aspect_ratio = _rgb.cols / static_cast<data_t>(_rgb.rows);
data_t aspect_ratio = _rgb_width / static_cast<data_t>(_rgb_height);
_model.reset(new HPEOpenPose(_model_file, aspect_ratio, _tsize,
static_cast<data_t>(_threshold), _layout));
}
Expand Down Expand Up @@ -291,6 +295,7 @@ class Skeletonizer3D : public Source<json> {
// Input stream is over
return return_type::error;
}
cv::resize(_rgb, _rgb, cv::Size(_rgb_width, _rgb_height));
}
#endif
return return_type::success;
Expand Down

0 comments on commit 427fb6d

Please sign in to comment.