Camera2Tests: update SmartCamera for async api
Change-Id: I6eb541c96ee50756c35e7785fdae63e8e45e2726
This commit is contained in:
@@ -25,6 +25,8 @@ LOCAL_PROGUARD_ENABLED := disabled
|
||||
# comment it out for now since we need use some hidden APIs
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(call all-java-files-under, src) \
|
||||
$(call all-renderscript-files-under, src)
|
||||
|
||||
@@ -33,6 +33,8 @@ import android.renderscript.ScriptIntrinsicYuvToRGB;
|
||||
import android.renderscript.Type;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import com.android.ex.camera2.blocking.BlockingCameraManager;
|
||||
import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;
|
||||
import androidx.media.filterfw.Filter;
|
||||
import androidx.media.filterfw.Frame;
|
||||
import androidx.media.filterfw.FrameImage2D;
|
||||
@@ -132,12 +134,26 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
|
||||
|
||||
@Override
|
||||
protected void onOpen() {
|
||||
mLooperThread = new CameraTestThread();
|
||||
Handler mHandler;
|
||||
try {
|
||||
mHandler = mLooperThread.start();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
String backCameraId = "0";
|
||||
mCamera = mCameraManager.openCamera(backCameraId);
|
||||
BlockingCameraManager blkManager = new BlockingCameraManager(mCameraManager);
|
||||
mCamera = blkManager.openCamera(backCameraId, /*listener*/null, mHandler);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
} catch (BlockingOpenException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Element ele = Element.createPixel(mRS, Element.DataType.UNSIGNED_8,
|
||||
@@ -172,15 +188,7 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
mLooperThread = new CameraTestThread();
|
||||
Handler mHandler;
|
||||
try {
|
||||
mHandler = mLooperThread.start();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
mCamera.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
|
||||
mHandler);
|
||||
|
||||
Reference in New Issue
Block a user