NEW: release DJI Payload-SDK version 3.4
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
Binary file not shown.
@ -43,6 +43,7 @@ DJICameraStreamDecoder::DJICameraStreamDecoder()
|
||||
cbThreadStatus(-1),
|
||||
cb(nullptr),
|
||||
cbUserParam(nullptr),
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
pCodecCtx(nullptr),
|
||||
pCodec(nullptr),
|
||||
pCodecParserCtx(nullptr),
|
||||
@ -50,6 +51,7 @@ DJICameraStreamDecoder::DJICameraStreamDecoder()
|
||||
pFrameYUV(nullptr),
|
||||
pFrameRGB(nullptr),
|
||||
rgbBuf(nullptr),
|
||||
#endif
|
||||
bufSize(0)
|
||||
{
|
||||
pthread_mutex_init(&decodemutex, nullptr);
|
||||
@ -75,6 +77,7 @@ bool DJICameraStreamDecoder::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
avcodec_register_all();
|
||||
pCodecCtx = avcodec_alloc_context3(nullptr);
|
||||
if (!pCodecCtx) {
|
||||
@ -105,8 +108,8 @@ bool DJICameraStreamDecoder::init()
|
||||
pSwsCtx = nullptr;
|
||||
|
||||
pCodecCtx->flags2 |= AV_CODEC_FLAG2_SHOW_ALL;
|
||||
#endif
|
||||
initSuccess = true;
|
||||
|
||||
pthread_mutex_unlock(&decodemutex);
|
||||
|
||||
return true;
|
||||
@ -117,6 +120,8 @@ void DJICameraStreamDecoder::cleanup()
|
||||
pthread_mutex_lock(&decodemutex);
|
||||
|
||||
initSuccess = false;
|
||||
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
if (nullptr != pSwsCtx) {
|
||||
sws_freeContext(pSwsCtx);
|
||||
pSwsCtx = nullptr;
|
||||
@ -151,7 +156,7 @@ void DJICameraStreamDecoder::cleanup()
|
||||
av_free(pFrameRGB);
|
||||
pFrameRGB = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
pthread_mutex_unlock(&decodemutex);
|
||||
}
|
||||
|
||||
@ -184,6 +189,7 @@ void DJICameraStreamDecoder::decodeBuffer(const uint8_t *buf, int bufLen)
|
||||
int remainingLen = bufLen;
|
||||
int processedLen = 0;
|
||||
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
AVPacket pkt;
|
||||
av_init_packet(&pkt);
|
||||
pthread_mutex_lock(&decodemutex);
|
||||
@ -238,6 +244,7 @@ void DJICameraStreamDecoder::decodeBuffer(const uint8_t *buf, int bufLen)
|
||||
}
|
||||
pthread_mutex_unlock(&decodemutex);
|
||||
av_free_packet(&pkt);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DJICameraStreamDecoder::registerCallback(CameraImageCallback f, void *param)
|
||||
|
@ -29,9 +29,11 @@
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
extern "C" {
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "pthread.h"
|
||||
@ -66,6 +68,8 @@ private:
|
||||
void *cbUserParam;
|
||||
|
||||
pthread_mutex_t decodemutex;
|
||||
|
||||
#ifdef FFMPEG_INSTALLED
|
||||
AVCodecContext *pCodecCtx;
|
||||
AVCodec *pCodec;
|
||||
AVCodecParserContext *pCodecParserCtx;
|
||||
@ -73,6 +77,7 @@ private:
|
||||
|
||||
AVFrame *pFrameYUV;
|
||||
AVFrame *pFrameRGB;
|
||||
#endif
|
||||
uint8_t *rgbBuf;
|
||||
size_t bufSize;
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ LiveviewSample::LiveviewSample()
|
||||
|
||||
returnCode = DjiLiveview_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("Liveview init failed");
|
||||
perror("Liveview init failed");
|
||||
}
|
||||
|
||||
streamDecoder = {
|
||||
@ -59,7 +59,7 @@ LiveviewSample::~LiveviewSample()
|
||||
|
||||
returnCode = DjiLiveview_Deinit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("Liveview deinit failed");
|
||||
perror("Liveview deinit failed");
|
||||
}
|
||||
|
||||
for (auto pair : streamDecoder) {
|
||||
|
@ -204,9 +204,17 @@ static void DjiUser_ShowRgbImageCallback(CameraRGBImage img, void *userData)
|
||||
cout << " x: " << faces[i].x;
|
||||
cout << " y: " << faces[i].y << endl;
|
||||
|
||||
#ifdef OPEN_CV_VERSION_3
|
||||
cv::rectangle(mat, cvPoint(faces[i].x, faces[i].y),
|
||||
cvPoint(faces[i].x + faces[i].width, faces[i].y + faces[i].height),
|
||||
Scalar(0, 0, 255), 2, 1, 0);
|
||||
#endif
|
||||
|
||||
#ifdef OPEN_CV_VERSION_4
|
||||
cv::rectangle(mat, cv::Point(faces[i].x, faces[i].y),
|
||||
cv::Point(faces[i].x + faces[i].width, faces[i].y + faces[i].height),
|
||||
Scalar(0, 0, 255), 2, 1, 0);
|
||||
#endif
|
||||
}
|
||||
imshow(name, mat);
|
||||
} else if (s_demoIndex == 3) {
|
||||
@ -265,8 +273,15 @@ static void DjiUser_ShowRgbImageCallback(CameraRGBImage img, void *userData)
|
||||
|
||||
int baseLine = 0;
|
||||
Size labelSize = getTextSize(label, FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
|
||||
#ifdef OPEN_CV_VERSION_3
|
||||
rectangle(mat, Rect(Point(xLeftBottom, yLeftBottom - labelSize.height),
|
||||
Size(labelSize.width, labelSize.height + baseLine)), Scalar(0, 255, 0), CV_FILLED);
|
||||
#endif
|
||||
|
||||
#ifdef OPEN_CV_VERSION_4
|
||||
rectangle(mat, Rect(Point(xLeftBottom, yLeftBottom - labelSize.height),
|
||||
Size(labelSize.width, labelSize.height + baseLine)), Scalar(0, 255, 0), cv::FILLED);
|
||||
#endif
|
||||
putText(mat, label, Point(xLeftBottom, yLeftBottom), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user