#include <visp3/core/vpConfig.h>
#ifdef VISP_HAVE_MODULE_SENSOR
#include <visp3/sensor/vp1394CMUGrabber.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
#endif
#include <visp3/blob/vpDot2.h>
#include <visp3/core/vpPixelMeterConversion.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/vision/vpPose.h>
void computePose(std::vector<vpPoint> &point,
const std::vector<vpDot2> &dot,
const vpCameraParameters &cam,
bool init,
#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)
#endif
void computePose(std::vector<vpPoint> &point,
const std::vector<vpDot2> &dot,
const vpCameraParameters &cam,
bool init,
{
double x = 0, y = 0;
for (unsigned int i = 0; i < point.size(); i++) {
point[i].set_x(x);
point[i].set_y(y);
}
if (init == true) {
if (residual_dem < residual_lag)
cMo = cMo_dem;
else
cMo = cMo_lag;
}
}
#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)
{
if (init) {
for (unsigned int i = 0; i < dot.size(); i++) {
dot[i].setGraphics(true);
dot[i].setGraphicsThickness(2);
dot[i].initTracking(I);
}
} else {
for (unsigned int i = 0; i < dot.size(); i++) {
dot[i].track(I);
}
}
}
#endif
int main()
{
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) && \
(defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || (VISP_HAVE_OPENCV_VERSION >= 0x020100))
try {
#if defined(VISP_HAVE_DC1394)
#elif defined(VISP_HAVE_CMU1394)
#elif defined(VISP_HAVE_OPENCV)
cv::VideoCapture g(0);
if (!g.isOpened()) {
std::cout << "Failed to open the camera" << std::endl;
return -1;
}
cv::Mat frame;
g >> frame;
#endif
std::vector<vpDot2> dot(4);
std::vector<vpPoint> point;
double L = 0.06;
point.push_back(
vpPoint(-L, -L, 0));
point.push_back(
vpPoint(L, -L, 0));
point.push_back(
vpPoint(-L, L, 0));
bool init = true;
#if defined(VISP_HAVE_X11)
#elif defined(VISP_HAVE_GDI)
#elif defined(VISP_HAVE_OPENCV)
#endif
while (1) {
#if defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394)
#elif defined(VISP_HAVE_OPENCV)
g >> frame;
#endif
track(I, dot, init);
computePose(point, dot, cam, init, cMo);
if (init)
init = false;
break;
}
std::cout << "Catch an exception: " << e << std::endl;
}
#endif
}