use of com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testDetectFacesFromBytes.
/**
* Test detect faces from bytes or stream.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testDetectFacesFromBytes() throws IOException {
File images = new File(IMAGE_FACE_FILE);
DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build();
DetectedFaces result = service.detectFaces(options).execute();
assertDetectedFaces(result, options);
}
use of com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testDetectFaces.
/**
* Test detect faces.
*
* @throws IOException Signals that an I/O exception has occurred.
* @throws InterruptedException the interrupted exception
*/
@Test
public void testDetectFaces() throws IOException, InterruptedException {
DetectedFaces mockResponse = loadFixture(FIXTURE_FACES, DetectedFaces.class);
server.enqueue(new MockResponse().setBody(mockResponse.toString()));
// execute request
File images = new File(IMAGE_FILE);
DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build();
DetectedFaces serviceResponse = service.detectFaces(options).execute();
// first request
RecordedRequest request = server.takeRequest();
String path = PATH_DETECT_FACES + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY;
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
assertEquals(serviceResponse, mockResponse);
String contentDisposition = "Content-Disposition: form-data; name=\"images_file\"; filename=\"test.zip\"";
String body = request.getBody().readUtf8();
assertTrue(body.contains(contentDisposition));
}
Aggregations