示例#1
0
    protected Bitmap doInBackground(PersonModel... pms) {
      int count = pms.length;
      PersonModel pm;
      if (count > 0) {
        pm = pms[0];
        // Load picture taken from cam
        Bitmap orgImage = BitmapFactory.decodeFile(IMAGE_PATH);

        Photo myPhoto = pm.getPhoto();

        // myPhoto.scaleFaceRects(image.getMeasuredWidth(), image.getMeasuredHeight());
        // myPhoto.scaleFaceRects(orgImage.getWidth(), orgImage.getHeight());
        // myPhoto.scaleFaceRects(myPhoto.getWidth(), myPhoto.getHeight());
        Face face = myPhoto.getFaces().get(pm.getSelectedFace());
        int x = (int) face.getRectangle().left;
        int y = (int) face.getRectangle().top;
        int width = (int) (face.getRectangle().right - face.getRectangle().left);
        int height = (int) (face.getRectangle().bottom - face.getRectangle().top);
        // Crop it
        Bitmap nImage = Bitmap.createBitmap(orgImage, x, y, width, height);
        return nImage;
      } else {
        throw new RuntimeException("ERR: no personmodel given for picture resize");
      }
    }
示例#2
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ADD_NEW_USER_REQUEST) {
      if (resultCode == RESULT_OK) {
        // User input received
        Bundle extras = data.getExtras();
        PersonModel m_pm = (PersonModel) extras.get("UserInput");

        // Store input in central db
        AppharborWrapper ah = new AppharborWrapper(m_pm);
        FaceComWrapper fcw = new FaceComWrapper();
        try {
          m_pm = ah.addPerson(m_pm);

          // Add person to face.com, with the PersonID generated by AH
          m_pm = fcw.addPerson(m_pm);
          // Put the tagID from Face.com in AH
          ah.attachTag(m_pm.getID_DESCRIPTION(), m_pm.getIdTag());

        } catch (MalformedURLException e) {
          e.printStackTrace();
        }

        TextView tv = (TextView) findViewById(R.id.textView1);
        if (ah.errorCode != "") {
          tv.setText("ERROR: " + ah.errorCode);
        } else {
          tv.setText("Person added succesfully, and will now be available for recognition");
          Button button1 = (Button) findViewById(R.id.button1);
          button1.setText("");
          button1.setEnabled(false);
          Button button2 = (Button) findViewById(R.id.button2);
          button2.setText("");
          button2.setEnabled(false);
          Button button3 = (Button) findViewById(R.id.button3);
          button3.setText("OK");
          //            		button3.setOnClickListener(new View.OnClickListener() {
          //            			@Override
          //            			public void onClick(View arg0) {
          //            				// Run face recognition activity
          //            				// TODO: Should return to WingmanActivity.class instead
          //            				Intent myIntent = new Intent(getBaseContext(), WingmanActivity.class);
          //            				startActivity(myIntent);
          //            				finish();
          //            			}
          //            		});
        }
      }
    }
  }