【树莓派运行时间计算】

文章目录

  • 前言
  • 一、如何获取时刻?
  • 二、测试
    • 1.测试1
  • 总结
    • 1.猜想1:
    • 2.猜想2:
    • 3.猜想3:
    • 4. 猜想4:


前言

提示:这里可以添加本文要记录的大概内容:

为了计算树莓派运行速度,需要找函数来实际测试


提示:以下是本篇文章正文内容,下面案例可供参考

一、如何获取时刻?

【树莓派运行时间计算】_第1张图片

opencv t提供的

m_lastTime=doublegetTickConunt();

Qt
提供的

QTime time;
time.start();
Function();
qDebug() << time.elapsed();
#include 
#include 
#include 

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QElapsedTimer timer;
    timer.start(); // 开始计时

    // 在这里放入你想要测量执行时间的代码段

    qint64 elapsed = timer.elapsed(); // 获取经过的毫秒数
    qDebug() << "Running time:" << elapsed << "milliseconds";

    return a.exec();
}

二、测试

1.测试1

·**结论: QElapsedTimer go_timer_qe; //这个方法测试结果差不多 QTime go_timer; //这个方法测试的数据有严重问题,有空再查明原因**
代码如下(示例):

  qDebug() << go_timer_count ;

    if(go_timer_count==0)
    {
        go_timer_count++;
        go_timer_qe.start();
        time_Start = clock();
    }
    else
    {
         go_timer_count=0;
         qint64 elapsed = go_timer_qe.elapsed(); // 获取经过的毫秒数
         qDebug() << "Running time:" << elapsed << "milliseconds";

         time_End = clock();
         qDebug()<<(time_End - time_Start)<<"ms";
    }

结果

Running time: 30 milliseconds
16263 ms
0
1
Running time: 36 milliseconds
21306 ms     //错误数据
0
1
Running time: 26 milliseconds
23931 ms
0
1
Running time: 32 milliseconds
23546 ms
0
1
Running time: 37 milliseconds
19800 ms
0
1
Running time: 33 milliseconds
23835 ms
0
1
Running time: 33 milliseconds
23012 ms

总结

整体满足要求,可以开启新篇章。

1.猜想1:

不知道是不是定时器开启读取数据的原因,读取到的时间并不固定,还是说定时器本身就不准?

void MainWindow::readFarme()
{

    qDebug() << go_timer_count ;

    if(go_timer_count==0)
    {
        go_timer_count++;
        go_timer_qe.start();
       // time_Start = clock();


    }
    else
    {
         go_timer_count=0;
         qint64 elapsed = go_timer_qe.elapsed(); // 获取经过的毫秒数
         qDebug() << "Running time:" << elapsed << "milliseconds";

        // time_End = clock();
        // qDebug()<<(time_End - time_Start)<<"ms";
    }

    videocapture->read(matframe);
    //qDebug()<<"read frame...";
    if(bMethod)
    {

        cvtColor(matframe,tmp,COLOR_BGR2GRAY);
        Canny(tmp,dst,30,255);
    }
    else
    {
        dst =matframe.clone();

    }
    QPixmap qpixmap =Mat2QImage(dst);
    ui->label->setPixmap(qpixmap);



}
摄像头已打开
0
1
Running time: 516 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 21 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 17 milliseconds
0
1
Running time: 52 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 40 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 48 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 56 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 38 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 39 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 39 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 45 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 46 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 23 milliseconds
0
1
Running time: 24 milliseconds
0
1
Running time: 50 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 25 milliseconds
0
1
Running time: 24 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 48 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 25 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 40 milliseconds
0
1
Running time: 25 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 44 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 45 milliseconds
0
1
Running time: 52 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 38 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 40 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 48 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 39 milliseconds
0
1
Running time: 42 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 19 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 18 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 38 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 42 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 21 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 45 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 46 milliseconds
0
1
Running time: 18 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 47 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 45 milliseconds

2.猜想2:

摄像头已打开
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0

3.猜想3:

只开读取不显示,有一定影响,最小31 ,最大36

摄像头已打开
0
1
Running time: 489 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 33 milliseconds
0
08:23:00: The program has unexpectedly finished.

4. 猜想4:

有22-27 到41的,为什么会变小,难道是丢帧了,没有新的思路去研究?
dst =matframe.clone();
QPixmap qpixmap =Mat2QImage(dst);
ui->label->setPixmap(qpixmap);

摄像头已打开
0
1
Running time: 464 milliseconds
0
1
Running time: 22 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 49 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 40 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 44 milliseconds
0
1
Running time: 26 milliseconds
0
1
Running time: 42 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 32 milliseconds
0
08:33:09: Starting /home/pi/build-piqt_opencv_frame-Desktop-Debug/piqt_opencv_frame ...
摄像头已打开
0
1
Running time: 464 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 42 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 44 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 45 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 41 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 47 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 45 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 43 milliseconds
0
1
Running time: 29 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 38 milliseconds
0
1
Running time: 25 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 35 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 36 milliseconds
0
1
Running time: 27 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 50 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 37 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 31 milliseconds
0
1
Running time: 28 milliseconds
0
1
Running time: 33 milliseconds
0
1
Running time: 34 milliseconds
0
1
Running time: 21 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 32 milliseconds
0
1
Running time: 30 milliseconds
0
1
Running time: 39 milliseconds
0
1
Running time: 45 milliseconds
08:33:18: The program has unexpectedly finished.

你可能感兴趣的:(树莓派,树莓派运行时间计算)