當前位置: 首頁>>代碼示例>>Java>>正文


Java CameraInfo.CAMERA_FACING_BACK屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:VIQET,項目名稱:VIQET-Android,代碼行數:17,代碼來源:CameraActivity.java

示例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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:20,代碼來源:CameraFragment.java

示例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);
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:10,代碼來源:CameraView.java

示例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;
}
 
開發者ID:umesh-kushwaha,項目名稱:Android_Video_Recording_portrait,代碼行數:17,代碼來源:VideoCaptureActivity.java

示例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
}
 
開發者ID:Nilhcem,項目名稱:tensorflow-classifier-android,代碼行數:9,代碼來源:LegacyCameraConnectionFragment.java

示例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;
            }
        }

    }
}
 
開發者ID:Liuzhiyang94,項目名稱:ComponentProjectDemo,代碼行數:37,代碼來源:CameraActivity.java

示例7: hasCamera

@Override
public boolean hasCamera(final int facing) {
    if (facing == CameraInfo.CAMERA_FACING_BACK) {
        return hasCameraSupport();
    }
    return false;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:7,代碼來源:CameraHelperBase.java

示例8: openCameraFacing

@Override
public Camera openCameraFacing(final int facing) {
    if (facing == CameraInfo.CAMERA_FACING_BACK) {
        return Camera.open();
    }
    return null;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:7,代碼來源:CameraHelperBase.java

示例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;
}
 
開發者ID:AndroidKnife,項目名稱:RecordHelper,代碼行數:12,代碼來源:CameraHelper.java

示例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(); 
}
 
開發者ID:galme,項目名稱:ROLF-EV3,代碼行數:18,代碼來源:VideoStream.java

示例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;
}
 
開發者ID:lukamarin,項目名稱:Rocket.Chat-android,代碼行數:12,代碼來源:CameraHelper.java

示例12: hasCamera

@Override
public boolean hasCamera(final int facing) {
  if (facing == CameraInfo.CAMERA_FACING_BACK) {
    return hasCameraSupport();
  }
  return false;
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:7,代碼來源:CameraHelperBase.java

示例13: isRearCamera

public boolean isRearCamera() {
  return cameraId == CameraInfo.CAMERA_FACING_BACK;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:3,代碼來源:CameraView.java

示例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);
    }
}
 
開發者ID:feigxj,項目名稱:VideoRecorder-master,代碼行數:46,代碼來源:FFmpegRecorderActivity.java

示例15: getCameraInfo

@Override
public void getCameraInfo(final int cameraId, final CameraHelper.CameraInfo2 cameraInfo) {
    cameraInfo.facing = CameraInfo.CAMERA_FACING_BACK;
    cameraInfo.orientation = 90;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:5,代碼來源:CameraHelperBase.java


注:本文中的android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。