-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSurveillanceService.java
More file actions
45 lines (39 loc) · 1.37 KB
/
SurveillanceService.java
File metadata and controls
45 lines (39 loc) · 1.37 KB
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
package services;
import beans.HeadcountRequest;
import beans.HeadcountResponse;
import functions.HeadcountFunction;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* Created by Zhongyi on 2/8/16.
*/
public class SurveillanceService {
public static HeadcountResponse defaultResponse;
public static String path = "/tmp/cameras/";
public static HeadcountResponse getHeadcount(String cameraId) {
HeadcountRequest request = new HeadcountRequest();
BufferedImage image = null, backgroundImage;
try {
image = ImageIO.read(new File(path + cameraId + "/latest.bmp"));
backgroundImage = ImageIO.read(new File(path + cameraId + "/background.bmp"));
} catch (Exception e) {
backgroundImage = image;
}
request.setImage(image);
request.setBackgroundImage(backgroundImage);
HeadcountResponse response = new HeadcountFunction(request).getResult();
if (response.getHeadCount() == 0) {
File file = new File(path + cameraId + "/background.bmp");
try {
ImageIO.write(image, "bmp", file);
} catch (IOException e) {
e.printStackTrace();
}
}
defaultResponse = response;
return response;
}
}