【发布时间】:2021-04-09 00:43:26
【问题描述】:
我有这个函数,它返回 entry.getKey() 和 entry.getValue()。当我返回函数时,我会得到如下响应
Log.d("myTag", entry.getKey() + " " +entry.getValue());
healthy 0.345
unhealthy 0.0
healthy 0.543
从这个列表中,我想要的是具有最小 entry.getValue() 的对。
示例:上面的列表应该只返回 不健康的 0.0
我尝试通过 Collections minimum 返回,但它与 int 类型和 list 类型发生冲突...如何返回具有最小 entry.getValue() 的对?
**注意:参考 Log.d 并返回识别码**
public List<Recognition>recognizeImage(final Bitmap bitmap, final int sensorOriwentation){
Bitmap resized_bitmap = Bitmap.createScaledBitmap(bitmap, 224, 224, true);
List<Recognition> recognitions = new ArrayList<>();
inputImageBuffer = loadImage(resized_bitmap,sensorOriwentation);
tensorClassifier.run(inputImageBuffer.getBuffer(),probabilityImageBuffer.getBuffer().rewind());
Map<String,Float> labelledProbability = new TensorLabel(labels,
probabilityProcessor.process(probabilityImageBuffer)).getMapWithFloatValue();
for (Map.Entry<String, Float>entry : labelledProbability.entrySet()){
recognitions.add(new Recognition(entry.getKey(),entry.getValue()));
Log.d("myTag", "entry.getKey(): "+ entry.getKey() + " " + "entry.getValue(): "+entry.getValue());
}
return recognitions;
}
【问题讨论】:
-
this 回答你的问题了吗?
标签: java android for-loop arraylist