public Sample3D(String title){
		super(title);
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		//Read digitized data
		CSVReader[] cr = new CSVReader[3];
	 	cr[0] = new CSVReader("octaveTest/GoPro0093.xls",",");
		cr[1] = new CSVReader("octaveTest/GoPro0099.xls",",");
		cr[2] = new CSVReader("octaveTest/calibrationObject.xls","\t");
		
		//Add images
		JComponent cp = new JPanel();
		ImagePanel[] ip = new ImagePanel[4];
		//Scale images down to 1/5th. My laptop couldn't handle the full image...
		ImagePanel tempI = loadImage("octaveTest/GOPR0093.JPG");
		ip[0] = new ImagePanel(tempI.scaleImage(tempI.getOrig(),0.2));
		ip[0].setOpaque(true);
		tempI = loadImage("octaveTest/GOPR0099.JPG");
		ip[1] = new ImagePanel(tempI.scaleImage(tempI.getOrig(),0.2));
		ip[1].setOpaque(true);
		
		double[][] calibrationObject = getCoords(cr[2]);
		/*
		System.out.println("");
		for (int i = 0; i<calibrationObject.length;++i){
			System.out.print(i+"\t");
			for (int j = 0; j<calibrationObject[i].length;++j){
				System.out.print(calibrationObject[i][j]+"\t");
			}
			System.out.println("");
			
		}
		*/
		LensCalibration lc = new LensCalibration(calibrationObject,ip[0].origWidth/2,ip[0].origHeight/2);
		double[][][] undistortedCoord = new double[2][][];
		double[][][] undistortedUnknown = new double[2][][];
		Undistort[] ud = new Undistort[2];
		Matrix[][] Rt = new Matrix[2][2];
		for (int i = 0;i<2;++i){
			
			//System.out.println("Cam "+i);
			double[][] digitized = getCoords(cr[i]);
			double[][] confirm = new double[digitized.length][2];
			//Scale the coordinates down by 5. My laptop couldn't handle the full image...
			for (int r = 0;r<digitized.length;++r){
				//System.out.print(r+"\t");
				for (int c = 0;c<digitized[r].length;++c){
					digitized[r][c]/=5d;
					//System.out.print(digitized[r][c]+"\t");
				}
				
				//Set 50% of coordinates to null
				if (r % 2 > 0){
					confirm[r][0] = digitized[r][0];
					confirm[r][1] = digitized[r][1]; 
					digitized[r] = null;
				}else{
					confirm[r] = null;
				}
				//System.out.println("");	
			}
			
			ArrayList<Matrix> KRt = lc.calibrate(digitized);
			
			if(false){
				System.out.println("K");
				KRt.get(0).print(3,3);
				System.out.println("R");
				KRt.get(1).print(3,3);
				System.out.println("t");
				KRt.get(2).print(3,3);
				System.out.println("");
			}
			
			//Refine the calibration
			RefineParameters rp = new RefineParameters(calibrationObject,digitized,KRt.get(0),new double[]{0d,0d,0d,0d,0d},KRt.get(1),KRt.get(2));
			ArrayList<Matrix> KdRt = rp.getCalibration();
			Rt[i][0]=KdRt.get(2);
			Rt[i][1]=KdRt.get(3);
			
			if(false){
				System.out.println("refined K");
				KdRt.get(0).print(3,3);
				System.out.println("d");
				KdRt.get(1).print(3,3);
				System.out.println("R");
				KdRt.get(2).print(3,3);
				System.out.println("t");
				KdRt.get(3).print(3,3);
			}
			
			
			ud[i] = new Undistort(ip[i], KdRt.get(0), KdRt.get(1));
			ip[i+2] = new ImagePanel(ud[i].ubi);
			ip[i].plotCoordinates(digitized);
			undistortedCoord[i] = ud[i].undistortCoordinates(digitized);
			ip[i+2].plotCoordinates(undistortedCoord[i]);
			undistortedUnknown[i] = ud[i].undistortCoordinates(confirm);
			ip[i+2].plotCoordinates(ud[i].projectKnownPoints(calibrationObject, KdRt.get(2), KdRt.get(3)), new Color(0,255,0));
			
			//ip[i+2].paintImageToDraw();
			//ip[i+2].setOpaque(true);
			
			cp.add(ip[i]);
			cp.add(ip[i+2]);
			
			//DLT based on undistorted coordinates
			
		}
		DLT3D dlt3d = new DLT3D(calibrationObject,undistortedCoord);
		//Get 3D coords, and project to undistorted coords. UnknownPoints need to be undistorted as well
		double[][] unknownUndistorted3D = new double[undistortedUnknown[0].length][3];
		Matrix tempC;
		for (int i =0;i<unknownUndistorted3D.length;++i){
			if (undistortedUnknown[0][i] != null){
				tempC = dlt3d.scaleCoordinates(new double[][]{undistortedUnknown[0][i],undistortedUnknown[1][i]});
				unknownUndistorted3D[i] = new double[]{tempC.get(0,0),tempC.get(1,0),tempC.get(2,0)};
				//System.out.println("Marker "+i+" x "+tempC.get(0,0)+" y "+tempC.get(1,0)+" z "+tempC.get(2,0));
			}else{
				unknownUndistorted3D[i] = null;
			}
		}	
		
		ip[2].plotCoordinates(ud[0].projectKnownPoints(unknownUndistorted3D, Rt[0][0], Rt[0][1]), new Color(0,0,255));
		ip[3].plotCoordinates(ud[1].projectKnownPoints(unknownUndistorted3D, Rt[1][0], Rt[1][1]), new Color(0,0,255));
		//Matrix coordinates = dlt3d.scaleCoordinates(digitizedUnknownPoint);
		cp.setOpaque(true); // must be opaque	
		setContentPane(cp);
		pack();
		setSize(new Dimension(680,550));
	   setVisible(true);
	}