本文整理汇总了Java中android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK属性的典型用法代码示例。如果您正苦于以下问题:Java CameraInfo.CAMERA_FACING_BACK属性的具体用法?Java CameraInfo.CAMERA_FACING_BACK怎么用?Java CameraInfo.CAMERA_FACING_BACK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.Camera.CameraInfo
的用法示例。
在下文中一共展示了CameraInfo.CAMERA_FACING_BACK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findBackFacingCamera
private int findBackFacingCamera()
{
int cameraId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++)
{
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK)
{
Log.d(TAG_NAME, "Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
示例2: onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a container that will hold a SurfaceView for camera previews
mPreview = new Preview(this.getActivity());
// Find the total number of cameras available
mNumberOfCameras = Camera.getNumberOfCameras();
// Find the ID of the rear-facing ("default") camera
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < mNumberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
mCurrentCamera = mDefaultCameraId = i;
}
}
setHasOptionsMenu(mNumberOfCameras > 1);
}
示例3: flipCamera
public void flipCamera() {
if (Camera.getNumberOfCameras() > 1) {
cameraId = cameraId == CameraInfo.CAMERA_FACING_BACK
? CameraInfo.CAMERA_FACING_FRONT
: CameraInfo.CAMERA_FACING_BACK;
onPause();
onResume();
TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId);
}
}
示例4: findBackFacingCamera
private int findBackFacingCamera() {
cameraId = -1;
// Search for the back facing camera
// get the number of cameras
int numberOfCameras = Camera.getNumberOfCameras();
// for every camera check
for (int i = 0; i < numberOfCameras; i++) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
cameraId = i;
cameraFront = false;
break;
}
}
return cameraId;
}
示例5: getCameraId
private int getCameraId() {
CameraInfo ci = new CameraInfo();
for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
Camera.getCameraInfo(i, ci);
if (ci.facing == CameraInfo.CAMERA_FACING_BACK)
return i;
}
return -1; // No camera found
}
示例6: CameraTrans
private void CameraTrans(SurfaceHolder mholder) {
// 切换前后摄像头
int cameraCount = 0;
CameraInfo cameraInfo = new CameraInfo();
cameraCount = Camera.getNumberOfCameras();// 得到摄像头的个数
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);// 得到每一个摄像头的信息
if (startFontCamera) {
// 现在是后置,变更为前置
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
/**
* 记得释放camera,方便其他应用调用
*/
releaseCamera();
// 打开当前选中的摄像头
mcamera = Camera.open(i);
startFontCamera = false;
setStartPreview(mcamera, mholder);
break;
}
} else {
// 现在是前置, 变更为后置
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
/**
* 记得释放camera,方便其他应用调用
*/
releaseCamera();
mcamera = Camera.open(i);
startFontCamera = true;
setStartPreview(mcamera, mholder);
break;
}
}
}
}
示例7: hasCamera
@Override
public boolean hasCamera(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return hasCameraSupport();
}
return false;
}
示例8: openCameraFacing
@Override
public Camera openCameraFacing(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return Camera.open();
}
return null;
}
示例9: getDefaultCameraID
public static int getDefaultCameraID() {
int camerasCnt = getAvailableCamerasCount();
int defaultCameraID = 0;
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < camerasCnt; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
defaultCameraID = i;
}
}
return defaultCameraID;
}
示例10: switchCamera
/** Switch between the front facing and the back facing camera of the phone.
* If {@link #startPreview()} has been called, the preview will be briefly interrupted.
* If {@link #start()} has been called, the stream will be briefly interrupted.
* You should not call this method from the main thread if you are already streaming.
* @throws IOException
* @throws RuntimeException
**/
public void switchCamera() throws RuntimeException, IOException {
if (Camera.getNumberOfCameras() == 1) throw new IllegalStateException("Phone only has one camera !");
boolean streaming = mStreaming;
boolean previewing = mCamera!=null && mCameraOpenedManually;
mCameraId = (mCameraId == CameraInfo.CAMERA_FACING_BACK) ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK;
setCamera(mCameraId);
stopPreview();
mFlashEnabled = false;
if (previewing) startPreview();
if (streaming) start();
}
示例11: getDefaultCameraID
public static int getDefaultCameraID() {
int camerasCnt = getAvailableCamerasCount();
int defaultCameraID = 0;
CameraInfo cameraInfo = new CameraInfo();
for (int i=0; i <camerasCnt; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
defaultCameraID = i;
}
}
return defaultCameraID;
}
示例12: hasCamera
@Override
public boolean hasCamera(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return hasCameraSupport();
}
return false;
}
示例13: isRearCamera
public boolean isRearCamera() {
return cameraId == CameraInfo.CAMERA_FACING_BACK;
}
示例14: onClick
@Override
public void onClick(View v) {
//下一步
if (v.getId() == R.id.recorder_next) {
if (isRecordingStarted) {
rec = false;
saveRecording();
} else
initiateRecording(false);
} else if (v.getId() == R.id.recorder_flashlight) {
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
//showToast(this, "不能开启闪光灯");
return;
}
//闪光灯
if (isFlashOn) {
isFlashOn = false;
flashIcon.setSelected(false);
cameraParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
} else {
isFlashOn = true;
flashIcon.setSelected(true);
cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
}
mCamera.setParameters(cameraParameters);
} else if (v.getId() == R.id.recorder_frontcamera) {
//转换摄像头
cameraSelection = ((cameraSelection == CameraInfo.CAMERA_FACING_BACK) ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK);
initCameraLayout();
if (cameraSelection == CameraInfo.CAMERA_FACING_FRONT)
flashIcon.setVisibility(View.GONE);
else {
flashIcon.setVisibility(View.VISIBLE);
if (isFlashOn) {
cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(cameraParameters);
}
}
} else if (v.getId() == R.id.recorder_cancel) {
if (recording)
showCancellDialog();
else
videoTheEnd(false);
}
}
示例15: getCameraInfo
@Override
public void getCameraInfo(final int cameraId, final CameraHelper.CameraInfo2 cameraInfo) {
cameraInfo.facing = CameraInfo.CAMERA_FACING_BACK;
cameraInfo.orientation = 90;
}