31#ifndef DOXYGEN_SHOULD_SKIP_THIS
33#import "ViewController.h"
38@interface ViewController ()
41@implementation ViewController
42#pragma mark - Example of a function that uses ViSP
43- (void)processViSPHomography{
45 std::vector<vpPoint> oP(4), aP(4), bP(4);
48 oP[0].setWorldCoordinates( -L,-L, 0);
49 oP[1].setWorldCoordinates(2*L,-L, 0);
50 oP[2].setWorldCoordinates( L, 3*L, 0);
51 oP[3].setWorldCoordinates( -L, 4*L, 0);
53 vpHomogeneousMatrix bMo(0,0, 1, 0, 0, 0) ;
54 vpHomogeneousMatrix aMb(0.2, 0, 0.1, 0,
vpMath::rad(20), 0);
55 vpHomogeneousMatrix aMo = aMb*bMo ;
58 std::vector<double> xa(4), ya(4), xb(4), yb(4);
60 for(
int i=0 ;
i < 4;
i++){
62 xa[i] = oP[i].get_x();
63 ya[i] = oP[i].get_y();
65 xb[i] = oP[i].get_x();
66 yb[i] = oP[i].get_y();
74 std::cout <<
"Homography:\n" << aHb << std::endl;
77 vpTranslationVector atb;
83 std::cout <<
"atb: " << atb.
t() << std::endl;
86 vpImagePoint iPa, iPb;
87 vpCameraParameters
cam;
91 std::cout <<
"Ground truth:" << std::endl;
92 std::cout <<
" Point 3 in pixels in frame b: " << iPb << std::endl;
93 std::cout <<
" Point 3 in pixels in frame a: " << iPa << std::endl;
96 vpMatrix H =
cam.get_K() * aHb *
cam.get_K_inverse();
99 std::cout <<
"Estimation from homography:" << std::endl;
105 [
self processViSPHomography];
107- (void)didReceiveMemoryWarning {
108 [
super didReceiveMemoryWarning];
static void DLT(const std::vector< double > &xb, const std::vector< double > &yb, const std::vector< double > &xa, const std::vector< double > &ya, vpHomography &aHb, bool normalization=true)
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
static vpImagePoint project(const vpCameraParameters &cam, const vpHomography &bHa, const vpImagePoint &iPa)
static double rad(double deg)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)