Calling a bash script which uses python and opencv

조회 수: 8 (최근 30일)
Garoe Dorta
Garoe Dorta 2015년 4월 6일
답변: Erik 2015년 6월 4일
Hello,
I am trying to call a bash script on Ubuntu from Matlab. The script is itself a call to some python code in the form of
mpiexec -n 4 python $PY_SCRIPT_PATH $1 $2 $3 $4
The python code uses opencv, cuda, ...:
from sys import argv
import numpy as np
import time
import colorsys
import matplotlib.image as img
import matplotlib.pyplot as plt
import scipy.misc as scipy
import cv2
from Cheetah.Template import Template
import pycuda.compiler as nvcc
import pycuda.gpuarray as gpu
import pycuda.driver as cu
import pycuda.autoinit
from mpi4py import MPI
import math
The matlab terminal outputs
ImportError: /usr/lib/python2.7/dist-packages/cv2.so: undefined symbol: _ZTIN2cv5BRISKE
when I try to run the command. I tried reloading the .bashrc from the script to reset the environment variables with no luck. Does anyone know how to fix it?
Thanks

채택된 답변

Erik
Erik 2015년 6월 4일
i ran into a possible explanation from this SO question that references trying to import opencv:
dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: /opt/local/lib/libtiff.5.dylib
Referenced from: /opt/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib requires version 8.0.0 or later, but libtiff.5.dylib provides version 6.0.0
perhaps matlab executes system calls in some way that links against its old versions of libraries rather than the up to date ones you have installed?
you don't say whether the script runs fine when executed from a regular shell?
  댓글 수: 3
Erik
Erik 2015년 6월 4일
and do you use !, system(), unix(), or what? do these (or their outputs) differ?
Erik
Erik 2015년 6월 4일
did you get it running? i'm still trying to find a solution

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Erik
Erik 2015년 6월 4일
forcing matlab to use your preferred libtiff may work -- on osx:
$ DYLD_INSERT_LIBRARIES=/opt/local/lib/libtiff.5.dylib /Applications/MATLAB_R2015a.app/bin/matlab
on linux i think it's LD_PRELOAD

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by