Re: Seeking help in Octave C++ API

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Seeking help in Octave C++ API

Carlo de Falco-2


> Il giorno 5 apr 2021, alle ore 09:06, Siddhartha Roy <[hidden email]> ha scritto:
>
> Hi,
> I have gone through that link. But unfortunately I am still unable to find the solution to calling imreconstruct function from a C++ code(my code may depend on the octave compiler but not depend on the octave script i.e. .m file).
> Please help me in this matter.
> with regards,
> Siddhartha Roy


I am not sure what you mean here ...

"imreconstruct" is a function from the image package,
to use it in your code you need the image package to be
installed and loaded and then you can invoke it the "interp.feval"
as shown in the manual.

BTW, I believe this discussion is better suited for the
help mailing list/discourse channel so please continue the thread there.

HTH,
c.



Reply | Threaded
Open this post in threaded view
|

Re: Seeking help in Octave C++ API

Carlo de Falco-2


> Il giorno 5 apr 2021, alle ore 12:11, Siddhartha Roy <[hidden email]> ha scritto:
>
> I have installed image package but I don't know how to load the package while using C++. I mean I know how to load it in octave (by running "pkg load image") but I don't know how to load it while using C++.

You are going over the same point again and again!
Once you embed the interpreter, you can run any octave language code from your C++ program using the "feval" method ...

so, if at the Octave prompt you would write

  pkg ("load", "image")

in C++ you would do something like

  octave_value_list ov;
  ov(0) = "load";
  ov(1) = "image";
  interp.feval ("pkg", ov, 0);

Please stop writing to the maintainers list, as I said the help list is better suited for this topic.
It would also be nice if you would try to adapt to the etiquette of the Octave lists and stop top posting.

c.



Reply | Threaded
Open this post in threaded view
|

Re: Seeking help in Octave C++ API

Siddhartha
Hi Sir,
Sorry for my mistake. As I am new in this platform so I am unable to adopt the etiquette so quickly but I will learn this definitely.
As I followed your instructions and wrote a demo code in C++. I am attaching the code below for your reference :

#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/interpreter.h>
#include <octave/toplev.h>
#include <octave/builtin-defun-decls.h>
#include <iostream>

int main() {
    string_vector argv (2);
    argv(0) = "embedded";
    argv(1) = "-q"; // quiet
    octave_main (2, argv.c_str_vec (), true);
    octave_value_list ov;
    ov(0) = "load";
    ov(1) = "image";
    interp.feval("pkg",ov,0);
    octave_value_list in;
    for (octave_idx_type i = 0; i < 2; i++)
        in(i) = octave_value (5 * (i + 2));
    octave_value_list out;
    out = interp.feval("imregionalmax",ov,0);    // as I want to use imregionalmax
    return 0;
}
I run this code in ubuntu 18.04 terminal by command : "mkoctfile --link-stand-alone file_nape.cpp -o file_name" but I got this error :

image.png
Please help me in this to execute.

with regards,
Siddhartha Roy
Associate Software Engineer
Vehere Interactive Pvt. Ltd.


On Mon, Apr 5, 2021 at 7:35 PM Carlo De Falco <[hidden email]> wrote:


> Il giorno 5 apr 2021, alle ore 12:11, Siddhartha Roy <[hidden email]> ha scritto:
>
> I have installed image package but I don't know how to load the package while using C++. I mean I know how to load it in octave (by running "pkg load image") but I don't know how to load it while using C++.

You are going over the same point again and again!
Once you embed the interpreter, you can run any octave language code from your C++ program using the "feval" method ...

so, if at the Octave prompt you would write

  pkg ("load", "image")

in C++ you would do something like

  octave_value_list ov;
  ov(0) = "load";
  ov(1) = "image";
  interp.feval ("pkg", ov, 0);

Please stop writing to the maintainers list, as I said the help list is better suited for this topic.
It would also be nice if you would try to adapt to the etiquette of the Octave lists and stop top posting.

c.



Reply | Threaded
Open this post in threaded view
|

Re: Seeking help in Octave C++ API

Andreas Weber-6
Am 06.04.21 um 08:02 schrieb Siddhartha Roy:
> Sorry for my mistake. As I am new in this platform so I am unable to
> adopt the etiquette so quickly but I will learn this definitely.

You are still top posting with fullquote below instead of bottom posting
or interleaved posting.

> ...
>      string_vector argv (2);
>      argv(0) = "embedded";
>      argv(1) = "-q"; // quiet
>      octave_main (2, argv.c_str_vec (), true);

This looks like copied from an GNU Octave 4.x example

>      interp.feval("pkg",ov,0);
This looks like a line from GNU Octave 6.x

Which version of GNU Octave do you want to use?
-- Andy