use of android.hardware.Camera.CameraInfo in project XobotOS by xamarin.
the class CameraProfile method getJpegEncodingQualityParameter.
/**
* Returns a pre-defined still image capture (jpeg) quality level
* used for the given quality level in the Camera application for
* the first back-facing camera on the device. If the device has no
* back-facing camera, this returns 0.
*
* @param quality The target quality level
*/
public static int getJpegEncodingQualityParameter(int quality) {
int numberOfCameras = Camera.getNumberOfCameras();
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
return getJpegEncodingQualityParameter(i, quality);
}
}
return 0;
}
use of android.hardware.Camera.CameraInfo in project android_packages_apps_Camera by CyanogenMod.
the class CameraTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
AppDataDirGuesser.setInstance(new AppDataDirGuesser() {
@Override
public File guessSuitableDirectoryForGeneratedClasses() {
return getInstrumentation().getTargetContext().getCacheDir();
}
});
AppDataDirGuesser.getsInstance().guessSuitableDirectoryForGeneratedClasses();
LittleMock.initMocks(this);
mCameraInfo = new CameraInfo[2];
mCameraInfo[0] = new CameraInfo();
mCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
mCameraInfo[1] = new CameraInfo();
mCameraInfo[1].facing = CameraInfo.CAMERA_FACING_FRONT;
mMockCamera = new CameraProxy[2];
mMockCamera[0] = mMockBackCamera;
mMockCamera[1] = mMockFrontCamera;
doReturn(getParameters()).when(mMockCamera[0]).getParameters();
doReturn(getParameters()).when(mMockCamera[1]).getParameters();
mOneCameraInfo = new CameraInfo[1];
mOneCameraInfo[0] = new CameraInfo();
mOneCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
mOneMockCamera = new CameraProxy[1];
mOneMockCamera[0] = mMockBackCamera;
doReturn(getParameters()).when(mOneMockCamera[0]).getParameters();
// Mock takePicture call.
doAnswer(mTakePictureCallable).when(mMockBackCamera).takePicture(mShutterCallback.capture(), mRawPictureCallback.capture(), (PictureCallback) anyObject(), mJpegPictureCallback.capture());
// Mock autoFocus call.
doAnswer(mAutoFocusCallable).when(mMockBackCamera).autoFocus(mAutoFocusCallback.capture());
}
use of android.hardware.Camera.CameraInfo in project MagicCamera by wuhaoyu1990.
the class CameraEngine method getCameraInfo.
public static CameraInfo getCameraInfo() {
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(mCameraID, cameraInfo);
return cameraInfo;
}
use of android.hardware.Camera.CameraInfo in project android_frameworks_base by DirtyUnicorns.
the class CameraDeviceUserShim method connectBinderShim.
public static CameraDeviceUserShim connectBinderShim(ICameraDeviceCallbacks callbacks, int cameraId) {
if (DEBUG) {
Log.d(TAG, "Opening shim Camera device");
}
/*
* Put the camera open on a separate thread with its own looper; otherwise
* if the main thread is used then the callbacks might never get delivered
* (e.g. in CTS which run its own default looper only after tests)
*/
CameraLooper init = new CameraLooper(cameraId);
CameraCallbackThread threadCallbacks = new CameraCallbackThread(callbacks);
// TODO: Make this async instead of blocking
int initErrors = init.waitForOpen(OPEN_CAMERA_TIMEOUT_MS);
Camera legacyCamera = init.getCamera();
// Check errors old HAL initialization
LegacyExceptionUtils.throwOnServiceError(initErrors);
// Disable shutter sounds (this will work unconditionally) for api2 clients
legacyCamera.disableShutterSound();
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(cameraId, info);
Camera.Parameters legacyParameters = null;
try {
legacyParameters = legacyCamera.getParameters();
} catch (RuntimeException e) {
throw new ServiceSpecificException(ICameraService.ERROR_INVALID_OPERATION, "Unable to get initial parameters: " + e.getMessage());
}
CameraCharacteristics characteristics = LegacyMetadataMapper.createCharacteristics(legacyParameters, info);
LegacyCameraDevice device = new LegacyCameraDevice(cameraId, legacyCamera, characteristics, threadCallbacks);
return new CameraDeviceUserShim(cameraId, device, characteristics, init, threadCallbacks);
}
use of android.hardware.Camera.CameraInfo in project android_packages_apps_Camera by CyanogenMod.
the class PhotoModule method startFaceDetection.
@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void startFaceDetection() {
if (!ApiHelper.HAS_FACE_DETECTION)
return;
// Workaround for a buggy camera library
if (Util.noFaceDetectOnFrontCamera() && (CameraHolder.instance().getCameraInfo()[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT)) {
return;
}
if (mFaceDetectionStarted || mCameraState != IDLE)
return;
if (mParameters.getMaxNumDetectedFaces() > 0) {
mFaceDetectionStarted = true;
mFaceView.clear();
mFaceView.setVisibility(View.VISIBLE);
mFaceView.setDisplayOrientation(mDisplayOrientation);
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
mFaceView.setMirror(info.facing == CameraInfo.CAMERA_FACING_FRONT);
mFaceView.resume();
mFocusManager.setFaceView(mFaceView);
mCameraDevice.setFaceDetectionListener(new FaceDetectionListener() {
@Override
public void onFaceDetection(Face[] faces, android.hardware.Camera camera) {
mFaceView.setFaces(faces);
}
});
mCameraDevice.startFaceDetection();
}
}
Aggregations