2015-11-04 11 views
5

こんにちは私は、DJIファントム3プロのビデオストリームでOpenCvを使用して画像処理をしたいと思います。残念ながら、このことは自分のデコードビデオを作ることが必要です。私はそれが使用するメディアコーデックのAndroidクラスで動作するはずだが、私はしない方法を知っている。私はビデオファイルからビデオをデコードするいくつかの例を見ましたが、このコードを自分の目的に合わせて変更することはできませんでした。誰かがいくつかの例やチュートリアルを行う方法を示すことができますか?ヘルプDJI無人機からAndroidでビデオストリームをデコード

mReceivedVideoDataCallBack = new DJIReceivedVideoDataCallBack(){ 
     @Override 
     public void onResult(byte[] videoBuffer, int size){ 
      //recvData = true; 
      //DJI methods for decoding    
      //mDjiGLSurfaceView.setDataToDecoder(videoBuffer, size); 
     } 
    }; 

これはドローンからの符号化ストリームを送信している方法であり、そして私は、デコードのためvideoBufferを送信して、OpenCVのためにマットに変更する必要がありますしてくれてありがとう。

答えて

2

あなたの活動がTextureView.SurfaceTextureListener を実装してください。この

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"); 
       } 
      }   
} 

のようなビデオコールバックを初期化し、それが初期化された後TextureView mVideoSurfaceこの行を呼び出す:

mVideoSurface.setSurfaceTextureListener(this); 

をしてから実装します

@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"); 
     } 
    } 

    @Override 
    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { 
     Log.v(TAG, "onSurfaceTextureSizeChanged"); 
    } 

    @Override 
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { 
     Log.v(TAG, "onSurfaceTextureDestroyed"); 
     if (mCodecManager != null) { 
      mCodecManager.cleanSurface(); 
      mCodecManager = null; 
     } 

     return false; 
    } 

    @Override 
    public void onSurfaceTextureUpdated(SurfaceTexture surface) { 
     final Bitmap image = mVideoSurface.getBitmap(); 
     //Do whatever you want with the bitmap image here on every frame 
    } 

お役に立てれば!

関連する問題