|
|
|
@ -3,7 +3,6 @@ package org.wlld.imageRecognition.border;
|
|
|
|
|
import org.wlld.MatrixTools.Matrix;
|
|
|
|
|
import org.wlld.MatrixTools.MatrixOperation;
|
|
|
|
|
import org.wlld.imageRecognition.TempleConfig;
|
|
|
|
|
import org.wlld.test.Ma;
|
|
|
|
|
import org.wlld.tools.ArithUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -48,7 +47,15 @@ public class Border {
|
|
|
|
|
height = maxX - minX;
|
|
|
|
|
width = maxY - minY;
|
|
|
|
|
BorderBody borderBody = templeConfig.getBorderBodyMap().get(id);
|
|
|
|
|
|
|
|
|
|
if (borderBody == null) {
|
|
|
|
|
borderBody = new BorderBody();
|
|
|
|
|
}
|
|
|
|
|
//拿到参数矩阵
|
|
|
|
|
Matrix matrixX = borderBody.getX();
|
|
|
|
|
Matrix matrixTx = borderBody.getTx();
|
|
|
|
|
Matrix matrixTy = borderBody.getTy();
|
|
|
|
|
Matrix matrixTw = borderBody.getTw();
|
|
|
|
|
Matrix matrixTh = borderBody.getTh();
|
|
|
|
|
//多元线性回归的四个输出值
|
|
|
|
|
double tx = ArithUtil.div(minX, modelHeight);
|
|
|
|
|
double ty = ArithUtil.div(minY, modelWidth);
|
|
|
|
@ -56,8 +63,26 @@ public class Border {
|
|
|
|
|
double th = Math.log(ArithUtil.div(height, modelHeight));
|
|
|
|
|
//进行参数汇集 矩阵转化为行向量
|
|
|
|
|
matrix = MatrixOperation.matrixToVector(matrix, true);
|
|
|
|
|
//将矩阵的末尾填1
|
|
|
|
|
matrix = MatrixOperation.push(matrix, 1);
|
|
|
|
|
//将参数矩阵的末尾填1
|
|
|
|
|
matrix = MatrixOperation.push(matrix, 1, true);
|
|
|
|
|
if (matrixX == null) {//如果是第一次直接赋值
|
|
|
|
|
matrixX = matrix;
|
|
|
|
|
matrixTx = new Matrix(1, 1);
|
|
|
|
|
matrixTy = new Matrix(1, 1);
|
|
|
|
|
matrixTw = new Matrix(1, 1);
|
|
|
|
|
matrixTh = new Matrix(1, 1);
|
|
|
|
|
matrixTx.setNub(0, 0, tx);
|
|
|
|
|
matrixTy.setNub(0, 0, ty);
|
|
|
|
|
matrixTw.setNub(0, 0, tw);
|
|
|
|
|
matrixTh.setNub(0, 0, th);
|
|
|
|
|
} else {//将新的参数矩阵添加到原来的末尾
|
|
|
|
|
matrixX = MatrixOperation.pushVector(matrixX, matrix, true);
|
|
|
|
|
matrixTx = MatrixOperation.push(matrixTx, tx, false);
|
|
|
|
|
matrixTy = MatrixOperation.push(matrixTy, ty, false);
|
|
|
|
|
matrixTw = MatrixOperation.push(matrixTw, tw, false);
|
|
|
|
|
matrixTh = MatrixOperation.push(matrixTh, th, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|