lumifyApi.logout();
}
private void resolveAndUnresolveDetectedObject() throws ApiException {
LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");
ClientApiDetectedObjects detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
LOGGER.info("detectedObjects: %s", detectedObjects.toString());
assertEquals(15, detectedObjects.getDetectedObjects().size());
// Resolving a new detected object
double x1 = 1.0;
double x2 = 2.0;
double y1 = 3.0;
double y2 = 4.0;
lumifyApi.getVertexApi().resolveDetectedObject(
artifactVertexId,
"Susan",
CONCEPT_TEST_PERSON,
"auth1",
null,
null,
null,
null,
x1,
x2,
y1,
y2
);
detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
assertEquals(16, detectedObjects.getDetectedObjects().size());
ClientApiProperty susanDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
assertNotNull(susanDetectedObject);
// Unresolving a detected object not found by opencv
lumifyApi.getVertexApi().unresolveDetectedObject(artifactVertexId, susanDetectedObject.getKey());
detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
assertEquals(15, detectedObjects.getDetectedObjects().size());
susanDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
assertNull(susanDetectedObject);
// Resolving a detected object that opencv found
ClientApiDetectedObject testDetectedObjectValue = ClientApiDetectedObject.fromProperty(detectedObjects.getDetectedObjects().get(0));
x1 = testDetectedObjectValue.getX1();
x2 = testDetectedObjectValue.getX2();
y1 = testDetectedObjectValue.getY1();
y2 = testDetectedObjectValue.getY2();
lumifyApi.getVertexApi().resolveDetectedObject(
artifactVertexId,
"Joe",
CONCEPT_TEST_PERSON,
"auth1",
null,
null,
null,
testDetectedObjectValue.getOriginalPropertyKey(),
x1,
x2,
y1,
y2
);
detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
assertEquals(16, detectedObjects.getDetectedObjects().size());
ClientApiProperty joeDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
assertNotNull(joeDetectedObject);
// Re-resolve a detected object
lumifyApi.getVertexApi().resolveDetectedObject(
artifactVertexId,
"Jeff",
CONCEPT_TEST_PERSON,
"auth1",
ClientApiDetectedObject.fromProperty(joeDetectedObject).getResolvedVertexId(),
null,
null,
testDetectedObjectValue.getOriginalPropertyKey(),
x1,
x2,
y1,
y2
);
detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
assertEquals(16, detectedObjects.getDetectedObjects().size());
List<ClientApiProperty> jeffDetectedObjects = findResolvedDetectedObjects(detectedObjects, x1, x2, y1, y2);
assertNotNull(jeffDetectedObjects);
assertEquals(1, jeffDetectedObjects.size());
// Unresolving a detected object that opencv found
ClientApiProperty jeffDetectedObject = jeffDetectedObjects.get(0);
lumifyApi.getVertexApi().unresolveDetectedObject(artifactVertexId, jeffDetectedObject.getKey());
detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
assertEquals(15, detectedObjects.getDetectedObjects().size());
jeffDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
assertNull(jeffDetectedObject);
}