Mixed updates and improvements.
This commit is contained in:
12
README.md
12
README.md
@ -32,16 +32,16 @@ Fast triangulation of multiple persons from multiple camera views.
|
|||||||
cd /RapidPoseTriangulation/swig/ && make all && cd ../tests/ && python3 test_interface.py && cd ..
|
cd /RapidPoseTriangulation/swig/ && make all && cd ../tests/ && python3 test_interface.py && cd ..
|
||||||
|
|
||||||
cd /RapidPoseTriangulation/scripts/ && \
|
cd /RapidPoseTriangulation/scripts/ && \
|
||||||
g++ -std=c++17 -fPIC -O3 -march=native -Wall -Werror -flto=auto -fopenmp -fopenmp-simd \
|
g++ -std=c++2a -fPIC -O3 -march=native -Wall -Werror -flto=auto -fopenmp -fopenmp-simd \
|
||||||
$(pkg-config --cflags opencv4) \
|
|
||||||
-I /RapidPoseTriangulation/rpt/ \
|
-I /RapidPoseTriangulation/rpt/ \
|
||||||
-I /onnxruntime/include/ \
|
-isystem /usr/include/opencv4/ \
|
||||||
-I /onnxruntime/include/onnxruntime/core/session/ \
|
-isystem /onnxruntime/include/ \
|
||||||
-I /onnxruntime/include/onnxruntime/core/providers/tensorrt/ \
|
-isystem /onnxruntime/include/onnxruntime/core/session/ \
|
||||||
|
-isystem /onnxruntime/include/onnxruntime/core/providers/tensorrt/ \
|
||||||
-L /onnxruntime/build/Linux/Release/ \
|
-L /onnxruntime/build/Linux/Release/ \
|
||||||
test_skelda_dataset_cpp.cpp \
|
test_skelda_dataset_cpp.cpp \
|
||||||
/RapidPoseTriangulation/rpt/*.cpp \
|
/RapidPoseTriangulation/rpt/*.cpp \
|
||||||
-o test_skelda_dataset \
|
-o test_skelda_dataset.bin \
|
||||||
-Wl,--start-group \
|
-Wl,--start-group \
|
||||||
-lonnxruntime_providers_tensorrt \
|
-lonnxruntime_providers_tensorrt \
|
||||||
-lonnxruntime_providers_shared \
|
-lonnxruntime_providers_shared \
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <mutex>
|
|
||||||
#include <atomic>
|
|
||||||
#include <cmath>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// ROS2
|
// ROS2
|
||||||
#include <rclcpp/rclcpp.hpp>
|
#include <rclcpp/rclcpp.hpp>
|
||||||
@ -14,15 +14,15 @@
|
|||||||
#include <std_msgs/msg/string.hpp>
|
#include <std_msgs/msg/string.hpp>
|
||||||
|
|
||||||
// OpenCV / cv_bridge
|
// OpenCV / cv_bridge
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
#include <cv_bridge/cv_bridge.h>
|
#include <cv_bridge/cv_bridge.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
// JSON library
|
// JSON library
|
||||||
#include "/RapidPoseTriangulation/extras/include/nlohmann/json.hpp"
|
#include "/RapidPoseTriangulation/extras/include/nlohmann/json.hpp"
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
|
||||||
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
||||||
|
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
|
|||||||
@ -581,20 +581,21 @@ void TriangulatorInternal::reset()
|
|||||||
|
|
||||||
void TriangulatorInternal::print_stats()
|
void TriangulatorInternal::print_stats()
|
||||||
{
|
{
|
||||||
std::cout << "Triangulator statistics:" << std::endl;
|
std::cout << "{" << std::endl;
|
||||||
std::cout << " Number of calls: " << num_calls << std::endl;
|
std::cout << " \"triangulator_calls\": " << num_calls << "," << std::endl;
|
||||||
std::cout << " Init time: " << init_time / num_calls << std::endl;
|
std::cout << " \"init_time\": " << init_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Undistort time: " << undistort_time / num_calls << std::endl;
|
std::cout << " \"undistort_time\": " << undistort_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Project time: " << project_time / num_calls << std::endl;
|
std::cout << " \"project_time\": " << project_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Match time: " << match_time / num_calls << std::endl;
|
std::cout << " \"match_time\": " << match_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Pairs time: " << pairs_time / num_calls << std::endl;
|
std::cout << " \"pairs_time\": " << pairs_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Pair scoring time: " << pair_scoring_time / num_calls << std::endl;
|
std::cout << " \"pair_scoring_time\": " << pair_scoring_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Grouping time: " << grouping_time / num_calls << std::endl;
|
std::cout << " \"grouping_time\": " << grouping_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Full time: " << full_time / num_calls << std::endl;
|
std::cout << " \"full_time\": " << full_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Merge time: " << merge_time / num_calls << std::endl;
|
std::cout << " \"merge_time\": " << merge_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Post time: " << post_time / num_calls << std::endl;
|
std::cout << " \"post_time\": " << post_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Convert time: " << convert_time / num_calls << std::endl;
|
std::cout << " \"convert_time\": " << convert_time / num_calls << "," << std::endl;
|
||||||
std::cout << " Total time: " << total_time / num_calls << std::endl;
|
std::cout << " \"total_time\": " << total_time / num_calls << std::endl;
|
||||||
|
std::cout << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|||||||
1
scripts/.gitignore
vendored
1
scripts/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
test_skelda_dataset
|
|
||||||
@ -1,12 +1,12 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// OpenCV
|
// OpenCV
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
@ -15,10 +15,10 @@
|
|||||||
#include "/RapidPoseTriangulation/extras/include/nlohmann/json.hpp"
|
#include "/RapidPoseTriangulation/extras/include/nlohmann/json.hpp"
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
|
||||||
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
|
||||||
#include "/RapidPoseTriangulation/rpt/interface.hpp"
|
|
||||||
#include "/RapidPoseTriangulation/rpt/camera.hpp"
|
#include "/RapidPoseTriangulation/rpt/camera.hpp"
|
||||||
|
#include "/RapidPoseTriangulation/rpt/interface.hpp"
|
||||||
|
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
||||||
|
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
@ -232,12 +232,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
all_poses_3d.push_back(std::move(poses_3d));
|
all_poses_3d.push_back(std::move(poses_3d));
|
||||||
all_ids.push_back(item["id"].get<std::string>());
|
all_ids.push_back(item["id"].get<std::string>());
|
||||||
|
old_id = item["index"];
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
// Print timing stats
|
// Print timing stats
|
||||||
std::cout << "\nMetrics:" << std::endl;
|
std::cout << "\nMetrics:" << std::endl;
|
||||||
tri_model->print_stats();
|
|
||||||
size_t warmup = 10;
|
size_t warmup = 10;
|
||||||
double avg_time_image = time_image / (time_count - warmup);
|
double avg_time_image = time_image / (time_count - warmup);
|
||||||
double avg_time_pose2d = time_pose2d / (time_count - warmup);
|
double avg_time_pose2d = time_pose2d / (time_count - warmup);
|
||||||
@ -249,6 +249,7 @@ int main(int argc, char **argv)
|
|||||||
<< " \"avg_time_3d\": " << avg_time_pose3d << ",\n"
|
<< " \"avg_time_3d\": " << avg_time_pose3d << ",\n"
|
||||||
<< " \"fps\": " << fps << "\n"
|
<< " \"fps\": " << fps << "\n"
|
||||||
<< "}" << std::endl;
|
<< "}" << std::endl;
|
||||||
|
tri_model->print_stats();
|
||||||
|
|
||||||
// Store the results as json
|
// Store the results as json
|
||||||
json all_results;
|
json all_results;
|
||||||
|
|||||||
@ -361,7 +361,7 @@ def main():
|
|||||||
save_json(config, config_path)
|
save_json(config, config_path)
|
||||||
|
|
||||||
# Call the CPP binary
|
# Call the CPP binary
|
||||||
os.system("/RapidPoseTriangulation/scripts/test_skelda_dataset")
|
os.system("/RapidPoseTriangulation/scripts/test_skelda_dataset.bin")
|
||||||
|
|
||||||
# Load the results
|
# Load the results
|
||||||
print("Loading exports ...")
|
print("Loading exports ...")
|
||||||
|
|||||||
@ -330,7 +330,9 @@ def main():
|
|||||||
|
|
||||||
# Load 2D pose model
|
# Load 2D pose model
|
||||||
if utils_pipeline.use_whole_body(whole_body):
|
if utils_pipeline.use_whole_body(whole_body):
|
||||||
kpt_model = utils_2d_pose.load_wb_model(min_bbox_score, min_bbox_area, batch_poses)
|
kpt_model = utils_2d_pose.load_wb_model(
|
||||||
|
min_bbox_score, min_bbox_area, batch_poses
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
kpt_model = utils_2d_pose.load_model(min_bbox_score, min_bbox_area, batch_poses)
|
kpt_model = utils_2d_pose.load_model(min_bbox_score, min_bbox_area, batch_poses)
|
||||||
|
|
||||||
@ -446,10 +448,7 @@ def main():
|
|||||||
all_ids.append(label["id"])
|
all_ids.append(label["id"])
|
||||||
times[i][2] = time_3d
|
times[i][2] = time_3d
|
||||||
|
|
||||||
# Print per-step triangulation timings
|
# Print per-step timings
|
||||||
print("")
|
|
||||||
triangulator.print_stats()
|
|
||||||
|
|
||||||
warmup_iters = 10
|
warmup_iters = 10
|
||||||
if len(times) > warmup_iters:
|
if len(times) > warmup_iters:
|
||||||
times = times[warmup_iters:]
|
times = times[warmup_iters:]
|
||||||
@ -464,6 +463,7 @@ def main():
|
|||||||
}
|
}
|
||||||
print("\nMetrics:")
|
print("\nMetrics:")
|
||||||
print(json.dumps(tstats, indent=2))
|
print(json.dumps(tstats, indent=2))
|
||||||
|
triangulator.print_stats()
|
||||||
|
|
||||||
_ = evals.mpjpe.run_eval(
|
_ = evals.mpjpe.run_eval(
|
||||||
labels,
|
labels,
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
#include <onnxruntime_cxx_api.h>
|
#include <onnxruntime_cxx_api.h>
|
||||||
#include <onnxruntime_c_api.h>
|
#include <onnxruntime_c_api.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
#include <tensorrt_provider_options.h>
|
#include <tensorrt_provider_options.h>
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
@ -646,27 +646,10 @@ namespace utils_2d_pose
|
|||||||
|
|
||||||
std::vector<std::array<float, 5>> RTMDet::call(const cv::Mat &image)
|
std::vector<std::array<float, 5>> RTMDet::call(const cv::Mat &image)
|
||||||
{
|
{
|
||||||
auto stime = std::chrono::high_resolution_clock::now();
|
|
||||||
std::chrono::duration<float> elapsed;
|
|
||||||
|
|
||||||
cv::Mat preprocessed = preprocess(image);
|
cv::Mat preprocessed = preprocess(image);
|
||||||
std::vector<cv::Mat> inputs = {preprocessed};
|
std::vector<cv::Mat> inputs = {preprocessed};
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Preprocess time: " << elapsed.count() << "s\n";
|
|
||||||
stime = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
auto results = call_by_image(inputs);
|
auto results = call_by_image(inputs);
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Inference time: " << elapsed.count() << "s\n";
|
|
||||||
stime = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
auto outputs = postprocess(results, image);
|
auto outputs = postprocess(results, image);
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Postprocess time: " << elapsed.count() << "s\n";
|
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,26 +801,9 @@ namespace utils_2d_pose
|
|||||||
std::vector<std::vector<std::array<float, 3>>> RTMPose::call(
|
std::vector<std::vector<std::array<float, 3>>> RTMPose::call(
|
||||||
const cv::Mat &image, const std::vector<std::array<float, 5>> &bboxes)
|
const cv::Mat &image, const std::vector<std::array<float, 5>> &bboxes)
|
||||||
{
|
{
|
||||||
auto stime = std::chrono::high_resolution_clock::now();
|
|
||||||
std::chrono::duration<float> elapsed;
|
|
||||||
|
|
||||||
std::vector<cv::Mat> inputs = preprocess(image, bboxes);
|
std::vector<cv::Mat> inputs = preprocess(image, bboxes);
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Preprocess time: " << elapsed.count() << "s\n";
|
|
||||||
stime = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
auto results = call_by_image(inputs);
|
auto results = call_by_image(inputs);
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Inference time: " << elapsed.count() << "s\n";
|
|
||||||
stime = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
auto outputs = postprocess(results, image, bboxes);
|
auto outputs = postprocess(results, image, bboxes);
|
||||||
|
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
|
||||||
std::cout << "Postprocess time: " << elapsed.count() << "s\n";
|
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class BaseModel(ABC):
|
|||||||
raise FileNotFoundError("File not found:", model_path)
|
raise FileNotFoundError("File not found:", model_path)
|
||||||
|
|
||||||
if model_path.endswith(".onnx"):
|
if model_path.endswith(".onnx"):
|
||||||
|
print("Loading model:", model_path)
|
||||||
self.init_onnxruntime(model_path)
|
self.init_onnxruntime(model_path)
|
||||||
self.runtime = "ort"
|
self.runtime = "ort"
|
||||||
else:
|
else:
|
||||||
|
|||||||
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
my_app
|
|
||||||
@ -13,14 +13,14 @@ Various module tests
|
|||||||
```bash
|
```bash
|
||||||
cd /RapidPoseTriangulation/tests/
|
cd /RapidPoseTriangulation/tests/
|
||||||
|
|
||||||
g++ -std=c++17 -O3 -march=native -Wall -DCOMPILE_EXAMPLE_MAIN \
|
g++ -std=c++17 -O3 -march=native -Wall \
|
||||||
$(pkg-config --cflags opencv4) \
|
$(pkg-config --cflags opencv4) \
|
||||||
-I /onnxruntime/include \
|
-I /onnxruntime/include \
|
||||||
-I /onnxruntime/include/onnxruntime/core/session \
|
-I /onnxruntime/include/onnxruntime/core/session \
|
||||||
-I /onnxruntime/include/onnxruntime/core/providers/tensorrt \
|
-I /onnxruntime/include/onnxruntime/core/providers/tensorrt \
|
||||||
-L /onnxruntime/build/Linux/Release \
|
-L /onnxruntime/build/Linux/Release \
|
||||||
test_utils2d.cpp \
|
test_utils2d.cpp \
|
||||||
-o my_app \
|
-o my_app.bin \
|
||||||
-Wl,--start-group \
|
-Wl,--start-group \
|
||||||
-lonnxruntime_providers_tensorrt \
|
-lonnxruntime_providers_tensorrt \
|
||||||
-lonnxruntime_providers_shared \
|
-lonnxruntime_providers_shared \
|
||||||
@ -30,5 +30,5 @@ g++ -std=c++17 -O3 -march=native -Wall -DCOMPILE_EXAMPLE_MAIN \
|
|||||||
$(pkg-config --libs opencv4) \
|
$(pkg-config --libs opencv4) \
|
||||||
-Wl,-rpath,/onnxruntime/build/Linux/Release
|
-Wl,-rpath,/onnxruntime/build/Linux/Release
|
||||||
|
|
||||||
./my_app
|
./my_app.bin
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user