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


Java PreviewCallback类代码示例

本文整理汇总了Java中android.hardware.Camera.PreviewCallback的典型用法代码示例。如果您正苦于以下问题:Java PreviewCallback类的具体用法?Java PreviewCallback怎么用?Java PreviewCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onCreateView

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View view = super.onCreateView(inflater, container, savedInstanceState);

	nv21 = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];

	this.setPreviewCallback(new PreviewCallback() {
		@Override
		public void onPreviewFrame(byte[] data, Camera camera) {
			synchronized (nv21) {
				System.arraycopy(data, 0, nv21, 0, data.length);
				isNV21ready = true;
			}
		}

	});
	return view;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:21,代码来源:FaceOverlapFragment.java

示例2: CameraPreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public CameraPreview(Context context, Camera camera,
                     PreviewCallback previewCb,
                     AutoFocusCallback autoFocusCb) {
    super(context);
    this.context=context;
    mCamera = camera;
    previewCallback = previewCb;
    autoFocusCallback = autoFocusCb;

    /* 
     * Set camera to continuous focus if supported, otherwise use
     * software auto-focus. Only works for API level >=9.
     */
    /*
    Camera.Parameters parameters = camera.getParameters();
    for (String f : parameters.getSupportedFocusModes()) {
        if (f == Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
            mCamera.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            autoFocusCallback = null;
            break;
        }
    }
    */

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);

    // deprecated setting, but required on Android versions prior to 3.0
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:33,代码来源:CameraPreview.java

示例3: CameraPreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@SuppressWarnings("deprecation")
	public CameraPreview(Context context, Camera camera,
                         PreviewCallback previewCb,
                         AutoFocusCallback autoFocusCb) {
        super(context);
        mCamera = camera;
        previewCallback = previewCb;
        autoFocusCallback = autoFocusCb;

        /* 
         * Set camera to continuous focus if supported, otherwise use
         * software auto-focus. Only works for API level >=9.
         */
        //API9以上实现连续对焦
        
//        Camera.Parameters parameters = camera.getParameters();
//        for (String f : parameters.getSupportedFocusModes()) {
//            if (f == Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
//            	parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
//                autoFocusCallback = null;
//                break;
//            }
//        }
        

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);

        // deprecated setting, but required on Android versions prior to 3.0
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
 
开发者ID:Becavalier,项目名称:QRDataTransfer-Android,代码行数:34,代码来源:CameraPreview.java

示例4: run

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@Override
            public void run() {
                if (!Running || mCamera == null) {                // handled by shutDown()
                    this.cancel();
                    return;
                }

                mCamera.setOneShotPreviewCallback(new PreviewCallback() {
                    public void onPreviewFrame(byte[] data, Camera camera) {
//                        currentPreview = data;
                        long t = System.currentTimeMillis();
                        imageQueue.add(new TimeValue(t, jpegFromPreview(data)));    // convert to jpeg on the fly, spread out the CPU work
   //                     imageQueue.add(new TimeValue(t, data));
                        if (debug) Log.i(TAG, "CameraTask, time: " + t);
                    }
                });
            }
 
开发者ID:cycronix,项目名称:cloudturbine,代码行数:18,代码来源:CTandroidAV.java

示例5: surfaceCreated

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public void surfaceCreated(SurfaceHolder holder) 
{
    // The Surface has been created, acquire the camera and tell it where
    // to draw.
    camera = Camera.open();
    try 
    {
        camera.setPreviewDisplay(holder);

        camera.setPreviewCallback(new PreviewCallback() 
        {

            public void onPreviewFrame(byte[] data, Camera arg1) 
            {
               
                    Preview.this.invalidate();
            }
        });
    }
    catch (IOException e) 
    {
        e.printStackTrace();
    }
}
 
开发者ID:coder212,项目名称:androtelebot,代码行数:25,代码来源:Preview.java

示例6: BarcodePreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public BarcodePreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) {
    super(context);
    mCamera = camera;
    previewCallback = previewCb;
    autoFocusCallback = autoFocusCb;

    Camera.Parameters parameters = camera.getParameters();
    for (String f : parameters.getSupportedFocusModes()) {
        if (f == Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
            parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            autoFocusCallback = null;
            break;
        }
    }

    mHolder = getHolder();
    mHolder.addCallback(this);
}
 
开发者ID:dimasdanz,项目名称:KendaliPintuAndroid,代码行数:19,代码来源:BarcodePreview.java

