@Override public void Init(VideoCaptureDeviceInfoAndroid deviceInfoAndroid, List<AndroidVideoCaptureDevice> listToPopulate) throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { Camera camera = null; // From Android 2.3 and onwards for (int i = 0; i < Camera.getNumberOfCameras(); ++i) { AndroidVideoCaptureDevice newDevice = deviceInfoAndroid.new AndroidVideoCaptureDevice(); Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(i, info); newDevice.index = i; newDevice.orientation = info.orientation; if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { newDevice.deviceUniqueName = "Camera " + i + ", Facing back, Orientation " + info.orientation; } else { newDevice.deviceUniqueName = "Camera " + i + ", Facing front, Orientation " + info.orientation; newDevice.frontCameraType = FrontFacingCameraType.Android23; } camera = Camera.open(i); Camera.Parameters parameters = camera.getParameters(); deviceInfoAndroid.AddDeviceInfo(newDevice, parameters); camera.release(); camera = null; listToPopulate.add(newDevice); } }
@Override public void Init(VideoCaptureDeviceInfoAndroid deviceInfoAndroid, List<AndroidVideoCaptureDevice> listToPopulate) throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { // TODO Auto-generated method stub }
@Override public List<VideoCaptureDeviceInfo> getVideoCaptureDevices(Context ctxt) { VideoCaptureDeviceInfoAndroid deviceInfoAndroid = VideoCaptureDeviceInfoAndroid.CreateVideoCaptureDeviceInfoAndroid(0, ctxt); List<VideoCaptureDeviceInfo> arr = new ArrayList<VideoCaptureDeviceInfo>(); if(deviceInfoAndroid == null) { return arr; } int i; for(i = 0; i < deviceInfoAndroid.NumberOfDevices(); i++) { String deviceName = deviceInfoAndroid.GetDeviceUniqueName(i); CaptureCapabilityAndroid[] caps = deviceInfoAndroid.GetCapabilityArray(deviceName); VideoCaptureDeviceInfo vcdi = new VideoCaptureDeviceInfo(); int orientation = deviceInfoAndroid.GetOrientation(deviceName); boolean invertWidthHeight = false; if(orientation == 90 || orientation == 270) { invertWidthHeight = true; } for(CaptureCapabilityAndroid cap : caps) { VideoCaptureCapability vcc = new VideoCaptureCapability(); vcc.height = invertWidthHeight ? cap.width : cap.height; vcc.width = invertWidthHeight ? cap.height : cap.width; vcc.fps = cap.maxFPS; vcdi.capabilities.add(vcc); } CaptureCapabilityAndroid bcap = deviceInfoAndroid.GetBestCapability(deviceName); if(bcap != null) { vcdi.bestCapability = new VideoCaptureCapability(); vcdi.bestCapability.width = invertWidthHeight ? bcap.width : bcap.width; vcdi.bestCapability.height = invertWidthHeight ? bcap.height : bcap.height; vcdi.bestCapability.fps = bcap.maxFPS; } arr.add(vcdi); } return arr; }
/** * Init the camera list * @param deviceInfoAndroid the VideoCaptureDeviceInfoAndroid instance * @param listToPopulate List to be populated with detected devices * @throws SecurityException * @throws IllegalArgumentException * @throws NoSuchMethodException * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InvocationTargetException */ public abstract void Init(VideoCaptureDeviceInfoAndroid deviceInfoAndroid, List<AndroidVideoCaptureDevice> listToPopulate) throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException;