zoukankan      html  css  js  c++  java
  • OPENCV----在APP性能测试中的应用(一)

    应用项目:  APP的性能测试

    应用场景:  APP启动速度  视频开播速度 加载速度  等~~

    缘来:  基于APP日志UiAutomator的测试方案,测试结果不能直白且精确的反应,用户的体验

    改进: 通过手工操作或自动操作的方式录取视频,然后用图像处理的方式,来获取测试结果

    架构流程图:

    主要的核心点:

      视频分帧: 基于ffmpeg库 进行分帧

                  样例: ffmpeg  -hide_banner -i video.mp4 -an -vsync 0 .frames\%06d.png > null

           图片对比: 基于opencv库进行图片对比

           核心代码:

    int diff_count(const Mat& lmat, const Mat& rmat, int threshold) {
        int cols = lmat.cols;
        int rows = lmat.rows;
        int esize = (int)lmat.elemSize();
    
        if ( rmat.cols != cols || rmat.rows != rows || (int)rmat.elemSize() != esize ) {
            return -1;
        }
    
        int total = rows * cols;
        int dcount = 0;
    
        for ( int i = 0; i < total; i++ ) {
            uchar* lptr = lmat.data + i*esize;
            uchar* rptr = rmat.data + i*esize;
    
            int sum = 0;
            for ( int j = 0; j < esize; j++ ) {
                uchar lu = lptr[j];
                uchar ru = rptr[j];
    
                int tmp = lu > ru ? lu - ru : ru - lu;
                sum += tmp*tmp;
            }
    
            if ( sqrt(sum)/esize >= threshold ) {
                dcount++;
            }
        }
    
        return dcount;
    }
  • 相关阅读:
    CEAC认证
    CEAC认证
    java 和.net 开发平台的感受(菜鸟级)
    NBA现场直播在线看
    NBA现场直播在线看
    CEAC认证
    NBA现场直播在线看
    NBA现场直播在线看
    选择冒泡排序
    折半查找法
  • 原文地址:https://www.cnblogs.com/udld/p/7134186.html
Copyright © 2011-2022 走看看