Example usage for android.hardware Camera addCallbackBuffer

List of usage examples for android.hardware Camera addCallbackBuffer

Introduction

In this page you can find the example usage for android.hardware Camera addCallbackBuffer.

Prototype

public final void addCallbackBuffer(byte[] callbackBuffer) 

Source Link

Document

Adds a pre-allocated buffer to the preview callback buffer queue.

Usage

From source file:org.artoolkit.ar.samples.nftBook.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    nftBookActivity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:org.artoolkit.ar.samples.ARNative.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    ARNativeActivity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:com.mobiuso.argo.ARModule.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    ARMovieActivity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:org.artoolkit.ar.samples.ARNativeES1.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    ARNativeES1Activity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:org.artoolkit.ar.samples.ARNativeOSG.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    ARNativeOSGActivity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:org.artoolkit.ar.samples.nftSimple.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    nftSimpleActivity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:org.artoolkit.ar.utils.calib_optical.CameraSurface.java

@Override
public void onPreviewFrame(byte[] data, Camera cam) {

    calib_optical_Activity.nativeVideoFrame(data);

    cam.addCallbackBuffer(data);
}

From source file:com.longle1.facedetection.MainActivity.java

@Override
public void onPreviewFrame(final byte[] data, final Camera camera) {
    try {//from  ww w.jav a 2  s  .co m
        Size size = camera.getParameters().getPreviewSize();
        processImage(data, size.width, size.height);
        camera.addCallbackBuffer(data);
    } catch (RuntimeException e) {
        // The camera has probably just been released, ignore.
    }
}

From source file:uk.ac.horizon.artcodes.camera.CameraView.java

public void setDetector(Detector processor, Experience experience) {
    this.experience = experience;
    this.detector = processor;
    if (detector != null) {
        if (camera == null) {
            createCamera();// ww w .ja  v a  2s .  com
        }
        if (camera != null) {
            cameraIsFocused = !deviceNeedsTapToFocus;
            camera.addCallbackBuffer(detector.createBuffer(info, surfaceWidth, surfaceHeight));
            camera.setPreviewCallbackWithBuffer(new Camera.PreviewCallback() {
                @Override
                public void onPreviewFrame(final byte[] data, final Camera camera) {

                    boolean focusedOnThisFrame = false;

                    if (deviceNeedsTapToFocus || !cameraIsFocused) {
                        synchronized (cameraFocusLock) {
                            while (!cameraIsFocused) {
                                try {
                                    Log.i("FOCUS", "cameraFocusLock.wait(); Thread: "
                                            + Thread.currentThread().getName());
                                    focusedOnThisFrame = true;
                                    cameraFocusLock.wait();
                                } catch (InterruptedException ignored) {
                                }
                            }
                            Log.i("FOCUS", "notified Thread: " + Thread.currentThread().getName());
                        }
                    }

                    if (cameraIsFocused) {
                        Log.i("FOCUS", "cameraIsFocused test: " + cameraIsFocused);
                        if (!focusedOnThisFrame) {
                            detector.setData(data);
                        }
                        camera.addCallbackBuffer(data);
                    }
                }
            });
        }

        if (Camera.getNumberOfCameras() > 1) {
            detector.getSettings().add(new DetectorSetting() {
                @Override
                public void nextValue() {
                    stopCamera();
                    facing = 1 - facing;
                    startCamera();
                }

                @Override
                public int getIcon() {
                    switch (facing) {
                    case Camera.CameraInfo.CAMERA_FACING_BACK:
                        return R.drawable.ic_camera_rear_24dp;
                    case Camera.CameraInfo.CAMERA_FACING_FRONT:
                        return R.drawable.ic_camera_front_24dp;
                    }
                    return 0;
                }

                @Override
                public int getText() {
                    switch (facing) {
                    case Camera.CameraInfo.CAMERA_FACING_BACK:
                        return R.string.camera_rear;
                    case Camera.CameraInfo.CAMERA_FACING_FRONT:
                        return R.string.camera_front;
                    }

                    return 0;
                }
            });
        }
    }
}

From source file:com.nekomeshi312.whiteboardcorrection.CameraViewFragment.java

private void setPreviewCallback() {
    if (!mCameraSetting.isCameraOpen())
        return;/*from  w  w w.ja  v  a  2s  .  c  om*/

    final Camera camera = mCameraSetting.getCamera();
    //?? bit/pixel
    PixelFormat pixelinfo = new PixelFormat();
    int pixelformat = camera.getParameters().getPreviewFormat();
    PixelFormat.getPixelFormatInfo(pixelformat, pixelinfo);
    //???
    Camera.Parameters parameters = camera.getParameters();
    Size sz = parameters.getPreviewSize();
    //??????
    int bufSize = sz.width * sz.height * pixelinfo.bitsPerPixel / 8;
    mBuffer = new byte[bufSize];
    camera.addCallbackBuffer(mBuffer);
    camera.setPreviewCallbackWithBuffer(this);
}