【发布时间】:2017-04-16 00:49:19
【问题描述】:
我必须在我的 C++ 应用程序中从 DJI Phantom 3 摄像头获取实时流视频,以便在 OpenCV 中进行计算机视觉处理。
首先,我尝试在这个回调中通过 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流连接的东西,可以使用OpenCV在我的最终C++应用程序中轻松获取数据videoCapture。但是,libstreaming 使用自己的surfaceView。换句话说,我必须将 libstreaming surfaceView 与 DJI Drone 的 videoSurface 链接起来。我真的是 Android 新手,所以不知道该怎么做。
总而言之,这是正确的方法吗?有人有更好的主意吗?提前致谢
【问题讨论】:
标签: android c++ ffmpeg dji-sdk libstreaming