当前位置: 首页>>代码示例>>Java>>正文


Java Camera.addCallbackBuffer方法代码示例

本文整理汇总了Java中android.hardware.Camera.addCallbackBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.addCallbackBuffer方法的具体用法?Java Camera.addCallbackBuffer怎么用?Java Camera.addCallbackBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera的用法示例。


在下文中一共展示了Camera.addCallbackBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setNextFrame

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Sets the frame data received from the camera.  This adds the previous unused frame buffer
 * (if present) back to the camera, and keeps a pending reference to the frame data for
 * future use.
 */
void setNextFrame(byte[] data, Camera camera) {
    synchronized (mLock) {
        if (mPendingFrameData != null) {
            camera.addCallbackBuffer(mPendingFrameData.array());
            mPendingFrameData = null;
        }

        if (!mBytesToByteBuffer.containsKey(data)) {
            Log.d(TAG,
                    "Skipping frame.  Could not find ByteBuffer associated with the image " +
                            "data from the camera.");
            return;
        }

        // Timestamp and frame ID are maintained here, which will give downstream code some
        // idea of the timing of frames received and when frames were dropped along the way.
        mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
        mPendingFrameId++;
        mPendingFrameData = mBytesToByteBuffer.get(data);

        // Notify the processor thread if it is waiting on the next frame (see below).
        mLock.notifyAll();
    }
}
 
开发者ID:Jugendhackt,项目名称:SocialPaka,代码行数:30,代码来源:CameraSource.java

示例2: setNextFrame

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Sets the frame data received from the camera.  This adds the previous unused frame buffer
 * (if present) back to the camera, and keeps a pending reference to the frame data for
 * future use.
 */
void setNextFrame(byte[] data, Camera camera) {
    synchronized (mLock) {
        if (mPendingFrameData != null) {
            camera.addCallbackBuffer(mPendingFrameData.array());
            mPendingFrameData = null;
        }

        if (!mBytesToByteBuffer.containsKey(data)) {
            Log.d(TAG,
                "Skipping frame.  Could not find ByteBuffer associated with the image " +
                "data from the camera.");
            return;
        }

        // Timestamp and frame ID are maintained here, which will give downstream code some
        // idea of the timing of frames received and when frames were dropped along the way.
        mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
        mPendingFrameId++;
        mPendingFrameData = mBytesToByteBuffer.get(data);

        // Notify the processor thread if it is waiting on the next frame (see below).
        mLock.notifyAll();
    }
}
 
开发者ID:volkansahin45,项目名称:Moneycim,代码行数:30,代码来源:CameraSource.java

示例3: setNextFrame

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Sets the frame data received from the camera.  This adds the previous unused frame buffer
 * (if present) back to the camera, and keeps a pending reference to the frame data for
 * future use.
 */
void setNextFrame(byte[] data, Camera camera) {
    synchronized (mLock) {
        if (mPendingFrameData != null) {
            camera.addCallbackBuffer(mPendingFrameData.array());
            mPendingFrameData = null;
        }
        if (!mBytesToByteBuffer.containsKey(data)) {
            Log.d(TAG, "Skipping frame.  Could not find ByteBuffer associated with the image " + "data from the camera.");
            return;
        }
        // Timestamp and frame ID are maintained here, which will give downstream code some
        // idea of the timing of frames received and when frames were dropped along the way.
        mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
        mPendingFrameId++;
        mPendingFrameData = mBytesToByteBuffer.get(data);
        // Notify the processor thread if it is waiting on the next frame (see below).
        mLock.notifyAll();
    }
}
 
开发者ID:EzequielAdrianM,项目名称:Camera2Vision,代码行数:25,代码来源:CameraSource.java

示例4: setUpSurfaceTextureInternal

