J'utilise un nouveau thread pour envoyer le fichier, et un peu d'extrait de code pour convertir le bitmap en un fichier. La conversion de bitmap fichier est vraiment lent, et il semble que l'envoi d'informations à clarifai ne fait rien ...Je dois envoyer un fichier image au serveur Clarifai pour la classification des images, mais je reçois toujours des "images sautées, l'application fait trop de travail"
//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");
}
});
}
});
Ce bit d'extrait de code est dans la méthode onActivityResult. Aucun des messages de journal n'imprime sauf "0"
L'exemple est un fichier/repo privé. je ne peux pas y accéder. – McFiddlyWiddly
@McFiddlyWiddly Oups, le lien a été mis à jour. – yper