提交 c0b3fc97 编写于 作者: G gineshidalgo99

Ubuntu fixes for TX2

上级 f4789174
......@@ -29,7 +29,7 @@ addons:
# Build your code e.g. by calling make
script:
- ./ubuntu/install_cmake.sh
- ./3rdparty/ubuntu/install_ubuntu_deps_and_cuda.sh
- sudo apt-get -y install libatlas-base-dev
- sudo apt-get -y install libopencv-dev
- pip install --upgrade numpy
......
......@@ -101,7 +101,7 @@ PYTHON_LIB := /usr/lib /usr/local/lib
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial
# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
......
......@@ -212,7 +212,9 @@ ifeq ($(USE_OPENCV), 1)
LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_objdetect opencv_video opencv_calib3d
ifeq ($(OPENCV_VERSION), 3)
LIBRARIES += opencv_imgcodecs opencv_videoio opencv_cudawarping
LIBRARIES += opencv_imgcodecs opencv_videoio
# Cuda warping removed for TX2 compatibility (PR #989)
# LIBRARIES += opencv_imgcodecs opencv_videoio opencv_cudawarping
else
LIBRARIES += opencv_contrib opencv_gpu
endif
......
......@@ -23,7 +23,7 @@ function executeShInItsFolder {
# $1 = sh file name
# $2 = folder where the sh file is
# $3 = folder to go back
cd $2
cd $2
exitIfError
sudo chmod +x $1
exitIfError
......@@ -41,7 +41,7 @@ exitIfError
executeShInItsFolder "install_openpose_JetsonTX2_JetPack3.1.sh" "./ubuntu" "./"
executeShInItsFolder "install_openpose_JetsonTX2_JetPack3.1.sh" "./3rdparty/ubuntu/" "./"
exitIfError
......
......@@ -23,7 +23,7 @@ function executeShInItsFolder {
# $1 = sh file name
# $2 = folder where the sh file is
# $3 = folder to go back
cd $2
cd $2
exitIfError
sudo chmod +x $1
exitIfError
......@@ -36,14 +36,14 @@ function executeShInItsFolder {
rm -r ./3rdparty/caffe
git submodule update --init --recursive
mv ./ubuntu/install_caffe_JetsonTX2_JetPack3.3.sh ./3rdparty/caffe/install_caffe_JetsonTX2_JetPack3.3.sh
mv ./ubuntu/Makefile.config.Ubuntu16_cuda9_JetsonTX2_caffe ./3rdparty/caffe/Makefile.config.Ubuntu16_cuda9_JetsonTX2_caffe
mv ./3rdparty/ubuntu/install_caffe_JetsonTX2_JetPack3.3.sh ./3rdparty/caffe/install_caffe_JetsonTX2_JetPack3.3.sh
mv ./3rdparty/ubuntu/Makefile.config.Ubuntu16_cuda9_JetsonTX2_caffe ./3rdparty/caffe/Makefile.config.Ubuntu16_cuda9_JetsonTX2_caffe
executeShInItsFolder "install_caffe_JetsonTX2_JetPack3.3.sh" "./3rdparty/caffe" "../.."
exitIfError
executeShInItsFolder "install_openpose_JetsonTX2_JetPack3.3.sh" "./ubuntu" "./"
executeShInItsFolder "install_openpose_JetsonTX2_JetPack3.3.sh" "./3rdparty/ubuntu/" "./"
exitIfError
......
#!/bin/bash
echo "NOTE: This script assumes Ubuntu 16 or 14 and Nvidia Graphics card up to 10XX. Otherwise, install it by yourself or it will fail."
# Install CUDA 8.0
ubuntu_version="$(lsb_release -r)"
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
if [[ $ubuntu_version == *"14."* ]]; then
......@@ -10,4 +13,5 @@ elif [[ $ubuntu_version == *"16."* ]]; then
sudo dpkg --install cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
fi
sudo apt-get update
sudo apt-get install cuda
sudo apt-get install cuda-8-0
# sudo apt-get install cuda
#!/bin/bash
echo "NOTE: This script assumes Ubuntu 16 or 14 and Nvidia Graphics card up to 10XX. Otherwise, install it by yourself or it will fail."
# Install cuDNN 5.1
ubuntu_version="$(lsb_release -r)"
CUDNN_URL="http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz"
wget -c ${CUDNN_URL}
sudo tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local
......
......@@ -51,10 +51,10 @@ echo ""
echo "------------------------- Compiling OpenPose -------------------------"
# Go back to main folder
cd ..
cd ../..
# Copy Makefile & Makefile.config
cp ubuntu/Makefile.example_openpose Makefile
cp ubuntu/Makefile.config.Ubuntu16_cuda9_JetsonTX2_openpose Makefile.config
cp 3rdparty/ubuntu/Makefile.example Makefile
cp 3rdparty/ubuntu/Makefile.config.Ubuntu16_cuda8_JetsonTX2 Makefile.config
# Compile OpenPose
make all -j$NUM_CORES
exitIfError
......
......@@ -51,10 +51,10 @@ echo ""
echo "------------------------- Compiling OpenPose -------------------------"
# Go back to main folder
cd ..
cd ../..
# Copy Makefile & Makefile.config
cp ubuntu/Makefile.example Makefile
cp ubuntu/Makefile.config.Ubuntu16_cuda8_JetsonTX2 Makefile.config
cp 3rdparty/ubuntu/Makefile.example_openpose Makefile
cp 3rdparty/ubuntu/Makefile.config.Ubuntu16_cuda9_JetsonTX2_openpose Makefile.config
# Compile OpenPose
make all -j$NUM_CORES
exitIfError
......
......@@ -2,24 +2,6 @@
### INSTALL PREREQUISITES
ubuntu_version="$(lsb_release -r)"
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
if [[ $ubuntu_version == *"14."* ]]; then
wget -c "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb"
sudo dpkg --install cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb
elif [[ $ubuntu_version == *"16."* ]]; then
wget -c "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb"
sudo dpkg --install cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
fi
sudo apt-get update
sudo apt-get install cuda-8-0
# Install cuDNN 5.1
CUDNN_URL="http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz"
wget -c ${CUDNN_URL}
sudo tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local
rm cudnn-8.0-linux-x64-v5.1.tgz && sudo ldconfig
# Basic
sudo apt-get --assume-yes update
sudo apt-get --assume-yes install build-essential
......
#!/bin/bash
### INSTALL PREREQUISITES
# Install CUDA 8.0
bash install_cuda.sh
# Install cuDNN 5.1
bash install_cudnn.sh
# Caffe prerequisites
bash install_ubuntu_deps.sh
......@@ -23,7 +23,7 @@ function executeShInItsFolder {
# $1 = sh file name
# $2 = folder where the sh file is
# $3 = folder to go back
cd $2
cd $2
exitIfError
sudo chmod +x $1
exitIfError
......@@ -41,7 +41,7 @@ exitIfError
executeShInItsFolder "install_openpose_if_cuda8.sh" "./ubuntu" "./"
executeShInItsFolder "install_openpose_if_cuda8.sh" "./3rdparty/ubuntu_deprecated/" "./"
exitIfError
......
......@@ -63,13 +63,13 @@ echo ""
echo "------------------------- Compiling OpenPose -------------------------"
# Go back to main folder
cd ..
cd ../..
# Copy Makefile & Makefile.config
cp ubuntu/Makefile.example Makefile
cp 3rdparty/ubuntu/Makefile.example Makefile
if [[ $ubuntu_le_14 == true ]]; then
cp ubuntu/Makefile.config.Ubuntu14_cuda8.example Makefile.config
cp 3rdparty/ubuntu_deprecated/Makefile.config.Ubuntu14_cuda8.example Makefile.config
else
cp ubuntu/Makefile.config.Ubuntu16_cuda8.example Makefile.config
cp 3rdparty/ubuntu_deprecated/Makefile.config.Ubuntu16_cuda8.example Makefile.config
fi
# Compile OpenPose
make all -j$NUM_CORES
......
:: Avoid printing all the comments in the Windows cmd
@echo off
SET UNZIP_EXE=unzip\unzip.exe
SET WGET_EXE=wget\wget.exe
:: Download temporary zip
echo ----- Downloading Caffe -----
SET SPINNAKER_FOLDER=spinnaker\
SET ZIP_NAME=spinnaker_2018_01_24.zip
SET ZIP_FULL_PATH=%SPINNAKER_FOLDER%%ZIP_NAME%
%WGET_EXE% -c http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/windows/%ZIP_NAME% -P %SPINNAKER_FOLDER%
echo:
echo ----- Unzipping Caffe -----
%UNZIP_EXE% %ZIP_FULL_PATH%
echo:
:: echo ----- Deleting Temporary Zip File %ZIP_FULL_PATH% -----
:: del "%ZIP_FULL_PATH%"
echo ----- Caffe Downloaded and Unzipped -----
......@@ -39,7 +39,7 @@ This installation section is only intended if you plan to modify the OpenPose co
- **Ubuntu** 14 and 16.
- **Windows** 8 and 10.
- **Mac OSX** Mavericks and above.
- **Nvidia Jetson TX2**, installation instructions in [doc/installation_jetson_tx2.md](./installation_jetson_tx2.md).
- **Nvidia Jetson TX2**, installation instructions in [doc/installation_jetson_tx2_jetpack3.1.md](./installation_jetson_tx2_jetpack3.1.md) and [doc/installation_jetson_tx2_jetpack3.3.md](./installation_jetson_tx2_jetpack3.3.md).
- OpenPose has also been used on **Windows 7**, **CentOS**, and **Nvidia Jetson (TK1 and TX1)** embedded systems. However, we do not officially support them at the moment.
......@@ -125,14 +125,14 @@ Any problem installing OpenPose? Check [doc/faq.md](./faq.md) and/or post a GitH
4. Nvidia GPU version prerequisites:
1. **Note: OpenPose has been tested extensively with CUDA 8.0 and cuDNN 5.1**. We highly recommend using those versions to minimize potential installation issues. Other versions should also work, but we do not provide support about any CUDA/cuDNN installation/compilation issue, as well as problems relate dto their integration into OpenPose.
2. [**CUDA 8**](https://developer.nvidia.com/cuda-80-ga2-download-archive):
- Ubuntu: Run `sudo ubuntu/install_cuda.sh` or alternatively download and install it from their website.
- Ubuntu: Run `sudo 3rdparty/ubuntu/install_cuda.sh` (if Ubuntu 16 or 14 and for Graphic cards up to 10XX) or alternatively download and install it from their website.
- Windows: Install CUDA 8.0 after Visual Studio 2015 is installed to assure that the CUDA installation will generate all necessary files for VS. If CUDA was already installed, re-install it.
- **Important installation tips**:
- New Nvidia model GPUs (e.g., Nvidia V, GTX 2080, any Nvidia with Volta or Turing architecture, etc.) require at least CUDA 9.
- (Windows issue, reported Sep 2018): If your computer hangs when installing CUDA drivers, try installing first the [Nvidia drivers](http://www.nvidia.com/Download/index.aspx), and then installing CUDA without the Graphics Driver flag.
- (Windows): If CMake returns and error message similar to `CUDA_TOOLKIT_ROOT_DIR not found or specified` or any other CUDA component missing, then: 1) Re-install Visual Studio 2015; 2) Reboot your PC; 3) Re-install CUDA.
3. [**cuDNN 5.1**](https://developer.nvidia.com/rdp/cudnn-archive):
- Ubuntu: Run `sudo ubuntu/install_cudnn.sh` or alternatively download and install it from their website.
- Ubuntu: Run `sudo 3rdparty/ubuntu/install_cudnn.sh` (if Ubuntu 16 or 14 and for Graphic cards up to 10XX) or alternatively download and install it from their website.
- Windows (and Ubuntu if manual installation): In order to manually install it, just unzip it and copy (merge) the contents on the CUDA folder, usually `/usr/local/cuda/` in Ubuntu and `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0` in Windows.
5. AMD GPU version prerequisites:
1. Download official AMD drivers for Windows from [**AMD - Windows**](https://support.amd.com/en-us/download).
......@@ -140,7 +140,7 @@ Any problem installing OpenPose? Check [doc/faq.md](./faq.md) and/or post a GitH
3. Ubuntu only: Install `sudo apt-get install libviennacl-dev`. This comes packaged inside OpenPose for Windows.
4. AMD Drivers have not been tested on OSX. Please email us if you wish to test it. This has only been tested on Vega series cards.
6. Ubuntu - Other prerequisites:
- Caffe prerequisites: By default, OpenPose uses Caffe under the hood. If you have not used Caffe previously, install its dependencies by running `sudo bash ./ubuntu/install_cmake.sh`.
- Caffe prerequisites: By default, OpenPose uses Caffe under the hood. If you have not used Caffe previously, install its dependencies by running `sudo bash ./3rdparty/ubuntu/install_ubuntu_deps_and_cuda.sh` (if Ubuntu 16 or 14 and for Graphic cards up to 10XX) or run `sudo bash ./3rdparty/ubuntu/install_ubuntu_deps.sh` after installing your desired CUDA and cuDNN versions.
- OpenCV must be already installed on your machine. It can be installed with `apt-get install libopencv-dev`. You can also use your own compiled OpenCV version.
7. Windows - **Caffe, OpenCV, and Caffe prerequisites**:
- CMake automatically downloads all the Windows DLLs. Alternatively, you might prefer to download them manually:
......
......@@ -54,7 +54,7 @@ CUDA, cuDNN, OpenCV and Atlas must be already installed on your machine:
### Installation - Script Compilation
Build Caffe & the OpenPose library + download the required Caffe models for Ubuntu 14.04 or 16.04 (auto-detected for the script) and CUDA 8:
```bash
bash ./ubuntu/install_caffe_and_openpose_if_cuda8.sh
bash ./3rdparty/ubuntu_deprecated/install_caffe_and_openpose_if_cuda8.sh
```
**Highly important**: This script only works with CUDA 8 and Ubuntu 14 or 16. Otherwise, see [doc/installation.md](installation.md) or [Installation - Manual Compilation](#installation---manual-compilation).
......@@ -81,9 +81,9 @@ Alternatively to the script installation, if you want to use CUDA 7, avoid using
cd ../../models/
bash ./getModels.sh # It just downloads the Caffe trained models
cd ..
cp ubuntu/Makefile.example Makefile
cp 3rdparty/ubuntu/Makefile.example Makefile
# Same file cp command as the one used for Caffe
cp ubuntu/Makefile.config.Ubuntu14_cuda7.example Makefile.config
cp 3rdparty/ubuntu_deprecated/Makefile.config.Ubuntu14_cuda7.example Makefile.config
# Change any custom flag from the resulting Makefile.config (e.g., OpenCV 3, Atlas/OpenBLAS/MKL, etc.)
make all -j`nproc`
```
......@@ -97,7 +97,7 @@ Alternatively to the script installation, if you want to use CUDA 7, avoid using
make clean
make all -j$(NUM_CORES)
```
**Highly important**: There are 2 `Makefile.config.Ubuntu##.example` analogous files, one in the main folder and one in [3rdparty/caffe/](../3rdparty/caffe/), corresponding to OpenPose and Caffe configuration files respectively. Any change must be done to both files (e.g., OpenCV 3 flag, Atlab/OpenBLAS/MKL flag, etc.). E.g., for CUDA 8 and Ubuntu16: [3rdparty/caffe/Makefile.config.Ubuntu16_cuda8.example](../3rdparty/caffe/Makefile.config.Ubuntu16.example) and [ubuntu/Makefile.config.Ubuntu16_cuda8.example](../ubuntu/Makefile.config.Ubuntu16_cuda8.example).
**Highly important**: There are 2 `Makefile.config.Ubuntu##.example` analogous files, one in the main folder and one in [3rdparty/caffe/](../3rdparty/caffe/), corresponding to OpenPose and Caffe configuration files respectively. Any change must be done to both files (e.g., OpenCV 3 flag, Atlab/OpenBLAS/MKL flag, etc.). E.g., for CUDA 8 and Ubuntu16: [3rdparty/caffe/Makefile.config.Ubuntu16_cuda8.example](../3rdparty/caffe/Makefile.config.Ubuntu16.example) and [3rdparty/ubuntu_deprecated/Makefile.config.Ubuntu16_cuda8.example](../3rdparty/ubuntu_deprecated/Makefile.config.Ubuntu16_cuda8.example).
......
......@@ -31,7 +31,7 @@ Notes:
## Installation
Use the following script for installation of both caffe and OpenPose:
```
./ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.1.sh
./3rdparty/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.1.sh
```
......@@ -45,4 +45,4 @@ To activate hand or face resolution please complete this command with the follow
```
--hand -hand_net_resolution 256x256
--face -face_net_resolution 256x256
```
```
......@@ -31,7 +31,7 @@ Notes:
## Installation
Use the following script for installation of both caffe and OpenPose:
```
./ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.3.sh
./3rdparty/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.3.sh
```
......@@ -45,4 +45,4 @@ To activate hand or face resolution please complete this command with the follow
```
--hand -hand_net_resolution 256x256
--face -face_net_resolution 256x256
```
\ No newline at end of file
```
......@@ -135,13 +135,14 @@ Examples:
:: Ceres-compatible version not implemented for Windows yet. Make a pull request if you have a working version in Windows.
```
5. Hint to verify extrinsic calibration is successful:
1. Translation vector - Global distance:
1. Our final reprojection error (after rescaling) for the bundle adjustment step is usually about 0.1-0.15 pixels.
2. Translation vector - Global distance:
1. Manually open each one of the generated XML files from the folder indicated by the flag `--camera_parameter_path` (or the default one indicated by the `--help` flag if the former was not used).
2. The field `CameraMatrix` is a 3 x 4 matrix (you can see that the subfield `rows` in that file is 3 and `cols` is 4).
3. Order the matrix in that 3 x 4 shape (e.g., by copying in a different text file with the shape of 3 rows and 4 columns).
4. The 3 first components of the last column of the `CameraMatrix` field define the global `translation` (in meters) with respect to the global origin (in our case camera 1).
5. Thus, the distance between that camera and the origin camera 1 should be (approximately) equal to the L2-norm of the `translation` vector.
2. Translation vector - Relative x-y-z distances:
3. Translation vector - Relative x-y-z distances:
1. The 3x1 `translation` vector represents the `x`, `y`, and `z` distances to the origin camera, respectively. The camera is looking along the positive `z` axis, the `y` axis is down, and the `x` axis is right. This should match the real distance between both cameras.
......
......@@ -299,6 +299,8 @@ OpenPose Library - Release Notes
3. Added bundle adjustment refinement for camera extrinsic calibration.
4. Added `CameraMatrixInitial` field into the XML calibration files to keep the information of the original camera extrinsic parameters when bundle adjustment is run.
27. Video with the 3D output can be saved with the new `--write_video_3d` flag.
28. Added Mac OpenCL compatibility.
29. Added documentation for Nvidia TX2 with JetPack 3.3.
2. Functions or parameters renamed:
1. By default, python example `tutorial_developer/python_2_pose_from_heatmaps.py` was using 2 scales starting at -1x736, changed to 1 scale at -1x368.
2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary.
......@@ -319,6 +321,7 @@ OpenPose Library - Release Notes
5. Fixed bug in `KeepTopNPeople` that could provoke segmentation fault for `number_people_max` > 1.
6. Camera parameter reader can now take folder paths even if they are not finished in `/` (e.g., `~/Desktop/` worked but `~/Desktop` did not).
7. 3D module: If the image area was smaller than HD resolution image area, the 3D keypoints were not properly estimated.
8. OpenCL fixes.
......
......@@ -1193,7 +1193,7 @@ namespace op
}
#if defined(USE_CERES) && defined(USE_EIGEN)
double computeReprojectionError(
double computeReprojectionErrorInPixels(
const std::vector<std::vector<cv::Point2f>>& points2DVectorsExtrinsic, const Eigen::MatrixXd& BAValid,
const Eigen::Matrix<double, 3, Eigen::Dynamic>& points3D, const std::vector<cv::Mat> cameraExtrinsics,
const std::vector<cv::Mat> cameraIntrinsics, const bool verbose = true)
......@@ -1405,7 +1405,7 @@ namespace op
try
{
// Outlier removal
auto reprojectionError = computeReprojectionError(
auto reprojectionError = computeReprojectionErrorInPixels(
points2DVectorsExtrinsic, BAValid, points3D, cameraExtrinsics, cameraIntrinsics, false);
auto reprojectionErrorPrevious = reprojectionError+1;
while (reprojectionError != reprojectionErrorPrevious)
......@@ -1416,12 +1416,12 @@ namespace op
removeOutliersReprojectionError(
points2DVectorsExtrinsic, BAValid, points3D, cameraExtrinsics, cameraIntrinsics,
errorThreshold);
reprojectionError = computeReprojectionError(
reprojectionError = computeReprojectionErrorInPixels(
points2DVectorsExtrinsic, BAValid, points3D, cameraExtrinsics, cameraIntrinsics);
// Verbose
log("Reprojection Error (after outlier removal iteration): "
+ std::to_string(reprojectionError) + ",\twith error threshold of "
+ std::to_string(errorThreshold) + ".", Priority::High);
+ std::to_string(reprojectionError) + " pixels,\twith error threshold of "
+ std::to_string(errorThreshold) + " pixels.", Priority::High);
}
}
catch (const std::exception& e)
......@@ -1925,10 +1925,10 @@ namespace op
extrinsics.at<double>(x, y) = rotation(x, y);
refinedExtrinsics[cameraIndex] = extrinsics;
}
const auto reprojectionError = computeReprojectionError(
const auto reprojectionError = computeReprojectionErrorInPixels(
points2DVectorsExtrinsic, BAValid, points3D, refinedExtrinsics, cameraIntrinsics);
log("Reprojection Error (after Bundle Adjustment): " + std::to_string(reprojectionError),
Priority::High);
log("Reprojection Error (after Bundle Adjustment): " + std::to_string(reprojectionError)
+ " pixels.", Priority::High);
}
catch (const std::exception& e)
{
......@@ -1963,7 +1963,8 @@ namespace op
const int startIndex = startPerFrame + t * numberCorners;
const int endPerFrame = x + 1 + y * gridInnerCorners.x;
const int endIndex = endPerFrame + t * numberCorners;
if (BAValid.col(startIndex).any() && BAValid.col(endIndex).any()) // These points are used for BA, must have been constructed.
// These points are used for BA, must have been constructed.
if (BAValid.col(startIndex).any() && BAValid.col(endIndex).any())
{
const double length = (points3D.col(startIndex) - points3D.col(endIndex)).norm();
sumSquareLength += length * length;
......@@ -1983,7 +1984,8 @@ namespace op
const int startIndex = startPerFrame + t * numberCorners;
const int endPerFrame = x + (y + 1) * gridInnerCorners.x;
const int endIndex = endPerFrame + t * numberCorners;
if (BAValid.col(startIndex).any() && BAValid.col(endIndex).any()) // These points are used for BA, must have been constructed.
// These points are used for BA, must have been constructed.
if (BAValid.col(startIndex).any() && BAValid.col(endIndex).any())
{
const double length = (points3D.col(startIndex) - points3D.col(endIndex)).norm();
sumSquareLength += length * length;
......@@ -1996,10 +1998,10 @@ namespace op
}
}
const double scalingFactor = 0.001f * gridSquareSizeMm * sumLength / sumSquareLength;
log("Scaling factor: " + std::to_string(scalingFactor) + ",\tMin grid length: " + std::to_string(minLength)
+ ",\tMax grid length: " + std::to_string(maxLength), Priority::High);
// Scale extrinsics
for (auto cameraIndex = 1; cameraIndex < numberCameras; cameraIndex++) // scale the translation (and the 3D point)
log("Scaling factor: " + std::to_string(scalingFactor) + ",\tMin grid length: "
+ std::to_string(minLength) + ",\tMax grid length: " + std::to_string(maxLength), Priority::High);
// Scale extrinsics: Scale the translation (and the 3D point)
for (auto cameraIndex = 1; cameraIndex < numberCameras; cameraIndex++)
{
refinedExtrinsics[cameraIndex].at<double>(0, 3) *= scalingFactor;
refinedExtrinsics[cameraIndex].at<double>(1, 3) *= scalingFactor;
......@@ -2008,9 +2010,10 @@ namespace op
// Scale 3D points
points3D *= scalingFactor;
// Final reprojection error
const auto reprojectionError = computeReprojectionError(
const auto reprojectionError = computeReprojectionErrorInPixels(
points2DVectorsExtrinsic, BAValid, points3D, refinedExtrinsics, cameraIntrinsics);
log("Reprojection Error (after rescaling): " + std::to_string(reprojectionError), Priority::High);
log("Reprojection Error (after rescaling): " + std::to_string(reprojectionError) + " pixels.",
Priority::High);
}
catch (const std::exception& e)
{
......@@ -2032,7 +2035,7 @@ namespace op
// Initial reprojection error
if (printInitialReprojection)
{
const auto reprojectionError = computeReprojectionError(
const auto reprojectionError = computeReprojectionErrorInPixels(
points2DVectorsExtrinsic, BAValid, points3D, refinedExtrinsics, cameraIntrinsics);
log("Reprojection Error (initial): " + std::to_string(reprojectionError), Priority::High);
log(" ", Priority::High);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册