提交 4e455b28 编写于 作者: G gineshidalgo99

GPU moved to gpu module

上级 d4018ba9
......@@ -205,7 +205,7 @@ You can include the 3D reconstruction module by:
- Copy `Spinnaker_v140.lib` and `Spinnakerd_v140.lib` from `{PointGreyParentDirectory}\Point Grey Research\Spinnaker\lib64\vs2015\` into `{OpenPoseDirectory}\3rdparty\windows\spinnaker\lib\`.
- (Optional) Spinnaker SDK overview: [https://www.ptgrey.com/spinnaker-sdk](https://www.ptgrey.com/spinnaker-sdk).
2. Install the 3D visualizer, FreeGLUT:
1. Ubuntu: run `sudo apt-get install freeglut3 freeglut3-dev`.
1. Ubuntu: run `sudo apt-get install freeglut3 freeglut3-dev libxmu-dev libxi-dev`.
2. Windows:
1. It is automatically downloaded by the CMake installer.
2. Alternatively, if you prefer to download it yourself, you could either:
......
......@@ -87,10 +87,10 @@ namespace op
#include <openpose/face/headers.hpp>
#include <openpose/filestream/headers.hpp>
#include <openpose/gui/headers.hpp>
#include <openpose/gpu/gpu.hpp>
#include <openpose/hand/headers.hpp>
#include <openpose/pose/headers.hpp>
#include <openpose/producer/headers.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/errorAndLog.hpp>
#include <openpose/utilities/fileSystem.hpp>
namespace op
......
#ifndef OPENPOSE_UTILITIES_CUDA_HPP
#define OPENPOSE_UTILITIES_CUDA_HPP
#ifndef OPENPOSE_GPU_CUDA_HPP
#define OPENPOSE_GPU_CUDA_HPP
#include <utility> // std::pair
#include <openpose/core/common.hpp>
......@@ -10,7 +10,7 @@ namespace op
OP_API void cudaCheck(const int line = -1, const std::string& function = "", const std::string& file = "");
OP_API int getGpuNumber();
OP_API int getCudaGpuNumber();
inline unsigned int getNumberCudaBlocks(const unsigned int totalRequired,
const unsigned int numberCudaThreads = CUDA_NUM_THREADS)
......@@ -22,4 +22,4 @@ namespace op
const Point<int>& frameSize);
}
#endif // OPENPOSE_UTILITIES_CUDA_HPP
#endif // OPENPOSE_GPU_CUDA_HPP
#ifndef OPENPOSE_UTILITIES_CUDA_HU
#define OPENPOSE_UTILITIES_CUDA_HU
#ifndef OPENPOSE_GPU_CUDA_HU
#define OPENPOSE_GPU_CUDA_HU
namespace op
{
......@@ -147,4 +147,4 @@ namespace op
}
}
#endif // OPENPOSE_UTILITIES_CUDA_HU
#endif // OPENPOSE_GPU_CUDA_HU
#ifndef OPENPOSE_GPU_ENUM_CLASSES_HPP
#define OPENPOSE_GPU_ENUM_CLASSES_HPP
namespace op
{
enum class GpuMode : unsigned char
{
CUDA = 0,
OPEN_CL = 1,
CPU_ONLY = 2,
Size,
};
}
#endif // OPENPOSE_GPU_ENUM_CLASSES_HPP
#ifndef OPENPOSE_GPU_GPU_HPP
#define OPENPOSE_GPU_GPU_HPP
#include <openpose/core/common.hpp>
#include <openpose/gpu/enumClasses.hpp>
namespace op
{
OP_API int getGpuNumber();
OP_API GpuMode getGpuMode();
}
#endif // OPENPOSE_GPU_GPU_HPP
#ifndef OPENPOSE_GPU_HEADERS_HPP
#define OPENPOSE_GPU_HEADERS_HPP
// gpu module
#include <openpose/gpu/enumClasses.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/gpu.hpp>
#endif // OPENPOSE_GPU_HEADERS_HPP
......@@ -3,7 +3,6 @@
// utilities module
#include <openpose/utilities/check.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/enumClasses.hpp>
#include <openpose/utilities/errorAndLog.hpp>
#include <openpose/utilities/fastMath.hpp>
......
......@@ -3,6 +3,7 @@
// wrapper module
#include <openpose/wrapper/wrapper.hpp>
#include <openpose/wrapper/wrapperAuxiliary.hpp>
#include <openpose/wrapper/wrapperStructFace.hpp>
#include <openpose/wrapper/wrapperStructHand.hpp>
#include <openpose/wrapper/wrapperStructInput.hpp>
......
......@@ -260,16 +260,17 @@ namespace op
// Implementation
#include <openpose/core/headers.hpp>
#include <openpose/experimental/tracking/headers.hpp>
#include <openpose/face/headers.hpp>
#include <openpose/filestream/headers.hpp>
#include <openpose/gui/headers.hpp>
#include <openpose/gpu/gpu.hpp>
#include <openpose/hand/headers.hpp>
#include <openpose/pose/headers.hpp>
#include <openpose/producer/headers.hpp>
#include <openpose/experimental/tracking/headers.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/fileSystem.hpp>
#include <openpose/utilities/standard.hpp>
#include <openpose/wrapper/wrapperAuxiliary.hpp>
namespace op
{
template<typename TDatums, typename TWorker, typename TQueue>
......@@ -447,94 +448,9 @@ namespace op
const auto renderHandGpu = wrapperStructHand.enable && wrapperStructHand.renderMode == RenderMode::Gpu;
// Check no wrong/contradictory flags enabled
if (wrapperStructPose.alphaKeypoint < 0. || wrapperStructPose.alphaKeypoint > 1.
|| wrapperStructFace.alphaHeatMap < 0. || wrapperStructFace.alphaHeatMap > 1.
|| wrapperStructHand.alphaHeatMap < 0. || wrapperStructHand.alphaHeatMap > 1.)
error("Alpha value for blending must be in the range [0,1].", __LINE__, __FUNCTION__, __FILE__);
if (wrapperStructPose.scaleGap <= 0.f && wrapperStructPose.scalesNumber > 1)
error("The scale gap must be greater than 0 (it has no effect if the number of scales is 1).",
__LINE__, __FUNCTION__, __FILE__);
if (!renderOutput && (!wrapperStructOutput.writeImages.empty() || !wrapperStructOutput.writeVideo.empty()))
{
const auto message = "In order to save the rendered frames (`--write_images` or `--write_video`), you"
" cannot disable `--render_pose`.";
log(message, Priority::High);
}
if (!wrapperStructOutput.writeHeatMaps.empty() && wrapperStructPose.heatMapTypes.empty())
{
const auto message = "In order to save the heatmaps (`--write_heatmaps`), you need to pick which heat"
" maps you want to save: `--heatmaps_add_X` flags or fill the"
" wrapperStructPose.heatMapTypes.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (!wrapperStructOutput.writeHeatMaps.empty()
&& (wrapperStructPose.heatMapScale != ScaleMode::UnsignedChar &&
wrapperStructOutput.writeHeatMapsFormat != "float"))
{
const auto message = "In order to save the heatmaps, you must either set"
" wrapperStructPose.heatMapScale to ScaleMode::UnsignedChar (i.e. range [0, 255])"
" or `--write_heatmaps_format` to `float` to storage floating numbers in binary"
" mode.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (mUserOutputWs.empty() && mThreadManagerMode != ThreadManagerMode::Asynchronous
&& mThreadManagerMode != ThreadManagerMode::AsynchronousOut)
{
const std::string additionalMessage{
" You could also set mThreadManagerMode = mThreadManagerMode::Asynchronous(Out) and/or add your"
" own output worker class before calling this function."
};
const auto savingSomething = (
!wrapperStructOutput.writeImages.empty() || !wrapperStructOutput.writeVideo.empty()
|| !wrapperStructOutput.writeKeypoint.empty() || !wrapperStructOutput.writeJson.empty()
|| !wrapperStructOutput.writeCocoJson.empty() || !wrapperStructOutput.writeHeatMaps.empty()
);
if (!wrapperStructOutput.displayGui && !savingSomething)
{
const auto message = "No output is selected (`--no_display`) and no results are generated (no"
" `--write_X` flags enabled). Thus, no output would be generated."
+ additionalMessage;
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (wrapperStructInput.framesRepeat && savingSomething)
{
const auto message = "Frames repetition (`--frames_repeat`) is enabled as well as some writing"
" function (`--write_X`). This program would never stop recording the same"
" frames over and over. Please, disable repetition or remove writing.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
// Warnings
if ((wrapperStructOutput.displayGui && wrapperStructOutput.guiVerbose) && !renderOutput)
{
const auto message = "No render is enabled (e.g. `--render_pose 0`), so you might also want to"
" remove the display (set `--no_display` or `--no_gui_verbose`). If you"
" simply want to use OpenPose to record video/images without keypoints, you"
" only need to set `--num_gpu 0`." + additionalMessage;
log(message, Priority::High);
}
if (wrapperStructInput.realTimeProcessing && savingSomething)
{
const auto message = "Real time processing is enabled as well as some writing function. Thus, some"
" frames might be skipped. Consider disabling real time processing if you"
" intend to save any results.";
log(message, Priority::High);
}
}
if (!wrapperStructOutput.writeVideo.empty() && wrapperStructInput.producerSharedPtr == nullptr)
error("Writting video is only available if the OpenPose producer is used (i.e."
" wrapperStructInput.producerSharedPtr cannot be a nullptr).", __LINE__, __FUNCTION__, __FILE__);
if (!wrapperStructPose.enable)
{
if (!wrapperStructFace.enable)
error("Body keypoint detection must be enabled.", __LINE__, __FUNCTION__, __FILE__);
if (wrapperStructHand.enable)
error("Body keypoint detection must be enabled in order to run hand keypoint detection.",
__LINE__, __FUNCTION__, __FILE__);
}
#ifdef CPU_ONLY
if (wrapperStructPose.gpuNumber > 0)
error("GPU number must be negative or 0 if CPU_ONLY is enabled.", __LINE__, __FUNCTION__, __FILE__);
#endif
const auto userOutputWsEmpty = mUserOutputWs.empty();
wrapperConfigureSecurityChecks(wrapperStructPose, wrapperStructFace, wrapperStructHand, wrapperStructInput,
wrapperStructOutput, renderOutput, userOutputWsEmpty, mThreadManagerMode);
// Get number threads
// CPU --> 1 thread or no pose extraction
......
#ifndef OPENPOSE_WRAPPER_AUXILIARY_HPP
#define OPENPOSE_WRAPPER_AUXILIARY_HPP
#include <openpose/wrapper/wrapperStructFace.hpp>
#include <openpose/wrapper/wrapperStructHand.hpp>
#include <openpose/wrapper/wrapperStructInput.hpp>
#include <openpose/wrapper/wrapperStructOutput.hpp>
#include <openpose/wrapper/wrapperStructPose.hpp>
namespace op
{
/**
* It checks that no wrong/contradictory flags are enabled for Wrapper
* @param wrapperStructPose
* @param wrapperStructFace
* @param wrapperStructHand
* @param wrapperStructInput
* @param wrapperStructOutput
* @param renderOutput
* @param userOutputWsEmpty
* @param threadManagerMode
*/
void wrapperConfigureSecurityChecks(const WrapperStructPose& wrapperStructPose,
const WrapperStructFace& wrapperStructFace,
const WrapperStructHand& wrapperStructHand,
const WrapperStructInput& wrapperStructInput,
const WrapperStructOutput& wrapperStructOutput,
const bool renderOutput,
const bool userOutputWsEmpty,
const ThreadManagerMode threadManagerMode);
}
#endif // OPENPOSE_WRAPPER_AUXILIARY_HPP
#include <thrust/device_ptr.h>
#include <thrust/extrema.h>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/core/maximumBase.hpp>
namespace op
......
......@@ -5,7 +5,7 @@
#include <caffe/net.hpp>
#include <glog/logging.h> // google::InitGoogleLogging
#endif
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/utilities/fileSystem.hpp>
#include <openpose/utilities/standard.hpp>
#include <openpose/core/netCaffe.hpp>
......
#include <thrust/device_ptr.h>
#include <thrust/scan.h>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hu>
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#include <openpose/core/nmsBase.hpp>
namespace op
......
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hu>
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#include <openpose/core/resizeAndMergeBase.hpp>
namespace op
......
......@@ -4,133 +4,133 @@
namespace op
{
// User configurable code
// Intrinsic and distortion parameters
// Camera 1 parameters
const cv::Mat INTRINSIC_1 = (cv::Mat_<double>(3, 3) << 817.93481631740565, 0, 600.70689997785121,
0, 816.51774059837908, 517.84529566329593,
0, 0, 1);
const cv::Mat DISTORTION_1 = (cv::Mat_<double>(8, 1) <<
-1.8102158829399091, 9.1966147162623262, -0.00044293900343777355, 0.0013638377686816653, 1.3303863414979364, -1.418905163635487, 8.4725535468475819, 4.7911023525901033);
// Camera 2 parameters
const cv::Mat INTRINSIC_2 = (cv::Mat_<double>(3, 3) << 816.20921132436638, 0, 612.67087968681585,
0, 816.18292222910486, 530.47901782670431,
0, 0, 1);
const cv::Mat DISTORTION_2 = (cv::Mat_<double>(8, 1) <<
-5.1088507540294881, 133.63995617304997, -0.0010048069080912836, 0.00018825291386406282, 20.688286893903879, -4.7604289550474768, 132.42412342224557, 70.01195364029752);
const cv::Mat INTRINSIC_3 = (cv::Mat_<double>(3, 3) << 798.42980806905666, 0, 646.48130011561727,
0, 798.46535448393979, 523.91590563194586,
0, 0, 1);
// Camera 3
const cv::Mat DISTORTION_3 = (cv::Mat_<double>(8, 1) <<
-0.57530495294002304, -0.54721992620722582, -0.00037614702677289967, -0.00081995658363481598, -0.020321660897680775, -0.18040544059116842, -0.87724444571603022, -0.13136636671099691);
// User configurable code
// Intrinsic and distortion parameters
// Camera 1 parameters
const cv::Mat INTRINSIC_1 = (cv::Mat_<double>(3, 3) << 817.93481631740565, 0, 600.70689997785121,
0, 816.51774059837908, 517.84529566329593,
0, 0, 1);
const cv::Mat DISTORTION_1 = (cv::Mat_<double>(8, 1) <<
-1.8102158829399091, 9.1966147162623262, -0.00044293900343777355, 0.0013638377686816653, 1.3303863414979364, -1.418905163635487, 8.4725535468475819, 4.7911023525901033);
// Camera 2 parameters
const cv::Mat INTRINSIC_2 = (cv::Mat_<double>(3, 3) << 816.20921132436638, 0, 612.67087968681585,
0, 816.18292222910486, 530.47901782670431,
0, 0, 1);
const cv::Mat DISTORTION_2 = (cv::Mat_<double>(8, 1) <<
-5.1088507540294881, 133.63995617304997, -0.0010048069080912836, 0.00018825291386406282, 20.688286893903879, -4.7604289550474768, 132.42412342224557, 70.01195364029752);
const cv::Mat INTRINSIC_3 = (cv::Mat_<double>(3, 3) << 798.42980806905666, 0, 646.48130011561727,
0, 798.46535448393979, 523.91590563194586,
0, 0, 1);
// Camera 3
const cv::Mat DISTORTION_3 = (cv::Mat_<double>(8, 1) <<
-0.57530495294002304, -0.54721992620722582, -0.00037614702677289967, -0.00081995658363481598, -0.020321660897680775, -0.18040544059116842, -0.87724444571603022, -0.13136636671099691);
// Extrinsic parameters - rotation and pose orientation between cameras
// Camera 1
const cv::Mat M_1_1 = (cv::Mat_<double>(3, 4) << 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0);
// Not working on Windows
// const cv::Mat M_1_1 = cv::Mat::eye(3, 4, CV_64F);
// From camera 1 to 2
const cv::Mat M_1_2 = (cv::Mat_<double>(3, 4) << 0.999962504862692, -0.00165862051503619, 0.00849928507093793, -238.301309354482,
0.00176155163779584, 0.999925029704659, -0.0121174215889211, 4.75863886121558,
-0.00847854967298925, 0.0121319391740716, 0.999890459124058, 15.9219925821916);
// From camera 1 to 3
const cv::Mat M_1_3 = (cv::Mat_<double>(3, 4) << 0.995809442124071, -0.000473104796892308, 0.0914512501193800, -461.301274485705,
0.00165046455210419, 0.999916727562850, -0.0127989806923977, 6.22648121362088,
-0.0914375794917412, 0.0128962828696210, 0.995727299487585, 63.4911132860733);
// From camera 2 to 3
const cv::Mat M_2_3 = (cv::Mat_<double>(3, 4) << 0.999644115423621, -0.00194501088674130, -0.0266056278177532, -235.236375502202,
0.00201646110733780, 0.999994431880356, 0.00265896462686206, 9.52238656728889,
0.0266003079592876, -0.00271166755609303, 0.999642471324391, -4.23534963077479);
// Extrinsic parameters - rotation and pose orientation between cameras
// Camera 1
const cv::Mat M_1_1 = (cv::Mat_<double>(3, 4) << 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0);
// Not working on Windows
// const cv::Mat M_1_1 = cv::Mat::eye(3, 4, CV_64F);
// From camera 1 to 2
const cv::Mat M_1_2 = (cv::Mat_<double>(3, 4) << 0.999962504862692, -0.00165862051503619, 0.00849928507093793, -238.301309354482,
0.00176155163779584, 0.999925029704659, -0.0121174215889211, 4.75863886121558,
-0.00847854967298925, 0.0121319391740716, 0.999890459124058, 15.9219925821916);
// From camera 1 to 3
const cv::Mat M_1_3 = (cv::Mat_<double>(3, 4) << 0.995809442124071, -0.000473104796892308, 0.0914512501193800, -461.301274485705,
0.00165046455210419, 0.999916727562850, -0.0127989806923977, 6.22648121362088,
-0.0914375794917412, 0.0128962828696210, 0.995727299487585, 63.4911132860733);
// From camera 2 to 3
const cv::Mat M_2_3 = (cv::Mat_<double>(3, 4) << 0.999644115423621, -0.00194501088674130, -0.0266056278177532, -235.236375502202,
0.00201646110733780, 0.999994431880356, 0.00265896462686206, 9.52238656728889,
0.0266003079592876, -0.00271166755609303, 0.999642471324391, -4.23534963077479);
// Do not modify this code
const std::vector<cv::Mat> INTRINSICS{ INTRINSIC_1, INTRINSIC_2, INTRINSIC_3 };
const std::vector<cv::Mat> DISTORTIONS{ DISTORTION_1, DISTORTION_2, DISTORTION_3 };
// Do not modify this code
const std::vector<cv::Mat> INTRINSICS{ INTRINSIC_1, INTRINSIC_2, INTRINSIC_3 };
const std::vector<cv::Mat> DISTORTIONS{ DISTORTION_1, DISTORTION_2, DISTORTION_3 };
const std::vector<cv::Mat> M{ M_1_1, M_1_2, M_1_3 };
// Not working on Windows
// const std::vector<cv::Mat> M_EACH_CAMERA{
// INTRINSIC_1 * M_1_1,
// INTRINSIC_2 * M_1_2,
// INTRINSIC_3 * M_1_3
// };
// Not working on Windows
// const std::vector<cv::Mat> M_EACH_CAMERA{
// INTRINSIC_1 * M_1_1,
// INTRINSIC_2 * M_1_2,
// INTRINSIC_3 * M_1_3
// };
const cv::Mat getIntrinsics(const int cameraIndex)
{
try
{
return INTRINSICS[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
const cv::Mat getIntrinsics(const int cameraIndex)
{
try
{
return INTRINSICS[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
const cv::Mat getDistorsion(const int cameraIndex)
{
try
{
return DISTORTIONS[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
const cv::Mat getDistorsion(const int cameraIndex)
{
try
{
return DISTORTIONS[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
const cv::Mat getM(const int cameraIndex)
{
try
{
return INTRINSICS[cameraIndex] * M[cameraIndex];
// return M_EACH_CAMERA[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
std::vector<cv::Mat> getMs()
{
try
{
// Security checks
if (INTRINSICS.size() != DISTORTIONS.size())
error("The INTRINSICS and DISTORTIONS vector should have the same size.",
__LINE__, __FUNCTION__, __FILE__);
if (INTRINSICS.size() != M.size())
error("The INTRINSICS and M_EACH_CAMERA vector should have the same size.",
__LINE__, __FUNCTION__, __FILE__);
const cv::Mat getM(const int cameraIndex)
{
try
{
return INTRINSICS[cameraIndex] * M[cameraIndex];
// return M_EACH_CAMERA[cameraIndex];
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return cv::Mat{};
}
}
std::vector<cv::Mat> getMs()
{
try
{
// Security checks
if (INTRINSICS.size() != DISTORTIONS.size())
error("The INTRINSICS and DISTORTIONS vector should have the same size.",
__LINE__, __FUNCTION__, __FILE__);
if (INTRINSICS.size() != M.size())
error("The INTRINSICS and M_EACH_CAMERA vector should have the same size.",
__LINE__, __FUNCTION__, __FILE__);
std::vector<cv::Mat> result(INTRINSICS.size());
for (auto i = 0u ; i < result.size(); i++)
result[i] = getM(i);
return result;
// return M_EACH_CAMERA;
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return{};
}
}
unsigned long long getNumberCameras()
{
try
{
return INTRINSICS.size();
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return 0;
}
}
std::vector<cv::Mat> result(INTRINSICS.size());
for (auto i = 0u ; i < result.size(); i++)
result[i] = getM(i);
return result;
// return M_EACH_CAMERA;
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return{};
}
}
unsigned long long getNumberCameras()
{
try
{
return INTRINSICS.size();
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return 0;
}
}
}
......@@ -388,6 +388,7 @@ namespace op
// glutSetOption(GLUT_MULTISAMPLE,8);
// Ideally adding also GLUT_BORDERLESS | GLUT_CAPTIONLESS should fix the problem of disabling the `x`
// button, but it does not work (tested in Ubuntu)
// https://stackoverflow.com/questions/3799803/is-it-possible-to-make-a-window-withouth-a-top-in-glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);
// create and set up a window
......
......@@ -6,7 +6,7 @@
#include <openpose/core/netCaffe.hpp>
#include <openpose/core/resizeAndMergeCaffe.hpp>
#include <openpose/face/faceParameters.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/utilities/fastMath.hpp>
#include <openpose/utilities/openCv.hpp>
#include <openpose/face/faceExtractorCaffe.hpp>
......
......@@ -3,7 +3,7 @@
#include <cuda_runtime_api.h>
#endif
#include <openpose/face/renderFace.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/face/faceGpuRenderer.hpp>
namespace op
......
#include <openpose/face/faceParameters.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hu>
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#include <openpose/utilities/render.hu>
#include <openpose/face/renderFace.hpp>
......
set(SOURCES_OP_GPU
cuda.cpp
gpu.cpp)
include(${CMAKE_SOURCE_DIR}/cmake/Utils.cmake)
prepend(SOURCES_OP_GPU_WITH_CP ${CMAKE_CURRENT_SOURCE_DIR} ${SOURCES_OP_GPU})
set(SOURCES_OP_GPU_WITH_CP ${SOURCES_OP_GPU_WITH_CP} PARENT_SCOPE)
set(SOURCES_OPENPOSE ${SOURCES_OPENPOSE} ${SOURCES_OP_GPU_WITH_CP} PARENT_SCOPE)
if (UNIX AND NOT APPLE)
if (${GPU_MODE} MATCHES "CUDA")
cuda_add_library(openpose_gpu ${SOURCES_OP_GPU})
else()
add_library(openpose_gpu ${SOURCES_OP_GPU})
endif ()
# target_link_libraries(openpose_gpu openpose_core)
install(TARGETS openpose_gpu
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
endif (UNIX AND NOT APPLE)
......@@ -3,7 +3,7 @@
#include <cuda_runtime.h>
#include <openpose/utilities/fastMath.hpp>
#endif
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
namespace op
{
......@@ -38,7 +38,7 @@ namespace op
}
}
int getGpuNumber()
int getCudaGpuNumber()
{
try
{
......
#ifdef USE_CUDA
#include <openpose/gpu/cuda.hpp>
#endif
#ifdef USE_OPENCL
#include <openpose/core/clManager.hpp>
#endif
#include <openpose/gpu/gpu.hpp>
namespace op
{
int getGpuNumber()
{
try
{
#ifdef USE_CUDA
return getCudaGpuNumber();
#elif defined USE_OPENCL
return CLManager::getTotalGPU();
#else
error("OpenPose must be compiled with the `USE_CUDA` or `USE_OPENCL` macro definition in order to use"
" this functionality.", __LINE__, __FUNCTION__, __FILE__);
return -1;
#endif
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return -1;
}
}
GpuMode getGpuMode()
{
try
{
#ifdef USE_CUDA
return GpuMode::CUDA;
#elif defined USE_OPENCL
return GpuMode::OPEN_CL;
#else
return GpuMode::CPU_ONLY;
#endif
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return GpuMode::CPU_ONLY;
}
}
}
......@@ -5,8 +5,8 @@
#include <openpose/core/maximumCaffe.hpp>
#include <openpose/core/netCaffe.hpp>
#include <openpose/core/resizeAndMergeCaffe.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/hand/handParameters.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/fastMath.hpp>
#include <openpose/utilities/keypoint.hpp>
#include <openpose/utilities/openCv.hpp>
......
......@@ -2,8 +2,8 @@
#include <cuda.h>
#include <cuda_runtime_api.h>
#endif
#include <openpose/gpu/cuda.hpp>
#include <openpose/hand/renderHand.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/hand/handGpuRenderer.hpp>
namespace op
......
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#include <openpose/hand/handParameters.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hu>
#include <openpose/utilities/render.hu>
#include <openpose/hand/renderHand.hpp>
......
#include <openpose/gpu/cuda.hpp>
#include <openpose/pose/poseParameters.hpp>
#include <openpose/utilities/check.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/fastMath.hpp>
#include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/bodyPartConnectorBase.hpp>
namespace op
......
......@@ -4,10 +4,10 @@
#include <openpose/core/netCaffe.hpp>
#include <openpose/core/nmsCaffe.hpp>
#include <openpose/core/resizeAndMergeCaffe.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/pose/bodyPartConnectorCaffe.hpp>
#include <openpose/pose/poseParameters.hpp>
#include <openpose/utilities/check.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/fastMath.hpp>
#include <openpose/utilities/openCv.hpp>
#include <openpose/utilities/standard.hpp>
......
......@@ -4,7 +4,7 @@
#endif
#include <openpose/pose/poseParameters.hpp>
#include <openpose/pose/renderPose.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/gpu/cuda.hpp>
#include <openpose/utilities/keypoint.hpp>
#include <openpose/pose/poseGpuRenderer.hpp>
......@@ -152,9 +152,9 @@ namespace op
gpuToCpuMemoryIfLastRenderer(outputData.getPtr(), outputData.getVolume());
cudaCheck(__LINE__, __FUNCTION__, __FILE__);
#else
UNUSED(elementRendered);
UNUSED(outputData);
UNUSED(poseKeypoints);
UNUSED(scaleInputToOutput);
UNUSED(scaleNetToOutput);
error("OpenPose must be compiled with the `USE_CUDA` macro definitions in order to run this"
" functionality. You can alternatively use CPU rendering (flag `--render_pose 1`).",
......
#include <openpose/gpu/cuda.hpp>
#include <openpose/gpu/cuda.hu>
#include <openpose/pose/poseParameters.hpp>
#include <openpose/utilities/cuda.hpp>
#include <openpose/utilities/cuda.hu>
#include <openpose/utilities/render.hu>
#include <openpose/pose/renderPose.hpp>
......
set(SOURCES_OP_UTILITIES
cuda.cpp
set(SOURCES_OP_UTILITIES
errorAndLog.cpp
fileSystem.cpp
flagsToOpenPose.cpp
......
set(SOURCES_OP_WRAPPER
defineTemplates.cpp
wrapperAuxiliary.cpp
wrapperStructFace.cpp
wrapperStructHand.cpp
wrapperStructInput.cpp
......
#include <openpose/thread/enumClasses.hpp>
#include <openpose/wrapper/wrapperAuxiliary.hpp>
namespace op
{
void wrapperConfigureSecurityChecks(const WrapperStructPose& wrapperStructPose,
const WrapperStructFace& wrapperStructFace,
const WrapperStructHand& wrapperStructHand,
const WrapperStructInput& wrapperStructInput,
const WrapperStructOutput& wrapperStructOutput,
const bool renderOutput,
const bool userOutputWsEmpty,
const ThreadManagerMode threadManagerMode)
{
try
{
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
// Check no wrong/contradictory flags enabled
if (wrapperStructPose.alphaKeypoint < 0. || wrapperStructPose.alphaKeypoint > 1.
|| wrapperStructFace.alphaHeatMap < 0. || wrapperStructFace.alphaHeatMap > 1.
|| wrapperStructHand.alphaHeatMap < 0. || wrapperStructHand.alphaHeatMap > 1.)
error("Alpha value for blending must be in the range [0,1].", __LINE__, __FUNCTION__, __FILE__);
if (wrapperStructPose.scaleGap <= 0.f && wrapperStructPose.scalesNumber > 1)
error("The scale gap must be greater than 0 (it has no effect if the number of scales is 1).",
__LINE__, __FUNCTION__, __FILE__);
if (!renderOutput && (!wrapperStructOutput.writeImages.empty() || !wrapperStructOutput.writeVideo.empty()))
{
const auto message = "In order to save the rendered frames (`--write_images` or `--write_video`), you"
" cannot disable `--render_pose`.";
log(message, Priority::High);
}
if (!wrapperStructOutput.writeHeatMaps.empty() && wrapperStructPose.heatMapTypes.empty())
{
const auto message = "In order to save the heatmaps (`--write_heatmaps`), you need to pick which heat"
" maps you want to save: `--heatmaps_add_X` flags or fill the"
" wrapperStructPose.heatMapTypes.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (!wrapperStructOutput.writeHeatMaps.empty()
&& (wrapperStructPose.heatMapScale != ScaleMode::UnsignedChar &&
wrapperStructOutput.writeHeatMapsFormat != "float"))
{
const auto message = "In order to save the heatmaps, you must either set"
" wrapperStructPose.heatMapScale to ScaleMode::UnsignedChar (i.e. range [0, 255])"
" or `--write_heatmaps_format` to `float` to storage floating numbers in binary"
" mode.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (userOutputWsEmpty && threadManagerMode != ThreadManagerMode::Asynchronous
&& threadManagerMode != ThreadManagerMode::AsynchronousOut)
{
const std::string additionalMessage{
" You could also set mThreadManagerMode = mThreadManagerMode::Asynchronous(Out) and/or add your"
" own output worker class before calling this function."
};
const auto savingSomething = (
!wrapperStructOutput.writeImages.empty() || !wrapperStructOutput.writeVideo.empty()
|| !wrapperStructOutput.writeKeypoint.empty() || !wrapperStructOutput.writeJson.empty()
|| !wrapperStructOutput.writeCocoJson.empty() || !wrapperStructOutput.writeHeatMaps.empty()
);
if (!wrapperStructOutput.displayGui && !savingSomething)
{
const auto message = "No output is selected (`--no_display`) and no results are generated (no"
" `--write_X` flags enabled). Thus, no output would be generated."
+ additionalMessage;
error(message, __LINE__, __FUNCTION__, __FILE__);
}
if (wrapperStructInput.framesRepeat && savingSomething)
{
const auto message = "Frames repetition (`--frames_repeat`) is enabled as well as some writing"
" function (`--write_X`). This program would never stop recording the same"
" frames over and over. Please, disable repetition or remove writing.";
error(message, __LINE__, __FUNCTION__, __FILE__);
}
// Warnings
if ((wrapperStructOutput.displayGui && wrapperStructOutput.guiVerbose) && !renderOutput)
{
const auto message = "No render is enabled (e.g. `--render_pose 0`), so you might also want to"
" remove the display (set `--no_display` or `--no_gui_verbose`). If you"
" simply want to use OpenPose to record video/images without keypoints, you"
" only need to set `--num_gpu 0`." + additionalMessage;
log(message, Priority::High);
}
if (wrapperStructInput.realTimeProcessing && savingSomething)
{
const auto message = "Real time processing is enabled as well as some writing function. Thus, some"
" frames might be skipped. Consider disabling real time processing if you"
" intend to save any results.";
log(message, Priority::High);
}
}
if (!wrapperStructOutput.writeVideo.empty() && wrapperStructInput.producerSharedPtr == nullptr)
error("Writting video is only available if the OpenPose producer is used (i.e."
" wrapperStructInput.producerSharedPtr cannot be a nullptr).", __LINE__, __FUNCTION__, __FILE__);
if (!wrapperStructPose.enable)
{
if (!wrapperStructFace.enable)
error("Body keypoint detection must be enabled.", __LINE__, __FUNCTION__, __FILE__);
if (wrapperStructHand.enable)
error("Body keypoint detection must be enabled in order to run hand keypoint detection.",
__LINE__, __FUNCTION__, __FILE__);
}
#ifdef CPU_ONLY
if (wrapperStructPose.gpuNumber > 0)
error("GPU number must be negative or 0 if CPU_ONLY is enabled.", __LINE__, __FUNCTION__, __FILE__);
#endif
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册