80,351
社区成员
发帖
与我相关
我的任务
分享
private void UpdateUI(Mat Mat2Show)
{
double time = (endTime-startTime)/Core.getTickFrequency();
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putDouble("Time", time);
bundle.putDouble("x", x);
bundle.putDouble("y", y);
bundle.putDouble("z", z);
msg.setData(bundle);
msg.obj = Mat2Show;
msg.what = Unity.MessageID.UPDATE_UI;
Log.i(Unity.TAG, "SteroVision SendMessage");
handler.sendMessage(msg);
}
Handler handler = new Handler(Looper.getMainLooper());
case Unity.MessageID.UPDATE_UI:
//Update UI
msgBundle = msg.getData();
showMat = ((Mat)msg.obj).clone();
//post(new UIRunnable());
double time = msgBundle.getDouble("Time");
textView.setText("Computing Time is "+time*1000+"ms");
coordinateTextView.setText("x="+msgBundle.getDouble("x")*100+"cm, y="+msgBundle.getDouble("y")*100+"cm, z="+msgBundle.getDouble("z")*100+"cm");
showImage(showMat, imageView);
//textView.invalidate();
//coordinateTextView.invalidate();
//imageView.invalidate();
Log.i(Unity.TAG, "is UpdateUIing");
break;
private void showImage(Mat matImage, ImageView imageView)
{
Bitmap bitmap = Bitmap.createBitmap(matImage.width(), matImage.height(), Config.RGB_565);
Utils.matToBitmap(matImage, bitmap);
imageView.setImageBitmap(bitmap);
}
mHandlerThread = new HandlerThread("WorkerThread");
mHandlerThread.start();
}
if (null == mHandler)
mHandler = new Handler(mHandlerThread.getLooper());