我GaussianBlur
在windows和ubuntu上使用,ubuntu的release模式的时间和windows的debug模式差不多?
在 vs2017 发布和调试模式下,我打开 /openmp /fp:fast /sdl- /permissive- /Gy /Oi /arch:AVX2 /O2 /Ot /MD。
并且 opencv3.4.0 在 ubuntu 16.04 中构建:
cmake -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_IPP=ON -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D WITH_NVCUVID=ON -D WITH_CUDA=ON -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS= OFF -D WITH_CSTRIPES=ON -D WITH_OPENCL=ON CMAKE_INSTALL_PREFIX=/usr/local/ ..
生成文件:
CC = g++
OPENCV_INC_PATH := ./opencv-3.4.0/include
OPENCV_LIB_PATH := ./opencv-3.4.0/build/lib
OBJS = edgeBlend.o
LIBS = edgeBlend.so
INCLUDE_PATH := -I ${OPENCV_INC_PATH}
LIB_PATH := -L ${OPENCV_LIB_PATH}
CXXFLAGS := ${INCLUDE_PATH} ${LIB_PATH} -Wall -O2 -std=c++11 -fPIC -march=native -ffast-math -fopenmp
LD_FLAGS := -lopencv_core -lz -lrt -ldl -lm -lpthread -ljpeg -ltiff -lpng -lopnecv_imgproc
all : $(LIB)
%.o : %.cpp
$(CC) $(CXXFLAGS) -c $< -o $(@)
$(LIB) : $(OBJS)
rm -f $(@)
$(CC) $^ -shared -o $(@) ${LIB_PATH} ${LD_FLAGS}
rm -f $(OBJS)
clean:
rm -f $(OBJS) $(LIB)
以下是我的代码,图像大小为 640*480*3:
double start = cv::getTickCount();
cv::GaussianBlur(img_cont, edge_gau, Size(3, 3), 0.8);
cv::GaussianBlur(img_back, img_gau, Size(3, 3), 0.8);
double end = cv::getTickCount();
double time = (end - start) / cv::getTickFrequency();
视窗:
调试耗时:0.02s
发布耗时:0.005s
Ubuntu:
发布成本时间:0.02s