|
From: | astie darmayantie |
Subject: | Re: Adding .m into javaoctave |
Date: | Wed, 22 Aug 2012 15:53:25 +0700 |
yes, it already works just now! i might be mistype the code last time and suppose that i had to install the image package everytime i re-compile the program.
well, now the question is.. if it calls my normal installation path, why it could not read my function? as it's located on my image package directory?
and i try to call my function using load like this:octave.eval("pkg load image;");
OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
octave.eval("load /home/astie/octave/image-1.0.15/mainProg2108.m;");octave.eval("im=rgb2gray(i);");
octave.eval("i=imread('/home/astie/thesis/octave/maple.png');");
octave.eval("i=i(:,:,1);");and i got this error :
octave.eval("res=mainProg2108(i);");
OctaveDouble res = octave.get(OctaveDouble.class, "res");
octave.close();
Double result = res.get(1);
System.out.println(result);
Exception in thread "main" dk.ange.octave.exception.OctaveEvalException: load: /home/astie/octave/image-1.0.15/mainProg2108.m: inconsistent number of columns near line 2
why is it happening? because i search on the internet, there is someone who experience the same problem, but they have not tell what's causing this problem. thank you--2012/8/22 Martin Helm <address@hidden>
Am 22.08.2012 07:03, schrieb astie darmayantie:
javaoctave just calls your normal octave installation, unless you have> it said that the image package is not installed. can i install it like
> i do in octave?
> because seems like the javaoctave can not "remember" that i have
> installed the image package, so that i had to "remind" it every time i
> recompile.
>
> and here's my code :
> import dk.ange.octave.OctaveEngine;
> import dk.ange.octave.OctaveEngineFactory;
> import dk.ange.octave.type.OctaveDouble;
>
> public class testOctave {
>
> public static void main(String[] args){
> OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
> octave.eval("i=imread('/home/astie/thesis/octave/maple.png');");
> octave.eval("pkg install -forge image;");
> octave.eval("res=mainProg2108(i);");
> OctaveDouble res = octave.get(OctaveDouble.class, "res");
> octave.close();
> Double result = res.get(1);
> System.out.println(result);
>
>
> }
>
> }
>
> the mainProg2108 is a function i made. in this case, am i able to
> called it from javaoctave? if yes, where should i put the .m file?
> as in the actual octave i just put it on the directory of image package.
>
>
> Thank you.
>
> regards,
>
>
> astie
two or more of them and it calls the wrong one where no image package is
installed.
You should call
octave.eval("pkg load image"); //works perfectly well for me
instead of the octave.eval("pkg install -forge image;");
If that does not work please add a
octave.eval("pkg list")
and post the full terminal output of a run of your program.
Regards,
Astie Darmayantie
[Prev in Thread] | Current Thread | [Next in Thread] |