Go Back   Android Forums > Android Discussion > Android Applications
Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.

test: Reply
 
LinkBack Thread Tools
Old October 4th, 2012, 08:15 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2012
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Face detection problem

Hi,

im using a samsung galaxy S2 i9100 to develope a simple face detection app, here is my code:

import android.media.FaceDetector;
import android.media.FaceDetector.Face;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Bitmap.Config;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class DigitalEye extends Activity implements View.OnClickListener {

Button TakePic,faceButton;
ImageView Photo;
TextView Caras;
Intent camara;
final static int camaraData = 0;
Bitmap bmpCamara;
ImageView Caraprueba;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_digital_eye);

TakePic = (Button) findViewById(R.id.takepic);
faceButton = (Button) findViewById(R.id.face);
Caras = (TextView) findViewById(R.id.Caras);
Photo = (ImageView) findViewById(R.id.photo);
Caraprueba = (ImageView) findViewById(R.id.caraprueba);

TakePic.setOnClickListener(this);
faceButton.setOnClickListener(this);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_digital_ eye, menu);
return true;
}

public void onClick(View v) {
// TODO Auto-generated method stub

switch(v.getId()){

case R.id.takepic:

camara = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA PTURE);
startActivityForResult(camara, camaraData);
break;

case R.id.face:
Bitmap bmpface = bmpCamara;

int width = bmpface.getWidth();
int heigth = bmpface.getHeight();

Face[] Face = new FaceDetector.Face[5];
FaceDetector Detector = new FaceDetector(width,heigth,5);

Bitmap bitmap565 = Bitmap.createBitmap(width, heigth, Config.RGB_565);
Paint ditherPaint = new Paint();
Paint drawPaint = new Paint();

ditherPaint.setDither(true);
drawPaint.setColor(Color.RED);
drawPaint.setStyle(Paint.Style.STROKE);
drawPaint.setStrokeWidth(2);

Canvas canvas = new Canvas();
canvas.setBitmap(bitmap565);
canvas.drawBitmap(bmpface, 0, 0, ditherPaint);

int Num_Face = Detector.findFaces(bitmap565, Face);

Caras.setText("Caras reconocidas:----> " + Num_Face);
Caraprueba.setImageBitmap(bmpface);

}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);

if(resultCode == RESULT_OK){

Bundle extras = data.getExtras();
bmpCamara = (Bitmap) extras.get("data");
Photo.setImageBitmap(bmpCamara);

}
}

}

i have a button to take the picture and another one to do the face detection, the problem is it only works when i use the front camera!, i cant make it work with the back camera and i dont know why. i would like a little help here :P, thanks

Advertisements
Seaheart28 is offline  
Reply With Quote
sponsored links
Reply


Go Back   Android Forums > Android Discussion > Android Applications
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 01:07 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.