提交 d141b6ca 编写于 作者: G Gines Hidalgo

OpenCL and 3D working again

上级 a7ad79ed
......@@ -19,7 +19,7 @@ endfunction (download_model)
function(download_zip FILE_NAME URL DOWNLOAD_PATH CHECKSUM)
set(FULL_FILE_PATH "${DOWNLOAD_PATH}/${FILE_NAME}")
if (NOT EXISTS ${FULL_FILE_PATH})
message(STATUS "Downloading ${URL}...")
message(STATUS "Downloading ${URL}/${FILE_NAME}...")
file(DOWNLOAD "${URL}/${FILE_NAME}" "${DOWNLOAD_PATH}/${FILE_NAME}"
EXPECTED_MD5 ${CHECKSUM})
message(STATUS "Extracting ${FULL_FILE_PATH}...")
......
......@@ -103,7 +103,10 @@ NOTE: These instructions are only required when compiling OpenPose brom source.
- CMake automatically downloads all the Windows DLLs. Alternatively, you might prefer to download them manually:
- Dependencies:
- Note: Leave the zip files in `3rdparty/windows/` so that CMake does not try to download them again.
- [Caffe](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/caffe_15_2019_05_16.zip): Unzip as `3rdparty/windows/caffe/`.
- Caffe (if you are not sure which one you need, donwload the default one):
- [CUDA Caffe (Default)](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/caffe_15_2019_05_16.zip): Unzip as `3rdparty/windows/caffe/`.
- [CPU Caffe](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/caffe_cpu_2018_05_27.zip): Unzip as `3rdparty/windows/caffe_cpu/`.
- [OpenCL Caffe](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/caffe_opencl_2018_02_13.zip): Unzip as `3rdparty/windows/caffe_opencl/`.
- [Caffe dependencies](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/caffe3rdparty_15_2019_03_14.zip): Unzip as `3rdparty/windows/caffe3rdparty/`.
- [OpenCV 4.0.1](http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/opencv_401_v14_15_2019_03_14.zip): Unzip as `3rdparty/windows/opencv/`.
6. **Eigen prerequisite** (optional, only required for some specific extra functionality, such as extrinsic camera calibration):
......
......@@ -154,9 +154,9 @@ namespace op
}
}
double triangulateWithOptimization(cv::Mat& reconstructedPoint, const std::vector<cv::Mat>& cameraMatrices,
const std::vector<cv::Point2d>& pointsOnEachCamera,
const double reprojectionMaxAcceptable)
double triangulateWithOptimization(
cv::Mat& reconstructedPoint, const std::vector<cv::Mat>& cameraMatrices,
const std::vector<cv::Point2d>& pointsOnEachCamera, const double reprojectionMaxAcceptable)
{
try
{
......@@ -356,7 +356,7 @@ namespace op
{
if (!keypoints.empty())
{
detectionMissed++;
++detectionMissed;
if (detectionMissed > 1)
{
numberBodyParts = keypoints.getSize(1);
......@@ -372,7 +372,7 @@ namespace op
std::vector<int> indexesUsed;
std::vector<std::vector<cv::Point2d>> xyPoints;
std::vector<std::vector<cv::Mat>> cameraMatricesPerPoint;
for (auto part = 0; part < numberBodyParts; part++)
for (auto part = 0; part < numberBodyParts; ++part)
{
// Create vector of points
// auto missedPoint = false;
......@@ -383,7 +383,7 @@ namespace op
for (auto i = 0u ; i < keypointsVector.size() ; i++)
{
const auto& keypoints = keypointsVector[i];
if (isValidKeypoint(&keypoints[baseIndex], imageSizes[i]))
if (!keypoints.empty() && isValidKeypoint(&keypoints[baseIndex], imageSizes[i]))
{
xyPointsElement.emplace_back(
cv::Point2d{keypoints[baseIndex], keypoints[baseIndex+1]});
......@@ -408,9 +408,9 @@ namespace op
const auto imageRatio = std::sqrt(imageSizes[0].x * imageSizes[0].y / 1310720.);
const auto reprojectionMaxAcceptable = 25 * imageRatio;
std::vector<double> reprojectionErrors(xyPoints.size());
keypoints3D.reset({ 1, numberBodyParts, 4 }, 0.f);
if (!xyPoints.empty())
{
keypoints3D.reset({ 1, numberBodyParts, 4 }, 0.f);
// Do 3D reconstruction
std::vector<cv::Point3f> xyzPoints(xyPoints.size());
for (auto i = 0u; i < xyPoints.size(); i++)
......@@ -434,7 +434,7 @@ namespace op
// 20 pixels for 1280x1024 image
bool atLeastOnePointProjected = false;
const auto lastChannelLength = keypoints3D.getSize(2);
for (auto index = 0u; index < indexesUsed.size(); index++)
for (auto index = 0u; index < indexesUsed.size(); ++index)
{
if (std::isfinite(xyzPoints[index].x) && std::isfinite(xyzPoints[index].y)
&& std::isfinite(xyzPoints[index].z)
......
......@@ -11,7 +11,8 @@
namespace op
{
#ifdef USE_OPENCL
typedef cl::KernelFunctor<cl::Buffer, cl::Buffer, cl::Buffer, cl::Buffer, cl::Buffer, unsigned int, int, int, int, float, float> PAFScoreKernelFunctor;
typedef cl::KernelFunctor<cl::Buffer, cl::Buffer, cl::Buffer, cl::Buffer, cl::Buffer, unsigned int, int, int,
int, float, float, float> PAFScoreKernelFunctor;
const std::string pafScoreKernel = MULTI_LINE_STRING(
int intRoundGPU(const Type a)
......@@ -19,9 +20,10 @@ namespace op
return (int)(a+0.5);
}
Type process(__global const Type* bodyPartA, __global const Type* bodyPartB, __global const Type* mapX, __global const Type* mapY,
const int heatmapWidth, const int heatmapHeight, const Type interThreshold,
const Type interMinAboveThreshold, const Type defaultNmsThreshold)
Type process(
__global const Type* bodyPartA, __global const Type* bodyPartB, __global const Type* mapX,
__global const Type* mapY, const int heatmapWidth, const int heatmapHeight, const Type interThreshold,
const Type interMinAboveThreshold, const Type defaultNmsThreshold)
{
const Type vectorAToBX = bodyPartB[0] - bodyPartA[0];
const Type vectorAToBY = bodyPartB[1] - bodyPartA[1];
......@@ -67,7 +69,7 @@ namespace op
const Type l2Dist = sqrt((Type)(vectorAToBX*vectorAToBX + vectorAToBY*vectorAToBY));
const Type threshold = sqrt((Type)(heatmapWidth*heatmapHeight))/150; // 3.3 for 368x656, 6.6 for 2x resolution
if (l2Dist < threshold)
return T(defaultNmsThreshold+1e-6); // Without 1e-6 will not work because I use strict greater
return Type(defaultNmsThreshold+1e-6); // Without 1e-6 will not work because I use strict greater
}
}
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册