修改position定位的bug完成

pull/1/head
lidapeng 5 years ago
parent f14fb57468
commit bc9ed128ae

@ -6,8 +6,8 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="ImageMarket" />
<module name="myBrain" />
<module name="ImageMarket" />
</profile>
</annotationProcessing>
</component>

@ -135,9 +135,10 @@ public class Operation {//进行计算
intoNerve2(eventId, frameBody.getMatrix(), templeConfig.getConvolutionNerveManager().getSensoryNerves(),
false, -1, matrixBack);
Matrix myMatrix = matrixBack.getMatrix();
//卷积层输出即边框回归的输入的特征向量 TODO 这地有BUG 要改
//卷积层输出即边框回归的输入的特征向量
frameBody.setEndMatrix(myMatrix);
int id = getClassificationId2(myMatrix);
Matrix vector = MatrixOperation.matrixToVector(myMatrix, true);
int id = getClassificationId2(vector);
frameBody.setId(id);
}
return toPosition(frameBodies, frame.getWidth(), frame.getHeight());
@ -188,12 +189,12 @@ public class Operation {//进行计算
private Matrix getBoxMatrix(Matrix matrix, Map<Integer, Box> boxMap) throws Exception {
Matrix positionMatrix = null;
double endDist = 0;
double endDist = -1;
for (Map.Entry<Integer, Box> entry : boxMap.entrySet()) {
Box box = entry.getValue();
Matrix boxMatrix = box.getMatrix();
double dist = MatrixOperation.getEDist(matrix, boxMatrix);
if (endDist == 0 || dist < endDist) {
if (endDist == -1 || dist < endDist) {
endDist = dist;
positionMatrix = box.getMatrixPosition();
}

@ -1,7 +1,6 @@
package org.wlld.imageRecognition;
import org.wlld.MatrixTools.Matrix;
import org.wlld.MatrixTools.MatrixOperation;
import org.wlld.config.StudyPattern;
import org.wlld.function.ReLu;
import org.wlld.function.Sigmod;
@ -89,6 +88,7 @@ public class TempleConfig {
for (Map.Entry<Integer, KClustering> entry : kClusteringMap.entrySet()) {
entry.getValue().start();
}
boxReady = true;
}
}
@ -123,7 +123,7 @@ public class TempleConfig {
this.studyPattern = studyPattern;
if (isHavePosition) {
for (int i = 1; i < classificationNub + 1; i++) {
kClusteringMap.put(i, new KClustering(20));
kClusteringMap.put(i, new KClustering(10));
}
}
switch (studyPattern) {

@ -57,11 +57,11 @@ public class KClustering {
Matrix[] matrices2 = new Matrix[speciesQuantity];//待比较均值K
for (Box matrixBody : matrixList) {//遍历当前集合
Matrix matrix = matrixBody.getMatrix();
double min = 0;
double min = -1;
int id = 0;
for (int i = 0; i < matrices.length; i++) {
double dist = MatrixOperation.getEDist(matrix, matrices[i]);
if (min == 0 || dist < min) {
if (min == -1 || dist < min) {
min = dist;
id = i;
}
@ -69,8 +69,12 @@ public class KClustering {
List<Box> matrixList1 = clusterMap.get(id);
matrixList1.add(matrixBody);
}
//重新计算均值
for (Map.Entry<Integer, List<Box>> entry : clusterMap.entrySet()) {
if (entry.getValue().size() == 0) {
System.out.println("空值:" + entry.getKey());
}
Matrix matrix = average(entry.getValue());
matrices2[entry.getKey()] = matrix;
}
@ -121,9 +125,9 @@ public class KClustering {
if (matrixList.size() > 1) {
Random random = new Random();
for (int i = 0; i < matrices.length; i++) {//初始化均值向量
int index = random.nextInt(matrixList.size());
//int index = random.nextInt(matrixList.size());
//要进行深度克隆
matrices[i] = matrixList.get(index).getMatrix();
matrices[i] = matrixList.get(i).getMatrix();
}
//进行两者的比较
boolean isEqual = false;
@ -139,7 +143,6 @@ public class KClustering {
}
while (!isEqual);
//聚类结束,进行坐标均值矩阵计算
System.out.println("聚类循环次数:" + nub);
position();
isReady = true;
} else {

@ -30,13 +30,13 @@ public class HelloWorld {
public static void test() throws Exception {
Picture picture = new Picture();
TempleConfig templeConfig = new TempleConfig();
//templeConfig.setHavePosition(true);
// Frame frame = new Frame();
// frame.setWidth(3024);
// frame.setHeight(4032);
// frame.setLengthHeight(100);
// frame.setLengthWidth(100);
// templeConfig.setFrame(frame);
templeConfig.setHavePosition(true);
Frame frame = new Frame();
frame.setWidth(3024);
frame.setHeight(4032);
frame.setLengthHeight(100);
frame.setLengthWidth(100);
templeConfig.setFrame(frame);
ModelParameter modelParameter = JSONObject.parseObject(ModelData.DATA, ModelParameter.class);
templeConfig.init(StudyPattern.Accuracy_Pattern, true, 3204, 4032, 1);
templeConfig.insertModel(modelParameter);
@ -51,26 +51,27 @@ public class HelloWorld {
operation.learning(right, 1, true);
operation.learning(wrong, 0, true);
}
templeConfig.startLvq();
templeConfig.boxStudy();//边框聚类
templeConfig.startLvq();//原型向量量化
//templeConfig.boxStudy();//边框回归
//templeConfig.clustering();//进行聚类
// ModelParameter modelParameter1 = templeConfig.getModel();
// String a = JSON.toJSONString(modelParameter1);
// System.out.println(a);
// for (int j = 1; j < 2; j++) {
// Matrix right = picture.getImageMatrixByLocal("/Users/lidapeng/Desktop/myDocment/c/c" + j + ".png");
// Map<Integer, List<FrameBody>> map = operation.lookWithPosition(right, j);
// System.out.println("j===" + j);
// }
//测试集图片,进行识别测试
for (int j = 121; j < 140; j++) {
for (int j = 1; j < 2; j++) {
Matrix right = picture.getImageMatrixByLocal("/Users/lidapeng/Desktop/myDocment/c/c" + j + ".png");
Matrix wrong = picture.getImageMatrixByLocal("/Users/lidapeng/Desktop/myDocment/b/b" + j + ".png");
int rightId = operation.toSee(right);
int wrongId = operation.toSee(wrong);
System.out.println("该图是菜单:" + rightId);
System.out.println("该图是桌子:" + wrongId);
Map<Integer, List<FrameBody>> map = operation.lookWithPosition(right, j);
System.out.println("j===" + j);
}
//测试集图片,进行识别测试
// for (int j = 121; j < 140; j++) {
// Matrix right = picture.getImageMatrixByLocal("/Users/lidapeng/Desktop/myDocment/c/c" + j + ".png");
// Matrix wrong = picture.getImageMatrixByLocal("/Users/lidapeng/Desktop/myDocment/b/b" + j + ".png");
// int rightId = operation.toSee(right);
// int wrongId = operation.toSee(wrong);
// System.out.println("该图是菜单:" + rightId);
// System.out.println("该图是桌子:" + wrongId);
// }
}

Loading…
Cancel
Save