Hello everyone. What I want to do is to detect the yawning and blinking of eyes. So far I have just been able to create a videoview and displayed a camera preview on that videoview. Now I need to apply some techniques like haar cascade or some other to detect the eyes and face. I have been looking all over internet but couldnt find exact solution. Can someone please tell me an easy solution to this.
This is the code of my CameraPreview class so far.
public class CameraPreview extends Activity implements SurfaceHolder.Callback{
private VideoView videoView = null;
private SurfaceHolder holder = null;
private Camera camera = null;
private static final String TAG = "Video";
private int cameraId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nextpage);
cameraId = getFrontCameraId();
try {
camera = Camera.open(cameraId);
camera.setDisplayOrientation(90);
camera.lock();
} catch(RuntimeException re) {
Log.v(TAG, "Could not initialize the Camera");
re.printStackTrace();
}
videoView = (VideoView) this.findViewById(R.id.videoView);
holder = videoView.getHolder();
holder.addCallback(this);
}
private int getFrontCameraId(){
int camId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
CameraInfo ci = new CameraInfo();
for(int i = 0;i < numberOfCameras;i++){
Camera.getCameraInfo(i,ci);
if(ci.facing == CameraInfo.CAMERA_FACING_FRONT){
camId = i;
}
}
return camId;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
Log.v(TAG, "in surfaceCreated");
try {
camera.setPreviewDisplay(holder);
camera.startPreview();
} catch(IOException e) {
Log.v(TAG, "Could not start the preview");
e.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera.release();
}
}
Thanks in advance :)