从DJI无人机解码Android上的视频流


NetworkAttachedStorage
2024-12-15 09:42:40 (2月前)
  1. =真;
  2. // DJI解码方法
  3. //mDjiGLSurfaceView.setDataToDecoder(videoBuffer,size);
  4. }
  5. };

这是从中发送编码流的方法

无人驾驶飞机
</跨度>
,我需要发送解码videoBuffer然后修改为Mat for OpenCV。

2 条回复
  1. 0# 诸葛神侯 | 2019-08-31 10-32



    像这样初始化视频回调




    1. mReceivedVideoDataCallBack = new DJICamera.CameraReceivedVideoDataCallback() {
      @Override
      public void onResult(byte[] videoBuffer, int size) {
      if(mCodecManager != null){
      // Send the raw H264 video data to codec manager for decoding
      mCodecManager.sendDataToDecoder(videoBuffer, size);
      }else {
      Log.e(TAG, mCodecManager is null”);
      }
      }
      }

    2. </code>


    让您的活动实现TextureView.SurfaceTextureListener
    并且对于TextureView mVideoSurface在初始化之后调用此行:




    1. mVideoSurface.setSurfaceTextureListener(this);

    2. </code>


    然后实施:




    1. @Override
      public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
      Log.v(TAG, onSurfaceTextureAvailable”);
      DJICamera camera = FPVDemoApplication.getCameraInstance();
      if (mCodecManager == null && surface != null && camera != null) {
      //Normal init for the surface
      mCodecManager = new DJICodecManager(this, surface, width, height);
      Log.v(TAG, Initialized CodecManager”);
      }
      }

    2. @Override
    3. public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
    4.     Log.v(TAG, "onSurfaceTextureSizeChanged");
    5. }
    6. @Override
    7. public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
    8.     Log.v(TAG, "onSurfaceTextureDestroyed");
    9.     if (mCodecManager != null) {
    10.         mCodecManager.cleanSurface();
    11.         mCodecManager = null;
    12.     }
    13.     return false;
    14. }
    15. @Override
    16. public void onSurfaceTextureUpdated(SurfaceTexture surface) {
    17.     final Bitmap image = mVideoSurface.getBitmap();
    18.     //Do whatever you want with the bitmap image here on every frame
    19. }
    20. </code>


    希望这可以帮助!


登录 后才能参与评论