20 |
|
|
21 |
|
#include <ctype.h> |
22 |
|
|
23 |
< |
VIEW ourview = STDVIEW(470); /* viewing parameters */ |
23 |
> |
VIEW ourview = STDVIEW; /* viewing parameters */ |
24 |
> |
int hresolu, vresolu; /* image resolution */ |
25 |
|
|
26 |
|
int psample = 8; /* pixel sample size */ |
27 |
|
double maxdiff = .15; /* max. sample difference */ |
70 |
|
char *dname; |
71 |
|
{ |
72 |
|
extern char *progname, *octname; |
73 |
< |
char *devargv[3]; |
73 |
> |
char *id; |
74 |
|
register int i; |
75 |
|
|
76 |
< |
devargv[0] = dname; |
76 |
< |
devargv[1] = octname!=NULL ? octname : progname; |
77 |
< |
devargv[2] = NULL; |
76 |
> |
id = octname!=NULL ? octname : progname; |
77 |
|
/* check device table */ |
78 |
|
for (i = 0; devtable[i].name; i++) |
79 |
|
if (!strcmp(dname, devtable[i].name)) |
80 |
< |
if ((dev = (*devtable[i].init)(devargv[1])) == NULL) { |
80 |
> |
if ((dev = (*devtable[i].init)(dname, id)) == NULL) { |
81 |
|
sprintf(errmsg, "cannot initialize %s", dname); |
82 |
|
error(USER, errmsg); |
83 |
|
} else |
84 |
|
return; |
85 |
|
/* not there, try exec */ |
86 |
< |
if ((dev = comm_init(devargv)) == NULL) { |
86 |
> |
if ((dev = comm_init(dname, id)) == NULL) { |
87 |
|
sprintf(errmsg, "cannot start device \"%s\"", dname); |
88 |
|
error(USER, errmsg); |
89 |
|
} |
115 |
|
newimage(); /* set up image */ |
116 |
|
|
117 |
|
for ( ; ; ) { /* quit in command() */ |
118 |
< |
while (ourview.hresolu <= 1<<pdepth && |
119 |
< |
ourview.vresolu <= 1<<pdepth) |
118 |
> |
while (hresolu <= 1<<pdepth && |
119 |
> |
vresolu <= 1<<pdepth) |
120 |
|
command("done: "); |
121 |
|
|
122 |
< |
if (ourview.hresolu <= psample<<pdepth && |
123 |
< |
ourview.vresolu <= psample<<pdepth) { |
122 |
> |
if (hresolu <= psample<<pdepth && |
123 |
> |
vresolu <= psample<<pdepth) { |
124 |
|
sprintf(buf, "%d sampling...\n", 1<<pdepth); |
125 |
|
(*dev->comout)(buf); |
126 |
|
rsample(); |
127 |
|
} else { |
128 |
|
sprintf(buf, "%d refining...\n", 1<<pdepth); |
129 |
|
(*dev->comout)(buf); |
130 |
< |
refine(&ptrunk, 0, 0, ourview.hresolu, |
132 |
< |
ourview.vresolu, pdepth+1); |
130 |
> |
refine(&ptrunk, 0, 0, hresolu, vresolu, pdepth+1); |
131 |
|
} |
132 |
|
if (dev->inpready) |
133 |
|
command(": "); |
198 |
|
goto commerr; |
199 |
|
getmove(args); |
200 |
|
break; |
201 |
< |
case 'r': /* rotate camera */ |
202 |
< |
if (badcom("rotate")) |
203 |
< |
goto commerr; |
201 |
> |
case 'r': /* rotate/repaint */ |
202 |
> |
if (badcom("rotate")) { |
203 |
> |
if (badcom("repaint")) |
204 |
> |
goto commerr; |
205 |
> |
getrepaint(args); |
206 |
> |
break; |
207 |
> |
} |
208 |
|
getrotate(args); |
209 |
|
break; |
210 |
|
case 'p': /* pivot view */ |
266 |
|
* difference, we subsample the super-pixels. The testing process |
267 |
|
* includes initialization of the next row. |
268 |
|
*/ |
269 |
< |
xsiz = (((pframe.r-pframe.l)<<pdepth)+ourview.hresolu-1) / |
270 |
< |
ourview.hresolu; |
269 |
< |
ysiz = (((pframe.u-pframe.d)<<pdepth)+ourview.vresolu-1) / |
270 |
< |
ourview.vresolu; |
269 |
> |
xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu; |
270 |
> |
ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu; |
271 |
|
rl = (RECT *)malloc(xsiz*sizeof(RECT)); |
272 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
273 |
|
if (rl == NULL || pl == NULL) |
276 |
|
* Initialize the bottom row. |
277 |
|
*/ |
278 |
|
rl[0].l = rl[0].d = 0; |
279 |
< |
rl[0].r = ourview.hresolu; rl[0].u = ourview.vresolu; |
279 |
> |
rl[0].r = hresolu; rl[0].u = vresolu; |
280 |
|
pl[0] = findrect(pframe.l, pframe.d, &ptrunk, rl, pdepth); |
281 |
|
for (x = 1; x < xsiz; x++) { |
282 |
|
rl[x].l = rl[x].d = 0; |
283 |
< |
rl[x].r = ourview.hresolu; rl[x].u = ourview.vresolu; |
284 |
< |
pl[x] = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
283 |
> |
rl[x].r = hresolu; rl[x].u = vresolu; |
284 |
> |
pl[x] = findrect(pframe.l+((x*hresolu)>>pdepth), |
285 |
|
pframe.d, &ptrunk, rl+x, pdepth); |
286 |
|
} |
287 |
|
/* sample the image */ |
309 |
|
* Find super-pixel at this position in next row. |
310 |
|
*/ |
311 |
|
r.l = r.d = 0; |
312 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
313 |
< |
p = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
314 |
< |
pframe.d+(((y+1)*ourview.vresolu)>>pdepth), |
312 |
> |
r.r = hresolu; r.u = vresolu; |
313 |
> |
p = findrect(pframe.l+((x*hresolu)>>pdepth), |
314 |
> |
pframe.d+(((y+1)*vresolu)>>pdepth), |
315 |
|
&ptrunk, &r, pdepth); |
316 |
|
/* |
317 |
|
* Test super-pixel in next row. |