ARTICLE AD BOX
Хотел сделать мобильное приложение с помощью Kotlin, Tensorflow Lite и Android Studio, но есть проблема с распаковкой score из модели tensorflow для распознавания объектов, также красным подчеркивается location.get(). Вроде как все важные библиотеки я инициализировал. Прошу, помогите мне с этим. Заранее спасибо за ответы!
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) { bitmap = textureView.bitmap!! var image = TensorImage.fromBitmap(bitmap) image = imageProcessor.process(image) val outputs = model.process(image) val detectionResult = outputs.detectionResultList.get(0) val locations = detectionResult.locationAsRectF; val classes = detectionResult.categoryAsString; val scores = detectionResult.scoreAsFloat var mutable = bitmap.copy(Bitmap.Config.ARGB_8888, true) var canvas = Canvas(mutable) var x = 0 val h = mutable.height val w = mutable.width paint.textSize = h/15f paint.strokeWidth = h/85f scores.forEachIndexed {index, fl -> x = index x *= 4 if(fl > 0.5){ paint.setColor(colors.get(index)) paint.style = Paint.Style.STROKE canvas.drawRect( RectF( locations.get(x + 1) * w, locations.get(x) * h, locations.get(x + 3) * w, locations.get(x + 2) * h ), paint) paint.style = Paint.Style.FILL canvas.drawText(labels.get(classes.get(index).toInt())+" "+fl.toString(), locations.get(x+1)*w, locations.get(x)*h, paint) } }Explore related questions
See similar questions with these tags.
