Face detection not working in android 11

Dhansekar Balu 1 Reputation point
2021-10-04T07:42:27.157+00:00

faceServiceClient.detect() return null, in Android 11. Can't get face id, I am trying to detect face in android 11(API level - 30) but unable to get response. So if any possible solution you have, Please acknowledge me and do the needful.

Azure Face
Azure Face
An Azure service that provides artificial intelligence algorithms that detect, recognize, and analyze human faces in images.
165 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Dhansekar Balu 1 Reputation point
    2021-10-05T11:01:47.417+00:00

    This github link - https://github.com/microsoft/Cognitive-Face-Android

    return faceServiceClient.detect() this line code not working in android 11

    private class DetectionTask extends AsyncTask<InputStream, String, Face[]> {
        @Override
        protected Face[] doInBackground(InputStream... params) {
            // Get an instance of face service client to detect faces in image.
            FaceServiceClient faceServiceClient = SampleApp.getFaceServiceClient();
            try {
                publishProgress("Detecting...");
    
                // Start detection.
    
    • return faceServiceClient.detect(
    • params[0], /* Input stream of image to detect */
    • true, /* Whether to return face ID */
    • false, /* Whether to return face landmarks */
    • /* Which face attributes to analyze, currently we support:
    • age,gender,headPose,smile,facialHair */
    • null);
          } catch (Exception e) {
              publishProgress(e.getMessage());
              return null;
          }
      }
      
      @Override
      protected void onPreExecute() {
      
      // setUiBeforeBackgroundTask();
      }
      @Override
      protected void onProgressUpdate(String... values) {
          // Show the status of background detection task on screen.
          setUiDuringBackgroundTask(values[0]);
      }
      
      @Override
      protected void onPostExecute(Face[] result) {
          progressDialog.dismiss();
      
          if (result != null) {
      
      // // Set the adapter of the ListView which contains the details of detected faces.
      mFaceListAdapter = new FaceListAdapter(result);
      ListView listView = (ListView) findViewById(R.id.list_identified_faces);
      listView.setAdapter(mFaceListAdapter);
              if (result.length == 0) {
                  try {
                      detected = false;
                      setInfo("No faces detected!");
                      AlertDialog.Builder builder =
                              new AlertDialog.Builder(PunchinActivity.this, R.style.AppCompatAlertDialogStyleErrorUpdate);
                      builder.setTitle(getResources().getString(R.string.app_name));
                      builder.setMessage("No faces detected!");
                      builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                              myAlertDialog.dismiss();
                              FaceListAdapter faceListAdapter = new FaceListAdapter(null);
                            /*  ListView listView = (ListView) findViewById(R.id.list_identified_faces);
                              listView.setAdapter(faceListAdapter);
                              setInfo("");
      
                              myCamera.startPreview();
      
      */
                              try {
                                  myCamera.stopPreview();
                                  myCamera.release();
                                  myCamera = null;
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }
                              finish();
                          }
                      });
                      builder.setCancelable(false);
                      myAlertDialog = builder.create();
                      myAlertDialog.show();
                  } catch (Resources.NotFoundException e) {
                      e.printStackTrace();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              } else {
                  detected = true;
                  setInfo("Click on the \"Identify\" button to identify the faces in image.");
                  identify();
              }
          } else {
              detected = false;
          }
      

    // refreshIdentifyButtonEnabledStatus();

        }
    }
    

  2. Dhansekar Balu 1 Reputation point
    2021-10-09T06:27:41.673+00:00

    This issue is priority for us, So please Do the needful ASAP.

    0 comments No comments

  3. YutongTie-MSFT 52,776 Reputation points
    2021-10-09T06:35:42.2+00:00

    @Dhansekar Balu Sorry for the delay, I have escalated this issue to related team but I have no response from them since the weekend timing.

    I would highly recommend you to raise a support ticket to assign a support engineer to debug this 1:1. Please go ahead to raise it and share the ticket number to me so that I can help the expediate the process. If you do not have a support plan, please let me know your Azure Subscription ID, I can enable you a one time free ticket for this issue.

    Regards,
    Yutong

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.