35 #ifndef _vpMegaPose_h_
36 #define _vpMegaPose_h_
38 #include <visp3/core/vpConfig.h>
39 #if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_THREADS)
43 #include <unordered_map>
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 #include <visp3/core/vpCameraParameters.h>
48 #include <visp3/core/vpImage.h>
49 #include <visp3/core/vpRGBa.h>
50 #include <visp3/core/vpRect.h>
52 #include <nlohmann/json.hpp>
78 std::vector<double> values = j;
79 assert(values.size() == 16);
80 std::copy(values.begin(), values.end(), T.
data);
85 std::vector<double> values;
87 for (
unsigned i = 0; i < 16; ++i) {
88 values.push_back(T.
data[i]);
93 inline void to_megapose_json(nlohmann::json &j,
const vpRect &d)
95 std::vector<double> values = {
96 d.getLeft(), d.getTop(), d.getRight(), d.getBottom()
101 inline void from_megapose_json(
const nlohmann::json &j,
vpRect &d)
103 std::vector<double> values = j.get<std::vector<double>>();
104 assert((values.size() == 4));
105 d.setLeft(values[0]);
107 d.setRight(values[2]);
108 d.setBottom(values[3]);
113 m.
score = j[
"score"];
114 from_megapose_json(j.at(
"cTo"), m.
cTo);
115 from_megapose_json(j.at(
"boundingBox"), m.
boundingBox);
155 SET_SO3_GRID_SIZE = 10,
156 GET_LIST_OBJECTS = 11,
157 RET_LIST_OBJECTS = 12,
189 std::vector<vpMegaPoseEstimate> estimatePoses(
const vpImage<vpRGBa> &image,
const std::vector<std::string> &objectNames,
191 const std::vector<vpRect> *
const detections =
nullptr,
192 const std::vector<vpHomogeneousMatrix> *
const initial_cTos =
nullptr,
193 int refinerIterations = -1);
204 std::vector<double> scorePoses(
const vpImage<vpRGBa> &image,
const std::vector<std::string> &objectNames,
205 const std::vector<vpHomogeneousMatrix> &cTos);
216 vpImage<vpRGBa> viewObjects(
const std::vector<std::string> &objectNames,
217 const std::vector<vpHomogeneousMatrix> &poses,
const std::string &viewType);
223 void setCoarseNumSamples(
const unsigned num);
229 std::vector<std::string> getObjectNames();
241 std::pair<vpMegaPose::ServerMessage, std::vector<uint8_t>> readMessage()
const;
243 const static std::unordered_map<vpMegaPose::ServerMessage, std::string> m_codeMap;
Type * data
Address of the first element of the data array.
Generic class defining intrinsic camera parameters.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Defines a rectangle in the plane.