当前位置:   article > 正文

rknn3588 rstp yolov5_rk3588 rtsp

rk3588 rtsp

目录

rknn3588官网

只有linux支持rtsp,代码:

Android支持h264裸流,不支持rtsp码流实时运算

笔者实现了Android rtsp yolov5实时检测 50帧

更换yolov5模型

ffmpegrtsp转264裸流

ndk下载:

格式RK_FORMAT_YCbCr_420_SP:

android系统rtsp读流进行算法识别

设置权限

依赖项:

返回 opencv yuv

rknn输入数据转换

这个是Ubuntu系统的:


rknn3588官网

rknn-toolkit2/rknpu2/examples/rknn_yolov5_demo/utils/mpp_decoder.cpp at 77b71094e08391c543d9c65fea5f7cf98cc16eee · airockchip/rknn-toolkit2 · GitHub

只有linux支持rtsp,代码:

if(ZLMEDIAKIT_LIBS)
      add_definitions(-DBUILD_VIDEO_RTSP)
 endif()

  1. #if defined(BUILD_VIDEO_RTSP)
  2.     process_video_rtsp(&app_ctx, video_name);
  3. #else
  4.     printf("rtsp no support\n");
  5. #endif

Android支持h264裸流,不支持rtsp码流实时运算

rknn-toolkit2/rknpu2/examples/rknn_yolov5_demo at 77b71094e08391c543d9c65fea5f7cf98cc16eee · airockchip/rknn-toolkit2 · GitHub

笔者实现了Android rtsp yolov5实时检测 50帧

下载地址:

https://download.csdn.net/download/jacke121/89197233

更换yolov5模型

代码地址:

cpp/postprocess.cc

label地址 类别数 anchors

  1. #define LABEL_NALE_TXT_PATH "/storage/emulated/0/Android/data/com.rockchip.gpadc.yolodemo/files/coco_2_labels.txt"
  2. static char *labels[OBJ_CLASS_NUM];
  3. int anchor0[6] = {25, 59, 18, 99, 57, 76};
  4. int anchor1[6] = {32, 164, 62, 217, 147, 165};
  5. int anchor2[6] = {85, 388, 179, 457, 421, 368};

用的模型是yolov5 relu版

ffmpegrtsp转264裸流

ffmpeg -i rtsp://admin:xxx@192.168.1.6:554/ch1/main/av_stream -vcodec copy -an -f h264 output.h264

ndk下载:

ffmpeg编译android平台-(ubuntu+ndkr16b+ffmpeg3.4.12)_android-ndk-r16b-CSDN博客

格式RK_FORMAT_YCbCr_420_SP:

  1. origin = wrapbuffer_fd(fd, width, height, RK_FORMAT_YCbCr_420_SP, width_stride, height_stride);
  2. src = wrapbuffer_fd(mpp_frame_fd, width, height, RK_FORMAT_YCbCr_420_SP, width_stride, height_stride);

android系统rtsp读流进行算法识别

设置权限

  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2. package="your.package.name">
  3. <!-- 网络通信权限 -->
  4. <uses-permission android:name="android.permission.INTERNET"/>
  5. <!-- 检查网络状态权限 -->
  6. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  7. <!-- 外部存储读写权限 -->
  8. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  9. <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  10. </manifest>

依赖项:

ffmpeg

mpp

返回 opencv yuv

FFmpegMPPDecoder/src/H264MPPDecoder.cpp at main · Done4/FFmpegMPPDecoder · GitHub

  1. RK_U32 h_stride = mpp_frame_get_hor_stride(frame);
  2. RK_U32 v_stride = mpp_frame_get_ver_stride(frame);
  3. MppBuffer buffer = mpp_frame_get_buffer(frame);
  4. cv::Mat yuvImg(height * 3/2, width, CV_8UC1);
  5. RK_U8 *base = (RK_U8 *)mpp_buffer_get_ptr(buffer);
  6. RK_U8 *base_c = base + h_stride * v_stride;
  7. int idx = 0;
  8. for (int i = 0; i < height; i++, base += h_stride, idx += width)
  9. {
  10. memcpy(yuvImg.data + idx, base, width);
  11. }
  12. for (int i = 0; i < height / 2; i++, base_c += h_stride, idx += width)
  13. {
  14. memcpy(yuvImg.data + idx, base_c, width);
  15. }

rknn输入数据转换

  1. g_rga_src = wrapbuffer_virtualaddr((void *)inDataRaw, img_width, img_height,
  2. RK_FORMAT_RGBA_8888);
  3. // convert color format and resize. RGA8888 -> RGB888
  4. ret = imresize(g_rga_src, g_rga_dst);

输入数据:

  1. #if ZERO_COPY
  2. #else
  3. rknn_input inputs[1];
  4. inputs[0].index = 0;
  5. inputs[0].type = RKNN_TENSOR_UINT8;
  6. inputs[0].size = m_in_width * m_in_height * m_in_channel;
  7. inputs[0].fmt = RKNN_TENSOR_NHWC;
  8. inputs[0].pass_through = 0;
  9. inputs[0].buf = g_rga_dst.vir_addr;
  10. #ifdef EVAL_TIME
  11. gettimeofday(&start_time, NULL);
  12. #endif
  13. rknn_inputs_set(ctx, 1, inputs);

这个是Ubuntu系统的:

rk3399pro硬解码(vpu,rtsp)使用 - 简书

https://download.csdn.net/download/weixin_44277869/87771089

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号