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


Java Parameters.getPreviewSize方法代码示例

本文整理汇总了Java中android.hardware.Camera.Parameters.getPreviewSize方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.getPreviewSize方法的具体用法?Java Parameters.getPreviewSize怎么用?Java Parameters.getPreviewSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera.Parameters的用法示例。


在下文中一共展示了Parameters.getPreviewSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPreviewFrame

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
    Parameters parameters = camera.getParameters();
    Size size = parameters.getPreviewSize();

    Image barcode = new Image(size.width, size.height, "Y800");
    barcode.setData(data);

    int result = scanner.scanImage(barcode);
    
    if (result != 0) {
        previewing = false;
        mCamera.setPreviewCallback(null);
        mCamera.stopPreview();
        
        SymbolSet syms = scanner.getResults();
        for (Symbol sym : syms) {
          //  scanText.setText("barcode result " + sym.getData());
            Toast.makeText(MainActivity.this,sym.getData(),Toast.LENGTH_SHORT).show();
            barcodeScanned = false;
            mCamera.setPreviewCallback(previewCb);
            mCamera.startPreview();
          //  previewing = true;
            mCamera.autoFocus(autoFocusCB);
        }
    }
}
 
开发者ID:pesehr,项目名称:AndroidQrCodeScanner,代码行数:27,代码来源:MainActivity.java

示例2: logCameraParameters

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@UiThread
private void logCameraParameters() {
	if (LOG.isLoggable(INFO)) {
		Parameters params = camera.getParameters();
		if (Build.VERSION.SDK_INT >= 15) {
			LOG.info("Video stabilisation enabled: "
					+ params.getVideoStabilization());
		}
		LOG.info("Scene mode: " + params.getSceneMode());
		LOG.info("Focus mode: " + params.getFocusMode());
		LOG.info("Flash mode: " + params.getFlashMode());
		Size size = params.getPreviewSize();
		LOG.info("Preview size: " + size.width + "x" + size.height);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:16,代码来源:CameraView.java

示例3: jpegFromPreview

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
byte[] jpegFromPreview(byte[] currentPreview) {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        Parameters parameters = mCamera.getParameters();
        Size size = parameters.getPreviewSize();
        YuvImage image = new YuvImage(currentPreview, parameters.getPreviewFormat(), size.width, size.height, null);

        image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), quality, baos);

        byte[] jpeg = baos.toByteArray();
        float rotation = (float) 0.;
        if (cameraId == 1 && mDisplay.getRotation() == Surface.ROTATION_0)
                rotation = (float) 270.;
        else if (cameraId == 0 && mDisplay.getRotation() == Surface.ROTATION_0)
                rotation = (float) 90.;

        if (debug) Log.i(TAG, "cameraId: " + cameraId + ", getRotation: " + mDisplay.getRotation() + ", rotation: " + rotation);

        if (rotation != 0.) {
            // This is the same image as the preview but in JPEG and not rotated
            Bitmap bitmap = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.length);
            ByteArrayOutputStream rotatedStream = new ByteArrayOutputStream();

            // Rotate the Bitmap
            Matrix matrix = new Matrix();
            matrix.postRotate(rotation);

            // We rotate the same Bitmap
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, image.getWidth(), image.getHeight(), matrix, false);

            // We dump the rotated Bitmap to the stream
            bitmap.compress(CompressFormat.JPEG, 50, rotatedStream);
            jpeg = rotatedStream.toByteArray();
            // whew
        }
        return jpeg;
    }
 
开发者ID:cycronix,项目名称:cloudturbine,代码行数:39,代码来源:CTandroidAV.java

示例4: doInBackground

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@Override
protected byte[] doInBackground(Object... objs) {
    byte[] frame = (byte[]) objs[0];
    Parameters parameters = (Parameters) objs[1];
    if (frame_firstUpdateTime == 0) {
        frame_firstUpdateTime = System.currentTimeMillis();
    }
    frame_currentUpdateTime = System.currentTimeMillis();

    int datasize = 0;
    cameraImageSize = parameters.getPreviewSize();
    YuvImage image = new YuvImage(frame, parameters.getPreviewFormat(), cameraImageSize.width,
            cameraImageSize.height, null);
    ByteArrayOutputStream tmpBuffer = new ByteArrayOutputStream();
    image.compressToJpeg(new Rect(0, 0, image.getWidth(), image.getHeight()), 90, tmpBuffer);
    Log.d(LOG_TAG, "compression took: "
            + (System.currentTimeMillis()-frame_currentUpdateTime));
    synchronized (frameLock) {
        frameBuffer = tmpBuffer.toByteArray();
        frameGeneratedTime = System.currentTimeMillis();
        frameID++;
        frameLock.notify();
    }
    datasize = tmpBuffer.size();
    frame_count++;
    frame_totalsize += datasize;
    if (frame_count % 50 == 0) {
        Log.d(LOG_TAG, "(IMG)\t" +
                "BW: " + 8.0 * frame_totalsize / (frame_currentUpdateTime - frame_firstUpdateTime) / 1000 +
                " Mbps\tCurrent FPS: " + 8.0 * datasize / (frame_currentUpdateTime - frame_prevUpdateTime) / 1000 + " Mbps\t" +
                "FPS: " + 1000.0 * frame_count / (frame_currentUpdateTime - frame_firstUpdateTime));
    }
    frame_prevUpdateTime = frame_currentUpdateTime;
    return tmpBuffer.toByteArray();
}
 
开发者ID:cmusatyalab,项目名称:faceswap,代码行数:36,代码来源:VideoStreamingThread.java


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