在android中在live feed上叠加图像

在android中在live feed上叠加图像,android,android-layout,image-processing,overlay,Android,Android Layout,Image Processing,Overlay,我想在android中的live feed上叠加一个图像。有人能建议从哪里开始吗? 我已将所需的url转换为图像。代码如下: ImageView imgView=(ImageView)findViewById(R.id.ImageView01); Drawable Drawable=LoadImageFromWebOperations(“https://www.google.com.pk/logos/classicplus.png"); imgView.setImageDrawable(可绘制)

我想在android中的live feed上叠加一个图像。有人能建议从哪里开始吗? 我已将所需的url转换为图像。代码如下:

ImageView imgView=(ImageView)findViewById(R.id.ImageView01); Drawable Drawable=LoadImageFromWebOperations(“https://www.google.com.pk/logos/classicplus.png"); imgView.setImageDrawable(可绘制)

现在,我想要的是如何将这个图像覆盖到视频中所需的区域,即手检测区域。问题是,这个感兴趣的区域可以移动,因为它是一个活的提要。。。。
非常感谢您的帮助。

我通过叠加两个视图(下面命名为“预览”和“叠加”)来实现这一点。一个负责相机预览,另一个控制画布来绘制我想要的任何东西

res/layout/main.xml
中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
  <FrameLayout
      android:id="@+id/toplevelframe"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
    <your.project.Preview
    android:id="@+id/preview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
    <your.project.Overlay
    android:id="@+id/overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
  </FrameLayout>
</LinearLayout>
onResume()中

onPause()
中:

Overlay
扩展视图并在画布上绘制。没有什么特别的,只要重写
onDraw()

对于摄影机预览类(
preview
),请查看示例。看起来是这样的:

class Preview extends ViewGroup implements SurfaceHolder.Callback {
...
  private SurfaceView mSurfaceView;
  private SurfaceHolder mHolder;
  private Camera mCamera;
...
  public Preview(Context context, AttributeSet aset) {
      ...
      mSurfaceView = new SurfaceView(context);
      addView(mSurfaceView);
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder = mSurfaceView.getHolder();
      mHolder.addCallback(this);
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
...
  public void setCamera(Camera camera) {
      mCamera = camera;
      if (mCamera != null) {
          mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
          requestLayout();
      }
   }
...
}

然后实现的所有方法。

我通过叠加两个视图(下面命名为Preview和Overlay)来实现。一个负责相机预览,另一个控制画布来绘制我想要的任何东西

res/layout/main.xml
中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
  <FrameLayout
      android:id="@+id/toplevelframe"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
    <your.project.Preview
    android:id="@+id/preview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
    <your.project.Overlay
    android:id="@+id/overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
  </FrameLayout>
</LinearLayout>
onResume()中

onPause()
中:

Overlay
扩展视图并在画布上绘制。没有什么特别的,只要重写
onDraw()

对于摄影机预览类(
preview
),请查看示例。看起来是这样的:

class Preview extends ViewGroup implements SurfaceHolder.Callback {
...
  private SurfaceView mSurfaceView;
  private SurfaceHolder mHolder;
  private Camera mCamera;
...
  public Preview(Context context, AttributeSet aset) {
      ...
      mSurfaceView = new SurfaceView(context);
      addView(mSurfaceView);
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder = mSurfaceView.getHolder();
      mHolder.addCallback(this);
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
...
  public void setCamera(Camera camera) {
      mCamera = camera;
      if (mCamera != null) {
          mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
          requestLayout();
      }
   }
...
}

然后实现的所有方法。

相对布局和视图。布局()方法是您的朋友。我是否必须先将图像视图转换为位图,然后将其覆盖在视频上?如何播放视频?创建RelativeLayout,将VideoView和ImageView放入其中。通过布局方法设置ImageView位置。不,基本上我使用的是本机摄像头,下面的代码是:public void surfaceCreated(SurfaceHolder holder){Log.i(TAG,“surfaceCreated”);mCamera=new VideoCapture(Highgui.CV_CAP_ANDROID);if(mCamera.isOpened()){(new Thread(this)).start()}else{mCamera.release();mCamera=null;Log.e(标记,“无法打开本机相机”);}}并且我使用opencv提供的布局,它基本上是一个没有xml文件相对布局和view.layout()的代码(视图)方法是您的朋友我必须先将imageview转换为位图以将其覆盖在视频上如何播放视频?创建RelativeLayout,将VideoView和imageview放入其中。通过布局方法设置imageview位置。不,基本上我使用的是本机相机下面是代码:public void surfaceCreated(SurfaceHolder holder){Log.i(TAG,“surfaceCreated”);mCamera=newvideocapture(Highgui.CV_CAP_ANDROID);if(mCamera.isOpened()){(new Thread(this)).start();}else{mCamera.release();mCamera=null;Log.e(TAG,“无法打开本机摄像头”);}我使用opencv提供的布局,它基本上是一个没有xml文件的代码(视图)
if (mCamera != null) {
    mPreview.setCamera(null);
    mCamera.release();
    mCamera = null;
}
class Preview extends ViewGroup implements SurfaceHolder.Callback {
...
  private SurfaceView mSurfaceView;
  private SurfaceHolder mHolder;
  private Camera mCamera;
...
  public Preview(Context context, AttributeSet aset) {
      ...
      mSurfaceView = new SurfaceView(context);
      addView(mSurfaceView);
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder = mSurfaceView.getHolder();
      mHolder.addCallback(this);
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
...
  public void setCamera(Camera camera) {
      mCamera = camera;
      if (mCamera != null) {
          mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
          requestLayout();
      }
   }
...
}