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 */ |
69 |
|
devopen(dname) /* open device driver */ |
70 |
|
char *dname; |
71 |
|
{ |
72 |
< |
extern char *progname; |
73 |
< |
char *devargv[3]; |
72 |
> |
extern char *progname, *octname; |
73 |
> |
char *id; |
74 |
|
register int i; |
75 |
+ |
|
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)(progname)) == 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 |
< |
devargv[0] = dname; |
84 |
< |
devargv[1] = progname; |
85 |
< |
devargv[2] = NULL; |
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, |
131 |
< |
ourview.vresolu, pdepth+1); |
130 |
> |
refine(&ptrunk, 0, 0, hresolu, vresolu, pdepth+1); |
131 |
|
} |
132 |
|
if (dev->inpready) |
133 |
|
command(": "); |
145 |
|
char inpbuf[256]; |
146 |
|
char *args; |
147 |
|
again: |
148 |
< |
(*dev->comout)(prompt); /* get command + arguments */ |
150 |
< |
(*dev->comin)(inpbuf); |
148 |
> |
(*dev->comin)(inpbuf, prompt); /* get command + arguments */ |
149 |
|
for (args = inpbuf; *args && *args != ' '; args++) |
150 |
|
; |
151 |
|
if (*args) *args++ = '\0'; |
197 |
|
goto commerr; |
198 |
|
getmove(args); |
199 |
|
break; |
200 |
< |
case 'r': /* rotate camera */ |
201 |
< |
if (badcom("rotate")) |
202 |
< |
goto commerr; |
200 |
> |
case 'r': /* rotate/repaint */ |
201 |
> |
if (badcom("rotate")) { |
202 |
> |
if (badcom("repaint")) |
203 |
> |
goto commerr; |
204 |
> |
getrepaint(args); |
205 |
> |
break; |
206 |
> |
} |
207 |
|
getrotate(args); |
208 |
|
break; |
209 |
|
case 'p': /* pivot view */ |
265 |
|
* difference, we subsample the super-pixels. The testing process |
266 |
|
* includes initialization of the next row. |
267 |
|
*/ |
268 |
< |
xsiz = (((pframe.r-pframe.l)<<pdepth)+ourview.hresolu-1) / |
269 |
< |
ourview.hresolu; |
268 |
< |
ysiz = (((pframe.u-pframe.d)<<pdepth)+ourview.vresolu-1) / |
269 |
< |
ourview.vresolu; |
268 |
> |
xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu; |
269 |
> |
ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu; |
270 |
|
rl = (RECT *)malloc(xsiz*sizeof(RECT)); |
271 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
272 |
|
if (rl == NULL || pl == NULL) |
275 |
|
* Initialize the bottom row. |
276 |
|
*/ |
277 |
|
rl[0].l = rl[0].d = 0; |
278 |
< |
rl[0].r = ourview.hresolu; rl[0].u = ourview.vresolu; |
278 |
> |
rl[0].r = hresolu; rl[0].u = vresolu; |
279 |
|
pl[0] = findrect(pframe.l, pframe.d, &ptrunk, rl, pdepth); |
280 |
|
for (x = 1; x < xsiz; x++) { |
281 |
|
rl[x].l = rl[x].d = 0; |
282 |
< |
rl[x].r = ourview.hresolu; rl[x].u = ourview.vresolu; |
283 |
< |
pl[x] = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
282 |
> |
rl[x].r = hresolu; rl[x].u = vresolu; |
283 |
> |
pl[x] = findrect(pframe.l+((x*hresolu)>>pdepth), |
284 |
|
pframe.d, &ptrunk, rl+x, pdepth); |
285 |
|
} |
286 |
|
/* sample the image */ |
308 |
|
* Find super-pixel at this position in next row. |
309 |
|
*/ |
310 |
|
r.l = r.d = 0; |
311 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
312 |
< |
p = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
313 |
< |
pframe.d+(((y+1)*ourview.vresolu)>>pdepth), |
311 |
> |
r.r = hresolu; r.u = vresolu; |
312 |
> |
p = findrect(pframe.l+((x*hresolu)>>pdepth), |
313 |
> |
pframe.d+(((y+1)*vresolu)>>pdepth), |
314 |
|
&ptrunk, &r, pdepth); |
315 |
|
/* |
316 |
|
* Test super-pixel in next row. |