@Override public void onPictureTaken(byte[] arg0, Camera arg1) { // TODO Auto-generated method stub /*Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length); */ Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues()); OutputStream imageFileOS; try { imageFileOS = getContentResolver().openOutputStream(uriTarget); imageFileOS.write(arg0); imageFileOS.flush(); imageFileOS.close(); prompt.setText("Image saved: " + uriTarget.toString()); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } camera.startPreview(); camera.startFaceDetection(); }
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void startFaceDetection() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && camera != null && !isDetectingFaces && camera.getParameters().getMaxNumDetectedFaces() > 0) { camera.startFaceDetection(); isDetectingFaces = true; } }
public void startFaceDetection() { // Try starting Face Detection Camera.Parameters params = mCamera.getParameters(); // start face detection only *after* preview has started if (params.getMaxNumDetectedFaces() > 0) { // camera supports face detection, so can start it: mCamera.startFaceDetection(); } }
private void startFaceDetection() { Camera.Parameters params = camera.getParameters(); if (params.getMaxNumDetectedFaces() > 0) { // camera supports camera.startFaceDetection(); } else { Toast.makeText(getApplicationContext(), getString(R.string.no_face_detect), Toast.LENGTH_LONG) .show(); } }
/** * Start the camera and set up its preview texture to the given texture (essentially copying * camera into texture. * * @param texture */ public void startCamera(int texture) { surface = new SurfaceTexture(texture); surface.setOnFrameAvailableListener(this); camera = Camera.open(); camera.setFaceDetectionListener(this); try { camera.setPreviewTexture(surface); camera.startPreview(); } catch (IOException ioe) { Log.w("MainActivity", "Failed to start camera preview on texture."); } camera.startFaceDetection(); }
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // TODO Auto-generated method stub if (previewing) { camera.stopFaceDetection(); camera.stopPreview(); previewing = false; } if (camera != null) { try { camera.setPreviewDisplay(surfaceHolder); camera.startPreview(); prompt.setText( String.valueOf("Max Face: " + camera.getParameters().getMaxNumDetectedFaces())); camera.startFaceDetection(); previewing = true; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
@Override public void startFaceDetection() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { camera.startFaceDetection(); } }