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

Calibration with more verbose & better NVCaffe doc

上级 4cfad62a
......@@ -173,23 +173,26 @@ endif (WIN32)
### PROJECT OPTIONS
# Select the DL Framework
set(DL_FRAMEWORK CAFFE CACHE STRING "Select Deep Learning Framework.")
set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE)
# set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE CAFFE2 TENSORFLOW)
if (WIN32)
set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE)
else (WIN32)
set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE)
# set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE PYTORCH TENSORFLOW)
endif (WIN32)
# Suboptions for Caffe DL Framework
include(CMakeDependentOption)
if (${DL_FRAMEWORK} MATCHES "CAFFE")
if (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
CMAKE_DEPENDENT_OPTION(BUILD_CAFFE "Build Caffe as part of OpenPose." ON
"DL_FRAMEWORK" ON)
# OpenPose flags
add_definitions(-DUSE_CAFFE)
endif (${DL_FRAMEWORK} MATCHES "CAFFE")
OPTION (NV_CAFFE "Use NVCaffe instead of normal Caffe." OFF)
if (NV_CAFFE)
MESSAGE("-- Using NVIDIA NVCaffe")
add_definitions(-DNV_CAFFE)
endif (NV_CAFFE)
# Nvidia NVCaffe
if (${DL_FRAMEWORK} MATCHES "NV_CAFFE")
MESSAGE(STATUS "Using NVIDIA NVCaffe")
add_definitions(-DNV_CAFFE)
endif (${DL_FRAMEWORK} MATCHES "NV_CAFFE")
endif (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
# Set the acceleration library
if (APPLE)
......@@ -684,11 +687,9 @@ if (WIN32)
endif (WIN32)
### CAFFE
### CAFFE/NVCAFFE in Ubuntu
if (UNIX OR APPLE)
if (${DL_FRAMEWORK} MATCHES "CAFFE")
if (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
# Check if the user specified caffe paths
if (Caffe_INCLUDE_DIRS AND Caffe_LIBS AND NOT BUILD_CAFFE)
message(STATUS "\${Caffe_INCLUDE_DIRS} set by the user to " ${Caffe_INCLUDE_DIRS})
......@@ -827,9 +828,7 @@ if (UNIX OR APPLE)
message(FATAL_ERROR "Caffe not found. Either turn on the BUILD_CAFFE option or specify the path of Caffe includes
and libs using -DCaffe_INCLUDE_DIRS and -DCaffe_LIBS.")
endif (NOT Caffe_FOUND AND NOT BUILD_CAFFE)
endif (${DL_FRAMEWORK} MATCHES "CAFFE")
endif (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
endif (UNIX OR APPLE)
### PROJECT INCLUDES
......@@ -915,9 +914,9 @@ elseif (WIN32)
debug ${GLOG_LIBRARY_DEBUG} optimized ${GLOG_LIBRARY_RELEASE})
endif (UNIX OR APPLE)
# Deep net Framework
if (${DL_FRAMEWORK} MATCHES "CAFFE")
if (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
set(OpenPose_3rdparty_libraries ${OpenPose_3rdparty_libraries} ${Caffe_LIBS} ${GFLAGS_LIBRARY})
endif (${DL_FRAMEWORK} MATCHES "CAFFE")
endif (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
# CPU vs. GPU
if (USE_MKL)
set(OpenPose_3rdparty_libraries ${OpenPose_3rdparty_libraries} ${MKL_LIBS})
......
......@@ -367,11 +367,19 @@ For Windows, simply replace the OpenCV DLLs and include folder for your custom o
#### Custom NVIDIA NVCaffe
This has been tested with the official Nvidia Docker image [nvcr.io/nvidia/caffe:18.12-py2](https://ngc.nvidia.com/catalog/containers/nvidia:caffe).
This functionality was added by the community, and we do not officially support it. New pull requests with additional functionality or fixing any bug are welcome!
This functionality was added by the community, and we do not officially support it. For questions and issues, please only post on the related [Pull Request #1169](https://github.com/CMU-Perceptual-Computing-Lab/openpose/pull/1169). New GitHub issues about this topic (i.e., outside PR #1169) will be automatically closed with no answer.
It has been tested with the official Nvidia Docker image [nvcr.io/nvidia/caffe:18.12-py2](https://ngc.nvidia.com/catalog/containers/nvidia:caffe).
To use a NVIDIA's NVCaffe docker image instead of the standard Caffe, 1) set the `NV_CAFFE` variable in CMake, 2) set the `BUILD_CAFFE` variable to `OFF`, and 3) set the correct `Caffe_INCLUDE_DIRS` and `Caffe_LIBS` paths following [Custom Caffe](#custom-caffe).
For questions and issues, please only post on the related [Pull Request #1169](https://github.com/CMU-Perceptual-Computing-Lab/openpose/pull/1169). New GitHub issues about this topic (i.e., outside PR #1169) will be automatically closed with no answer.
Windows support has not been added. Replace `set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE)` by `set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE)` in `CMakeLists.txt` if you intend to use it for Windows, and feel free to do a pull request of it working!
To use a NVIDIA's NVCaffe docker image instead of the standard Caffe, set the following CMake flags:
1. Set the `DL_FRAMEWORK` variable to `NV_CAFFE`.
2. Set the `BUILD_CAFFE` variable to `OFF`.
3. Set the correct `Caffe_INCLUDE_DIRS` and `Caffe_LIBS` paths following [Custom Caffe](#custom-caffe).
......
......@@ -368,6 +368,7 @@ OpenPose Library - Release Notes
## Current version - future OpenPose 1.5.1
1. Main improvements:
1. Highly improved 3D triangulation for >3 cameras by fixing some small bugs.
2. Added community-based support for Nvidia NVCaffe.
2. Functions or parameters renamed:
1. `--3d_min_views` default value (-1) no longer means that all camera views are required. Instead, it will be equal to max(2, min(4, #cameras-1)). This should provide a good trade-off between recall and precission.
3. Main bugs fixed:
......
......@@ -273,7 +273,8 @@ namespace op
// Sanity check
if (angles.empty())
error("Variables `angles` is empty.", __LINE__, __FUNCTION__, __FILE__);
error("Variables `angles` is empty when calling estimateAverageAngle().",
__LINE__, __FUNCTION__, __FILE__);
// angles in range (-pi, pi]
auto anglesNormalized = angles;
......@@ -840,6 +841,12 @@ namespace op
}
}
const std::string sEmptyErrorMessage = "No chessboard was found in any of the images. Are you sure you"
" are using the right value for `--grid_number_inner_corners`? Remember that it corresponds to the"
" number of inner corners on the image (not the total number of corners!). I.e., it corresponds to"
" the number of squares on each side minus 1! (or the number of total corners on each side - 1)."
" It follows the OpenCV notation.";
......@@ -903,6 +910,9 @@ namespace op
imagesWithCorners.emplace_back(imageToPlot);
}
}
// Sanity check
if (points2DVectors.empty())
error(sEmptyErrorMessage, __LINE__, __FUNCTION__, __FILE__);
// Run calibration
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
......@@ -1052,9 +1062,9 @@ namespace op
if (coutAndImshowVerbose)
log("########## Projection Matrix from secondary camera to main camera ##########",
Priority::High);
MCam1ToCam0s.emplace_back(getMFromCam1ToCam0(RGridToMainCam0, tGridToMainCam0,
RGridToMainCam1, tGridToMainCam1,
coutAndImshowVerbose));
MCam1ToCam0s.emplace_back(
getMFromCam1ToCam0(RGridToMainCam0, tGridToMainCam0, RGridToMainCam1, tGridToMainCam1,
coutAndImshowVerbose));
if (coutResults)
{
if (coutAndImshowVerbose)
......@@ -1069,6 +1079,9 @@ namespace op
log("Invalid frame (chessboard not found).", Priority::High);
}
}
// Sanity check
if (MCam1ToCam0s.empty())
error(sEmptyErrorMessage, __LINE__, __FUNCTION__, __FILE__);
log("Finished processing images.", Priority::High);
// Pseudo RANSAC calibration
......@@ -2101,10 +2114,15 @@ namespace op
const cv::Size gridInnerCornersCvSize{gridInnerCorners.x, gridInnerCorners.y};
// Load parameters (distortion, intrinsics, initial extrinsics)
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
log("Loading parameters...", Priority::High);
CameraParameterReader cameraParameterReader;
cameraParameterReader.readParameters(parameterFolder);
const auto cameraExtrinsicsInitial = cameraParameterReader.getCameraExtrinsicsInitial();
// Sanity check
if (cameraExtrinsicsInitial.empty())
error("Camera intrinsics could not be loaded from " + parameterFolder
+ ". Are they in the right path? Remember than the XML must contain the right intrinsic"
+ " parameters before using this function. ", __LINE__, __FUNCTION__, __FILE__);
bool initialEmpty = false;
for (const auto& cameraExtrinsicInitial : cameraExtrinsicsInitial)
{
......@@ -2114,6 +2132,7 @@ namespace op
break;
}
}
log("Parameters loaded.", Priority::High);
// Camera extrinsics
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
auto cameraExtrinsics = (initialEmpty
......@@ -2126,14 +2145,14 @@ namespace op
const auto cameraDistortions = (
imagesAreUndistorted
? std::vector<cv::Mat>{cameraIntrinsics.size()} : cameraParameterReader.getCameraDistortions());
// Read images in folder
log("Reading images in folder...", Priority::High);
const auto numberCorners = gridInnerCorners.area();
std::vector<std::vector<cv::Point2f>> points2DVectorsExtrinsic(numberCameras); // camera - keypoints
std::vector<std::vector<unsigned int>> matchIndexes(numberCameras); // camera - indixes found
if (imageAndPaths.empty())
error("imageAndPaths.empty()!.", __LINE__, __FUNCTION__, __FILE__);
log("Images read.", Priority::High);
// Get 2D grid corners of each image
std::vector<cv::Mat> imagesWithCorners;
const auto imageSize = imageAndPaths.at(0).first.size();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册