Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
Android Huawei image segmentation not working on release build

I'm using Huawei image segmentation for background removal from images. This code work perfectly fine on debug build but it does not work on a release build. I don't understand what could be the case.

Code:

  private fun imageSegmentation(bitmap: Bitmap?) {
            if (bitmap == null) {
                dialog.dismiss()
                Toast.makeText(requireContext(), "Something went wrong. Try again!", Toast.LENGTH_LONG).show()
                return
            }
    
            val setting =
                MLImageSegmentationSetting.Factory()
                    .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)
                    .setExact(true)
                    .create()
            val analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting)
            val mlFrame = MLFrame.Creator().setBitmap(bitmap).create()
            val task = analyzer?.asyncAnalyseFrame(mlFrame)
            task?.addOnSuccessListener { mlImageSegmentationResults ->
                if (mlImageSegmentationResults != null) {
                    removalFlag = true
                    removalBitmap = mlImageSegmentationResults.foreground
                } else
                    Toast.makeText(context, "No human body is detected!", Toast.LENGTH_LONG).show()
                dialog.dismiss()
            }?.addOnFailureListener {
                Toast.makeText(context, "No human body is detected!", Toast.LENGTH_LONG).show()
                dialog.dismiss()
            }
        }

Dependencies:

 implementation 'com.huawei.hms:ml-computer-vision-segmentation:2.2.0.300'
 implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:2.2.0.300'

Note: According to my understanding the task?.addOnSuccessListener is called but mlImageSegmentationResults return's null.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Stuff like this usually happens when you have ProGuard enabled but not correctly configured. Make sure to add appropriate rules to proguard-rules.pro file to prevent it from obfuscating relevant classes.

Information about this is usually provided by the library developers. After a quick search I came up with this example. Sources seem to be documented well enough, so that it should not be a problem to find the correct settings.

Keep in mind that you probably need to add rules for more than one library.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda