Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /APSCpp/APSCpp_main.c [f61243] .. [03d2ea] Maximize Restore

  Switch to side-by-side view

--- a/APSCpp/APSCpp_main.c
+++ b/APSCpp/APSCpp_main.c
@@ -49,9 +49,14 @@
 #include "sphereAlign.h"
 
 // APSCpp.cpp
-int LoadProjectImages( char* script, ArrayList * DIlist );
-KeypointXMLList * GenerateKeyspp( char * imgname, int maxdim, DIinfo * pdi, double stgfov );
+int LoadProjectImages( char* script, ArrayList * DIlist, bool equalAngle );
+KeypointXMLList * GenerateKeyspp( char * imgname, int maxdim, 
+								  DIinfo * pdi, double stgfov, int * KPcount );
 int MultiMatch_ANN ( MultiMatch* );
+
+// globals
+double globFov = 0;	// width for all images in degrees
+
 
 void Usage ()
 {
@@ -75,6 +80,8 @@
 	WriteLine ("                          apply to all images.  Enables stereographic option.");
  	WriteLine ("  --stereographic <on|off|1|0> reprojection on (if enabled) or off. Default on.");
  	WriteLine ("  --stgfov <d>            minimum hfov (degrees) for reprojection. Default 65.");
+	WriteLine ("  --equal-angle-fisheye   Set fisheye lens type to equal-angle instead of");
+	WriteLine ("                          equal-area. Ignored for PTAssembler projects.");
 	WriteLine ("  --disable-areafilter    Do not use max-area filtration, which is default.");
 	WriteLine ("                          See manpage for details.");
 	WriteLine ("  --integer-coordinates   Truncate match coordinates to integer numbers.");
@@ -420,17 +427,17 @@
 	DIinfo * pdi = 0;
 	char buffer[262];
 
-	fprintf(pto, "# Hugin project file generated by APSCpp\n\n");
+	fprintf(pto, "# Stitcher project file generated by APSCpp version %s\n\n", PACKAGE_VERSION);
 	fprintf(pto, "p f2 w3000 h1500 v360  n\"JPEG q90\"\n");
 	fprintf(pto, "m g1 i0\n\n");
 	
 	int imageIndex = 0;
 	HashTable* imageNameTab = HashTable_new0 (NULL, NULL);
 	ArrayList* resolutions = ArrayList_new0 ( (void *) Resolution_delete);
-	int i;
-	for(i=0; i<ArrayList_Count(mm->keySets); i++) {
-		KeypointXMLList* kx = (KeypointXMLList*) ArrayList_GetItem(mm->keySets, i);
-		HashTable_AddItem(imageNameTab, kx->imageFile, (void*)imageIndex);
+	int i, iks;
+	for( iks = 0; iks < ArrayList_Count(mm->keySets); iks++ ) {
+		KeypointXMLList* kx = (KeypointXMLList*) ArrayList_GetItem(mm->keySets, iks );
+ 		HashTable_AddItem(imageNameTab, kx->imageFile, (void*)imageIndex);
 		ArrayList_AddItem(resolutions, Resolution_new (kx->xDim, kx->yDim));
 		
 		char*  imageFile = kx->imageFile;
@@ -465,6 +472,7 @@
 		  }*/
 
 		double yaw = 0.0, pitch = 0.0, rotation = 0.0, hfov = 180.0;
+		double a = 0, b = -0.01, c = 0;
 		int format = 0;
 		if (pos != NULL) {
 			yaw = pos->yaw;
@@ -475,12 +483,16 @@
 			pitch = pdi->pitch;
 			rotation = pdi->roll;
 			format = pdi->format;
-			hfov = pdi->hfov;
+			if( format == 8 ) format = 3;
+			hfov = fovdeg( pdi->flpix, kx->xDim, format );
+			a = pdi->a;
+			b = pdi->b;
+			c = pdi->c;
 		}
 		
 		if (imageIndex == 0 || refIdx == -1) {
-			sprintf(buffer, "i w%d h%d f%d a0 b-0.01 c0 d0 e0 p%g r%g v%g y%g  u10 n\"%s\"",
-				kx->xDim, kx->yDim, format, pitch, rotation, hfov, yaw, imageFile);
+			sprintf(buffer, "i w%d h%d f%d a%g b%g c%g d0 e0 p%g r%g v%g y%g  u10 n\"%s\"",
+				kx->xDim, kx->yDim, format, a, b, c, pitch, rotation, hfov, yaw, imageFile);
 		} else {
 			sprintf(buffer, "i w%d h%d f%d a=%d b=%d c=%d d0 e0 p%g r%g v=%d y%g  u10 n\"%s\"",
 				kx->xDim, kx->yDim, format, refIdx, refIdx, refIdx, pitch, rotation, refIdx, yaw, imageFile);
@@ -534,7 +546,6 @@
 	char *projectfile = 0;
     // "--projection" option sets these for all images
 	int globFmt = -1;	// PT format code
-	double globFov = 0;	// width in degrees
 	int Nerr = 0;	// counts commandline errors
 
 	// downscale option = largest allowed image dimension (0: none)
@@ -552,6 +563,9 @@
   
 	// Use input alignment if feasible
 	bool useLayout = false;
+
+	// treat fisheye lens as equal-angle
+	bool equalAngle = false;
 
 	// Use area based weighting for final match selection.
 	bool useAreaFiltration = true;
@@ -574,6 +588,7 @@
 	int optionCount = 0;
 	int optionN = 1;
 	int i;
+	int totalKPs = 0;
 
 	WriteLine ("\nAPSCpp, enhanced autopano-sift-c version %s \n", PACKAGE_VERSION);
 
@@ -633,6 +648,8 @@
 				}
 			} else if (strcmp (optionStr, "--disable-areafilter") == 0) {
 				useAreaFiltration = false;
+			} else if (strcmp (optionStr, "--equal-angle-fisheye") == 0) {
+				equalAngle = true;
 			} else if (strcmp (optionStr, "--integer-coordinates") == 0) {
 				useIntegerCoordinates = true;
 			} else if (strcmp (optionStr, "--absolute-pathnames") == 0) {
@@ -686,7 +703,7 @@
 	// enable ++ mode by creating DIlist
 		DIlist = ArrayList_new0( (void *) DIinfo_delete );
 	// read the proect file image info into DIlist, or die
-		if( LoadProjectImages( argv[optionCount + 1], DIlist ) ==0 ){
+		if( LoadProjectImages( argv[optionCount + 1], DIlist, equalAngle ) == 0 ){
 		  WriteLine ("Error reading project file.");
 		  exit(1);
 		}
@@ -696,8 +713,14 @@
 	}
 
 
-	if( DIlist && useStereographic ){
-		WriteLine("  Stereographic projection enabled for hfov >= %.1f degrees", stgfov );
+	WriteLine("  Default fisheye lens type is %s.",  
+		equalAngle ? "equal-angle" : "equal-area" );
+
+	if( DIlist ){
+		if( useStereographic )
+		  WriteLine("  Stereographic projection enabled for hfov >= %.1f degrees.", stgfov );
+		if( useLayout )
+		  WriteLine("  Will try to use source image layout to guide CP placement.");
 	}
 
 
@@ -715,7 +738,7 @@
 			for( i=0; i<argc - 1 - optionCount; i++) {
 			  pd = DIinfo_new0();
 			  pd->format = globFmt;
-			  pd->hfov = globFov;
+			  pd->flpix = 0;
 			  strcpy(pd->name, argv[i+optionCount+1] );
 			  // note dimensions are still zero
 			  ArrayList_AddItem( DIlist, pd );
@@ -724,19 +747,26 @@
 	// process the images
 		for( i = 0; i < ArrayList_Count( DIlist ); i++ ){
 		  pd = (pDIinfo) ArrayList_GetItem( DIlist, i);
-		  ArrayList_AddItem(keylists, GenerateKeyspp( pd->name, maxdim, pd,
-			  useStereographic ? stgfov : -1 ) );
+		  if( !DIinfo_isDummy( pd ) )
+			ArrayList_AddItem(keylists, GenerateKeyspp( pd->name, maxdim, pd,
+							  useStereographic ? stgfov : -1, &totalKPs ) );
 		}
 	} else {
 	// std mode: image names only from commandline
 		for( i=0; i<argc - 1 - optionCount; i++) {
-		  ArrayList_AddItem(keylists, GenerateKeyspp( argv[i+optionCount+1], maxdim, 0, 0 ) );
+		  ArrayList_AddItem( keylists, GenerateKeyspp( argv[i+optionCount+1], 
+			                 maxdim, 0, 0, &totalKPs ) );
 		}
 	}
 
     finish = clock();
     time = ((double)finish - (double)start ) / CLOCKS_PER_SEC;
     WriteLine("%.1f seconds to find keypoints", time);
+
+ // fail if no keypoints were found
+	if( totalKPs < 2 ){
+		FatalError("No keypoints found!");
+	}
 
 /** Find control points **/