realisation de API algo
This commit is contained in:
1 parent
25aa328a2d
commit
4fbc3d98dd
4 files changed
+130
-2
No files matched your search
@@ -0,0 +1,55 @@
|
|||||||
|
package pdl.backend;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
public class Algorithm {
|
||||||
|
private final String name;
|
||||||
|
private final String pass;
|
||||||
|
private final ArrayList<Parameter> parameters;
|
||||||
|
|
||||||
|
public Algorithm(String name, String pass) {
|
||||||
|
this.name = name;
|
||||||
|
this.pass = pass;
|
||||||
|
this.parameters = new ArrayList<>();
|
||||||
|
switch (pass) {
|
||||||
|
case "changeLuminosity":
|
||||||
|
Parameter param1 = new Parameter("delta", "", -255, 255, false);
|
||||||
|
this.parameters.add(param1);
|
||||||
|
break;
|
||||||
|
case "histogram":
|
||||||
|
break;
|
||||||
|
case "colorFilter":
|
||||||
|
Parameter param2 = new Parameter("hue", "Teinte", 0, 360, false);
|
||||||
|
this.parameters.add(param2);
|
||||||
|
break;
|
||||||
|
case "meanFilter":
|
||||||
|
Parameter param3 = new Parameter("size", "Taille du filtre", 1, 101, true);
|
||||||
|
this.parameters.add(param3);
|
||||||
|
break;
|
||||||
|
case "gaussienFilter":
|
||||||
|
Parameter param4 = new Parameter("size", "Taille du filtre", 1, 101, true);
|
||||||
|
this.parameters.add(param4);
|
||||||
|
break;
|
||||||
|
case "contours":
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid pass");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPass() {
|
||||||
|
return this.pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Parameter> getParameters() {
|
||||||
|
return this.parameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,12 +5,12 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.print.attribute.standard.Media;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
@@ -113,6 +113,43 @@ public class ImageController {
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/algorithms", produces = "application/json")
|
||||||
|
@ResponseBody
|
||||||
|
public ArrayNode getAlgorithmList() {
|
||||||
|
ArrayList<Algorithm> algorithms = new ArrayList<Algorithm>();
|
||||||
|
Algorithm algo = new Algorithm("Changement de luminosité", "changeLuminosity");
|
||||||
|
algorithms.add(algo);
|
||||||
|
algo = new Algorithm("Changement de teinte", "colorFilter");
|
||||||
|
algorithms.add(algo);
|
||||||
|
algo = new Algorithm("Filtre Moyenneur", "meanFilter");
|
||||||
|
algorithms.add(algo);
|
||||||
|
algo = new Algorithm("Filtre Gaussien", "gaussienFilter");
|
||||||
|
algorithms.add(algo);
|
||||||
|
algo = new Algorithm("Détection de contours", "contours");
|
||||||
|
algorithms.add(algo);
|
||||||
|
algo = new Algorithm("Histogramme", "histogram");
|
||||||
|
algorithms.add(algo);
|
||||||
|
|
||||||
|
ArrayNode nodes = mapper.createArrayNode();
|
||||||
|
for (Algorithm a : algorithms) {
|
||||||
|
ObjectNode objectNode = mapper.createObjectNode();
|
||||||
|
objectNode.put("name", a.getName());
|
||||||
|
objectNode.put("pass", a.getPass());
|
||||||
|
ArrayNode parameters = objectNode.putArray("parameters");
|
||||||
|
for (Parameter p : a.getParameters()) {
|
||||||
|
ObjectNode paramNode = mapper.createObjectNode();
|
||||||
|
paramNode.put("name", p.getName());
|
||||||
|
paramNode.put("displayName", p.getDisplayName());
|
||||||
|
paramNode.put("min", p.getMin());
|
||||||
|
paramNode.put("max", p.getMax());
|
||||||
|
paramNode.put("mustBeOdd", p.mustBeOdd());
|
||||||
|
parameters.add(paramNode);
|
||||||
|
}
|
||||||
|
nodes.add(objectNode);
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/images/{id}", produces = { MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE,
|
@GetMapping(value = "/images/{id}", produces = { MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE,
|
||||||
"application/json" })
|
"application/json" })
|
||||||
public ResponseEntity<?> getImage(@PathVariable("id") long id,
|
public ResponseEntity<?> getImage(@PathVariable("id") long id,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package pdl.backend;
|
|||||||
|
|
||||||
import boofcv.struct.image.GrayU8;
|
import boofcv.struct.image.GrayU8;
|
||||||
import boofcv.struct.image.Planar;
|
import boofcv.struct.image.Planar;
|
||||||
import boofcv.alg.color.ColorHsv;
|
|
||||||
|
|
||||||
public class ImageProcessing {
|
public class ImageProcessing {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package pdl.backend;
|
||||||
|
|
||||||
|
public class Parameter {
|
||||||
|
private final String name;
|
||||||
|
private final String displayName;
|
||||||
|
private final int min;
|
||||||
|
private final int max;
|
||||||
|
private final boolean mustBeOdd;
|
||||||
|
|
||||||
|
public Parameter(String name, String displayName, int min, int max, boolean mustBeOdd) {
|
||||||
|
this.name = name;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.max = max;
|
||||||
|
this.min = min;
|
||||||
|
this.mustBeOdd = mustBeOdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMin() {
|
||||||
|
return this.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return this.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mustBeOdd() {
|
||||||
|
return this.mustBeOdd;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user