本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例15: setPreviewCallback
import android.hardware.Camera.PreviewCallback; //导入依赖的package包/类
@Override
public void setPreviewCallback(PreviewCallback my) {
Log.e("test++++++++++++++", "setPreviewCallback");
if (cameras != null) {
cameras.setPreviewCallback(my);
}
}