Ejemplo n.º 1
0
/// testing the following member methods
/// getDeltaX, getDeltaU, getZ, getDisparity
bool testGetDeltaXAndGetDeltaU() {
  CvStereoCamModel camModel;
  camModel.setCameraParams(FX, FY, TX, CLX, CRX, CY, DISPUNITSCALE);

  for (int i=1; i<100/DISPUNITSCALE; i++) {
    double disp = i;
    double du = 25.;
    double dx = camModel.getDeltaX(du, disp);
    double dx0 = du * TX/(disp*DISPUNITSCALE - (CLX - CRX));
    double diff = 0.;
    if ( dx != dx0 ) {
      printf("getDeltaX() test failed, du=%f, raw disp=%f, dx=%f\n",
          du, disp, dx);
      return false;
    }
    double z  = camModel.getZ(disp);
    double z0 = FX*TX/(DISPUNITSCALE*disp - (CLX - CRX));
    diff = fabs(z-z0);
    if (diff > .1e-10) {
      printf("getZ() test failed, disp = %f, z=%e, z0=%e, diff=%e\n",
          disp, z, z0, diff);
      return false;
    }
    // and convert it back
    double du0 = camModel.getDeltaU(dx, z);
    diff = fabs(du-du0);
    if ( diff > .1e-10) {
      printf("getDeltaU() test failed, dx=%f, z=%f, du=%e, du0=%e, diff=%e\n",
          dx, z, du, du0, diff);
      return false;
    }
  }

  return true;
}
Ejemplo n.º 2
0
/// testing the following member methods
/// getDeltaY, getDeltaV, getZ, getDisparity
bool testGetDeltaYAndGetDeltaV() {
  bool status = true;
  CvStereoCamModel camModel;
  camModel.setCameraParams(FX, FY, TX, CLX, CRX, CY, DISPUNITSCALE);

  for (int i=1; i<100/DISPUNITSCALE; i++) {
    double disp = i;
    double dv = 25.;
    double dy = camModel.getDeltaY(dv, disp);
    double dy0 = dv * TX * FX /(disp*DISPUNITSCALE - (CLX - CRX))/FY;
    double diff = 0.;
    diff = fabs(dy-dy0);
    if ( diff > .1e-10 ) {
      printf("getDeltaV() test failed, dv=%f, raw disp=%f, dy=%e, dy0=%e\n",
          dv, disp, dy, dy0);
      return false;
    }
    double z = camModel.getZ(disp);
    double z0 = FX*TX/(DISPUNITSCALE*disp - (CLX - CRX));
    diff = fabs(z-z0);
    if (diff > .1e-10) {
      printf("getZ() test failed, disp = %f, z=%e, z0=%e, diff=%e\n",
          disp, z, z0, diff);
      return false;
    }
    // and convert it back
    double dv0 = camModel.getDeltaV(dy, z);
    diff = fabs(dv-dv0);
    if ( diff > .1e-10) {
      printf("getDeltaU() test failed, dx=%f, z=%f, du=%e, du0=%e, diff=%e\n",
          dy, z, dv, dv0, diff);
      return false;
    }
  }

  return true;
}