当前位置: 首页>>代码示例>>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;未经允许,请勿转载。