fixed crash

This commit is contained in:
Joe Dong
2023-09-06 15:30:31 +08:00
parent 1f2c91abd3
commit 0cbcaf2f19
2 changed files with 14 additions and 7 deletions
+6 -2
View File
@@ -766,11 +766,15 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr<ob::Frame> &frame,
hw_decode = true;
#else
auto covert_frame = softwareDecodeColorFrame(frame);
video_frame = covert_frame->as<ob::ColorFrame>();
if(covert_frame) {
video_frame = covert_frame->as<ob::ColorFrame>();
}
#endif
} else {
auto covert_frame = softwareDecodeColorFrame(frame);
video_frame = covert_frame->as<ob::ColorFrame>();
if (covert_frame) {
video_frame = covert_frame->as<ob::ColorFrame>();
}
}
} else if (frame->type() == OB_FRAME_COLOR) {
video_frame = frame->as<ob::ColorFrame>();
+8 -5
View File
@@ -1,6 +1,7 @@
#include "orbbec_camera/rk_mpp_decoder.h"
#include <rclcpp/rclcpp.hpp>
#include <glog/logging.h>
#include <magic_enum/magic_enum.hpp>
namespace orbbec_camera {
@@ -118,11 +119,13 @@ bool RKMjpegDecoder::mppFrame2RGB(const MppFrame frame, uint8_t *data) {
memset(data, 0, width * height * 3);
auto buffer_ptr = mpp_buffer_get_ptr(buffer);
#if defined(USE_LIBYUV)
// use libyuv to convert yuv420sp to rgb888
libyuv::I420ToRGB24((const uint8_t *)buffer_ptr, width,
(const uint8_t *)buffer_ptr + width * height, width / 2,
(const uint8_t *)buffer_ptr + width * height * 5 / 4, width / 2, data,
width * 3, width, height);
auto *y = (const uint8_t *)buffer_ptr;
auto *uv = y + width * height;
int ret = libyuv::NV12ToRGB24(y, width, uv, width, data, width * 3, width, height);
if (ret) {
RCLCPP_ERROR_STREAM(rclcpp::get_logger("rk_mpp_decoder"), "libyuv error " << ret);
return false;
}
return true;
#else
rga_info_t src_info;