home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
Staging
/
process.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-06
|
5KB
|
186 lines
#include "../polygons.h"
#define BORDER 5
/*
*
* acquireModel
*
* This is the main program to take an RCDE image and search for
* polygons using the perceptual grouping algorithm of the building
* finder.
*
* The image _must_ be part of a 3d world so that the grouping algorithm
* can recover the world-to-image transform matrix/function.
*
* The algorithm proceeds as follows:
*
* Open the 3d lines file,
* Compute 3d intersections,
* Partition the image into regions of Maxblock in size
* compute polygon.
* if a polygon is found in region i, then mark region i
* as done.
* place all polygons into the 3dWorld
* Open the 2dLines file
* Compute 2d intersections,
* For all regions that are not marked as used,
* compute polygons.
*
* Save polygons with the image 2dWorld.
* Store 2d polygon data to file until they can be triangulated
*
*
* Takes the following parameters:
*
* Image Name : directory and filename of the input image.
* 3d lines : Line file for 3d data (null if no such file exists)
* 2d lines : Line file for 2d data
* Maxblock : Maximum block size to use for each iteration
* of the building detector algorithm. (in feet).
* Overlap : Amount of overlap between iterations. (in feet).
*
*
*
* Written for RCDE Version 2.
*
* RADIUS Project.
* UMass, Amherst.
* Computer Vision Research Laboratory
*
* Christopher Jaynes
*/
/*
* Global Defs necessary to run the detector properly (pane and image)
*
*/
c_handle userPane;
c_handle userImage;
int acquireModel(double Sensitivity, int constrain, double maxBlock, double overlap)
{
struct c_handle_1_int_3* pick, *pick_a_pane();
c_handle view;
double_2 *drawPoint1, *drawPoint2;
char lineFile[280];
char cornerFile[280];
c_handle inImage;
int i;
int j;
int numRegionsX, numRegionsY;
double_2 *temp;
int Ncorners;
/*
* Open the input image file. User selected the appropriate image.
*/
setup_defaults(Sensitivity);
CONSTRAIN = constrain;
pick = pick_a_pane(get_interactor(0),1,"Pick Image for Model Acquisition.");
in_pane = pick->h1;
inImage = working_image(get_2d_world(top_image(1,in_pane)));
view = top_view(1,in_pane);
view_trans = two_d_to_window_transform(view);
image_trans = image_to_window_transform(view);
numRegionsY = (image_y_dim(inImage)-(2*BORDER)) / (maxBlock-overlap);
numRegionsX = (image_x_dim(inImage)-(2*BORDER)) / (maxBlock-overlap);
fprintf(stderr,"NumX %d, NumY %d\n",numRegionsX,numRegionsY);
strcpy(lineFile,get2_5dlineFile(inImage));
sprintf(cornerFile,"%scorners",getTempDir(inImage));
for (i = 0; i < numRegionsY; i++)
for (j = 0; j < numRegionsX; j++) {
xstart = j*(maxBlock-overlap)+BORDER;
ystart = i*(maxBlock-overlap)+BORDER;
xstop = (j*(maxBlock-overlap))+maxBlock+BORDER;
ystop = (i*(maxBlock-overlap))+maxBlock+BORDER;
if (xstop >= image_x_dim(inImage) )
xstop = image_x_dim(inImage) - BORDER;
if (ystop >= image_y_dim(inImage) )
ystop = image_y_dim(inImage) - BORDER;
temp = (double_2 *) transform_point(view_trans,(double)
xstart, (double) ystart, 0);
drawPoint1 = (double_2 *)inverse_transform_point(image_trans,
temp->d1, temp->d2,0);
temp = (double_2 *) transform_point(view_trans,(double)
xstop, (double) ystop, 0);
drawPoint2 = (double_2 *)inverse_transform_point(image_trans,
temp->d1, temp->d2,0);
refresh(in_pane);
/*** Draw the bounding region ***/
draw_fat_line(in_pane,drawPoint1->d1,drawPoint1->d2,
drawPoint2->d1,drawPoint1->d2,1.0);
draw_fat_line(in_pane,drawPoint2->d1,drawPoint1->d2,
drawPoint2->d1,drawPoint2->d2,1.0);
draw_fat_line(in_pane,drawPoint2->d1,drawPoint2->d2,
drawPoint1->d1,drawPoint2->d2,1.0);
draw_fat_line(in_pane,drawPoint1->d1,drawPoint2->d2,
drawPoint1->d1,drawPoint1->d2,1.0);
fprintf(stderr,"Region %d:(%d %d, %d %d)\n",
i+j,xstart,ystart,xstop,ystop);
strcpy(lineFile,get2_5dlineFile(inImage));
Ncorners = compute_intersections_region(lineFile,cornerFile,
in_pane, inImage, xstart,ystart, xstop,ystop);
fprintf(stderr,"Found %d corners.\n",Ncorners);
strcpy(lineFile, get2dlineFile(inImage));
process_region(lineFile, cornerFile, inImage);
}
}
/*
* mask_regions
*
* Take a list of bounding boxes that have been found to contain polygons.
*
* Remove from the line data any lines take have an endpoint within one
* of these regions.
* The modified line data is stored in a new file, return the new file name.
*
* NOTE: This procedure assumes that the lines are stored in the "Tokens"
* directory.
char *
mask_regions(file *name, boundingBox *list)
{
while (list != NULL)
list = list->next;
return(name);
}
*/