Blame view

src/main.cpp 1.94 KB
b0bb08d1c   tristan   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  #include <stdio.h> 
  #include <iostream>
  #include <opencv2/opencv.hpp>
  #include <opencv2/highgui/highgui.hpp> 
  #include <opencv2/objdetect/objdetect.hpp>
  #include <opencv2/imgproc/imgproc.hpp>
  
  #include "Autocalib.h"
  #include "3dReconst.h"
  
  using namespace std;
  
  
  int main(int argc, char *argv[])
  {
  	vector<cv::Mat> image;
  
  	for (int index=1; index<argc; index++) {
  		image.push_back( cv::imread( argv[index], cv::IMREAD_GRAYSCALE));
  	}
  
  	cout<<image[0].size()<<endl;
  	/* for(int i=0;i<image.size();i++)
  	{
  		int offset_x = 800;
      		int offset_y = 400;
      		cv::Rect roi;
      		roi.x = offset_x;
      		roi.y = offset_y;
      		roi.width = image[i].size().width - (offset_x*2);
  		cout<<"ok"<<endl;
      		roi.height = image[i].size().height - (offset_y*3);
      		image[i] = image[i](roi);
  		string name = "piece"+to_string(i)+".jpg";
                  cv::imwrite(name,image[i]);
  
  	}*/
  	
  	//Extract features AKAZE and estimat measuremental matrix
  	Autocalib clib;	
          vector<vector<cv::Point2d> > matchVector=clib.findFeaturePoint(image,0.001);
  	vector<vector<cv::Point2d> > measureVector;
  	if(image.size()>2){  measureVector=clib.getMeasureVector(matchVector); }
  	else{measureVector=matchVector;}
  	//cout<<measureVector.size()<<endl;
  
  	//Estimate Fundamental matrix and show epipolair lines with images (before rectification)
  	vector<cv::Mat> fundMatVector =clib.estimatFundMatVector(measureVector);
  	clib.showEpipolarLines(image, measureVector, fundMatVector);
  	
  	//optimisation
  	cv::Mat measureMatrix = clib.vectorPoint2Mat(measureVector);
  	vector <cv::Mat>  P;  // P : camera matrix
  	P=clib.estimatParameter(measureMatrix);
          for(int i=0; i<P.size();i++)
  	{cout <<"matrice de camera"<<endl<< P[i]<<endl;}
  	
  	
  	
  	//reconstruction 3d
  	Reconst rec;
  	vector<cv::Mat> rectifImage;
  	rectifImage=rec.RectificaEpipolarLines(image, measureVector,  fundMatVector);
  	rec.disparity(rectifImage);
  	rec.GetPointCloud(P,image[0]);
  	rec.filterPointCloud(rectifImage.size()/2);
  
  	return 0;
  }