我正在制作阅读小文字的应用,但我无法获得sharp focus
。我正在使用SCENE_MODE_BARCODE
用于小文本的场景模式,但它似乎无法正常工作我尝试了autofocus
但也没有结果。
抱歉英语不好。
我的预览类代码是
public class MyView extends SurfaceView implements SurfaceHolder.Callback {
Camera surfacecmr;
SurfaceHolder mholder;
@SuppressWarnings("deprecation")
public MyView(Context context, Camera cmr) {
super(context);
surfacecmr = cmr;
mholder = getHolder();
mholder.addCallback(this);
mholder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
// surfacecmr.setDisplayOrientation(90);
surfacecmr.setPreviewDisplay(holder);
surfacecmr.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
if (mholder.getSurface() == null)
return;
surfacecmr.stopPreview();
// get Camera parameters
Camera.Parameters params = surfacecmr.getParameters();
params.setSceneMode(Camera.Parameters.SCENE_MODE_BARCODE);
surfacecmr.setParameters(params);
try {
surfacecmr.setPreviewDisplay(mholder);
} catch (IOException e) {
e.printStackTrace();
}
surfacecmr.startPreview();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
surfacecmr.release();
}
}