|
|
|
|
@ -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);
|
|
|
|
|
|