-
Notifications
You must be signed in to change notification settings - Fork 5
/
DezonerVerticle.java
39 lines (33 loc) · 1.42 KB
/
DezonerVerticle.java
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
package org.genericsystem.watch;
import org.genericsystem.cv.Zones;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
public class DezonerVerticle extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(DezonerVerticle.class);
public static void main(String[] args) {
VerticleDeployer.deployVerticle(new DezonerVerticle());
}
@Override
public void start() throws Exception {
MessageConsumer<String> consumer = vertx.eventBus().consumer(VerticleDeployer.NEW_IMAGE_ADDED_TO_CLASS);
consumer.handler(message -> vertx.executeBlocking(future -> {
String imagePath = message.body();
System.out.println(">>>>> New image to de-zone: " + imagePath);
if (Zones.isZonesFilePresent(imagePath)) {
// The zones file was found, proceed trough OCR directly
vertx.eventBus().publish(VerticleDeployer.ACCURATE_ZONES_FOUND, imagePath);
future.complete();
} else {
// No zones file was found, need to define the zones manually
vertx.eventBus().publish(VerticleDeployer.ACCURATE_ZONES_NOT_FOUND, imagePath);
// TODO: replace the future.fail by a notification to the system that a zone needs to be defined for this file
future.fail("No accurate zones found for " + imagePath);
}
}, res -> {
if (res.failed())
throw new IllegalStateException(res.cause());
}));
}
}