Search in sources :

Example 1 with CamSystemCalibrationData

use of org.codeaurora.snapcam.filter.ClearSightNativeEngine.CamSystemCalibrationData in project android_packages_apps_Snap by LineageOS.

the class ClearSightImageProcessor method init.

public void init(StreamConfigurationMap map, int width, int height, Context context, OnMediaSavedListener mediaListener) {
    Log.d(TAG, "init() start");
    mIsClosing = false;
    mImageProcessThread = new HandlerThread("CameraImageProcess");
    mImageProcessThread.start();
    mClearsightRegisterThread = new HandlerThread("ClearsightRegister");
    mClearsightRegisterThread.start();
    mClearsightProcessThread = new HandlerThread("ClearsightProcess");
    mClearsightProcessThread.start();
    mImageEncodeThread = new HandlerThread("CameraImageEncode");
    mImageEncodeThread.start();
    mDepthProcessThread = new HandlerThread("DepthProcess");
    mDepthProcessThread.start();
    mImageProcessHandler = new ImageProcessHandler(mImageProcessThread.getLooper());
    mClearsightRegisterHandler = new ClearsightRegisterHandler(mClearsightRegisterThread.getLooper());
    mClearsightProcessHandler = new ClearsightProcessHandler(mClearsightProcessThread.getLooper());
    mImageEncodeHandler = new ImageEncodeHandler(mImageEncodeThread.getLooper());
    mDepthProcessHandler = new DepthProcessHandler(mImageEncodeThread.getLooper());
    mFinalPictureSize = new Size(width, height);
    mFinalPictureRatio = (float) width / (float) height;
    mFinalMonoSize = getFinalMonoSize();
    Size maxSize = findMaxOutputSize(map);
    int maxWidth = maxSize.getWidth();
    int maxHeight = maxSize.getHeight();
    mImageReader[CAM_TYPE_BAYER] = createImageReader(CAM_TYPE_BAYER, maxWidth, maxHeight);
    mImageReader[CAM_TYPE_MONO] = createImageReader(CAM_TYPE_MONO, maxWidth, maxHeight);
    mEncodeImageReader[CAM_TYPE_BAYER] = createEncodeImageReader(CAM_TYPE_BAYER, maxWidth, maxHeight);
    mEncodeImageReader[CAM_TYPE_MONO] = createEncodeImageReader(CAM_TYPE_MONO, maxWidth, maxHeight);
    mMediaSavedListener = mediaListener;
    CameraManager cm = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
    try {
        CameraCharacteristics cc = cm.getCameraCharacteristics("0");
        byte[] blob = cc.get(OTP_CALIB_BLOB);
        CamSystemCalibrationData calibrationData = CamSystemCalibrationData.createFromBytes(blob);
        ClearSightNativeEngine.getInstance().init(mNumFrameCount * 2, maxWidth, maxHeight, calibrationData);
        mDepthProcessHandler.obtainMessage(MSG_CALIBRATION_DATA, 0, 0, calibrationData).sendToTarget();
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
    Log.d(TAG, "init() done");
}
Also used : CamSystemCalibrationData(org.codeaurora.snapcam.filter.ClearSightNativeEngine.CamSystemCalibrationData) Size(android.util.Size) CameraManager(android.hardware.camera2.CameraManager) CameraAccessException(android.hardware.camera2.CameraAccessException) HandlerThread(android.os.HandlerThread) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics)

Aggregations

CameraAccessException (android.hardware.camera2.CameraAccessException)1 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)1 CameraManager (android.hardware.camera2.CameraManager)1 HandlerThread (android.os.HandlerThread)1 Size (android.util.Size)1 CamSystemCalibrationData (org.codeaurora.snapcam.filter.ClearSightNativeEngine.CamSystemCalibrationData)1