本文整理匯總了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);
}
}
示例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);
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
示例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
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
示例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);
}
}
}