OPENCV----在APP性能测试中的应用

枕上从妨一夜睡,灯前读尽十年诗。这篇文章主要讲述OPENCV----在APP性能测试中的应用相关的知识,希望能为你提供帮助。
 
应用项目:    APP的性能测试
 
应用场景:   APP启动速度   视频开播速度 加载速度   等~~
 
缘来:   基于APP日志和UiAutomator的测试方案,测试结果不能直白且精确的反应,用户的体验
 
改进: 通过手工操作或自动操作的方式录取视频,然后用图像处理的方式,来获取测试结果
 
架构流程图:

OPENCV----在APP性能测试中的应用

文章图片

【OPENCV----在APP性能测试中的应用】 
主要的核心点:
视频分帧: 基于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; }

 

    推荐阅读