super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "obColor version = " + VERSION);
m_versionInt = Build.VERSION.SDK_INT;
mWm = (WindowManager) getSystemService(WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
mWm.getDefaultDisplay().getMetrics(dm);
try {
m_xc = new AstraContext(this, m_callbacks);
GlobalDef.USE_UVC = m_xc.IsUVC();
if (GlobalDef.USE_UVC) {
Log.i(TAG, "Astra Pro * Detected!");
} else {
Log.i(TAG, "Astra * Detected!");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
registerHomeListener();
}
private void initUVCCamera() {
// LiveStreamProcessor processor = new LiveStreamProcessor();
int previewWidth = processor.getSupportPreviewWidth();
int previewHeight = processor.getSupportPreviewHeight();
Log.i(TAG, "previewWidth = " + previewWidth);
文章插图
Log.i(TAG, "previewHeight = " + previewHeight);
liveCamera = new LiveCamera();
int rc = liveCamera.init(GlobalDef.RES_UVC_WIDTH,
GlobalDef.RES_UVC_HEIGHT, 30, processor, processor.getBuffer());
if (rc < 0) {
dialog();
return;
}
mSvPreview = new SurfaceView(this);
mSurfaceHolder = mSvPreview.getHolder();
mSurfaceHolder.addCallback(this);
createDisplayView();
}
private void createDisplayView() {
// Log.e(TAG, "createView");
WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
wmParams.type = WindowManager.LayoutParams.TYPE_PHONE;
wmParams.format = PixelFormat.RGBA_8888;
wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
wmParams.gravity = Gravity.RIGHT | Gravity.TOP;
wmParams.width = PREVIEW_WIDTH;
wmParams.height = PREVIEW_HEIGHT;
Log.d(TAG, "top color width = " + wmParams.width);
Log.d(TAG, "top color height = " + wmParams.height);
mWm.addView(mSvPreview, wmParams);
mSvPreview.measure(View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
}
@Override
protected void onPause() {
Log.w(TAG, "Activity onPause");
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
}
protected void onDestroy() {
if (mHomeListener != null) {
mHomeListener.stopWatch();
}
if (m_rgbdata != null) {
m_rgbdata.Close();
}
if (mDepthData != null) {
mDepthData.Close();
}
if (liveCamera != null) {
Log.d(TAG, "liveCamera.terminate()!!!");
liveCamera.terminate();
}
if (m_xc != null) {
m_xc.Close();
}
unRegisterHomeListener();
Log.i(TAG, "Activity onDestroy !");
System.exit(0);
super.onDestroy();
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// Log.e(TAG, "surfaceChanged");
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
Log.e(TAG, "surfaceCreated");
if (GlobalDef.USE_UVC) {
liveCamera.setPreviewDisplay(mSurfaceHolder);
}
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// Log.e(TAG, "surfaceDestroyed");
}
public class ColorView extends SurfaceView implements Callback, Runnable {
private SurfaceHolder m_holder;
private Canvas m_canvas;
private Paint m_paint;
Thread m_surfaceThread;
public ColorView(Context context) {
super(context);
m_holder = this.getHolder();
m_holder.addCallback(this);
m_paint = new Paint();
m_paint.setColor(Color.WHITE);
LinearLayout.LayoutParams layParams = new LinearLayout.LayoutParams(
- 中医心理学与西方心理学差别在哪里 华夏心理咨询培训机构怎么样
- 三叉穴在哪里 董氏奇穴治疗带状疱疹
- 想吃正宗阳澄湖大闸蟹去哪里买比较好 阳澄湖大闸蟹在哪里买
- 京东自营蜂蜜是真的吗 蜂蜜在哪里能买到真的
- 汗蒸东西十条附近哪里有汗蒸和桑拿 我家附近的汗蒸房在哪里
- 怎么知道一个女生敏感还是不敏感 女人敏感区在哪里图解
- 如何制作qq表白二维码 手机怎么做表白链接
- 比较有名的肿瘤医院在哪里 全国看肿瘤最好的中医院
- 有二维码还可以放歌的然后可以表白的是怎么弄的 表白网站制作网址免费
- 上衣尺码170/88A是什么意思