Saturday, 15 May 2010

c++ - Can't run an executable file in matlab with system(), but it works in command line -



c++ - Can't run an executable file in matlab with system(), but it works in command line -

i need run c++ executable file uses opencv library using scheme command in matlab. compile code create , successful. when run programme in command line works shown below.

lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg finding sift features... found 2596 features.

the problem when run matlab. next error happens:

>>system('lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg') finding sift features... error: unable load image tampered1.jpg lib/sift/bin/siftfeat -x -o tampered1.txt tampered1.jpg: aborted

the error happens in lib/sift/src/siftfeat.c in next piece of code:

fprintf( stderr, "finding sift features...\n" ); img = cvloadimage( img_file_name, 1 ); if( ! img ) fatal_error( "unable load image %s", img_file_name );

why happen? mean, if code runs in command line, why doesn't run scheme matlab command? doesn't matlab recognize cvloadimage function? using matlab r2014a , opencv-2.4.9. code copied pc , recompiled it. in original pc in code copied scheme command works.

you running system()-cmd in wrong folder. while phone call binary absolute path, path images relative. therefore, images need in folder, matlab executes system()-cmd. can check executing:

>> system('pwd') "folder/where/matlab/exec/your/cmd"

if output corresponds image location, should fine, otherwise have give programme absolute path this:

>> system('lib/sift/bin/siftfeat -x -o folder/to/your/txt/tampered1.txt folder/to/your/image/tampered1.jpg')

c++ matlab opencv

No comments:

Post a Comment