package pers.season.vml.test;

import java.io.IOException;
import java.util.UUID;

import javax.swing.JFrame;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

import pers.season.vml.statistics.appearance.AppearanceFitting;
import pers.season.vml.statistics.appearance.AppearanceModel;
import pers.season.vml.statistics.appearance.AppearanceModelTrain;
import pers.season.vml.statistics.regressor.LearningParams;
import pers.season.vml.statistics.regressor.RegressorTrain;
import pers.season.vml.statistics.shape.ShapeInstance;
import pers.season.vml.statistics.shape.ShapeModel;
import pers.season.vml.statistics.shape.ShapeModelTrain;
import pers.season.vml.statistics.texture.TextureInstance;
import pers.season.vml.statistics.texture.TextureModel;
import pers.season.vml.statistics.texture.TextureModelTrain;
import pers.season.vml.util.*;

public final class Entrance {

	static {
		// todo: x64/x86 judge
		// System.loadLibrary("lib/opencv_java2413_x64");
		System.loadLibrary("lib/opencv_java320_x64");
	}

	public static void main(String[] args) throws IOException {
		MuctData.init("e:/muct/jpg", "e:/muct/muct76-opencv.csv", MuctData.no_ignore);

		Kalman kalman = new Kalman(2);
		for (int i = 0; i < 1000; i++) {
			kalman.correct(new double[] {i, i*3});
			
			Mat pmat = kalman.predict();
			for (int p=0;p<pmat.rows();p++) {
				System.out.print(pmat.get(p, 0)[0] +", ");
			}

			System.out.println();
		}
		
		Mat refShape = RegressorTrain.getRefShape(100, 100);
		int point = 0;
		LearningParams lp = new LearningParams();
		lp.iteration = 1000;

		Size patchSize = new Size(61, 61);

		// Mat theta = RegressorTrain.trainLinearModel(refShape, point,
		// patchSize, new Size(61, 61), 3, 0.2, lp);
		// RegressorTrain.measureDistribution("e:/Cool/OneDrive/temp/",
		// "maxloc", "theta", refShape, point, theta,
		// patchSize, new Size(61, 61), 0.2, false);

		// ShapeModelTrain.train("models/shape/", 0.90, false);
		// ShapeModel sm = ShapeModel.load("models/shape/", "V", "Z_e");
		// ShapeModelTrain.visualize(sm);

		// TextureModelTrain.train("models/texture/", 0.95, 100, 100, true);
		// TextureModel tm = TextureModel.load("models/texture/", "U", "X_mean",
		// "Z_e", "meanShape", "delaunay");
		// TextureModelTrain.visualize(tm);

		// AppearanceModelTrain.train(sm, tm, "models/appearance/", 1.5, 0.98,
		// false);
		// AppearanceModel am = AppearanceModel.load(sm, tm,
		// "models/appearance/", "U", "Z_e", "shapeWeight");
		// AppearanceModelTrain.visualize(am);

		System.out.println("program ended.");

	}

}

@@ -1347,900 +1347,8 @@
 %0D%0A%09%09
-MuctData.init(%22e:/muct/jpg%22, %22e:/muct/muct76-opencv.csv%22, MuctData.no_ignore);%0D%0A%0D%0A%09%09Kalman kalman = new Kalman(2);%0D%0A%09%09for (int i = 0; i %3C 1000; i++) %7B%0D%0A%09%09%09kalman.correct(new double%5B%5D %7Bi, i*3%7D);%0D%0A%09%09%09%0D%0A%09%09%09Mat pmat = kalman.predict();%0D%0A%09%09%09for (int p=0;p%3Cpmat.rows();p++) %7B%0D%0A%09%09%09%09System.out.print(pmat.get(p, 0)%5B0%5D +%22, %22);%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09System.out.println();%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09Mat refShape = RegressorTrain.getRefShape(100, 100);%0D%0A%09%09int point = 0;%0D%0A%09%09LearningParams lp = new LearningParams();%0D%0A%09%09lp.iteration = 1000;%0D%0A%0D%0A%09%09Size patchSize = new Size(61, 61);%0D%0A%0D%0A%09%09// Mat theta = RegressorTrain.trainLinearModel(refShape, point,%0D%0A%09%09// patchSize, new Size(61, 61), 3, 0.2, lp);%0D%0A%09%09// RegressorTrain.measureDistribution(%22e:/Cool/OneDrive/temp/%22,%0D%0A%09%09// %22maxloc%22, %22theta%22, refShape, point, theta,%0D%0A%09%09// patchSize, new Size(61, 61), 0.2, false);%0D%0A%0D%0A%09%09// ShapeModelTrain.train(%22models/shape/%22, 0.90, false);%0D%0A%09%09// 
 Shap
@@ -1408,19 +1408,16 @@
 e%22);%0D%0A%09%09
-// 
 ShapeMod
@@ -1440,91 +1440,17 @@
 e(sm
-);%0D%0A%0D%0A%09%09// TextureModelTrain.train(%22models/texture/%22, 0.95, 100, 100, true
+, 4
 );%0D%0A%09%09
-// 
 Text
@@ -1514,22 +1514,16 @@
 X_mean%22,
-%0D%0A%09%09//
  %22Z_e%22, 
@@ -1551,19 +1551,16 @@
 y%22);%0D%0A%09%09
-// 
 TextureM
@@ -1585,107 +1585,17 @@
 e(tm
-);%0D%0A%0D%0A%09%09// AppearanceModelTrain.train(sm, tm, %22models/appearance/%22, 1.5, 0.98,%0D%0A%09%09// false
+, 4
 );%0D%0A%09%09
-// 
 Appe
@@ -1639,22 +1639,16 @@
 (sm, tm,
-%0D%0A%09%09//
  %22models
@@ -1693,19 +1693,16 @@
 t%22);%0D%0A%09%09
-// 
 Appearan
@@ -1726,16 +1726,19 @@
 alize(am
+, 4
 );%0D%0A%0D%0A%09%09

test code