|
|
@ -3,6 +3,7 @@ package coverTest;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import org.wlld.MatrixTools.Matrix;
|
|
|
|
import org.wlld.MatrixTools.Matrix;
|
|
|
|
|
|
|
|
import org.wlld.ModelData;
|
|
|
|
import org.wlld.config.Classifier;
|
|
|
|
import org.wlld.config.Classifier;
|
|
|
|
import org.wlld.config.RZ;
|
|
|
|
import org.wlld.config.RZ;
|
|
|
|
import org.wlld.config.StudyPattern;
|
|
|
|
import org.wlld.config.StudyPattern;
|
|
|
@ -20,6 +21,12 @@ import java.util.List;
|
|
|
|
public class FoodTest {
|
|
|
|
public class FoodTest {
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
|
|
|
// ModelParameter parameter = JSON.parseObject(ModelData.DATA, ModelParameter.class);
|
|
|
|
|
|
|
|
// if (parameter.getKnnVector() != null) {
|
|
|
|
|
|
|
|
// System.out.println("空的");
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// System.out.println("不是空===");
|
|
|
|
|
|
|
|
// }
|
|
|
|
test();
|
|
|
|
test();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -40,19 +47,20 @@ public class FoodTest {
|
|
|
|
|
|
|
|
|
|
|
|
public static void test2(TempleConfig templeConfig) throws Exception {
|
|
|
|
public static void test2(TempleConfig templeConfig) throws Exception {
|
|
|
|
if (templeConfig == null) {
|
|
|
|
if (templeConfig == null) {
|
|
|
|
|
|
|
|
ModelParameter parameter = JSON.parseObject(ModelData.DATA, ModelParameter.class);
|
|
|
|
templeConfig = getTemple(null);
|
|
|
|
templeConfig = getTemple(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Picture picture = new Picture();
|
|
|
|
Picture picture = new Picture();
|
|
|
|
List<Specifications> specificationsList = new ArrayList<>();
|
|
|
|
List<Specifications> specificationsList = new ArrayList<>();
|
|
|
|
Specifications specifications = new Specifications();
|
|
|
|
Specifications specifications = new Specifications();
|
|
|
|
specifications.setMinWidth(250);
|
|
|
|
specifications.setMinWidth(400);
|
|
|
|
specifications.setMinHeight(250);
|
|
|
|
specifications.setMinHeight(400);
|
|
|
|
specifications.setMaxWidth(750);
|
|
|
|
specifications.setMaxWidth(950);
|
|
|
|
specifications.setMaxHeight(750);
|
|
|
|
specifications.setMaxHeight(950);
|
|
|
|
specificationsList.add(specifications);
|
|
|
|
specificationsList.add(specifications);
|
|
|
|
Operation operation = new Operation(templeConfig);
|
|
|
|
Operation operation = new Operation(templeConfig);
|
|
|
|
for (int i = 1; i <= 28; i++) {
|
|
|
|
for (int i = 1; i <= 1; i++) {
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("D:\\share\\cai\\g/g" + i + ".jpg");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Documents/paramterTest/c" + i + ".jpg");
|
|
|
|
List<RegionBody> regionBody = operation.colorLook(threeChannelMatrix1, specificationsList);
|
|
|
|
List<RegionBody> regionBody = operation.colorLook(threeChannelMatrix1, specificationsList);
|
|
|
|
for (int j = 0; j < regionBody.size(); j++) {
|
|
|
|
for (int j = 0; j < regionBody.size(); j++) {
|
|
|
|
RegionBody regionBody1 = regionBody.get(j);
|
|
|
|
RegionBody regionBody1 = regionBody.get(j);
|
|
|
@ -70,17 +78,17 @@ public class FoodTest {
|
|
|
|
Cutting cutting = templeConfig.getCutting();
|
|
|
|
Cutting cutting = templeConfig.getCutting();
|
|
|
|
Food food = templeConfig.getFood();
|
|
|
|
Food food = templeConfig.getFood();
|
|
|
|
//切割
|
|
|
|
//切割
|
|
|
|
cutting.setMaxRain(320);//切割阈值
|
|
|
|
cutting.setMaxRain(310);//切割阈值
|
|
|
|
cutting.setTh(0.88);
|
|
|
|
cutting.setTh(0.8);
|
|
|
|
cutting.setRegionNub(200);
|
|
|
|
cutting.setRegionNub(200);
|
|
|
|
//knn参数
|
|
|
|
//knn参数
|
|
|
|
templeConfig.setKnnNub(3);
|
|
|
|
templeConfig.setKnnNub(1);
|
|
|
|
//池化比例
|
|
|
|
//池化比例
|
|
|
|
templeConfig.setPoolSize(2);//缩小比例
|
|
|
|
templeConfig.setPoolSize(2);//缩小比例
|
|
|
|
//聚类
|
|
|
|
//聚类
|
|
|
|
templeConfig.setFeatureNub(3);//聚类特征数量
|
|
|
|
templeConfig.setFeatureNub(3);//聚类特征数量
|
|
|
|
//菜品识别实体类
|
|
|
|
//菜品识别实体类
|
|
|
|
food.setShrink(60);//缩紧像素
|
|
|
|
food.setShrink(5);//缩紧像素
|
|
|
|
food.setTimes(2);//聚类数据增强
|
|
|
|
food.setTimes(2);//聚类数据增强
|
|
|
|
templeConfig.setClassifier(Classifier.KNN);
|
|
|
|
templeConfig.setClassifier(Classifier.KNN);
|
|
|
|
templeConfig.init(StudyPattern.Cover_Pattern, true, 400, 400, 3);
|
|
|
|
templeConfig.init(StudyPattern.Cover_Pattern, true, 400, 400, 3);
|
|
|
@ -96,35 +104,30 @@ public class FoodTest {
|
|
|
|
Operation operation = new Operation(templeConfig);
|
|
|
|
Operation operation = new Operation(templeConfig);
|
|
|
|
List<Specifications> specificationsList = new ArrayList<>();
|
|
|
|
List<Specifications> specificationsList = new ArrayList<>();
|
|
|
|
Specifications specifications = new Specifications();
|
|
|
|
Specifications specifications = new Specifications();
|
|
|
|
specifications.setMinWidth(250);
|
|
|
|
specifications.setMinWidth(400);
|
|
|
|
specifications.setMinHeight(250);
|
|
|
|
specifications.setMinHeight(400);
|
|
|
|
specifications.setMaxWidth(750);
|
|
|
|
specifications.setMaxWidth(950);
|
|
|
|
specifications.setMaxHeight(750);
|
|
|
|
specifications.setMaxHeight(950);
|
|
|
|
specificationsList.add(specifications);
|
|
|
|
specificationsList.add(specifications);
|
|
|
|
for (int i = 1; i <= 10; i++) {
|
|
|
|
for (int i = 1; i <= 1; i++) {
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("D:\\share\\cai\\a/a" + i + ".jpg");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Documents/paramterTest/a" + i + ".jpg");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix2 = picture.getThreeMatrix("D:\\share\\cai\\b/b" + i + ".jpg");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix2 = picture.getThreeMatrix("/Users/lidapeng/Documents/paramterTest/b" + i + ".jpg");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix3 = picture.getThreeMatrix("D:\\share\\cai\\c/c" + i + ".jpg");
|
|
|
|
operation.colorStudy(threeChannelMatrix1, 83, specificationsList);
|
|
|
|
ThreeChannelMatrix threeChannelMatrix4 = picture.getThreeMatrix("D:\\share\\cai\\d/d" + i + ".jpg");
|
|
|
|
System.out.println("=======================================");
|
|
|
|
ThreeChannelMatrix threeChannelMatrix5 = picture.getThreeMatrix("D:\\share\\cai\\e/e" + i + ".jpg");
|
|
|
|
operation.colorStudy(threeChannelMatrix2, 86, specificationsList);
|
|
|
|
ThreeChannelMatrix threeChannelMatrix6 = picture.getThreeMatrix("D:\\share\\cai\\f/f" + i + ".jpg");
|
|
|
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix7 = picture.getThreeMatrix("D:\\share\\cai\\h/h" + i + ".jpg");
|
|
|
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix8 = picture.getThreeMatrix("D:\\share\\cai\\i/i" + i + ".jpg");
|
|
|
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix9 = picture.getThreeMatrix("D:\\share\\cai\\j/j" + i + ".jpg");
|
|
|
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix10 = picture.getThreeMatrix("D:\\share\\cai\\k/k" + i + ".jpg");
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix1, 1, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix2, 2, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix3, 3, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix4, 4, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix5, 5, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix6, 6, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix7, 7, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix8, 8, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix9, 9, specificationsList);
|
|
|
|
|
|
|
|
operation.colorStudy(threeChannelMatrix10, 10, specificationsList);
|
|
|
|
|
|
|
|
System.out.println("=======================================" + i);
|
|
|
|
System.out.println("=======================================" + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
test2(templeConfig);
|
|
|
|
ModelParameter modelParameter = templeConfig.getModel();
|
|
|
|
|
|
|
|
if (modelParameter.getKnnVector() != null) {
|
|
|
|
|
|
|
|
System.out.println("not null 1");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String tr = JSON.toJSONString(modelParameter);
|
|
|
|
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
ModelParameter modelParameter1 = JSON.parseObject(tr, ModelParameter.class);
|
|
|
|
|
|
|
|
if (modelParameter1.getKnnVector() != null) {
|
|
|
|
|
|
|
|
System.out.println("not null 2");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//test2(templeConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void study() throws Exception {
|
|
|
|
public static void study() throws Exception {
|
|
|
|