To change this license header choose License Headers in Project Proper

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ru.sfedu.opencvweb.webapi;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.apache.log4j.Logger;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import ru.sfedu.opencvgraphic.api.MyAPI;
/**
*
* @author maksimustimenko
*/
@Path("/api")
public class FoursLab {
private static Logger logger = Logger.getLogger(FoursLab.class);
public static Boolean inited = false;
MyAPI instance = new MyAPI();
@GET
@Path("/segments")
@Produces("application/json")
public String segments(
@QueryParam("img_name")String imgName,
@QueryParam("min_height")int minHeight,
@QueryParam("min_width")int minWidth,
@QueryParam("max_height")int maxHeight,
@QueryParam("max_width")int maxWidth
) throws Exception{
init();
String path = instance.segment(imgName, minHeight, minWidth, maxHeight, maxWidth);
return "{\"status\": \"images uploaded segments\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/upDownPyramids")
@Produces("application/json")
public String upDownPyramids(
@QueryParam("img_name")String imgName,
@QueryParam("iterations")int iterations
) throws Exception{
init();
String path = instance.upDownPyramids(imgName, iterations);
return "{\"status\": \"images uploaded UPDOWN\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/pyramidDown")
@Produces("application/json")
public String pyramidDown(
@QueryParam("img_name")String imgName,
@QueryParam("iterations")int iterations
) throws Exception{
init();
String path = instance.pyramidDown(imgName, iterations);
return "{\"status\": \"images uploaded DOWN\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/pyramidUp")
@Produces("application/json")
public String pyramidUp(
@QueryParam("img_name")String imgName,
@QueryParam("iterations")int iterations
) throws Exception{
init();
String path = instance.pyramidUp(imgName, iterations);
return "{\"status\": \"images uploaded UP\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/fillFlood")
@Produces("application/json")
public String fillFlood(
@QueryParam("img_name")String imgName,
@QueryParam("color")int color,
@QueryParam("initVal")int initVal
) throws Exception{
init();
String path = instance.fillFlood(imgName, new Point(10, 10), null, new Scalar(initVal,initVal,initVal), new Scalar(initVal,initVal,initVal));
return "{\"status\": \"images uploaded fillFlood\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/filtering")
@Produces("application/json")
public String filtering(
@QueryParam("img_name")String imgName,
@QueryParam("core_size")int coreSize
) throws Exception{
init();
Size core = new Size(coreSize, coreSize);
String path = instance.filtering(imgName, core);
return "{\"status\": \"images uploaded filtering\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/filteringCore")
@Produces("application/json")
public String filteringCore(
@QueryParam("img_name")String imgName
) throws Exception{
init();
String path = instance.filtering_core(imgName);
return "{\"status\": \"images uploaded filtering\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/morfologyTest")
@Produces("application/json")
public String morfologyTest(
@QueryParam("img_name")String imgName
) throws Exception{
init();
String path = instance.morfologyTest(imgName);
return "{\"status\": \"images uploaded morfologyTest\", \"path\": \"" + path + "\"}";
}
@GET
@Path("/changeChanel")
@Produces("application/json")
public String changeChanel(
@QueryParam("img_name")String imgName,
@QueryParam("numChn")int numChn
) throws Exception{
init();
String path = instance.changeChanel(numChn, imgName);
return "{\"status\": \"images uploaded changeChanel\", \"path\": \"" + path + "\"}";
}
public void init() throws Exception{
if (!inited) {
inited = true;
instance.initApi();
}
}
}