15 |
|
#include "fvect.h" |
16 |
|
#include "depthcodec.h" |
17 |
|
|
18 |
– |
char *progname; /* set in main() */ |
19 |
– |
|
18 |
|
enum {CV_FWD, CV_REV, CV_PTS}; |
19 |
|
|
20 |
|
|
43 |
|
long nexpected = (long)dcp->res.xr * dcp->res.yr; |
44 |
|
|
45 |
|
if (dcp->inpfmt[0]) { |
46 |
< |
if (strstr(dcp->inpfmt, "ascii") != NULL) |
46 |
> |
if (!strcmp(dcp->inpfmt, "ascii")) |
47 |
|
dcp->format = 'a'; |
48 |
< |
else if (strstr(dcp->inpfmt, "float") != NULL) |
48 |
> |
else if (!strcmp(dcp->inpfmt, "float")) |
49 |
|
dcp->format = 'f'; |
50 |
< |
else if (strstr(dcp->inpfmt, "double") != NULL) |
50 |
> |
else if (!strcmp(dcp->inpfmt, "double")) |
51 |
|
dcp->format = 'd'; |
52 |
|
else { |
53 |
|
fputs(dcp->inpname, stderr); |
57 |
|
return 0; |
58 |
|
} |
59 |
|
} |
60 |
+ |
if (dcp->format == 'a') |
61 |
+ |
SET_FILE_TEXT(dcp->finp); |
62 |
|
|
63 |
|
do { |
64 |
|
int ok = 0; |
160 |
|
return 0; |
161 |
|
|
162 |
|
while (scanf("%d %d", &xy[0], &xy[1]) == 2) { |
163 |
< |
|
164 |
< |
loc2pix(xy, &dcp->res, |
165 |
< |
(xy[0]+.5)/dcp->res.xr, (xy[1]+.5)/dcp->res.yr); |
166 |
< |
|
163 |
> |
loc2pix(xy, &dcp->res, xy[0]/(double)dcp->res.xr, |
164 |
> |
xy[1]/(double)dcp->res.yr); |
165 |
|
d = decode_depth_pix(dcp, xy[0], xy[1]); |
166 |
|
if (d < -FTINY) |
167 |
|
return 0; |
170 |
– |
|
168 |
|
output_depth(dcp, d); |
172 |
– |
|
169 |
|
if (unbuf && fflush(stdout) == EOF) { |
170 |
|
fputs(progname, stderr); |
171 |
|
fputs(": write error on output\n", stderr); |
252 |
|
} |
253 |
|
if (!check_decode_worldpos(dcp)) |
254 |
|
return 0; |
255 |
< |
|
255 |
> |
|
256 |
|
while (scanf("%d %d", &xy[0], &xy[1]) == 2) { |
257 |
< |
loc2pix(xy, &dcp->res, |
258 |
< |
(xy[0]+.5)/dcp->res.xr, (xy[1]+.5)/dcp->res.yr); |
257 |
> |
loc2pix(xy, &dcp->res, xy[0]/(double)dcp->res.xr, |
258 |
> |
xy[1]/(double)dcp->res.yr); |
259 |
|
if (get_worldpos_pix(wpos, dcp, xy[0], xy[1]) < 0) |
260 |
|
return 0; |
261 |
|
output_worldpos(dcp, wpos); |
283 |
|
int unbuffered = 0; |
284 |
|
DEPTHCODEC dc; |
285 |
|
int a; |
286 |
< |
|
287 |
< |
progname = argv[0]; |
286 |
> |
/* set global progname */ |
287 |
> |
fixargv0(argv[0]); |
288 |
|
set_dc_defaults(&dc); |
289 |
|
dc.hdrflags = HF_ALL; |
290 |
|
for (a = 1; a < argc && argv[a][0] == '-'; a++) |
412 |
|
fputs(": cannot open for writing\n", stderr); |
413 |
|
return 1; |
414 |
|
} |
415 |
< |
SET_FILE_BINARY(dc.finp); |
416 |
< |
if ((conversion != CV_FWD) | (dc.format != 'a')) |
421 |
< |
SET_FILE_BINARY(stdout); |
415 |
> |
SET_FILE_BINARY(dc.finp); /* starting assumption */ |
416 |
> |
SET_FILE_BINARY(stdout); |
417 |
|
#ifdef getc_unlocked /* avoid stupid semaphores */ |
418 |
|
flockfile(dc.finp); |
419 |
|
flockfile(stdout); |
421 |
|
/* read/copy header */ |
422 |
|
if (!process_dc_header(&dc, a, argv)) |
423 |
|
return 1; |
424 |
+ |
|
425 |
+ |
if ((conversion != CV_FWD) & (dc.format == 'a')) |
426 |
+ |
SET_FILE_TEXT(stdout); |
427 |
|
/* process data */ |
428 |
|
switch (conversion) { |
429 |
|
case CV_FWD: /* distance -> depth code */ |