本文整理匯總了Java中android.hardware.Camera.CameraInfo類的典型用法代碼示例。如果您正苦於以下問題:Java CameraInfo類的具體用法?Java CameraInfo怎麽用?Java CameraInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CameraInfo類屬於android.hardware.Camera包,在下文中一共展示了CameraInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCameraInfo
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public WritableMap getCameraInfo(int index) {
CameraInfo info = new CameraInfo();
Size size = null;
try {
Camera.getCameraInfo(index, info);
Camera camera = Camera.open(index);
size = getMaxSupportedVideoSize(camera);
camera.release();
} catch (Exception var3) {
Logging.e("CameraEnumerationAndroid", "getCameraInfo failed on index " + index, var3);
return null;
}
WritableMap params = Arguments.createMap();
String facing = info.facing == 1 ? "front" : "back";
params.putString("label", "Camera " + index + ", Facing " + facing + ", Orientation " + info.orientation);
params.putString("id", "" + index);
params.putString("facing", facing);
params.putString("kind", "video");
params.putString("maxWidth", String.valueOf(size.width));
params.putString("maxHeight", String.valueOf(size.height));
return params;
}
示例2: findBackFacingCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
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;
}
示例3: getCameraDisplayOrientation
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
public static int getCameraDisplayOrientation(@NonNull Activity activity,
@NonNull CameraInfo info)
{
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
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 == Camera.CameraInfo.CAMERA_FACING_FRONT) {
return (360 - ((info.orientation + degrees) % 360)) % 360;
} else {
return (info.orientation - degrees + 360) % 360;
}
}
示例4: setDisplayOrientation
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@UiThread
private void setDisplayOrientation(int rotationDegrees) {
int orientation;
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(0, info);
if (info.facing == CAMERA_FACING_FRONT) {
orientation = (info.orientation + rotationDegrees) % 360;
orientation = (360 - orientation) % 360;
} else {
orientation = (info.orientation - rotationDegrees + 360) % 360;
}
if (LOG.isLoggable(INFO))
LOG.info("Display orientation " + orientation + " degrees");
try {
camera.setDisplayOrientation(orientation);
} catch (RuntimeException e) {
LOG.log(WARNING, "Error setting display orientation", e);
}
displayOrientation = orientation;
}
示例5: determineDisplayOrientation
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
public static int determineDisplayOrientation(Activity activity, int defaultCameraId) {
int displayOrientation = 0;
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
{
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(defaultCameraId, cameraInfo);
int degrees = getRotationAngle(activity);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
displayOrientation = (cameraInfo.orientation + degrees) % 360;
displayOrientation = (360 - displayOrientation) % 360;
} else {
displayOrientation = (cameraInfo.orientation - degrees + 360) % 360;
}
}
return displayOrientation;
}
示例6: onCreate
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@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);
}
示例7: init
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
private void init() {
setEGLContextClientVersion(2);
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.RGBA_8888);
setRenderer(this);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
float[] cube = OpenGLUtils.CUBE;
mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeBuffer.put(cube);
float[] textureCords = OpenGLUtils.getTextureCords(90, mCameraId == CameraInfo.CAMERA_FACING_FRONT, true);
mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTextureBuffer.put(textureCords);
List<CameraFilter> filters = new ArrayList<>();
filters.add(mCameraInputFilter);
filters.addAll(initFilters());
mCameraFilterGroup = new CameraFilterGroup(filters);
}
示例8: getDisplayOrientation
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
public int getDisplayOrientation() {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(0, info);
int degrees = 0;
switch (((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getRotation()) {
case 0:
degrees = 0;
break;
case 1:
degrees = 90;
break;
case 2:
degrees = 180;
break;
case 3:
degrees = 270;
break;
}
if (info.facing == 1) {
return (360 - ((info.orientation + degrees) % 360)) % 360;
}
return ((info.orientation - degrees) + 360) % 360;
}
示例9: flipCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
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);
}
}
示例10: determineCameraId
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
private int determineCameraId() {
final int cameraCount = Camera.getNumberOfCameras();
final CameraInfo cameraInfo = new CameraInfo();
// prefer back-facing camera
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK)
return i;
}
// fall back to front-facing camera
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
return i;
}
return -1;
}
示例11: initCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}
示例12: findBackFacingCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
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;
}
示例13: setUpCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
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);
}
示例14: switchCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@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();
}
}
}
示例15: initCamera
import android.hardware.Camera.CameraInfo; //導入依賴的package包/類
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Camera.Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}