import android.hardware.Camera; //导入方法依赖的package包/类
private void setUpSurfaceTextureInternal(final Camera camera, byte[] data) {
    if (null == camera) {
        log.error("setup camera failed, camera is null");
        return;
    }

    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    mSurfaceTexture = new SurfaceTexture(textures[0]);

    try {
        camera.addCallbackBuffer(data);
        camera.setPreviewTexture(mSurfaceTexture);
        camera.setPreviewCallbackWithBuffer(GPUImageRenderer.this);
        camera.startPreview();
    } catch (Exception e) {
        log.error("setup camera failed, " + e.getMessage());
    }
    log.debug("setUpSurfaceTextureInternal " + camera + " " + data.length);
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:21,代码来源:GPUImageRenderer.java

示例5: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {

    // On every camera frame, checks if current RenderScript output surface is valid,
    // instantiated and checks that current RenderScript custom class is instantiated too
    if (rsCompute != null && rsCompute.isValidHolder()) {

        // Execute computation
        rsCompute.compute(data);
    }

    // Adds camera buffer back so that can be used on next acquired frame
    camera.addCallbackBuffer(data);
}
 
开发者ID:csarron,项目名称:renderscript_examples,代码行数:15,代码来源:MainActivity.java

示例6: addCallbackBuffer

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void addCallbackBuffer(Camera camera, byte[] data) {
    if (ownsBuffers) {
        // Give the video buffer to the camera service again.
        camera.addCallbackBuffer(data);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:8,代码来源:CameraUtils8.java

示例7: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
    Log.d(TAG, "onPreviewFrame: ");
    synchronized (this) {
        mFrameChain[mChainIdx].putData(data);
        mCameraFrameReady = true;

        glRender.runOnDraw(GLRender.CMD_PROCESS_FRAME, mFrameChain[mChainIdx].getFrame(), camera);

        camera.addCallbackBuffer(mBuffer);
        this.notify();
    }
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:14,代码来源:CameraEngine.java

示例8: processFrame

import android.hardware.Camera; //导入方法依赖的package包/类
void processFrame(final byte[] data, final Camera camera) {
    if (mImageWidth != mCachePrevSize.x || mImageHeight != mCachePrevSize.y) {
        mImageWidth = mCachePrevSize.x;
        mImageHeight = mCachePrevSize.y;
        adjustImageScaling();

        synchronized (mFaceDetectorLock) {
            if (null != mFaceDetector) {
                mFaceDetector.reset();
            }
        }
    }

    synchronized (mFaceDetectorLock) {
        if (null != mFaceDetector) {
            mFaceDetector.onFrameAvailable(mCachePrevSize.x, mCachePrevSize.y, mRotation, mFlipVertical,
                    data, mDirectionDetector.getDirection());
        }
    }

    JniEntry.YUVtoRBGA(data, mCachePrevSize.x, mCachePrevSize.y, mGLRgbBuffer.array());

    mGLTextureId = TextureUtils.getTextureFromByteBufferWithOldTexId(
            mGLRgbBuffer,mCachePrevSize.x,mCachePrevSize.y,mGLTextureId);
    camera.addCallbackBuffer(data);
    mGLRgbBuffer.clear();
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:28,代码来源:GPUImageRenderer.java

示例9: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(final byte[] data, final Camera camera) {
    // 如果还没到下一帧所要求的时间点,则丢弃这一帧
    if ((System.currentTimeMillis() - mFirstFrameTick) < (mFrameCount + 1) * (1000 / mCameraFrameRate)) {
        camera.addCallbackBuffer(data);
        log.warn("too many frame from camera, drop it");
        return;
    }

    if (-1 == mFirstFrameTick) {
        mFirstFrameTick = System.currentTimeMillis();
    }
    mFrameCount++;

    if (mCacheCamera != camera) {
        mCacheCamera = camera;
        Size previewSize = camera.getParameters().getPreviewSize();
        mCachePrevSize = new Point(previewSize.width, previewSize.height);
    }

    if (mGLRgbBuffer == null || mGLRgbBuffer.capacity() != mCachePrevSize.x * mCachePrevSize.y * 4) {
        mGLRgbBuffer = ByteBuffer.allocate(mCachePrevSize.x * mCachePrevSize.y * 4);
    }

    runOnDraw(CMD_PROCESS_FRAME, data, camera);
    mSurfaceView.requestRender();
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:28,代码来源:GPUImageRenderer.java

示例10: createCamera

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera and applies the user settings.
 *
 * @throws RuntimeException if the method fails
 */
@SuppressLint("InlinedApi")
private Camera createCamera() {
    int requestedCameraId = getIdForRequestedCamera(mFacing);
    if (requestedCameraId == -1) {
        throw new RuntimeException("Could not find requested camera.");
    }
    Camera camera = Camera.open(requestedCameraId);

    SizePair sizePair = selectSizePair(camera, mRequestedPreviewWidth, mRequestedPreviewHeight);
    if (sizePair == null) {
        throw new RuntimeException("Could not find suitable preview size.");
    }
    Size pictureSize = sizePair.pictureSize();
    mPreviewSize = sizePair.previewSize();

    int[] previewFpsRange = selectPreviewFpsRange(camera, mRequestedFps);
    if (previewFpsRange == null) {
        throw new RuntimeException("Could not find suitable preview frames per second range.");
    }

    Camera.Parameters parameters = camera.getParameters();

    if (pictureSize != null) {
        parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
    }

    parameters.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
    parameters.setPreviewFpsRange(
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
    parameters.setPreviewFormat(ImageFormat.NV21);

    setRotation(camera, parameters, requestedCameraId);

    if (mFocusMode != null) {
        if (parameters.getSupportedFocusModes().contains(
                mFocusMode)) {
            parameters.setFocusMode(mFocusMode);
        } else {
            Log.i(TAG, "Camera focus mode: " + mFocusMode +
                    " is not supported on this device.");
        }
    }

    // setting mFocusMode to the one set in the params
    mFocusMode = parameters.getFocusMode();

    if (mFlashMode != null) {
        if (parameters.getSupportedFlashModes().contains(
                mFlashMode)) {
            parameters.setFlashMode(mFlashMode);
        } else {
            Log.i(TAG, "Camera flash mode: " + mFlashMode +
                    " is not supported on this device.");
        }
    }

    // setting mFlashMode to the one set in the params
    mFlashMode = parameters.getFlashMode();

    camera.setParameters(parameters);

    // Four frame buffers are needed for working with the camera:
    //
    //   one for the frame that is currently being executed upon in doing detection
    //   one for the next pending frame to process immediately upon completing detection
    //   two for the frames that the camera uses to populate future preview images
    camera.setPreviewCallbackWithBuffer(new CameraPreviewCallback());
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));

    return camera;
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:81,代码来源:CameraSource.java

示例11: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
	mPreviewFrameCallCount++;
	camera.addCallbackBuffer(data);
}
 
开发者ID:Zhaoss,项目名称:WeiXinRecordedDemo,代码行数:6,代码来源:MediaRecorderBase.java

示例12: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
    FaceDetector.getInstance().onFrameData(data);
    camera.addCallbackBuffer(data);
}
 
开发者ID:Yee-chen,项目名称:seeta4Android,代码行数:6,代码来源:CameraWrapper.java

示例13: createCamera

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera and applies the user settings.
 *
 * @throws RuntimeException if the method fails
 */
@SuppressLint("InlinedApi")
private Camera createCamera() {
    int requestedCameraId = getIdForRequestedCamera(mFacing);
    if (requestedCameraId == -1) {
        throw new RuntimeException("Could not find requested camera.");
    }
    Camera camera = Camera.open(requestedCameraId);

    SizePair sizePair = selectSizePair(camera, mRequestedPreviewWidth, mRequestedPreviewHeight);
    if (sizePair == null) {
        throw new RuntimeException("Could not find suitable preview size.");
    }
    Size pictureSize = sizePair.pictureSize();
    mPreviewSize = sizePair.previewSize();

    int[] previewFpsRange = selectPreviewFpsRange(camera, mRequestedFps);
    if (previewFpsRange == null) {
        throw new RuntimeException("Could not find suitable preview frames per second range.");
    }

    Camera.Parameters parameters = camera.getParameters();

    if (pictureSize != null) {
        parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
    }

    parameters.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
    parameters.setPreviewFpsRange(
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
    parameters.setPreviewFormat(ImageFormat.NV21);

    setRotation(camera, parameters, requestedCameraId);

    if (mFocusMode != null) {
        if (parameters.getSupportedFocusModes().contains(
                mFocusMode)) {
            parameters.setFocusMode(mFocusMode);
        } else {
        }
    }

    // setting mFocusMode to the one set in the params
    mFocusMode = parameters.getFocusMode();

    if (mFlashMode != null) {
        if (parameters.getSupportedFlashModes() != null) {
            if (parameters.getSupportedFlashModes().contains(
                    mFlashMode)) {
                parameters.setFlashMode(mFlashMode);
            } else {
            }
        }
    }

    // setting mFlashMode to the one set in the params
    mFlashMode = parameters.getFlashMode();

    camera.setParameters(parameters);

    // Four frame buffers are needed for working with the camera:
    //
    //   one for the frame that is currently being executed upon in doing detection
    //   one for the next pending frame to process immediately upon completing detection
    //   two for the frames that the camera uses to populate future preview images
    camera.setPreviewCallbackWithBuffer(new CameraPreviewCallback());
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));

    return camera;
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:79,代码来源:CameraSource.java

示例14: createCamera

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the camera and applies the user settings.
 *
 * @throws RuntimeException if the method fails
 */
@SuppressLint("InlinedApi")
private Camera createCamera() {
    int requestedCameraId = getIdForRequestedCamera(mFacing);
    if (requestedCameraId == -1) {
        throw new RuntimeException("Could not find requested camera.");
    }
    Camera camera = Camera.open(requestedCameraId);

    SizePair sizePair = selectSizePair(camera, mRequestedPreviewWidth, mRequestedPreviewHeight);
    if (sizePair == null) {
        throw new RuntimeException("Could not find suitable preview size.");
    }
    Size pictureSize = sizePair.pictureSize();
    mPreviewSize = sizePair.previewSize();

    int[] previewFpsRange = selectPreviewFpsRange(camera, mRequestedFps);
    if (previewFpsRange == null) {
        throw new RuntimeException("Could not find suitable preview frames per second range.");
    }

    Camera.Parameters parameters = camera.getParameters();

    if (pictureSize != null) {
        parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
    }

    parameters.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
    parameters.setPreviewFpsRange(
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
            previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
    parameters.setPreviewFormat(ImageFormat.NV21);

    setRotation(camera, parameters, requestedCameraId);

    if (mFocusMode != null) {
        if (parameters.getSupportedFocusModes().contains(
                mFocusMode)) {
            parameters.setFocusMode(mFocusMode);
        } else {
            Log.i(TAG, "Camera focus mode: " + mFocusMode +
                " is not supported on this device.");
        }
    }

    // setting mFocusMode to the one set in the params
    mFocusMode = parameters.getFocusMode();

    if (mFlashMode != null) {
        if (parameters.getSupportedFlashModes().contains(
                mFlashMode)) {
            parameters.setFlashMode(mFlashMode);
        } else {
            Log.i(TAG, "Camera flash mode: " + mFlashMode +
                " is not supported on this device.");
        }
    }

    // setting mFlashMode to the one set in the params
    mFlashMode = parameters.getFlashMode();

    camera.setParameters(parameters);

    // Four frame buffers are needed for working with the camera:
    //
    //   one for the frame that is currently being executed upon in doing detection
    //   one for the next pending frame to process immediately upon completing detection
    //   two for the frames that the camera uses to populate future preview images
    camera.setPreviewCallbackWithBuffer(new CameraPreviewCallback());
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));

    return camera;
}
 
开发者ID:DevipriyaSarkar,项目名称:OCR-Reader,代码行数:81,代码来源:CameraSource.java

示例15: onPreviewFrame

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
    mPrevCb.onGetYuvFrame(data);
    camera.addCallbackBuffer(mYuvPreviewFrame);
}
 
开发者ID:linsir6,项目名称:AndroidCameraUtil,代码行数:6,代码来源:CameraView.java


注:本文中的android.hardware.Camera.addCallbackBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。