DeepMatching 在ubuntu 16.04安装配置


    • 安装
      • 错误1:“找不到/usr/lib64/atlas/libsatlas.so文件”
      • 错误2:关于gfortran的未定义的引用
      • 错误3:一堆库不太对,如usr/lib/x86_64-linux-gnu/libjpeg.a
      • so最终我用的是下面版本
    • 运行


DeepMatching主页:http://lear.inrialpes.fr/src/deepmatching/

安装

下载安装了其中的CPU版本:
Version 1.2.2
1. 下载压缩包:
deepmatching_1.2.2.zip
2. 解压开后

make clean all

一直出现错误:
下面是具体错误,最终可以使用的makefile版本往下拖拖拖。。。

错误1:“找不到/usr/lib64/atlas/libsatlas.so文件”

所以,借鉴大家的智慧:
参考:https://blog.csdn.net/xczexcel/article/details/79574740
http://xiuyuliang.cn/2014/12/05/deepmatching/

#先装库:(一般都装过)
sudo apt-get install libatlas_dev
sudo apt-get install libatlas_base_dev

#然后在路径 /usr/lib下:

sudo ld -shared -o libsatlas.so --whole-archive libatlas.a liblapack.a --no-whole-archive libf77blas.a libcblas.a

#修改 makefile 文件:
LAPACKLDFLAGS=/usr/lib64/atlas/libsatlas.so
改为LAPACKLDFLAGS=/usr/lib/libsatlas.so

错误2:关于gfortran的未定义的引用

#修改第24行,改为静态编译
    all: deepmatching 改为 all: deepmatching-static   

错误3:一堆库不太对,如usr/lib/x86_64-linux-gnu/libjpeg.a

修改makefile大概13行

改为:
STATICLAPACKLDFLAGS=-fPIC -Wall -g -fopenmp -static -static-libstdc++ /usr/lib/x86_64-linux-gnu/libjpeg.a /usr/lib/x86_64-linux-gnu/libpng.a /usr/lib/x86_64-linux-gnu/libz.a /usr/lib/libblas.a /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a /usr/lib/gcc/x86_64-linux-gnu/5/libquadmath.a

so最终我用的是下面版本

CC=g++

OS_NAME=$(shell uname -s)
ifeq ($(OS_NAME),Linux)
  LAPACKLDFLAGS=/usr/lib/libsatlas.so   # single-threaded blas
  #LAPACKLDFLAGS=/usr/lib64/atlas/libtatlas.so  # multi-threaded blas
  #BLAS_THREADING=-D MULTITHREADED_BLAS # remove this if wrong
endif
ifeq ($(OS_NAME),Darwin)  # Mac OS X
  LAPACKLDFLAGS=-framework Accelerate # for OS X
endif
LAPACKCFLAGS=-Dinteger=int $(BLAS_THREADING)
STATICLAPACKLDFLAGS=-fPIC -Wall -g -fopenmp -static -static-libstdc++ /usr/lib/x86_64-linux-gnu/libjpeg.a /usr/lib/x86_64-linux-gnu/libpng.a /usr/lib/x86_64-linux-gnu/libz.a /usr/lib/libblas.a /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a /usr/lib/gcc/x86_64-linux-gnu/5/libquadmath.a # statically linked version

CFLAGS= -fPIC -Wall -g -std=c++11 $(LAPACKCFLAGS) -fopenmp -DUSE_OPENMP -O3
LDFLAGS=-fPIC -Wall -g -ljpeg -lpng -fopenmp
CPYTHONFLAGS=-I/usr/include/python2.7
LIBFLAGS= -L/lib/x86_64-linux-gnu -lpng -ljpeg -lz -lblas
SOURCES := $(shell find . -name '*.cpp' ! -name 'deepmatching_matlab.cpp')
OBJ := $(SOURCES:%.cpp=%.o)
HEADERS := $(shell find . -name '*.h')


all: deepmatching-static

.cpp.o:  %.cpp %.h
    $(CC) -o $@ $(CFLAGS) -c $+

deepmatching: $(HEADERS) $(OBJ)
    $(CC) -o $@ $^ $(LDFLAGS) $(LAPACKLDFLAGS)

deepmatching-static: $(HEADERS) $(OBJ)
    $(CC) -o $@ $^ $(STATICLAPACKLDFLAGS)

python: $(HEADERS) $(OBJ)
#    swig -python $(CPYTHONFLAGS) deepmatching.i # not necessary, only do if you have swig compiler
    g++ $(CFLAGS) -c deepmatching_wrap.c $(CPYTHONFLAGS)
    g++ -shared $(LDFLAGS) $(LAPACKLDFLAGS) deepmatching_wrap.o $(OBJ) -o _deepmatching.so $(LIBFLAGS)

clean:
    rm -f $(OBJ) deepmatching *~ *.pyc .gdb_history deepmatching_wrap.o _deepmatching.so deepmatching.mex???

运行

matlab有libsatlas.so的各种问题,最后使用的python版本的
按照README

make python

import deepmatching as dm
dm.deepmatching() # show some help about options
from PIL import Image
import numpy as np
img1 = np.array(Image.open('liberty1.png'))
img2 = np.array(Image.open('liberty2.png'))
matches = dm.deepmatching( img1, img2, '-downscale 2 -v' )

遇到了一点小问题,把原本deepmatching.py中116行

# if None in (im1,im2):
#   usage_python()
#   return
改为:
if im1 is None or im2 is None:
    usage_python()
    return

你可能感兴趣的:(python,linux)