1.makefile中的siftgpu_disable_devil = 1才能成功,不知道会有什么影响…
SLAM拾萃(3):siftGPU – 半闲居士 – 博客园 www.cnblogs.com
http://zhaoxuhui.top/blog/2017/05/15/Ubuntu%E4%B8%8BSiftGPU%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91.html zhaoxuhui.top
2.对于makefile调用siftgpu的库,网上没有介绍的,我采用了
DIR_INC = -I. -I../SiftGPU/src/SiftGPU -I/usr/include -I./opencv2 -I/usr/include/opencv -I/usr/include/opencv2 -I../glew-1.13.0/include -I../opencv-3.2.0/include
DIR_SRC = .
DIR_OBJ = ./build/debug
DIR_LIB = -L/usr/local/lib -L/usr/lib64 -L../opencv-3.2.0/build/lib -L../glew-1.13.0/lib -L../SiftGPU/bin
#LDFLAGS := -L../SiftGPU/bin/libsiftgpu.so EXECUTABLE := main
SRC = $(wildcard ${DIR_SRC}/*.cpp)
OBJ = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC}))
CC = g++
CFLAGS +=-D__STDC_CONSTANT_MACROS -fpermissive -g $(DIR_INC)
# CFLAGS +=-D__STDC_CONSTANT_MACROS $(DIR_INC) LIB = -lstdc++ ${DIR_LIB} -lX11 -lXi -lglut -lGL -lGLU -lm -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lavcodec -lavutil -lavformat -lsiftgpu -lopencv_imgcodecs
main:${OBJ}
$(CC) $(OBJ) $(LIB) -o $@
${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OBJ) $(BIN_PRG)
其中直接链接opencv,opengl,glut,glew,libsiftgpu.so即可,暂时还不是GPU,其中动态链接库的环境变量写入了ld.so.conf,
或者
1. 用ln将需要的so文件链接到/usr/lib或者/lib这两个默认的目录下边
ln -s /where/you/install/lib/*.so /usr/lib
sudo ldconfig
参考了
linux 缺少动态连接库.so–cannot open shared object file: No such file or directory www.cnblogs.com
测试代码
https://github.com/RichardYao1995/test_SiftGPU/blob/master/main.cpp github.com
更改siftgpu源码:
1.siftgpu.cpp里面含有
//process the image _pyramid->RunSIFT(_texImage);
//read back the timing _pyramid->GetPyramidTiming(_timing + 2);
//write output once if there is only one input if(_outpath[0] ){ SaveSIFT(_outpath); _outpath[0] = 0;}
//terminate the process when -exit is provided. if(GlobalUtil::_ExitAfterSIFT && GlobalUtil::_UseSiftGPUEX) exit(0);
指向siftpyramid.cpp的void SiftPyramid::RunSIFT(GLTexInput*input)函数,所以DetectKeypointsEX()是检测关键点的,但是pyramidgl.cpp,pyramidcl.cpp,pyramidcu.cpp都有,先看gl吧。。。cu是cuda 的,cl是opencl的。
programGLSL.h定义了一些关键点,梯度的变量,shaderman.cpp貌似计算??
这段关键点检测的代码封装的太好了。。需要再看看
void PyramidNaive::DetectKeypointsEX()
{
int i, j;
double t0, t, ts, t1, t2;
GLTexImage * tex, *aux;
FrameBufferObject fbo;
if(GlobalUtil::_timingS && GlobalUtil::_verbose)ts = CLOCK();
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
//extra gradient data required for visualization
int gradient_only_levels[2] = {param._level_min +1, param._level_max};
int n_gradient_only_level = GlobalUtil::_UseSiftGPUEX ? 2 : 1;
for ( i = _octave_min; i < _octave_min + _octave_num; i++)
{
for( j =0; j < n_gradient_only_level ; j++)
{
tex = GetLevelTexture(i, gradient_only_levels[j]);
tex->FitTexViewPort();
tex->AttachToFBO(0);
tex->BindTex();
ShaderMan::UseShaderGradientPass();
tex->DrawQuadMT4();
}
}
if(GlobalUtil::_timingS && GlobalUtil::_verbose)
{
glFinish();
t1 = CLOCK();
}
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
glDrawBuffers(2, buffers);
for ( i = _octave_min; i < _octave_min + _octave_num; i++)
{
if(GlobalUtil::_timingO)
{
t0 = CLOCK();
std::cout<<"#"<<(i + _down_sample_factor)<<"\t";
}
tex = GetBaseLevel(i) + 2;
aux = GetBaseLevel(i, DATA_KEYPOINT) +2;
aux->FitTexViewPort();
for( j = param._level_min + 2; j < param._level_max ; j++, aux++, tex++)
{
if(GlobalUtil::_timingL)t = CLOCK();
tex->AttachToFBO(0);
aux->AttachToFBO(1);
glActiveTexture(GL_TEXTURE0);
tex->BindTex();
glActiveTexture(GL_TEXTURE1);
(tex+1)->BindTex();
glActiveTexture(GL_TEXTURE2);
(tex-1)->BindTex();
ShaderMan::UseShaderKeypoint((tex+1)->GetTexID(), (tex-1)->GetTexID());
aux->DrawQuadMT8();
if(GlobalUtil::_timingL)
{
glFinish();
std::cout<<(CLOCK()-t)<<"\t";
}
tex->DetachFBO(0);
aux->DetachFBO(1);
}
if(GlobalUtil::_timingO)
{
std::cout<<"|\t"<<(CLOCK()-t0)<<"\n";
}
}
if(GlobalUtil::_timingS)
{
glFinish();
t2 = CLOCK();
if(GlobalUtil::_verbose)
std::cout <<"<Get Keypoints .. >\t"<<(t2-t1)<<"\n"
<<"<Extra Gradient.. >\t"<<(t1-ts)<<"\n";
}
UnloadProgram();
GLTexImage::UnbindMultiTex(3);
fbo.UnattachTex(GL_COLOR_ATTACHMENT1_EXT);
}