use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromBytes.
/**
* Test classify a single jpg image.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testClassifyImagesFromBytes() throws IOException {
InputStream imagesStream = new FileInputStream(SINGLE_IMAGE_FILE);
ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(imagesStream).imagesFilename("car.png").build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testClassifyWithFile.
/**
* Test classify with file.
*
* @throws IOException Signals that an I/O exception has occurred.
* @throws InterruptedException the interrupted exception
*/
@Test
public void testClassifyWithFile() throws IOException, InterruptedException {
ClassifiedImages mockResponse = loadFixture(FIXTURE_CLASSIFICATION, ClassifiedImages.class);
server.enqueue(new MockResponse().setBody(mockResponse.toString()));
// execute request
File images = new File(IMAGE_FILE);
ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(images).classifierIds(Arrays.asList("car")).build();
ClassifiedImages serviceResponse = service.classify(options).execute();
// first request
RecordedRequest request = server.takeRequest();
String path = PATH_CLASSIFY + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY;
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
assertEquals(serviceResponse, mockResponse);
}
Aggregations