Commits

Anonymous committed bba10d3

lala

Comments (0)

Files changed (1)

project2/photomerge/source/main.cpp

 #include "Image.h"
 #include "feature.h"
-#include "feature_matching.h"
-#include "warpping.h"
-#include "transition.h"
-#include "aligne.h"
 
 #include <cstdio>
 #include <cstdlib>
 
 using namespace vfx;
 
+//
+
 int main(int argc, char* argv[])
 {
-	const int picture_number = 3;
-	float focal_length = 100;
-	int pixel_width = 540, pixel_height = 720;
-	//int pixel_width = 634, pixel_height = 950;
-	char** path = new char*[100];
-	
-	path[0] = "../images/IMG_8717.JPG";
-	path[1] = "../images/IMG_8718.JPG";
-	path[2] = "../images/IMG_8719.JPG";
-	path[3] = "../images/IMG_8716.JPG";
-	
-	/*
-	path[0] = "../images/IMG_3223.JPG";
-	path[1] = "../images/IMG_3224.JPG";
-	path[2] = "../images/IMG_3225.JPG";
-	path[3] = "../images/IMG_3226.JPG";
-	*/
-
-	int i, j, k;
-	char buf[64];
-
-	std::vector<Features> feats(picture_number);
-	ByteImage* _src = new ByteImage[picture_number];
-	ByteImage* src = new ByteImage[picture_number];
-	FloatImage* img = new FloatImage[picture_number];
-
-	for(i = 0; i<picture_number; i++){
-			_src[i] = ImageCreator::loadFromJpeg(path[i]);
-			src[i] = ImageCreator::createByteImage(_src[i].width(), _src[i].height());
-	}
-
-	for(i=0; i<picture_number; i++)
-		warpping(focal_length, pixel_width, pixel_height, _src[i], src[i]);
-
-	for(i=0; i<picture_number; i++){
-			img[i] = ImageCreator::toFloatImage(src[i]);
-			detectFeatures(img[i], feats[i]);
-			std::printf("Image %d: %d features found.\n", i, feats[i].x.size());
-			//sprintf(buf, "features-%d.jpg", i);
-			//outputFeatureMap(buf, img[i], feats[i]);
-	}
-
-	std::printf("features matching\n");
-	std::vector<FeatureMatches> matches = matchFeatures(feats, 2);
-  
-  // Draw!
   
-  FeatureMatches mat = matches[0];
-
   /*
-  const int tw = img0.width() + img1.width();
-  const int th = std::max(img0.height(), img1.height());
-  const int w0 = img0.width(), w1 = img1.width();
-  const int h0 = img0.height(), h1 = img1.height();
+  ColorImage imgs[] = {
+    ImageCreator::loadFromJpeg("../images/_denny/input/1.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/2.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/3.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/4.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/5.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/6.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/7.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/8.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/9.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/10.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/11.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/12.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/13.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/14.jpg"),
+    ImageCreator::loadFromJpeg("../images/_denny/input/15.jpg")
+  };
+  */
   
-  ByteImage timgR = ImageCreator::createByteImage(tw, th);
-  ByteImage timgG = ImageCreator::createByteImage(tw, th);
-  ByteImage timgB = ImageCreator::createByteImage(tw, th);
+  ColorImage imgs[] = {
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail00.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail01.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail02.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail03.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail04.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail05.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail06.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail07.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail08.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail09.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail10.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail11.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail12.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail13.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail14.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail15.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail16.jpg"),
+    ImageCreator::loadFromJpeg("../images/_grail/input/grail17.jpg")
+  };
   
-  for(int y = 0; y < th; ++y)
-  {
-    const float* pSrc0 = img0.data() + y * img0.row();
-    const float* pSrc1 = img1.data() + y * img1.row();
-    byte* pDstR = timgR.data() + y * timgR.row();
-    byte* pDstG = timgG.data() + y * timgG.row();
-    byte* pDstB = timgB.data() + y * timgB.row();
-    
-    if(y < h0)
-      for(int x = 0; x < w0; ++x)
-      {
-        pDstR[x] = pSrc0[x] * 255;
-        pDstG[x] = pSrc0[x] * 255;
-        pDstB[x] = pSrc0[x] * 255;
-      }
-    if(y < h1)
-      for(int x = 0; x < w1; ++x)
-      {
-        pDstR[x+w0] = pSrc1[x] * 255;
-        pDstG[x+w0] = pSrc1[x] * 255;
-        pDstB[x+w0] = pSrc1[x] * 255;
-      }
-  }
+  auto matches = featureDetectionAndMatching(sizeof(imgs)/sizeof(imgs[0]), 
+                                             imgs, 
+                                             true);
   
-  {
-    int from = mat.first, to = mat.second, cnt = mat.x1.size();
-    for(int i = 0; i < cnt; ++i)
-    {
-      int x0 = mat.x1[i];
-      int y0 = mat.y1[i];
-      int x1 = w0 + mat.x2[i];
-      int y1 = mat.y2[i];
-      
-      if(from == 1 || to == 0)
-        x0 ^= x1 ^= x0 ^= x1, y0 ^= y1 ^= y0 ^= y1;
-      
-      ImageTool::line(timgR, x0, y0, x1, y1, 255);
-      ImageTool::line(timgG, x0, y0, x1, y1, 0);
-      ImageTool::line(timgB, x0, y0, x1, y1, 0);
-    }
-  }
   
-  ImageCreator::saveToJpeg("matching.jpg", timgR, timgG, timgB);
-  */
-
-	int cnt = 0;
-	float *t = new float[picture_number];
-	float *x = new float[picture_number];
-	float *y = new float[picture_number];
-	float*** matching = new float**[2];
-	t[0] = 0;
-	x[0] = 0;
-	y[0] = 0;
-
-	int dex = 0;
-	for(i=0; i<picture_number-1; i++){
-		dex = (i+1)*(i+2)/2-1;
-		cnt = matches[dex].x1.size();
-		matching[0] = new float*[cnt];
-		matching[1] = new float*[cnt];
-
-		for(j=0; j<cnt; j++){
-			matching[0][j] = new float[2];
-			matching[1][j] = new float[2];
-			matching[0][j][0] = matches[dex].x1[j];
-			matching[0][j][1] = matches[dex].y1[j];
-			matching[1][j][0] = matches[dex].x2[j];
-			matching[1][j][1] = matches[dex].y2[j];
-		}
-
-		std::printf("computing transition %d to %d\n", i, i+1);
-		transition(cnt, matching[1], matching[0], &t[i+1], &y[i+1], &x[i+1]);
-		delete matching[0];
-		delete matching[1];
-	}
-
-	float tt, tx, ty;
-	for(i=0; i<picture_number-1; i++){
-		tt = t[i] + t[i+1];
-		tx = cos(t[i+1])*x[i] - sin(t[i+1])*y[i] + x[i+1];
-		ty = cos(t[i+1])*y[i] + sin(t[i+1])*x[i] + y[i+1];
-		t[i+1] = tt;
-		x[i+1] = tx;
-		y[i+1] = ty;
-	}
-
-	ByteImage *fin = new ByteImage[4];
-	ByteImage **ali = new ByteImage*[picture_number];
-	for(int i=0; i<picture_number; i++){
-		ali[i] = new ByteImage[4];
-		for(j=0; j<4; j++)
-
-			ali[i][j] = ByteImage(src[i]);
-	}
-
-	std::printf("aligning pictures\n");
-	aligne(ali, fin, picture_number, t, x, y);
-	ImageCreator::saveToJpeg("alignemant.jpg", fin[0]);
-
-	system("pause");
   
   return 0;
 }