add jetson hardware decoder

This commit is contained in:
Joe Dong
2023-09-07 16:46:59 +08:00
parent 43118e286a
commit ee8b077fdd
10 changed files with 199 additions and 33 deletions
@@ -0,0 +1,23 @@
#pragma once
#include "utils.h"
#include <opencv2/opencv.hpp>
#include "jpeg_decoder.h"
#include <NvJpegDecoder.h>
#include <NvUtils.h>
#include <NvV4l2Element.h>
#include <NvJpegDecoder.h>
#include <NvV4l2Element.h>
namespace orbbec_camera {
class JetsonNvJPEGDecoder : public JPEGDecoder {
public:
JetsonNvJPEGDecoder(int width, int height);
~JetsonNvJPEGDecoder() override;
bool decode(const std::shared_ptr<ob::ColorFrame>& frame, uint8_t* dest) override;
private:
NvJPEGDecoder* decoder_;
};
} // namespace orbbec_camera
@@ -5,18 +5,12 @@
#include "libobsensor/ObSensor.hpp"
namespace orbbec_camera {
enum HWDecoder {
ROCKCHIP_MPP = 0,
NV_JPEG_DEC = 1,
AMLOGIC_CODEC = 2,
AV_CODEC = 3,
};
class MjpegDecoder {
class JPEGDecoder {
public:
MjpegDecoder(int width, int height);
JPEGDecoder(int width, int height);
virtual ~MjpegDecoder();
virtual ~JPEGDecoder();
virtual bool decode(const std::shared_ptr<ob::ColorFrame> &frame, uint8_t *dest) = 0;
@@ -56,7 +56,7 @@
#include "orbbec_camera/dynamic_params.h"
#include "orbbec_camera/d2c_viewer.h"
#include "magic_enum/magic_enum.hpp"
#include "mjpeg_decoder.h"
#include "jpeg_decoder.h"
#define STREAM_NAME(sip) \
(static_cast<std::ostringstream&&>(std::ostringstream() \
@@ -412,7 +412,7 @@ class OBCameraNode {
std::deque<IMUData> imu_history_;
IMUData accel_data_{ACCEL, {0, 0, 0}, -1.0};
// mjpeg decoder
std::shared_ptr<MjpegDecoder> mjpeg_decoder_ = nullptr;
std::shared_ptr<JPEGDecoder> jpeg_decoder_ = nullptr;
uint8_t* rgb_buffer_ = nullptr;
bool is_color_frame_decoded_ = false;
};
@@ -1,6 +1,6 @@
#pragma once
#include "mjpeg_decoder.h"
#include "jpeg_decoder.h"
#include <rockchip/mpp_buffer.h>
#include <rockchip/mpp_err.h>
#include <rockchip/mpp_frame.h>
@@ -17,11 +17,11 @@
#define MPP_ALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
namespace orbbec_camera {
class RKMjpegDecoder : public MjpegDecoder {
class RKJPEGDecoder : public JPEGDecoder {
public:
RKMjpegDecoder(int width, int height);
RKJPEGDecoder(int width, int height);
~RKMjpegDecoder() override;
~RKJPEGDecoder() override;
bool decode(const std::shared_ptr<ob::ColorFrame>& frame, uint8_t* dest) override;