// fill-in "n" ortho views from the given point "axyh" on the first image // The size of the geographic grid is "w,h static void build_projection_states( struct ortho_view *o, // output orthoviews struct tiff_tile_cache *t, // input images struct rpc *r, // input rpcs int n, // number of images double axyh[3], // corner on first image int w, int h) // desired grid size { // center in geographic coordinates double center[3], csouth[3]; eval_rpc(center, r, axyh[0], axyh[1] , axyh[2]); eval_rpc(csouth, r, axyh[0], axyh[1] + 1, axyh[2]); // stepsize given by 1 pixel to the south // XXX WARNING WRONG TODO FIXME : assumes North-South oriented image (!) double lat_step = csouth[1] - center[1]; double latitude = center[1] * (M_PI/180); double lonfactor = cos(latitude); double lon_step = -lat_step / lonfactor; double lon_step_m = (lon_step*lonfactor) * (M_PI/180) * EARTH_RADIUS; double lat_step_m = lat_step * (M_PI/180) * EARTH_RADIUS; fprintf(stderr, "projection center (%g %g %g) => (%.8lf %.8lf)\n", axyh[0], axyh[1], axyh[2], center[0], center[1]); fprintf(stderr, "lon_step = %g (%g meters)\n", lon_step, lon_step_m); fprintf(stderr, "lat_step = %g (%g meters)\n", lat_step, lat_step_m); // fill-in the fields for (int i = 0; i < n; i++) { o[i].t = t + i; o[i].r = r + i; o[i].w = w; o[i].h = h; o[i].lon_0 = center[0]; o[i].lat_0 = center[1]; o[i].lon_d = lon_step; o[i].lat_d = lat_step; //o->t = t + i; //o->r = r + i; //o->w = w; //o->h = h; //o->lon_0 = center[0]; //o->lat_0 = center[1]; //o->lon_d = lon_step; //o->lat_d = lat_step; } }
void intersect_rays(double out[3], double p[2], double q[2], struct rpc *r1, struct rpc *r2) { // compute height double err; out[2] = rpc_height(r1, r2, p[0], p[1], q[0], q[1], &err); // compute lon, lat eval_rpc(out, r1, p[0], p[1], out[2]); }
static void build_projection_states( struct projection_state *pa, struct projection_state *pb, struct rpc *ra, struct rpc *rb, double axyh[3], int w, int h) { // center in geographic coordinates double center[3], csouth[3]; eval_rpc(center, ra, axyh[0], axyh[1] , axyh[2]); eval_rpc(csouth, ra, axyh[0], axyh[1] + 1, axyh[2]); // stepsize given by 1 pixel to the south // XXX WARNING WRONG TODO FIXME : assumes North-South oriented image (!) double lat_step = csouth[1] - center[1]; double latitude = center[1] * (M_PI/180); double lonfactor = cos(latitude); double lon_step = -lat_step / lonfactor; double lon_step_m = (lon_step*lonfactor) * (M_PI/180) * EARTH_RADIUS; double lat_step_m = lat_step * (M_PI/180) * EARTH_RADIUS; fprintf(stderr, "projection center (%g %g %g) => (%.8lf %.8lf)\n", axyh[0], axyh[1], axyh[2], center[0], center[1]); fprintf(stderr, "lon_step = %g (%g meters)\n", lon_step, lon_step_m); fprintf(stderr, "lat_step = %g (%g meters)\n", lat_step, lat_step_m); // fill-in the fields pa->r = ra; pb->r = rb; pa->w = pb->w = w; pa->h = pb->h = h; pa->lon_0 = pb->lon_0 = center[0]; pa->lat_0 = pb->lat_0 = center[1]; pa->lon_d = pb->lon_d = lon_step; pa->lat_d = pb->lat_d = lat_step; }
void rpc_warpabt(float *outa, float *outb, int w, int h, int pd, struct tiff_tile_cache *ta, struct rpc *rpca, struct tiff_tile_cache *tb, struct rpc *rpcb, double axyh[3]) { // PA = rpca inverse // LA = rpca direct // PB = rpcb inverse // LB = rpcb direct // FALSE! it is actually the opposite (?) // center in geographic coordinates double c[3]; eval_rpc(c, rpca, axyh[0], axyh[1], axyh[2]); fprintf(stderr, "(%g %g %g) => %g %g\n", axyh[0], axyh[1], axyh[2], c[0], c[1]); // TODO: compute the stem more inteligently here // step = nominal resolution double csouth[3]; eval_rpc(csouth, rpca, axyh[0], axyh[1] + 1, axyh[2]); fprintf(stderr, "(%g %g %g) => %g %g\n", axyh[0], axyh[1]+1, axyh[2], csouth[0], csouth[1]); double ceast[3]; eval_rpc(ceast, rpca, axyh[0] + 1, axyh[1], axyh[2]); fprintf(stderr, "(%g %g %g) => %g %g\n", axyh[0]+1, axyh[1], axyh[2], ceast[0], ceast[1]); double lon_step = ceast[0] - c[0]; // in degrees double lat_step = csouth[1] - c[1]; // in degrees double latitude = c[1] * (M_PI/180); // in radians double lonfactor = cos(latitude); double lon_step_m = lon_step * (M_PI/180) * EARTH_RADIUS / lonfactor; double lat_step_m = lat_step * (M_PI/180) * EARTH_RADIUS; fprintf(stderr, "lon_step = %g (%g meters)\n", lon_step, lon_step_m); fprintf(stderr, "lat_step = %g (%g meters)\n", lat_step, lat_step_m); // actually apply the factor lon_step = lonfactor; if (1) { // some consistency tests double pc[3]; eval_rpci(pc, rpca, c[0], c[1], axyh[2]); fprintf(stderr, "(%g %g %g) => %g %g\n", c[0], c[1], axyh[2], pc[0], pc[1]); } assert(pd = ta->i->spp); assert(pd = tb->i->spp); for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { double lon = c[0] + i * lon_step; double lat = c[1] + j * lat_step; double paij[3]; eval_rpci(paij, rpca, lon, lat, axyh[2]); double pbij[3]; eval_rpci(pbij, rpcb, lon, lat, axyh[2]); float *oaij = outa + (j*w + i) * pd; float *obij = outb + (j*w + i) * pd; tiff_cache_interpolate_float(oaij, ta, paij[0], paij[1]); tiff_cache_interpolate_float(obij, tb, pbij[0], pbij[1]); } }
//build the set of sights void build_set_sights(type_sight *sights_list,list_of_pairs *list_pairs) { int N_pairs = list_pairs->real_size; double alt1=3000.; double alt2=45.; bool first_sight_found = false; // pid (pair id), to loop over pairs // ind, insertion variable int pid=0, ind=0; while(pid<N_pairs) { if (list_pairs->data[pid].process) { int ID; struct rpc *rpc_to_use; double X1,Y1,Z1,X2,Y2,Z2,q[3]; if (!first_sight_found) { rpc_to_use = &list_pairs->data[pid].rpc_master; ID = 1; q[0] = list_pairs->data[pid].q0[0]; q[1] = list_pairs->data[pid].q0[1]; q[2] = list_pairs->data[pid].q0[2]; first_sight_found = true; // look at this pair twice : // 1st : get the first sight // 2nd : get the slave sight // so : pid-- to go backwards pid--; } else { rpc_to_use = &list_pairs->data[pid].rpc_slave; ID = list_pairs->data[pid].sight_slave; q[0] = list_pairs->data[pid].q1[0]; q[1] = list_pairs->data[pid].q1[1]; q[2] = list_pairs->data[pid].q1[2]; } double point1[2],point2[2]; eval_rpc(point2, rpc_to_use, q[0], q[1], alt2); eval_rpc(point1, rpc_to_use, q[0], q[1], alt1); geotedic_to_ECEF(point1[0],point1[1],alt1,&X1,&Y1,&Z1); geotedic_to_ECEF(point2[0],point2[1],alt2,&X2,&Y2,&Z2); sights_list[ind].p[0] = X1; sights_list[ind].p[1] = Y1; sights_list[ind].p[2] = Z1; sights_list[ind].s[0] = X2; sights_list[ind].s[1] = Y2; sights_list[ind].s[2] = Z2; sights_list[ind].v[0] = X2-X1; sights_list[ind].v[1] = Y2-Y1; sights_list[ind].v[2] = Z2-Z1; VEC_NORMALIZE(sights_list[ind].v); sights_list[ind].ID = ID; ind++; } pid++; } }