1.进入异型个数识别修改

2.品规识别只识别是否是托盘
普洱算法
LAPTOP-S9HJSOEB\昊天 4 months ago
parent 8530a86cfd
commit 652827b38b

@ -6,6 +6,7 @@ import com.example.lxcameraapi.service.IndustrialCamera.algorithm.BoxPositionCon
import com.example.lxcameraapi.service.IndustrialCamera.algorithm.PcdPojo;
import com.example.lxcameraapi.service.IndustrialCamera.algorithm.PointCloudProcessor;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -20,6 +21,7 @@ import java.util.*;
import static com.example.lxcameraapi.controller.HikController.DATE_FORMATTER;
import static com.example.lxcameraapi.controller.HikController.TIME_FORMATTER;
@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {
@ -52,25 +54,97 @@ public class CategoryController {
@GetMapping("/getBoxCountByCategory")
public int getBoxCountByCategory(String streetId,String category) throws IOException {
if(category.equals("20")){
return 1;
}
String path =streetId+"\\"
+ LocalDate.now().format(DATE_FORMATTER)
+"\\"+category+"_"+ LocalDateTime.now().format(TIME_FORMATTER) +"_";
List<AppConfig.Camera> cameras = appConfig.getLxCamera();
int i = 0;
Map<Integer, String> map = new HashMap<>();
System.out.println(appConfig.getSpecialBox().toString());
for (AppConfig.SpecialBox specialBox:appConfig.getSpecialBox()){
System.out.println(category.equals(specialBox.getCategory()));
if (category.equals(specialBox.getCategory())){
map.put(specialBox.getCameraId(),specialBox.getComputeConfPath());
System.out.println(specialBox.getCameraId()+" "+specialBox.getComputeConfPath());
}
}
if (!map.isEmpty()){
log.info("map: {}", map);
System.out.println("map: "+map);
for (Integer cameraId:map.keySet()) {
for (AppConfig.Camera c : cameras) {
if (Objects.equals(c.getId(), cameraId)) {
log.info("cameraId: {}, path: {}", cameraId, path +"_"+c.getId()+ ".pcd");
LxPointCloudSaveImage.saveImage(c.getIp(), path +"_"+c.getId()+ ".pcd");
PcdPojo pojo = new PcdPojo();
pojo.setPcd1(path + "_"+c.getId()+ ".pcd");
pojo.setConfigPath(c.getConvertConfPath());
try {
pojo.setPCDInfo(pojo);
} catch (IOException e) {
throw new RuntimeException(e);
}
PointCloudProcessor pointCloudProcessor = new PointCloudProcessor();
List<BoxPositionConf> confs = pointCloudProcessor.getBoxPositionConf(map.get(c.getId()));
i += pointCloudProcessor.slicing(pojo, confs);
}
}
}
}else {
for (AppConfig.Camera c : cameras) {
if (streetId.equals(c.getStreetId())) {
log.info("cameraId: {}, path: {}", c.getId(), path +"_"+c.getId()+ ".pcd");
LxPointCloudSaveImage.saveImage(c.getIp(), path +"_"+c.getId()+ ".pcd");
PcdPojo pojo = new PcdPojo();
pojo.setPcd1(path + "_"+c.getId()+ ".pcd");
pojo.setConfigPath(c.getConvertConfPath());
try {
pojo.setPCDInfo(pojo);
} catch (IOException e) {
throw new RuntimeException(e);
}
PointCloudProcessor pointCloudProcessor = new PointCloudProcessor();
List<BoxPositionConf> confs = pointCloudProcessor.getBoxPositionConf(c.getComputeConfPath());
i += pointCloudProcessor.slicing(pojo, confs);
}
}
}
return i;
}
@GetMapping("/getBoxCountByCategoryTest")
public int getBoxCountByCategoryTest(String streetId,String category,String path1,String path2) throws IOException {
if(category.equals("20")){
return 1;
}
List<AppConfig.Camera> cameras = appConfig.getLxCamera();
int i = 0;
Map<Integer, String> map = new HashMap();
for (AppConfig.SpecialBox specialBox:appConfig.getSpecialBox()){
if (category==specialBox.getCategory()){
if (category.equals(specialBox.getCategory())){
map.put(specialBox.getCameraId(),specialBox.getComputeConfPath());
}
}
if (map.size()>0){
if (!map.isEmpty()){
for (Integer cameraId:map.keySet()) {
for (AppConfig.Camera c : cameras) {
if (Objects.equals(c.getId(), cameraId)) {
String sn = UUID.randomUUID().toString();
LxPointCloudSaveImage.saveImage(c.getIp(), path+ sn + ".pcd");
// LxPointCloudSaveImage.saveImage(c.getIp(), path1);
PcdPojo pojo = new PcdPojo();
pojo.setPcd1(path + sn + ".pcd");
if (c.getId()==1) {
pojo.setPcd1(path1);
}else {
pojo.setPcd1(path2);
}
pojo.setConfigPath(c.getConvertConfPath());
try {
pojo.setPCDInfo(pojo);
@ -87,9 +161,13 @@ public class CategoryController {
for (AppConfig.Camera c : cameras) {
if (streetId.equals(c.getStreetId())) {
String sn = UUID.randomUUID().toString();
LxPointCloudSaveImage.saveImage(c.getIp(), path + sn + ".pcd");
PcdPojo pojo = new PcdPojo();
pojo.setPcd1(path + sn + ".pcd");
if (c.getId()==1) {
pojo.setPcd1(path1);
}else {
pojo.setPcd1(path2);
}
pojo.setConfigPath(c.getConvertConfPath());
try {
pojo.setPCDInfo(pojo);

@ -226,6 +226,7 @@ public class HikController {
@GetMapping("/distinguish")
@ResponseBody
public Pojo distinguishOnnx(String streetNumber,int direction, String category) throws IOException {
String picPath = appConfig.getPicPath();
String path =streetNumber+"\\"
+ LocalDate.now().format(DATE_FORMATTER)
@ -243,18 +244,35 @@ public class HikController {
// 进行标定,保存图片
Imgcodecs.imwrite(picPath+path+".jpg", Objects.requireNonNull(img2));
// if (category.equals("20")){
//
// Pojo pojo = new Pojo();
// pojo.setResult(true);
// pojo.setDeterminePath(path+".jpg");
// return pojo;
// }
boolean flag = false;
try {
ClassifyEntity classifyEntity = onnxServiceNew.classifyOne(picPath+path+".jpg", null);
if(category.equals("20") ){
if (classifyEntity !=null && classifyEntity.getName() !=null && classifyEntity.getName().equals(category)) {
flag = true;
}
}else {
for (List<String> similar:appConfig.getSimilar()){
if (classifyEntity !=null && classifyEntity.getName() !=null && similar.contains(classifyEntity.getName())){
if (classifyEntity !=null && classifyEntity.getName() !=null && classifyEntity.getName().equals("box")) {
flag = true;
}
}
}
// if (classifyEntity !=null && classifyEntity.getName() !=null && classifyEntity.getName().equals(category)){
// flag = true;
// }else {
// for (List<String> similar:appConfig.getSimilar()){
// if (classifyEntity !=null && classifyEntity.getName() !=null && similar.contains(classifyEntity.getName())){
// flag = true;
// }
// }
// }
} catch (OrtException e) {
throw new RuntimeException(e);
}

@ -23,6 +23,16 @@ lxCamera:
# 深度切割配置,深货位配置,若切割后个数多与500个,则认为有个数
DeepConvertConfPath: "E://pz.json"
- id: 2
ip: 192.168.100.82
# 1左2右
direction: 1
# 图片保存裁剪路径,若不指定,则不保存图片
calibratePath: "E://pz.json"
# 切割配置。浅货位的配置,若切割后个数多与500个,则认为有个数
convertConfPath: "E://pz.json"
# 深度切割配置,深货位配置,若切割后个数多与500个,则认为有个数
DeepConvertConfPath: "E://pz.json"
#两台相机
hikCamera:
- id: 1
@ -45,7 +55,14 @@ deleteFile:
similar:
- ["0473","2222"]
- ["333","4444"]
#异形
specialBox:
# 相机id
- cameraId: 2
# 品规
category: 21
# 个数地址
computeConfPath: "E://pz.json"
yoloModelConfig:
# 模型地址

Loading…
Cancel
Save