36#include <visp3/core/vpConfig.h>
37#if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_THREADS)
41#include <unordered_map>
44#include <visp3/core/vpHomogeneousMatrix.h>
45#include <visp3/core/vpCameraParameters.h>
46#include <visp3/core/vpImage.h>
47#include <visp3/core/vpRGBa.h>
48#include <visp3/core/vpRect.h>
50#include VISP_NLOHMANN_JSON(json.hpp)
85 std::vector<double> values = j;
86 assert(values.size() == 16);
87 std::copy(values.begin(), values.end(), T.
data);
92 std::vector<double> values;
94 for (
unsigned i = 0;
i < 16; ++
i) {
95 values.push_back(T.
data[i]);
100inline void to_megapose_json(nlohmann::json &j,
const vpRect &d)
102 std::vector<double> values = {
103 d.getLeft(),
d.getTop(),
d.getRight(),
d.getBottom()
108inline void from_megapose_json(
const nlohmann::json &j,
vpRect &d)
110 std::vector<double> values =
j.get<std::vector<double>>();
111 assert((values.size() == 4));
112 d.setLeft(values[0]);
114 d.setRight(values[2]);
115 d.setBottom(values[3]);
121 from_megapose_json(
j.at(
"cTo"), m.
cTo);
201 std::vector<vpMegaPoseEstimate> estimatePoses(
const vpImage<vpRGBa> &image,
const std::vector<std::string> &objectNames,
203 const std::vector<vpRect> *
const detections =
nullptr,
204 const std::vector<vpHomogeneousMatrix> *
const initial_cTos =
nullptr,
205 int refinerIterations = -1);
216 std::vector<double> scorePoses(
const vpImage<vpRGBa> &image,
const std::vector<std::string> &objectNames,
217 const std::vector<vpHomogeneousMatrix> &cTos);
228 vpImage<vpRGBa> viewObjects(
const std::vector<std::string> &objectNames,
229 const std::vector<vpHomogeneousMatrix> &poses,
const std::string &viewType);
235 void setCoarseNumSamples(
const unsigned num);
241 std::vector<std::string> getObjectNames();
253 std::pair<vpMegaPose::ServerMessage, std::vector<uint8_t>> readMessage()
const;
255 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.
Definition of the vpImage class member functions.
@ GET_LIST_OBJECTS
Ask the server to set the number of samples for coarse estimation.
@ GET_VIZ
Code sent when server returns pose estimates.
@ SET_SO3_GRID_SIZE
Code sent when server returns a pose score.
@ RET_SCORE
Ask the server to score a pose estimate.
@ GET_POSE
Server has successfully completed operation, no return value expected.
@ RET_VIZ
Ask the server for a rendering of the object.
@ OK
An error occurred server side.
@ SET_INTR
Code sent when server returns the rendering of an object.
@ GET_SCORE
Set the intrinsics for the MegaPose server.
@ RET_POSE
Ask the server to estimate poses.
vpMegaPose(const std::string &host, int port, const vpCameraParameters &cam, unsigned height, unsigned width)
Defines a rectangle in the plane.