Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda