I'm using a new thread to send the file, and a bit of code snippet to convert the bitmap to a file. The converting from bitmap to file is REALLY slow, and it seems like the sending of information to clarifai doesn't do anything...
//Convert bitmap to byte array
Bitmap bitmap = mResultsBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, bos);
byte[] bitmapdata = bos.toByteArray();
//write the bytes in file
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
fos.write(bitmapdata);
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
final File pFIle2 = f;
//TODO: clarifai stuff
//TODO: clarifai stuff
Log.e("this:"," this is running 0");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Log.e("this:", " this is running 1");
client = new ClarifaiBuilder("mykeyhere1234}").buildSync();
Log.e("this:", " this is running 2");
Thread th = new Thread(new Runnable() {
@Override
public void run() {
Log.e("this:", " this is running 3");
Log.e("this", client.getDefaultModels().generalModel().predict()
.withInputs(
ClarifaiInput.forImage(ClarifaiImage.of(pFIle2))
)
.executeSync().rawBody());
Log.e("this:", " this is running 4");
}
});
}
});
This bit of code snippet is in the onActivityResult method. None of the log messages are printing except for "0"
The error in your log message is thrown when the API client is unable to acquire complete default models (i.e. general model and others) from the server after several repeated attempts. Please make sure:
Two additional points:
ClarifaiBuilder
/ClarifaiClient
instance should be constructed only once (probably at the start of the application).