當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。