mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 03:30:34 +08:00
fix for #1724: making Java samples compatible with Android 3.1+ targets
This commit is contained in:
parent
cff117c08b
commit
74749fccbf
@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
return mFrameHeight;
|
||||
}
|
||||
|
||||
public void setPreview() throws IOException {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
else
|
||||
mCamera.setPreviewDisplay(null);
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
|
||||
Log.i(TAG, "surfaceCreated");
|
||||
if (mCamera != null) {
|
||||
@ -61,14 +68,10 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
|
||||
params.setPreviewSize(getFrameWidth(), getFrameHeight());
|
||||
mCamera.setParameters(params);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
} else {
|
||||
try {
|
||||
mCamera.setPreviewDisplay(null);
|
||||
setPreview();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
|
||||
}
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
|
||||
}
|
||||
mCamera.startPreview();
|
||||
}
|
||||
|
@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
return mFrameHeight;
|
||||
}
|
||||
|
||||
public void setPreview() throws IOException {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
else
|
||||
mCamera.setPreviewDisplay(null);
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
|
||||
Log.i(TAG, "surfaceCreated");
|
||||
if (mCamera != null) {
|
||||
@ -61,14 +68,10 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
|
||||
params.setPreviewSize(getFrameWidth(), getFrameHeight());
|
||||
mCamera.setParameters(params);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
} else {
|
||||
try {
|
||||
mCamera.setPreviewDisplay(null);
|
||||
setPreview();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
|
||||
}
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
|
||||
}
|
||||
mCamera.startPreview();
|
||||
}
|
||||
|
@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
return mFrameHeight;
|
||||
}
|
||||
|
||||
public void setPreview() throws IOException {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
else
|
||||
mCamera.setPreviewDisplay(null);
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
|
||||
Log.i(TAG, "surfaceCreated");
|
||||
if (mCamera != null) {
|
||||
@ -61,14 +68,10 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
|
||||
params.setPreviewSize(getFrameWidth(), getFrameHeight());
|
||||
mCamera.setParameters(params);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
} else {
|
||||
try {
|
||||
mCamera.setPreviewDisplay(null);
|
||||
setPreview();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
|
||||
}
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
|
||||
}
|
||||
mCamera.startPreview();
|
||||
}
|
||||
|
@ -39,6 +39,13 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
return mFrameHeight;
|
||||
}
|
||||
|
||||
public void setPreview() throws IOException {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
else
|
||||
mCamera.setPreviewDisplay(null);
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
|
||||
Log.i(TAG, "surfaceCreated");
|
||||
if (mCamera != null) {
|
||||
@ -61,14 +68,10 @@ public abstract class SampleViewBase extends SurfaceView implements SurfaceHolde
|
||||
|
||||
params.setPreviewSize(getFrameWidth(), getFrameHeight());
|
||||
mCamera.setParameters(params);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mCamera.setPreviewTexture( new SurfaceTexture(10) );
|
||||
} else {
|
||||
try {
|
||||
mCamera.setPreviewDisplay(null);
|
||||
setPreview();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
|
||||
}
|
||||
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
|
||||
}
|
||||
mCamera.startPreview();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user