-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageDumpScheduler.java
More file actions
executable file
·50 lines (45 loc) · 1.14 KB
/
ImageDumpScheduler.java
File metadata and controls
executable file
·50 lines (45 loc) · 1.14 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
46
47
48
49
50
package ca.team2706.vision.trackerboxreloaded;
import java.util.ArrayList;
import java.util.List;
public class ImageDumpScheduler implements Runnable{
public static final int QUEUE_LIMIT = 10;
public static List<Bundle> bundles = new ArrayList<Bundle>();
public static Thread thread;
public static boolean b = true;
public static boolean stop = false;
@Override
public void run() {
try {
while(b){
if(bundles.size() > 0){
Bundle b = bundles.get(0);
bundles.remove(0);
while(bundles.size() > QUEUE_LIMIT){
bundles.remove(0);
}
try {
Main.imgDump(b.getRaw(), "raw",b.getTimeStamp(),b.getParams());
Main.imgDump(b.getBinMask(), "binMask", b.getTimeStamp(),b.getParams());
Main.imgDump(b.getOutput(), "output", b.getTimeStamp(),b.getParams());
} catch (Exception e) {
//Non fatal error
}
if(stop) {
ImageDumpScheduler.b = false;
}
}
}
}catch(Exception e) {
e.printStackTrace();
}
}
public static void schedule(Bundle b){
bundles.add(b);
}
public static void start(){
b = true;
stop = false;
thread = new Thread(new ImageDumpScheduler());
thread.start();
}
}