我正在使用Buildroot为Raspberry PI3构建自己的嵌入式Linux。这个操作系统将用于处理几个应用程序,其中一个应用程序执行基于OpenCV (v3.3.0)的对象检测。
我从Raspbian + Python开始,但是执行一个简单的示例需要很长时间,所以我决定使用优化的特性+ C++开发来设计自己的RTOS。
我认为通过这些优化,RPI + 1GB RAM的4核将处理这样的应用程序。问题是,即使有了这些东西,最简单的计算机视觉程序也要花费大量的时间。
PC与树莓PI3比较
这是一个简单的程序,我写它是为了了解程序每个部分的执行时间的数量级。
#include <stdio.h>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
using namespace cv;
using namespace std;
int main()
{
setUseOptimized(true);
clock_t t_access, t_proc, t_save, t_total;
// Access time.
t_access = clock();
Mat img0 = imread("img0.jpg", IMREAD_COLOR);// takes ~90ms
t_access = clock() - t_access;
// Processing time
t_proc = clock();
cvtColor(img0, img0, CV_BGR2GRAY);
blur(img0, img0, Size(9,9));// takes ~18ms
t_proc = clock() - t_proc;
// Saving time
t_save = clock();
imwrite("img1.jpg", img0);
t_save = clock() - t_save;
t_total = t_access + t_proc + t_save;
//printf("CLOCKS_PER_SEC = %d\n\n", CLOCKS_PER_SEC);
printf("(TEST 0) Total execution time\t %d cycles \t= %f ms!\n", t_total,((float)t_total)*1000./CLOCKS_PER_SEC);
printf("---->> Accessing in\t %d cycles \t= %f ms.\n", t_access,((float)t_access)*1000./CLOCKS_PER_SEC);
printf("---->> Processing in\t %d cycles \t= %f ms.\n", t_proc,((float)t_proc)*1000./CLOCKS_PER_SEC);
printf("---->> Saving in\t %d cycles \t= %f ms.\n", t_save,((float)t_save)*1000./CLOCKS_PER_SEC);
return 0;
}在i7 PC上执行的结果

在Raspberry PI (Buildroot生成OS )上的执行结果

正如你所看到的,两者有很大的不同。我需要的是优化每个细节,以便本例中的处理步骤以“接近”实时的方式在上进行,处理时间最长为15 is,而不是44 is。以下是我的问题:
发布于 2017-12-01 06:38:05
据我所知,你想要30到40英尺。对于您的I7:它是快速的,具有加速技术的音调,默认由itel启用。如果是覆盆子皮:嗯,我们喜欢它,但它是缓慢的,特别是在图像处理程序。
我如何优化我的操作系统,使其能够处理密集的计算应用程序,以及如何控制每个部分的优先级?
You should include some acceleration library for arm and re-compiled opencv again with those features enabled. 如何充分利用RPI3的4个核心来满足需求?
Paralleling your code so it could run on 4 cores 除了OpenCV,还有其他替代的可能性吗?
Ask your self first, what features do you need from OpenCV.我应该用C代替C++吗?
Changing language will not help you at all, stay and love C++. It is a beautiful language and very fast您推荐的硬件改进吗?
How about other board with mali GPU supported. So you could run opencv code directly on GPU, that will boost up your speed a lot.https://stackoverflow.com/questions/47578204
复制相似问题