Java Code Examples for android.hardware.Camera.Parameters#setPreviewSize()
The following examples show how to use
android.hardware.Camera.Parameters#setPreviewSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
private void startPreview(SurfaceHolder holder) { try { Parameters params = camera.getParameters(); if (params.getSupportedFocusModes().contains( Parameters.FOCUS_MODE_AUTO)) { params.setFocusMode(Parameters.FOCUS_MODE_AUTO); } List<Size> previewSizes = camera.getParameters().getSupportedPreviewSizes(); List<Size> pictureSizes = camera.getParameters().getSupportedPictureSizes(); params.setPreviewSize(previewSizes.get(previewSizes.size()-2).width,previewSizes.get(previewSizes.size()-2).height); params.setPictureSize(pictureSizes.get(pictureSizes.size()-2).width,pictureSizes.get(pictureSizes.size()-2).height); camera.setParameters(params); camera.setPreviewDisplay(holder); camera.startPreview(); previewConsumer.start(camera); } catch(IOException e) { Log.e(TAG, "Error starting camera preview", e); } }
Example 2
Source File: VideoStream.java From spydroid-ipcamera with GNU General Public License v3.0 | 6 votes |
protected synchronized void updateCamera() throws RuntimeException { if (mPreviewStarted) { mPreviewStarted = false; mCamera.stopPreview(); } Parameters parameters = mCamera.getParameters(); mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality); int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters); parameters.setPreviewFormat(mCameraImageFormat); parameters.setPreviewSize(mQuality.resX, mQuality.resY); parameters.setPreviewFpsRange(max[0], max[1]); try { mCamera.setParameters(parameters); mCamera.setDisplayOrientation(mOrientation); mCamera.startPreview(); mPreviewStarted = true; } catch (RuntimeException e) { destroyCamera(); throw e; } }
Example 3
Source File: CameraPreview.java From Android-IP-Camera with MIT License | 6 votes |
public CameraPreview(Context context, Camera camera) { super(context); mCamera = camera; mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); Parameters params = mCamera.getParameters(); List<Size> sizes = params.getSupportedPreviewSizes(); for (Size s : sizes) { Log.i(TAG, "preview size = " + s.width + ", " + s.height); } params.setPreviewSize(640, 480); // set preview size. smaller is better mCamera.setParameters(params); mPreviewSize = mCamera.getParameters().getPreviewSize(); Log.i(TAG, "preview size = " + mPreviewSize.width + ", " + mPreviewSize.height); int format = mCamera.getParameters().getPreviewFormat(); mFrameLength = mPreviewSize.width * mPreviewSize.height * ImageFormat.getBitsPerPixel(format) / 8; }
Example 4
Source File: CameraView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
private void startPreview(SurfaceHolder holder) { try { Parameters params = camera.getParameters(); if (params.getSupportedFocusModes().contains( Camera.Parameters.FOCUS_MODE_AUTO)) { params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); } List<Size> previewSizes = camera.getParameters().getSupportedPreviewSizes(); List<Size> pictureSizes = camera.getParameters().getSupportedPictureSizes(); params.setPreviewSize(previewSizes.get(previewSizes.size()-2).width,previewSizes.get(previewSizes.size()-2).height); params.setPictureSize(pictureSizes.get(pictureSizes.size()-2).width,pictureSizes.get(pictureSizes.size()-2).height); camera.setParameters(params); camera.setPreviewDisplay(holder); camera.startPreview(); previewConsumer.start(camera); } catch(IOException e) { Log.e(TAG, "Error starting camera preview", e); } }
Example 5
Source File: CameraPreview.java From Android-Barcode-Reader with MIT License | 6 votes |
public CameraPreview(Context context, Camera camera) { super(context); mCamera = camera; mContext = context; mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); Parameters params = mCamera.getParameters(); mWidth = 640; mHeight = 480; params.setPreviewSize(mWidth, mHeight); mCamera.setParameters(params); mMultiFormatReader = new MultiFormatReader(); mDialog = new AlertDialog.Builder(mContext).create(); }
Example 6
Source File: CameraSource.java From mlkit-material-android with Apache License 2.0 | 5 votes |
private void setPreviewAndPictureSize(Camera camera, Parameters parameters) throws IOException { // Gives priority to the preview size specified by the user if exists. CameraSizePair sizePair = PreferenceUtils.getUserSpecifiedPreviewSize(context); if (sizePair == null) { // Camera preview size is based on the landscape mode, so we need to also use the aspect // ration of display in the same mode for comparison. float displayAspectRatioInLandscape; if (Utils.isPortraitMode(graphicOverlay.getContext())) { displayAspectRatioInLandscape = (float) graphicOverlay.getHeight() / graphicOverlay.getWidth(); } else { displayAspectRatioInLandscape = (float) graphicOverlay.getWidth() / graphicOverlay.getHeight(); } sizePair = selectSizePair(camera, displayAspectRatioInLandscape); } if (sizePair == null) { throw new IOException("Could not find suitable preview size."); } previewSize = sizePair.preview; Log.v(TAG, "Camera preview size: " + previewSize); parameters.setPreviewSize(previewSize.getWidth(), previewSize.getHeight()); PreferenceUtils.saveStringPreference( context, R.string.pref_key_rear_camera_preview_size, previewSize.toString()); Size pictureSize = sizePair.picture; if (pictureSize != null) { Log.v(TAG, "Camera picture size: " + pictureSize); parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight()); PreferenceUtils.saveStringPreference( context, R.string.pref_key_rear_camera_picture_size, pictureSize.toString()); } }
Example 7
Source File: CameraManager.java From AndroidRecording with Apache License 2.0 | 5 votes |
public void setupCameraAndStartPreview(SurfaceHolder sf, Size sz, int displayRotation) { stopCameraPreview(); cameraRotationDegree = CameraHelper.setCameraDisplayOrientation(defaultCameraID, camera, displayRotation); Parameters param = camera.getParameters(); param.setPreviewSize(sz.width, sz.height); camera.setParameters(param); if (setDisplay(sf)) { startCameraPreview(); } }
Example 8
Source File: VideoStream.java From libstreaming with Apache License 2.0 | 5 votes |
protected synchronized void updateCamera() throws RuntimeException { // The camera is already correctly configured if (mUpdated) return; if (mPreviewStarted) { mPreviewStarted = false; mCamera.stopPreview(); } Parameters parameters = mCamera.getParameters(); mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality); int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters); double ratio = (double)mQuality.resX/(double)mQuality.resY; mSurfaceView.requestAspectRatio(ratio); parameters.setPreviewFormat(mCameraImageFormat); parameters.setPreviewSize(mQuality.resX, mQuality.resY); parameters.setPreviewFpsRange(max[0], max[1]); try { mCamera.setParameters(parameters); mCamera.setDisplayOrientation(mOrientation); mCamera.startPreview(); mPreviewStarted = true; mUpdated = true; } catch (RuntimeException e) { destroyCamera(); throw e; } }
Example 9
Source File: HelloCameraActivity.java From cameraMediaCodec with BSD 2-Clause "Simplified" License | 5 votes |
private void TestSpecifiedParam(CameraInfoCollector collector, List<Rect> list_rect) { collector.getFacing(true); //for log Camera cam = collector.getCamera(); Parameters para = cam.getParameters(); for (Rect rec:list_rect) { para.setPreviewSize(rec.right-rec.left, rec.bottom-rec.top); boolean setOK = true; try { cam.setParameters(para); } catch(RuntimeException ex) { setOK = false; } if (setOK == true) { Log.i(log_tag, "setParameters: size="+(rec.right-rec.left)+"x"+(rec.bottom-rec.top)+"-----------------OK"); } else { Log.e(log_tag, "setParameters: size="+(rec.right-rec.left)+"x"+(rec.bottom-rec.top)+"-----------------FAIL"); } } }
Example 10
Source File: CameraWizard.java From OnionCamera with MIT License | 5 votes |
public Size setPreviewSize(int width, int height) { Parameters parameters = camera.getParameters(); Size size; if (orientation == 0 || orientation == 180) { size = getBestPreviewSize(parameters, width, height); } else { size = getBestPreviewSize(parameters, height, width); } parameters.setPreviewSize(size.width, size.height); camera.setParameters(parameters); return size; }
Example 11
Source File: CameraWrapper.java From LandscapeVideoCamera with Apache License 2.0 | 5 votes |
public void configureForPreview(int viewWidth, int viewHeight) { final Parameters params = mNativeCamera.getNativeCameraParameters(); final CameraSize previewSize = getOptimalSize(params.getSupportedPreviewSizes(), viewWidth, viewHeight); params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight()); params.setPreviewFormat(ImageFormat.NV21); mNativeCamera.updateNativeCameraParameters(params); mNativeCamera.setDisplayOrientation(getRotationCorrection()); CLog.d(CLog.CAMERA, "Preview size: " + previewSize.getWidth() + "x" + previewSize.getHeight()); }
Example 12
Source File: CameraWrapper.java From VideoCamera with Apache License 2.0 | 5 votes |
public void configureForPreview(int viewWidth, int viewHeight) { final Parameters params = mNativeCamera.getNativeCameraParameters(); final CameraSize previewSize = getOptimalSize(params.getSupportedPreviewSizes(), viewWidth, viewHeight); params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight()); params.setPreviewFormat(ImageFormat.NV21); mNativeCamera.updateNativeCameraParameters(params); mNativeCamera.setDisplayOrientation(getRotationCorrection()); CLog.d(CLog.CAMERA, "Preview size: " + previewSize.getWidth() + "x" + previewSize.getHeight()); }
Example 13
Source File: Camera1Controller.java From pixelvisualcorecamera with Apache License 2.0 | 5 votes |
/** * Configures camera parameters common to all configurations. * Must be called before preview started. */ public void setDefaultParameters(int displayRotation) { Log.i(TAG, "setDefaultParameters"); assertState(STATE_ACQUIRED, "Default parameters may only be set before a preview is started"); CameraInfo info = new CameraInfo(); Camera.getCameraInfo(cameraId, info); boolean lensFacingFront = (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT); int previewOrientationDegrees = Orientation.getPreviewOrientation(lensFacingFront, displayRotation, info.orientation); camera.setDisplayOrientation(previewOrientationDegrees); Parameters params = camera.getParameters(); // We happen to know the preview sizes available for Pixel 2. params.setPreviewSize(Utils.MAX_PREVIEW_WIDTH, Utils.MAX_PREVIEW_HEIGHT); params.setRotation( Orientation.getOutputOrientation(lensFacingFront, displayRotation, info.orientation)); // Continuous picture is not supported Pixel 2's front camera. List<String> supportFocusModes = params.getSupportedFocusModes(); if (supportFocusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { Log.i(TAG, "setting continuous picture focus mode"); params.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); } // HDR+: Flash mode must be off. params.setFlashMode(Parameters.FLASH_MODE_OFF); // HDR+: Color effect must be none. params.setColorEffect(Parameters.EFFECT_NONE); // HDR+: White balance must be auto. params.setWhiteBalance(Parameters.WHITE_BALANCE_AUTO); camera.setParameters(params); }
Example 14
Source File: AndroidCameraOutput.java From sensorhub with Mozilla Public License 2.0 | 4 votes |
@Override public void init() throws SensorException { try { // TODO get closest values from camera characteristics imgWidth = 800; imgHeight = 600; frameRate = 1; // open camera and set parameters camera = Camera.open(cameraId); Parameters camParams = camera.getParameters(); camParams.setPreviewSize(imgWidth, imgHeight); camParams.setPreviewFormat(ImageFormat.NV21); camera.setParameters(camParams); // setup buffers and callback imgArea = new Rect(0, 0, imgWidth, imgHeight); int bufSize = imgWidth*imgHeight*ImageFormat.getBitsPerPixel(ImageFormat.NV21)/8; imgBuf1 = new byte[bufSize]; yuvImg1 = new YuvImage(imgBuf1, ImageFormat.NV21, imgWidth, imgHeight, null); imgBuf2 = new byte[bufSize]; yuvImg2 = new YuvImage(imgBuf2, ImageFormat.NV21, imgWidth, imgHeight, null); camera.addCallbackBuffer(imgBuf1); camera.addCallbackBuffer(imgBuf2); camera.setPreviewCallbackWithBuffer(this); camera.setDisplayOrientation(90); // create SWE Common data structure SWEFactory fac = new SWEFactory(); dataStruct = fac.newDataRecord(2); dataStruct.setName(getName()); Time time = fac.newTime(); time.getUom().setHref(Time.ISO_TIME_UNIT); time.setDefinition(SWEConstants.DEF_SAMPLING_TIME); time.setReferenceFrame(TIME_REF); dataStruct.addComponent("time", time); DataArray img = fac.newDataArray(imgHeight); img.setDefinition("http://sensorml.com/ont/swe/property/VideoFrame"); dataStruct.addComponent("videoFrame", img); DataArray imgRow = fac.newDataArray(imgWidth); img.addComponent("row", imgRow); DataRecord imgPixel = fac.newDataRecord(3); imgPixel.addComponent("red", fac.newCount(DataType.BYTE)); imgPixel.addComponent("green", fac.newCount(DataType.BYTE)); imgPixel.addComponent("blue", fac.newCount(DataType.BYTE)); imgRow.addComponent("pixel", imgPixel); // SWE Common encoding dataEncoding = fac.newBinaryEncoding(); dataEncoding.setByteEncoding(ByteEncoding.RAW); dataEncoding.setByteOrder(ByteOrder.BIG_ENDIAN); BinaryComponent timeEnc = fac.newBinaryComponent(); timeEnc.setRef("/" + time.getName()); timeEnc.setCdmDataType(DataType.DOUBLE); dataEncoding.addMemberAsComponent(timeEnc); //BinaryBlock compressedBlock = fac.newBinaryBlock(); //compressedBlock.setRef("/" + img.getName()); //compressedBlock.setCompression("H264"); BinaryBlock compressedBlock = fac.newBinaryBlock(); compressedBlock.setRef("/" + img.getName()); compressedBlock.setCompression("JPEG"); dataEncoding.addMemberAsBlock(compressedBlock); // resolve encoding so compressed blocks can be properly generated SWEHelper.assignBinaryEncoding(dataStruct, dataEncoding); // start streaming video if (previewSurfaceHolder != null) camera.setPreviewDisplay(previewSurfaceHolder); camera.startPreview(); } catch (Exception e) { throw new SensorException("Cannot access camera " + cameraId, e); } }
Example 15
Source File: CodeScanner.java From code-scanner with MIT License | 4 votes |
private void initialize() { Camera camera = null; final CameraInfo cameraInfo = new CameraInfo(); final int cameraId = mCameraId; if (cameraId == CAMERA_BACK || cameraId == CAMERA_FRONT) { final int numberOfCameras = Camera.getNumberOfCameras(); final int facing = cameraId == CAMERA_BACK ? CameraInfo.CAMERA_FACING_BACK : CameraInfo.CAMERA_FACING_FRONT; for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == facing) { camera = Camera.open(i); mCameraId = i; break; } } } else { camera = Camera.open(cameraId); Camera.getCameraInfo(cameraId, cameraInfo); } if (camera == null) { throw new CodeScannerException("Unable to access camera"); } final Parameters parameters = camera.getParameters(); if (parameters == null) { throw new CodeScannerException("Unable to configure camera"); } final int orientation = Utils.getDisplayOrientation(mContext, cameraInfo); final boolean portrait = Utils.isPortrait(orientation); final Point imageSize = Utils.findSuitableImageSize(parameters, portrait ? mHeight : mWidth, portrait ? mWidth : mHeight); final int imageWidth = imageSize.getX(); final int imageHeight = imageSize.getY(); parameters.setPreviewSize(imageWidth, imageHeight); parameters.setPreviewFormat(ImageFormat.NV21); final Point previewSize = Utils.getPreviewSize(portrait ? imageHeight : imageWidth, portrait ? imageWidth : imageHeight, mWidth, mHeight); final List<String> focusModes = parameters.getSupportedFocusModes(); final boolean autoFocusSupported = focusModes != null && (focusModes.contains(Parameters.FOCUS_MODE_AUTO) || focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)); if (!autoFocusSupported) { mAutoFocusEnabled = false; } final Point viewSize = new Point(mWidth, mHeight); if (autoFocusSupported && mAutoFocusEnabled) { Utils.setAutoFocusMode(parameters, mAutoFocusMode); final Rect frameRect = mScannerView.getFrameRect(); if (frameRect != null) { Utils.configureDefaultFocusArea(parameters, frameRect, previewSize, viewSize, imageWidth, imageHeight, orientation); } } final List<String> flashModes = parameters.getSupportedFlashModes(); final boolean flashSupported = flashModes != null && flashModes.contains(Parameters.FLASH_MODE_TORCH); if (!flashSupported) { mFlashEnabled = false; } final int zoom = mZoom; if (zoom != 0) { Utils.setZoom(parameters, zoom); } Utils.configureFpsRange(parameters); Utils.configureSceneMode(parameters); Utils.configureVideoStabilization(parameters); camera.setParameters(parameters); camera.setDisplayOrientation(orientation); synchronized (mInitializeLock) { final Decoder decoder = new Decoder(mDecoderStateListener, mFormats, mDecodeCallback); mDecoderWrapper = new DecoderWrapper(camera, cameraInfo, decoder, imageSize, previewSize, viewSize, orientation, autoFocusSupported, flashSupported); decoder.start(); mInitialization = false; mInitialized = true; } mMainThreadHandler.post(new FinishInitializationTask(previewSize)); }
Example 16
Source File: AndroidCameraAgentImpl.java From Camera2 with Apache License 2.0 | 4 votes |
private void applySettingsToParameters(final CameraSettings settings, final Parameters parameters) { final CameraCapabilities.Stringifier stringifier = mCapabilities.getStringifier(); Size photoSize = settings.getCurrentPhotoSize(); parameters.setPictureSize(photoSize.width(), photoSize.height()); Size previewSize = settings.getCurrentPreviewSize(); parameters.setPreviewSize(previewSize.width(), previewSize.height()); if (settings.getPreviewFrameRate() == -1) { parameters.setPreviewFpsRange(settings.getPreviewFpsRangeMin(), settings.getPreviewFpsRangeMax()); } else { parameters.setPreviewFrameRate(settings.getPreviewFrameRate()); } parameters.setPreviewFormat(settings.getCurrentPreviewFormat()); parameters.setJpegQuality(settings.getPhotoJpegCompressionQuality()); if (mCapabilities.supports(CameraCapabilities.Feature.ZOOM)) { parameters.setZoom(zoomRatioToIndex(settings.getCurrentZoomRatio(), parameters.getZoomRatios())); } parameters.setExposureCompensation(settings.getExposureCompensationIndex()); if (mCapabilities.supports(CameraCapabilities.Feature.AUTO_EXPOSURE_LOCK)) { parameters.setAutoExposureLock(settings.isAutoExposureLocked()); } parameters.setFocusMode(stringifier.stringify(settings.getCurrentFocusMode())); if (mCapabilities.supports(CameraCapabilities.Feature.AUTO_WHITE_BALANCE_LOCK)) { parameters.setAutoWhiteBalanceLock(settings.isAutoWhiteBalanceLocked()); } if (settings.getWhiteBalance() != null) { parameters.setWhiteBalance(stringifier.stringify(settings.getWhiteBalance())); } if (mCapabilities.supports(CameraCapabilities.Feature.FOCUS_AREA)) { if (settings.getFocusAreas().size() != 0) { parameters.setFocusAreas(settings.getFocusAreas()); } else { parameters.setFocusAreas(null); } } if (mCapabilities.supports(CameraCapabilities.Feature.METERING_AREA)) { if (settings.getMeteringAreas().size() != 0) { parameters.setMeteringAreas(settings.getMeteringAreas()); } else { parameters.setMeteringAreas(null); } } if (settings.getCurrentFlashMode() != CameraCapabilities.FlashMode.NO_FLASH) { parameters.setFlashMode(stringifier.stringify(settings.getCurrentFlashMode())); } if (settings.getCurrentSceneMode() != CameraCapabilities.SceneMode.NO_SCENE_MODE) { if (settings.getCurrentSceneMode() != null) { parameters .setSceneMode(stringifier.stringify(settings.getCurrentSceneMode())); } } parameters.setRecordingHint(settings.isRecordingHintEnabled()); Size jpegThumbSize = settings.getExifThumbnailSize(); if (jpegThumbSize != null) { parameters.setJpegThumbnailSize(jpegThumbSize.width(), jpegThumbSize.height()); } parameters.setPictureFormat(settings.getCurrentPhotoFormat()); CameraSettings.GpsData gpsData = settings.getGpsData(); if (gpsData == null) { parameters.removeGpsData(); } else { parameters.setGpsTimestamp(gpsData.timeStamp); if (gpsData.processingMethod != null) { // It's a hack since we always use GPS time stamp but does // not use other fields sometimes. Setting processing // method to null means the other fields should not be used. parameters.setGpsAltitude(gpsData.altitude); parameters.setGpsLatitude(gpsData.latitude); parameters.setGpsLongitude(gpsData.longitude); parameters.setGpsProcessingMethod(gpsData.processingMethod); } } }
Example 17
Source File: CameraEngine.java From TikTok with Apache License 2.0 | 4 votes |
public static void setDefaultParameters(){ if(camera == null){ return ; } Parameters parameters = camera.getParameters(); if (parameters.getSupportedFocusModes().contains( Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); } Size previewSize = CameraUtils.getLargePreviewSize(camera); parameters.setPreviewSize(PREVIEW_WIDTH, PREVIEW_HEIGHT); if(!isFrameRateSure && mRealFrameRate == CAMERA_FRAME_RATE){ List<int[]> fpsList = parameters.getSupportedPreviewFpsRange(); int tempFps = 30001; for(int i=0;i<fpsList.size();i++){ int[] fps = fpsList.get(i); if(fps[0] == fps[1]){ if(fps[0] >= (CAMERA_FRAME_RATE * 1000) && fps[0]<= tempFps){ tempFps = fps[0]; } } } if(tempFps == 30001){ mRealFrameRate = CAMERA_FRAME_RATE; }else{ mRealFrameRate = tempFps/1000; } } parameters.setPreviewFpsRange(mRealFrameRate * 1000,mRealFrameRate * 1000); parameters.setPreviewFrameRate(mRealFrameRate); Size pictureSize = CameraUtils.getLargePictureSize(camera); parameters.setPictureSize(pictureSize.width, pictureSize.height); parameters.setRotation(getRightCameraOrientation(CameraEngine.cameraID)); // parameters.setExposureCompensation(-1); camera.setParameters(parameters); // DebugTool.warn("CameraEngineExposureCompensation:" + parameters.getMinExposureCompensation() + "," + parameters.getMaxExposureCompensation()); // camera.setDisplayOrientation(getRightCameraOrientation(CameraEngine.cameraID)); // new Handler().postDelayed(new Runnable() { // @Override // public void run() { // int[] fpsa = new int[2]; // camera.getParameters().getPreviewFpsRange(fpsa); // DebugTool.warn("CameraEnginePreviewFpsAA:" + fpsa[0] + "," + fpsa[1] + "," + camera.getParameters().getPreviewFrameRate()); // } // },2000); // if(!isFrameReal && CacheUtil.getInt(AppUtil.getApplicationContext(),FRAME_RATE_KEY,0) == 0){ // byte[] data = new byte[PREVIEW_WIDTH*PREVIEW_HEIGHT*3/2]; // camera.addCallbackBuffer(data); // camera.setPreviewCallbackWithBuffer(new Camera.PreviewCallback() { // @Override // public void onPreviewFrame(byte[] data, Camera camera) { // mFrameCount++; // DebugTool.warn("CameraPreviewCallback:" + mFrameCount); // CameraEngine.camera.addCallbackBuffer(data); // if(mFrameStartTime > 0 && System.currentTimeMillis()-mFrameStartTime >= 2000){//开始确定帧率 // camera.setPreviewCallbackWithBuffer(null); // isFrameStart = false; // isFrameReal = true; // // if(mFrameCount>=mRealFrameRate){ // if(mFrameCount/2-mRealFrameRate<4){ // return ; // }else{ // mRealFrameRate = mFrameCount/2 + (5-mFrameCount%5); // } // } // DebugTool.warn("CameraPreviewCallback:mRealFrameRate:" + mRealFrameRate); // return ; // } // if(!isFrameStart){ // isFrameStart = true; // mFrameStartTime = System.currentTimeMillis(); // } // } // }); // } }