This commit is contained in:
2026-02-10 19:02:21 +08:00
parent 3d29e17225
commit 655e9cd56e
12 changed files with 333 additions and 46 deletions
@@ -137,12 +137,14 @@ object FoodModule {
}
suspend fun getFoodScoreList(bitmap: Bitmap, queryCount: Int = 15): List<IdNameScore> {
val floatArray = bitmap2FloatArray(bitmap, false) ?: return emptyList()
Timber.tag("FoodModule").d("向量:${floatArray.toJsonString()}")
val nameScoreList = queryFoodNameScore(floatArray, queryCount)
if (nameScoreList.isEmpty()) {
return emptyList()
}
//暂时不过滤
val maxScoreList = nameScoreList
.filter { it.score < 0.15 }
//.filter { it.score < 0.15 }
.groupBy { it.name }
.map { (_, value) -> value.minByOrNull { it.score }!! }
.toMutableList()
@@ -177,11 +177,12 @@ object ObjectBox {
}
suspend fun filter(name:String?) = safeDbOp {
var list = getBox<Food>()?.all?.distinctBy { it.name }
val list = getBox<Food>()?.all?.distinctBy { it.name }
if (name.isNullOrBlank().not()) {
list?.filter { it.name?.contains(name!!) == true }
}
list?:emptyList()
list?.filter { it.name?.contains(name) == true }
} else {
list
}?:emptyList()
}
suspend fun remove(name:String) = safeDbOp {