本文整理汇总了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);
}
}
}