当前位置: 首页>>代码示例>>Java>>正文


Java CameraInfo类代码示例

本文整理汇总了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;
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:27,代码来源:WebRTCModule.java

示例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;
}
 
开发者ID:VIQET,项目名称:VIQET-Android,代码行数:18,代码来源:CameraActivity.java

示例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;
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:CameraUtils.java

示例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;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:21,代码来源:CameraView.java

示例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;
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:20,代码来源:Util.java

示例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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:21,代码来源:CameraFragment.java

示例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);
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:21,代码来源:BaseCameraView.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:CameraPreview.java

示例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);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:11,代码来源:CameraView.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:21,代码来源:CameraManager.java

示例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;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:22,代码来源:RecorderVideoActivity.java

示例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;
}
 
开发者ID:umesh-kushwaha,项目名称:Android_Video_Recording_portrait,代码行数:18,代码来源:VideoCaptureActivity.java

示例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);
}
 
开发者ID:hajunho,项目名称:AndroidCamera,代码行数:19,代码来源:ActivityCamera.java

示例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();
		}
	}
}
 
开发者ID:orangecoder,项目名称:VideoRecord,代码行数:27,代码来源:MyCameraManager.java

示例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;
}
 
开发者ID:laoduDYM,项目名称:ChatDemoUI3.0,代码行数:22,代码来源:RecorderVideoActivity.java


注:本文中的android.hardware.Camera.CameraInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。