Created
July 15, 2018 13:19
-
-
Save ortegatron/d2b2fa620d00823866343ceaab5824b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modifications to openpose/python/openpose/_openpose.cpp | |
#include <openpose/hand/handExtractorCaffe.hpp> | |
#include <openpose/hand/handCpuRenderer.hpp> | |
OP_EXPORT void forward_hands(c_OP op, unsigned char* img, size_t rows, size_t cols, | |
float* hRects, size_t hRects_size, | |
int* size, unsigned char* displayImg, bool display) { | |
OpenPose* openPose = (OpenPose*)op; | |
cv::Mat image(rows, cols, CV_8UC3, img); | |
cv::Mat displayImage(rows, cols, CV_8UC3, displayImg); | |
std::vector<std::array<op::Rectangle<float>, 2>> handRectangles; | |
for (int i = 0; i<hRects_size; i++) { | |
// Left hand | |
op::Rectangle<float> left_hand = {hRects[i], hRects[i+1], hRects[i+2], hRects[i+3]}; | |
op::Rectangle<float> right_hand = {hRects[i+4], hRects[i+5], hRects[i+6], hRects[i+7]}; | |
std::array<op::Rectangle<float>, 2> body_hands = {left_hand, right_hand}; | |
handRectangles.emplace_back(body_hands); | |
} | |
openPose->forward_hands(image, handRectangles, handsOutput, displayImage, display); | |
if (output.getSize().size()) { | |
size[0] = output.getSize()[0]; | |
size[1] = output.getSize()[1]; | |
size[2] = output.getSize()[2]; | |
} | |
else { | |
size[0] = 0; size[1] = 0; size[2] = 0; | |
} | |
if (display) memcpy(displayImg, displayImage.ptr(), sizeof(unsigned char)*rows*cols * 3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment