Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Execution time of OpenCvs net.forward() way too much(in minutes) than in windows

Hi All,

i executed a simple program on a arm based debian platform and also on windows. Though in windows, the time taken is not much but in debian its in minutes. Please find the details of the opencv version and the code responsible. Windows- OpenCV3.4.6 - Did not build them, installed the prebuild binaries Debian - OpenCV4.2 and since its needed for arm based i cross compiled on my linux system using the following cmake parameters cmake -D WITH_OPENMP=ON -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_TOOLCHAIN_FILE=../opencv/platforms/linux/arm-gnueabi.toolchain.cmake ../opencv/ i.m using arm-linux-gnueabihf-g++ (version 5.3.1) cross compiler

The code responsible is as follows:

int main()
{
Net net = cv::dnn::readNetFromCaffe(caffeConfigFile, caffeWeightFile);
Mat  frame = imread("untitled.png", IMREAD_COLOR); 
cv::Mat inputBlob = cv::dnn::blobFromImage(frame, 1.0, cv::Size(300, 300), cv::Scalar(104.0, 177.0, 123.0), false, 
false);
net.setInput(inputBlob, "data");
double t = cv::getTickCount();
cv::Mat detection = net.forward("detection_out");
tt_opencvDNN = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
printf("setInput is %f", tt_opencvDNN);
}

I get 0.9s when run on windows and 214.5 sec when run on debian OS. Not sure what is wrong. Is it something to do with the libs i have compiled with? Am i missing some compiler options?

Execution time of OpenCvs net.forward() way too much(in minutes) than in windows

Hi All,

i executed a simple program on a arm based debian platform and also on windows. Though in windows, the time taken is not much but in debian its in minutes. Please find the details of the opencv version and the code responsible. Windows- OpenCV3.4.6 - Did not build them, installed the prebuild binaries Debian - OpenCV4.2 and since its needed for arm based i cross compiled on my linux system using the following cmake parameters cmake -D WITH_OPENMP=ON -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_TOOLCHAIN_FILE=../opencv/platforms/linux/arm-gnueabi.toolchain.cmake ../opencv/ i.m using arm-linux-gnueabihf-g++ (version 5.3.1) cross compiler

The code responsible is as follows:

int main()
{
Net net = cv::dnn::readNetFromCaffe(caffeConfigFile, caffeWeightFile);
Mat  frame = imread("untitled.png", IMREAD_COLOR); 
cv::Mat inputBlob = cv::dnn::blobFromImage(frame, 1.0, cv::Size(300, 300), cv::Scalar(104.0, 177.0, 123.0), false, 
false);
net.setInput(inputBlob, "data");
double t = cv::getTickCount();
cv::Mat detection = net.forward("detection_out");
tt_opencvDNN = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
printf("setInput is %f", tt_opencvDNN);
}

I get 0.9s when run on windows and 214.5 sec when run on debian OS. Not sure what is wrong. Is it something to do with the libs i have compiled with? Am i missing some compiler options?

EDITTED

I recompiled the binaries using the compiler flag -DENABLE_NEON=ON and now the time reduced from 214 seconds to 22 seconds. Is there anything more i can add to make it faster?