yolov5Ncnn占用资源

博客讲述了在设备上定时运行YoloV5目标检测程序时遇到的问题,即初始化失败导致系统出错。通过将初始化过程移到主页面并使YoloV5对象公共,解决了这一问题,确保了程序的稳定运行。这涉及到Android应用开发中的内存管理和程序设计优化。

定时运行yolov5检测程序。每次都调用以下过程,新建一个并初始化。

private static YoloV5Ncnn yolov5ncnn = new YoloV5Ncnn();
           boolean yolo_ret_init =      CONST.yolov5ncnn.Init(assetManager,CONST.strParam,CONST.strBin);
            if (!yolo_ret_init){
                Log.e("DetectUtil", "yolov5ncnn Init failed");
            }

设备运行一段时间后,系统出错退出或重启。

将此过程放主页面,yolov5ncnn改为public,运行转为正常。

2025-11-05 09:58:32.567 24027-24027 MediaCodecList com.tencent.yolov5ncnn D codecHandlesFormat: no format, so no extra checks 2025-11-05 09:58:32.572 24027-24085 CCodec com.tencent.yolov5ncnn D allocate(c2.android.avc.encoder) 2025-11-05 09:58:32.576 24027-24085 CCodec com.tencent.yolov5ncnn I setting up 'default' as default (vendor) store 2025-11-05 09:58:32.587 24027-24085 CCodec com.tencent.yolov5ncnn I Created component [c2.android.avc.encoder] for [c2.android.avc.encoder] 2025-11-05 09:58:32.590 24027-24085 CCodecConfig com.tencent.yolov5ncnn D read media type: video/avc 2025-11-05 09:58:32.600 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: algo.buffers.max-count.values 2025-11-05 09:58:32.601 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: output.subscribed-indices.values 2025-11-05 09:58:32.603 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: input.buffers.allocator-ids.values 2025-11-05 09:58:32.606 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: output.buffers.allocator-ids.values 2025-11-05 09:58:32.608 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: algo.buffers.allocator-ids.values 2025-11-05 09:58:32.611 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: output.buffers.pool-ids.values 2025-11-05 09:58:32.612 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D extent() != 1 for single value type: algo.buffers.pool-ids.values 2025-11-05 09:58:32.626 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D ignored struct field coding.gop.values 2025-11-05 09:58:32.627 24027-24085 ReflectedParamUpdater com.tencent.yolov5ncnn D ignored struct field coding.qp.values 2025-11-05 09:58:32.630 24027-24085 CCodecConfig com.tencent.yolov5ncnn D ignoring local param raw.color (0xc2001809) as it is already supported 2025-11-05 09:58:32.635 24027-24085 CCodecConfig com.tencent.yolov5ncnn I query failed after returning 13 values (BAD_INDEX) 2025-11-05 09:58:32.636 24027-24085 CCodecConfig com.tencent.yolov5ncnn D c2 config diff is Dict { c2::u32 algo.bitrate-mode.value = 3 c2::i32 coded.average-qp.value = 0 c2::u32 coded.bitrate.value = 64000 c2::float coded.frame-rate.value = 1 c2::u32 coded.picture-type.value = 0 c2::u32 coded.pl.level = 20492 c2::u32 coded.pl.profile = 20481 c2::u32 coded.vui.color.matrix = 0 c2::u32 coded.vui.color.primaries = 0 c2::u32 coded.vui.color.range = 0 c2::u32 coded.vui.color.transfer = 0 c2::u32 coding.intra-refresh.mode = 0 c2::float coding.intra-refresh.period = 0 c2::u32 coding.request-sync-frame.value = 0 c2::i64 coding.sync-frame-interval.value = 1000000 c2::u32 input.delay.value = 0 string input.media-type.value = "video/raw" string output.media-type.value = "video/avc" c2::u32 raw.color.matrix = 0 c2::u32 raw.color.primaries = 0 c2::u32 raw.color.range = 0 c2::u32 raw.color.transfer = 0 c2::u32 raw.size.height = 16 c2::u32 raw.size.width = 16 } 2025-11-05 09:58:32.636 24027-24085 ColorUtils com.tencent.yolov5ncnn W expected specified color aspects (0:0:0:0) 2025-11-05 09:58:32.643 24027-24027 MediaCodec com.tencent.yolov5ncnn E Media Quality Service not found. 2025-11-05 09:58:32.650 24027-24027 CodecSeeding com.tencent.yolov5ncnn D Seed: codec c2.android.avc.encoder, mediatype video/avc, overrideable 1 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp,0) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp-1080p,1.90) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp-720p,2.25) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp-540p,2.65) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp-480p,3.00) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-bpp-320x240,0) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-qpmax,-1) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-qpmax-1080p,45) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-qpmax-720p,43) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-qpmax-540p,42) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-target-qpmax-480p,38) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-bitrate-phaseout,1.75) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setTuningValue(vq-boost-missing-qp,0.20) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setFeatureValue(intra-refresh,0) 2025-11-05 09:58:32.650 24027-24027 CodecProperties com.tencent.yolov5ncnn D setFeatureValue(qp-bounds,0) 2025-11-05 09:58:32.651 24027-24027 CodecProperties com.tencent.yolov5ncnn D setFeatureValue(_vq_eligible.device,1) 2025-11-05 09:58:32.651 24027-24027 CodecProperties com.tencent.yolov5ncnn D setFeatureValue(_quality.target,1) 2025-11-05 09:58:32.651 24027-24027 CodecSeeding com.tencent.yolov5ncnn D Seed: codec c2.android.avc.encoder, mediatype video/avc, overrideable 0 2025-11-05 09:58:32.651 24027-24027 MediaCodec com.tencent.yolov5ncnn D shapeMediaFormat: deltas(1): AMessage(what = 0x00000000) = { int32_t android._encoding-quality-level = 0 } 2025-11-05 09:58:32.654 24027-24085 CCodec com.tencent.yolov5ncnn D [c2.android.avc.encoder] buffers are bound to CCodec for this session 2025-11-05 09:58:32.655 24027-24085 CCodecConfig com.tencent.yolov5ncnn D no c2 equivalents for color-format 2025-11-05 09:58:32.655 24027-24085 CCodecConfig com.tencent.yolov5ncnn D no c2 equivalents for flags 2025-11-05 09:58:32.655 24027-24085 CCodecConfig com.tencent.yolov5ncnn D no c2 equivalents for encoder 2025-11-05 09:58:32.663 24027-24085 CCodecConfig com.tencent.yolov5ncnn D c2 config diff is c2::u32 coded.bitrate.value = 3732480 c2::float coded.frame-rate.value = 15 c2::u32 raw.size.height = 648 c2::u32 raw.size.width = 1152 2025-11-05 09:58:32.664 24027-24085 ColorUtils com.tencent.yolov5ncnn W expected specified color aspects (0:0:0:0) 2025-11-05 09:58:32.672 24027-24085 BufferPoolAccessor2.0 com.tencent.yolov5ncnn D Destruction - bufferpool2 0x73cf1889f178 cached: 0/0M, 0/0% in use; allocs: 1, 0% recycled; transfers: 0, 0% unfetched 2025-11-05 09:58:32.672 24027-24085 CCodec com.tencent.yolov5ncnn D encoding statistics level = 0 2025-11-05 09:58:32.672 24027-24085 CCodec com.tencent.yolov5ncnn D setup formats input: AMessage(what = 0x00000000) = { Rect crop(0, 0, 1151, 647) int32_t color-standard = 0 int32_t color-range = 0 int32_t color-transfer = 0 int32_t frame-rate = 15 int32_t height = 648 int32_t intra-refresh-period = 0 string mime = "video/raw" int32_t video-qp-average = 0 int32_t width = 1152 int32_t android._dataspace = 0 int32_t using-sw-read-often = 1 int64_t android._C2MemoryUsage = 1 int32_t color-format = 21 int32_t android._color-format = 21 int32_t stride = 1152 int32_t slice-height = 648 } 2025-11-05 09:58:32.672 24027-24085 CCodec com.tencent.yolov5ncnn D setup formats output: AMessage(what = 0x00000000) = { int32_t bitrate = 3732480 int32_t bitrate-mode = 1 Rect crop(0, 0, 1151, 647) int32_t color-standard = 0 int32_t color-range = 0 int32_t color-transfer = 0 int32_t frame-rate = 15 int32_t height = 648 int32_t intra-refresh-period = 0 int32_t level = 4096 int32_t max-bitrate = 3732480 string mime = "video/avc" int32_t profile = 65536 int32_t video-qp-average = 0 int32_t width = 1152 } 2025-11-05 09:58:32.673 24027-24085 CCodecConfig com.tencent.yolov5ncnn I query failed after returning 14 values (BAD_INDEX) 2025-11-05 09:58:32.674 24027-24085 cent.yolov5ncnn com.tencent.yolov5ncnn E Failed to query component interface for required system resources: 6 2025-11-05 09:58:32.679 24027-24085 Codec2Client com.tencent.yolov5ncnn W query -- param skipped: index = 1342179345. 2025-11-05 09:58:32.679 24027-24085 Codec2Client com.tencent.yolov5ncnn W query -- param skipped: index = 2415921170. 2025-11-05 09:58:32.682 24027-24085 CCodecBufferChannel com.tencent.yolov5ncnn D [c2.android.avc.encoder#579] Using basic input block pool with poolID 1 => got 1 - OK (0) 2025-11-05 09:58:32.685 24027-24085 CCodecBufferChannel com.tencent.yolov5ncnn I [c2.android.avc.encoder#579] Created output block pool with allocatorID 16 => poolID 150 - OK 2025-11-05 09:58:32.686 24027-24085 CCodecBufferChannel com.tencent.yolov5ncnn D [c2.android.avc.encoder#579] Configured output block pool ids 150 => OK 2025-11-05 09:58:32.691 24027-24085 CCodecBuffers com.tencent.yolov5ncnn D [c2.android.avc.encoder#579:2D-BB-Input] updating image-data 2025-11-05 09:58:32.691 24027-24085 CCodecBuffers com.tencent.yolov5ncnn D [c2.android.avc.encoder#579:2D-BB-Input] updating stride = 1152, width: 1152, height: 648 2025-11-05 09:58:32.691 24027-24085 CCodecBuffers com.tencent.yolov5ncnn D [c2.android.avc.encoder#579:2D-BB-Input] updating vstride = 648 2025-11-05 09:58:32.756 24027-24027 MPEG4Writer com.tencent.yolov5ncnn D fpathconf _PC_FILESIZEBITS:64 2025-11-05 09:58:32.756 24027-24027 MPEG4Writer com.tencent.yolov5ncnn D File size limit set to 4503599627370495 bytes implicitly 2025-11-05 09:58:32.756 24027-24027 MPEG4Writer com.tencent.yolov5ncnn D MP4WtrCtrlHlpLooper Started 2025-11-05 09:58:32.758 24027-24027 MPEG4Writer com.tencent.yolov5ncnn I limits: 4503599627370495/0 bytes/us, bit rate: -1 bps and the estimated moov size 3192 bytes
最新发布
11-06
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值