Firefly开源社区

打印 上一主题 下一主题

[技术讨论] RK3588 opencv读取视频速度慢

18

积分

0

威望

0

贡献

技术小白

积分
18

RK3588 opencv读取视频速度慢

发表于 2023-11-13 08:55:23      浏览:1085 | 回复:1        打印      只看该作者   [复制链接] 楼主
问题描述及复现步骤:
我在RK3588上,用opencv读取和播放一个本地视频,发现用opencv读取帧数据耗时过长,每个帧基本上要0.28s左右,如下图所示:




然后我在笔记本电脑的ubuntu20.04虚拟机上执行了同样的代码,发现每个帧读取时间要少很多,大致在0.025s,如下图:





请问我如何解决这个问题?谢谢各位~




附:main.cpp源码

#include <opencv2/opencv.hpp>
#include <iostream>
#include <time.h>
using namespace cv;
using namespace std;

int main()
{
    clock_t start, end;
    clock_t t1, t2, t3, t4;

    double open_time, grab_time, read_time, show_time;

    namedWindow("example", WINDOW_AUTOSIZE);

    Mat mframe;
    VideoCapture vcapture;

    start = clock();
    bool openResult = vcapture.open("/home/zhuzhikai/QT_Programming/sample.mp4");
    if (!openResult)
    {
        cout << "The video cannot be opened!" << endl;
    }
    end = clock();
    open_time = (double)(end-start)/CLOCKS_PER_SEC;
    cout << "open_time = " << open_time << " ms " << endl;



    int num = 0;

    t1 = clock();

    while (vcapture.grab())
    {
        t2 = clock();
        grab_time = (double)(t2-t1)/CLOCKS_PER_SEC;

        vcapture >> mframe;

        t3 = clock();
        read_time = (double)(t3-t2)/CLOCKS_PER_SEC;

        if (mframe.size().width > 0 || mframe.size().height > 0)
        {
            imshow("example", mframe);
        }
        else
        {
            break;
        }

        if (waitKey(10) >= 0)
        {
            break;
        }

        t4 = clock();
        show_time = (double)(t4-t3)/CLOCKS_PER_SEC;

        cout << "Frame " << num << "  :   "
             << "grab_time = " << grab_time << " ms , "
             << "read_time = " << read_time << " ms , "
             << "show_time = " << show_time << " ms" << endl;
        num++;

        t1 = clock();
    }

    cout << "frame number = " << num << endl;

    return 0;
}



log.rar

604.8 KB, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

回复

使用道具 举报

6

积分

0

威望

0

贡献

吃瓜的群众

积分
6
发表于 昨天 18:28        只看该作者  沙发
你好,大佬,请问你解决了吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表