爲了在OpenCV中完成計算機視覺處理,我必須從我的C++應用程序中獲取來自DJI Phantom 3相機的實時流視頻。如何使用DJI Professional 3相機傳輸實時視頻?
首先,我試圖通過UDP套接字發送H264原始數據,這裏面回調:
mReceivedVideoDataCallBack = new CameraReceivedVideoDataCallback() {
@Override
public void onResult(byte[] videoBuffer, int size) {
//Here, I call a method from a class I created, that sends the buffer through UDP
if (gravar_trigger) controleVideo.enviarFrame(videoBuffer, size);
if (mCodecManager != null) mCodecManager.sendDataToDecoder(videoBuffer, size);
}
};
上述通信效果很好。但是,我無法在我的C++桌面應用程序中解碼UDP H264數據。我已經使用FFmpeg lib進行了測試,但無法使用我的UDP數據分配AVPacket
,以便使用avcodec_send_packet
和avcodec_receive_frame
進行解碼。我也有AVCodecContext
的問題,因爲我的UDP通信不是像RTSP這樣的流,它可以獲取有關其源的信息。因此,我必須改變我試圖解決問題的方式。
然後,我發現libstreaming,其中可以關聯到Android攝像機流到Wowza Server,創造一些像RTSP流連接,其中數據可以在我最後的C++應用程序輕鬆地使用OpenCV的videoCapture
獲得。但是,libstreaming使用它自己的surfaceView
。換句話說,我必須將libstreaming surfaceView
與DJI Drone的videoSurface
聯繫起來。我對Android非常陌生,所以不知道如何去做。
綜上所述,這是正確的做法嗎?有人有更好的主意?在此先感謝