示例7: createPreviewCallback

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

            Image barcode = new Image(size.width, size.height, "NV21");
            barcode.setData(data);
            barcode = barcode.convert("Y800");
            
            int result = mScanner.scanImage(barcode);
            if (result != 0) {
                mPreviewing = false;
                releaseCamera();

                SymbolSet syms = mScanner.getResults();
                for (Symbol sym : syms) {
                    Flow.with(ScanQRConfigActivity.this).scanned(sym);
                    break;
                }
            }
        }
    };

    return previewCallback;
}
 
开发者ID:pif,项目名称:glass-warehouse-automation,代码行数:27,代码来源:ScanQRConfigActivity.java

示例8: XCameraPreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public XCameraPreview(Context context, Camera camera,
                     PreviewCallback previewCb,
                     AutoFocusCallback autoFocusCb) {
    super(context);
    mCamera = camera;
    mPreviewCallback = previewCb;
    mAutoFocusCallback = autoFocusCb;

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);

    // deprecated setting, but required on Android versions prior to 3.0
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:17,代码来源:XCameraPreview.java

示例9: surfaceCreated

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public void surfaceCreated(SurfaceHolder holder) {
    Log.i(TAG, "surfaceCreated");
    mCamera = Camera.open();

    mCamera.setPreviewCallbackWithBuffer(new PreviewCallback() {
        public void onPreviewFrame(byte[] data, Camera camera) {
            synchronized (SampleViewBase.this) {
                System.arraycopy(data, 0, mFrame, 0, data.length);
                SampleViewBase.this.notify(); 
            }
            camera.addCallbackBuffer(mBuffer);
        }
    });
                
    (new Thread(this)).start();
}
 
开发者ID:itamaro,项目名称:higgs-bot,代码行数:17,代码来源:SampleViewBase.java

示例10: requestPreviewFrame

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public void requestPreviewFrame(final PreviewCallback callback) {
    try {
        camera.setOneShotPreviewCallback(callback);
    } catch (final RuntimeException x) {
        log.warn("problem requesting preview frame, callback won't be called", x);
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:8,代码来源:CameraManager.java

示例11: run

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@Override
public void run() {
    cameraManager.requestPreviewFrame(new PreviewCallback() {
        @Override
        public void onPreviewFrame(final byte[] data, final Camera camera) {
            decode(data);
        }
    });
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:ScanActivity.java

示例12: run

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@Override
public void run()
{
    cameraManager.requestPreviewFrame(new PreviewCallback()
    {
        @Override
        public void onPreviewFrame(final byte[] data, final Camera camera)
        {
            decode(data);
        }
    });
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:13,代码来源:ScanActivity.java

示例13: CameraPreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@SuppressWarnings("deprecation")
  public CameraPreview(Context context, Camera camera, PreviewCallback previewCb, AutoFocusCallback autoFocusCb) {
      super(context);
      mCamera = camera;
      previewCallback = previewCb;
      autoFocusCallback = autoFocusCb;

/*
       * Set camera to continuous focus if supported, otherwise use software
 * auto-focus. Only works for API level >=9.
 */

      Camera.Parameters parameters = camera.getParameters();
      for (String f: parameters.getSupportedFocusModes()) {
          if (f == Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
              parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
              autoFocusCallback = null;
              break;
          }
      }


      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder = getHolder();
      mHolder.addCallback(this);

      // deprecated setting, but required on Android versions prior to 3.0
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
 
开发者ID:zybieku,项目名称:ZbarCode,代码行数:31,代码来源:CameraPreview.java

示例14: CameraPreview

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
public CameraPreview(Context context, Camera camera,
                     PreviewCallback previewCb,
                     AutoFocusCallback autoFocusCb) {
    super(context);
    mCamera = camera;
    previewCallback = previewCb;
    autoFocusCallback = autoFocusCb;

    /* 
     * Set camera to continuous focus if supported, otherwise use
     * software auto-focus. Only works for API level >=9.
     */
    /*
    Camera.Parameters parameters = camera.getParameters();
    for (String f : parameters.getSupportedFocusModes()) {
        if (f == Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
            mCamera.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            autoFocusCallback = null;
            break;
        }
    }
    */

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);

    // deprecated setting, but required on Android versions prior to 3.0
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
 
开发者ID:pesehr,项目名称:AndroidQrCodeScanner,代码行数:32,代码来源:CameraPreview.java

示例15: setPreviewCallback

import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@Override
public void setPreviewCallback(PreviewCallback my) {
	Log.e("test++++++++++++++", "setPreviewCallback");
	if (cameras != null) {
		cameras.setPreviewCallback(my);

	}
}
 
开发者ID:hubert1002,项目名称:WiCamera3D,代码行数:9,代码来源:VideoSurfaceView2D.java


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