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


Java CameraInfo.CAMERA_FACING_FRONT屬性代碼示例

本文整理匯總了Java中android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT屬性的典型用法代碼示例。如果您正苦於以下問題:Java CameraInfo.CAMERA_FACING_FRONT屬性的具體用法?Java CameraInfo.CAMERA_FACING_FRONT怎麽用?Java CameraInfo.CAMERA_FACING_FRONT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.hardware.Camera.CameraInfo的用法示例。


在下文中一共展示了CameraInfo.CAMERA_FACING_FRONT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: setUpCamera

private void setUpCamera(final int id) {
    mCameraInstance = getCameraInstance(id);
    Parameters parameters = mCameraInstance.getParameters();
    // TODO adjust by getting supportedPreviewSizes and then choosing
    // the best one for screen size (best fill screen)
    if (parameters.getSupportedFocusModes().contains(
            Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
        parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
    }
    mCameraInstance.setParameters(parameters);

    int orientation = mCameraHelper.getCameraDisplayOrientation(
            ActivityCamera.this, mCurrentCameraId);
    CameraInfo2 cameraInfo = new CameraInfo2();
    mCameraHelper.getCameraInfo(mCurrentCameraId, cameraInfo);
    boolean flipHorizontal = cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT;
    mGPUImage.setUpCamera(mCameraInstance, orientation, flipHorizontal, false);
}
 
開發者ID:hajunho,項目名稱:AndroidCamera,代碼行數:18,代碼來源:ActivityCamera.java

示例3: switchCamera

@SuppressLint("NewApi")
public void switchCamera(SurfaceHolder mHolder) {
	if(mCamera != null)
	{
		mCamera.stopPreview();
		mCamera.release();
		if (currentCamera == CameraInfo.CAMERA_FACING_BACK) {
			currentCamera = CameraInfo.CAMERA_FACING_FRONT;
		} else {
			currentCamera = CameraInfo.CAMERA_FACING_BACK;
		}

		mCamera = Camera.open(currentCamera);

		try {
			mCamera.setPreviewDisplay(mHolder);
			cameraDisplayOrientation = CameraHelper.getCameraDisplayOrientation(
					(Activity)mContext, currentCamera);
			mCamera.setDisplayOrientation(cameraDisplayOrientation);
			
			mCamera.startPreview();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:orangecoder,項目名稱:VideoRecord,代碼行數:26,代碼來源:MyCameraManager.java

示例4: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	button01 = (Button) findViewById(R.id.button_first);
	button01.setOnClickListener(this);
	findViewById(R.id.button_take).setOnClickListener(
			new OnClickListener() {

				@Override
				public void onClick(View v) {
					livePusher.switchCamera();
				}
			});
	mSurfaceView = (SurfaceView) this.findViewById(R.id.surface);
	mSurfaceHolder = mSurfaceView.getHolder();
	mSurfaceHolder.addCallback(this);
	livePusher = new LivePusher(this, 960, 720, 1024000, 15,
			CameraInfo.CAMERA_FACING_FRONT);
	livePusher.setLiveStateChangeListener(this);
	livePusher.prepare(mSurfaceHolder);

}
 
開發者ID:liuxang,項目名稱:LivePublisher,代碼行數:23,代碼來源:MainActivity.java

示例5: getCameraPictureOrientation

private int getCameraPictureOrientation() {
  if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
    outputOrientation = getCameraPictureRotation(getActivity().getWindowManager()
                                                              .getDefaultDisplay()
                                                              .getOrientation());
  } else if (getCameraInfo().facing == CameraInfo.CAMERA_FACING_FRONT) {
    outputOrientation = (360 - displayOrientation) % 360;
  } else {
    outputOrientation = displayOrientation;
  }

  return outputOrientation;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:13,代碼來源:CameraView.java

示例6: getCameraType

private static int getCameraType(int orient, int camid) {
	int type = 0;
	boolean isFront = false;
	
	CameraInfo cameraInfo = new CameraInfo();
	Camera.getCameraInfo(camid, cameraInfo);
	if (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
		isFront = true;
	}

	if (orient == 90) {
		if (isFront) {
			type = 0;
		} else {
			type = 1;
		}
	} else if (orient == 0) {
		type = 2;
	} else if (orient == 180) {
		type = 3;
	} else if (orient == 270) {
		if (isFront) {
			type = 1;
		} else {
			type = 0;
		}
	}
	return type;
}
 
開發者ID:wjchen,項目名稱:AndroidUvcCameras,代碼行數:29,代碼來源:CameraService.java

示例7: 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

示例8: getCameraAngle

/**
 * 獲取照相機旋轉角度
 */
public int getCameraAngle(Activity activity) {
	int rotateAngle = 90;
	CameraInfo info = new CameraInfo();
	Camera.getCameraInfo(cameraId, info);
	int rotation = activity.getWindowManager().getDefaultDisplay()
			.getRotation();
	int degrees = 0;
	switch (rotation) {
		case Surface.ROTATION_0:
			degrees = 0;
			break;
		case Surface.ROTATION_90:
			degrees = 90;
			break;
		case Surface.ROTATION_180:
			degrees = 180;
			break;
		case Surface.ROTATION_270:
			degrees = 270;
			break;
	}

	if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
		rotateAngle = (info.orientation + degrees) % 360;
		rotateAngle = (360 - rotateAngle) % 360; // compensate the mirror
	} else { // back-facing
		rotateAngle = (info.orientation - degrees + 360) % 360;
	}
	return rotateAngle;
}
 
開發者ID:FacePlusPlus,項目名稱:MegviiFacepp-Android-SDK,代碼行數:33,代碼來源:ICamera.java

示例9: getFrontCameraId

@SuppressLint("NewApi")
private int getFrontCameraId() {
    CameraInfo ci = new CameraInfo();
    for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
        Camera.getCameraInfo(i, ci);
        if (ci.facing == CameraInfo.CAMERA_FACING_FRONT) {
            return i;
        }
    }
    return -1; // No front-facing camera found
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:11,代碼來源:CustomCameraView.java

示例10: getCameraDisplayOrientation

public int getCameraDisplayOrientation(final Activity activity, final int cameraId) {
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int degrees = 0;
    switch (rotation) {
        case Surface.ROTATION_0:
            degrees = 0;
            break;
        case Surface.ROTATION_90:
            degrees = 90;
            break;
        case Surface.ROTATION_180:
            degrees = 180;
            break;
        case Surface.ROTATION_270:
            degrees = 270;
            break;
    }

    int result;
    CameraInfo2 info = new CameraInfo2();
    getCameraInfo(cameraId, info);
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
    } else { // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    return result;
}
 
開發者ID:macyuan,項目名稱:TAG,代碼行數:28,代碼來源:CameraHelper.java

示例11: 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

示例12: setCameraDisplayOrientation

private void setCameraDisplayOrientation(int cameraId, Camera camera) {
    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int degrees = 0;
    switch (getDisplayRotation()) {
        case Surface.ROTATION_0:
            degrees = 0;
            break;
        case Surface.ROTATION_90:
            degrees = 90;
            break;
        case Surface.ROTATION_180:
            degrees = 180;
            break;
        case Surface.ROTATION_270:
            degrees = 270;
            break;
    }

    int result;
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360;  // compensate the mirror
    } else {  // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }

    // Adjust orientation of taken photo
    Camera.Parameters params = mCamera.getParameters();
    params.setRotation(result);
    mCamera.setParameters(params);

    // Adjust orientation of preview
    camera.setDisplayOrientation(result);
}
 
開發者ID:google,項目名稱:science-journal,代碼行數:35,代碼來源:CameraPreview.java

示例13: getCameraDisplayOrientation

public int getCameraDisplayOrientation(final Activity activity, final int cameraId) {
  int rotation = activity.getWindowManager().getDefaultDisplay()
      .getRotation();
  int degrees = 0;
  switch (rotation) {
    case Surface.ROTATION_0:
      degrees = 0;
      break;
    case Surface.ROTATION_90:
      degrees = 90;
      break;
    case Surface.ROTATION_180:
      degrees = 180;
      break;
    case Surface.ROTATION_270:
      degrees = 270;
      break;
  }

  int result;
  CameraInfo2 info = new CameraInfo2();
  getCameraInfo(cameraId, info);
  if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
    result = (info.orientation + degrees) % 360;
  } else { // back-facing
    result = (info.orientation - degrees + 360) % 360;
  }
  return result;
}
 
開發者ID:XueyanLiu,項目名稱:miku,代碼行數:29,代碼來源:CameraHelper.java

示例14: 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:beilly,項目名稱:autophoto,代碼行數:37,代碼來源:CameraActivity.java

示例15: switchCamera

public void switchCamera() {
	if (mCameras.size() > 1) {
		if (defaultCam == CameraInfo.CAMERA_FACING_BACK) {
			defaultCam = CameraInfo.CAMERA_FACING_FRONT;
			mSurfaceView.setVisibility(View.GONE);
			mSurfaceView.setVisibility(View.VISIBLE);
		} else if (defaultCam == CameraInfo.CAMERA_FACING_FRONT) {
			defaultCam = CameraInfo.CAMERA_FACING_BACK;
			mSurfaceView.setVisibility(View.GONE);
			mSurfaceView.setVisibility(View.VISIBLE);
		}
	}
}
 
開發者ID:BigAppOS,項目名稱:BigApp_WordPress_Android,代碼行數:13,代碼來源:MediaShootActivity.java


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