[Imtoolkit-users] RE : RE : RE : IM C++ bindings to Lua
Brought to you by:
scuri
From: DONGIEUX-AKKA C. (S. D. SECURITE)
<chr...@sa...> - 2010-07-26 07:20:36
|
Thanks a lot Antonio, I'll try that. Chris. ________________________________________ De : Antonio Scuri [sc...@te...] Date d'envoi : vendredi 23 juillet 2010 18:10 À : 'IM discussion list.' Objet : Re: [Imtoolkit-users] RE : RE : IM C++ bindings to Lua Sure, here is a very simple implementation of a IM function in Lua: static int imluaKernelSobel(lua_State *L) { imlua_pushimage(L, imKernelSobel()); return 1; } static const luaL_reg imkernel_lib[] = { {"KernelSobel", imluaKernelSobel}, ... {NULL, NULL} }; ... luaL_register(L, NULL, imkernel_lib); ... Since you are using LuaBind I don't know how to help you, but maybe there is a way how to tell to LuaBind what kind of object is that. Best, scuri Here is another one: static int imluaImageClone (lua_State *L) { imImage* image = imlua_checkimage(L, 1); imImage *new_image = imImageClone(image); imlua_pushimage(L, new_image); return 1; } > -----Original Message----- > From: DONGIEUX-AKKA Christophe (SAGEM DEFENSE SECURITE) > [mailto:chr...@sa...] > Sent: sexta-feira, 23 de julho de 2010 10:15 > To: IM discussion list. > Subject: [Imtoolkit-users] RE : RE : IM C++ bindings to Lua > > Yes, that's exactly the problem, getImage returns the pointer as > userdata. > > Concerning imlua_pushimage, I saw that function in the header, but as I > am quite new to Lua, I don't know exactly how to use it. > Could you give me an example? > > Thanks a lot for your answers. > Chris. > > ________________________________________ > De : Antonio Scuri [sc...@te...] > Date d'envoi : vendredi 23 juillet 2010 14:28 > À : 'IM discussion list.' > Objet : Re: [Imtoolkit-users] RE : IM C++ bindings to Lua > > Yes, the problem is probably in getImage when return the imImage to > Lua. I > don't know LuaBind but it will probably return the imImage pointer as > an > userdata, and it should return as an imImage Lua object created by > ImLua. > Maybe it has some way to do that. > > ImLua actually exports functions in C to do that, see "imlua.h" and > imlua_pushimage. > > Best, > scuri > > > -----Original Message----- > > From: DONGIEUX-AKKA Christophe (SAGEM DEFENSE SECURITE) > > [mailto:chr...@sa...] > > Sent: sexta-feira, 23 de julho de 2010 03:42 > > To: IM discussion list. > > Subject: [Imtoolkit-users] RE : IM C++ bindings to Lua > > > > Hi Antonio, > > > > No, there is no inheritance from the imImage structure, I just wanted > > to say that I want to "improve" my software by adding image > treatments > > executed from Lua. > > I tried to do something like that, but I couldn't make it work, maybe > > you could give my some hints: > > > > // in C++ > > class Foo > > { > > public: > > Foo(); > > { > > p_img = imImageCreate( ... ); > > } > > imImage* getImage() > > { > > return p_img; > > } > > }; > > > > ... > > // I init the imLua libraries > > imlua_open( L); > > imlua_open_fftw( L); > > imlua_open_process( L); > > ... > > // I expose my Foo class to Lua with Luabind > > luabind::module( L ) [ > > > > luabind::class_< Foo>( "Foo" ) > > .def( luabind::constructor<>() ) > > .def( "getImage", &Foo::getImage) > > > > ]; > > ... > > // I execute the below Lua script > > luaL_dofile( pState, "testIM.lua" ); > > // this function returns an error : "std::runtime_error: 'Trying to > use > > unregistered class'" > > > > > > // the Lua script: > > f = Foo() > > img = f:getImage() > > im.ImageMakeBinary( img ) > > > > > > Do you have an idea of what is the problem and how could I do to > solve > > it? > > > > Regards, > > Chris. > > ________________________________________ > > De : Antonio Scuri [sc...@te...] > > Date d'envoi : jeudi 22 juillet 2010 18:51 > > À : 'IM discussion list.' > > Objet : Re: [Imtoolkit-users] IM C++ bindings to Lua > > > > Hi Chris, > > > > ImLua already expose the imImage structure to Lua. Are you saying > > that you created a class that inherit from the imImage structure in > C++ > > to extend it? > > > > Anyway, in ImLua the image data is still stored in C/C++, it is not > > duplicated in Lua. > > > > If you create algorithms in Lua by combining IM functions then the > > cost is very low. But to implement the algorithm in Lua accessing > image > > pixels it will be very slow. > > > > Best Regards, > > Antonio Scuri > > > > > -----Original Message----- > > > From: DONGIEUX-AKKA Christophe (SAGEM DEFENSE SECURITE) > > > [mailto:chr...@sa...] > > > Sent: quinta-feira, 22 de julho de 2010 10:03 > > > To: imt...@li... > > > Subject: [Imtoolkit-users] IM C++ bindings to Lua > > > > > > Hello, > > > > > > I am writing a C++ program to display some image processed videos. > My > > > program has some basic image processing functions available through > > IM, > > > but I'd like to extend it thanks to Lua/imLua. > > > IM is working in C++ and Lua, so I'd like to expose my imImage > > instance > > > in C++ to Lua, make some treatments, and then go back to C++ to > > display > > > it. > > > Do you think it's possible? (I already know how to do bindings > thanks > > > to Luabind) > > > Will the data buffer contained in the C++ part of the imImage > > instance > > > be copied to the Lua world, or will C++ and Lua (imLua) share the > > same > > > memory zone? > > > What CPU and memory will it cost compared to C++ only image > > processing > > > with imLua? > > > > > > Thanks in advance, > > > Chris. > > > # > > > " Ce courriel et les documents qui lui sont joints peuvent contenir > > des > > > informations confidentielles ou ayant un caractère privé. S'ils ne > > vous > > > sont > > > pas destinés, nous vous signalons qu'il est strictement interdit de > > les > > > divulguer, de les reproduire ou d'en utiliser de quelque manière > que > > ce > > > soit le contenu. Si ce message vous a été transmis par erreur, > merci > > > d'en > > > informer l'expéditeur et de supprimer immédiatement de votre > système > > > informatique ce courriel ainsi que tous les documents qui y sont > > > attachés." > > > > ****** > > > " This e-mail and any attached documents may contain confidential > or > > > proprietary information. If you are not the intended recipient, you > > are > > > notified that any dissemination, copying of this e-mail and any > > > attachments > > > thereto or use of their contents by any means whatsoever is > strictly > > > prohibited. If you have received this e-mail in error, please > advise > > > the > > > sender immediately and delete this e-mail and all attached > documents > > > from your computer system." > > > # > > > ------------------------------------------------------------------- > -- > > -- > > > ------- > > > This SF.net email is sponsored by Sprint > > > What will you do first with EVO, the first 4G phone? > > > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > > > _______________________________________________ > > > Imtoolkit-users mailing list > > > Imt...@li... > > > https://lists.sourceforge.net/lists/listinfo/imtoolkit-users > > > > > > --------------------------------------------------------------------- > -- > > ------- > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ > > Imtoolkit-users mailing list > > Imt...@li... > > https://lists.sourceforge.net/lists/listinfo/imtoolkit-users > > # > > " Ce courriel et les documents qui lui sont joints peuvent contenir > des > > informations confidentielles ou ayant un caractère privé. S'ils ne > vous > > sont > > pas destinés, nous vous signalons qu'il est strictement interdit de > les > > divulguer, de les reproduire ou d'en utiliser de quelque manière que > ce > > soit le contenu. Si ce message vous a été transmis par erreur, merci > > d'en > > informer l'expéditeur et de supprimer immédiatement de votre système > > informatique ce courriel ainsi que tous les documents qui y sont > > attachés." > > ****** > > " This e-mail and any attached documents may contain confidential or > > proprietary information. If you are not the intended recipient, you > are > > notified that any dissemination, copying of this e-mail and any > > attachments > > thereto or use of their contents by any means whatsoever is strictly > > prohibited. If you have received this e-mail in error, please advise > > the > > sender immediately and delete this e-mail and all attached documents > > from your computer system." > > # > > > > > > --------------------------------------------------------------------- > -- > > ------- > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ > > Imtoolkit-users mailing list > > Imt...@li... > > https://lists.sourceforge.net/lists/listinfo/imtoolkit-users > > > ----------------------------------------------------------------------- > ------- > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Imtoolkit-users mailing list > Imt...@li... > https://lists.sourceforge.net/lists/listinfo/imtoolkit-users > # > " Ce courriel et les documents qui lui sont joints peuvent contenir des > informations confidentielles ou ayant un caractère privé. S'ils ne vous > sont pas destinés, nous vous signalons qu'il est strictement interdit > de les divulguer, de les reproduire ou d'en utiliser de quelque manière > que ce soit le contenu. Si ce message vous a été transmis par erreur, > merci d'en informer l'expéditeur et de supprimer immédiatement de votre > système informatique ce courriel ainsi que tous les documents qui y > sont attachés." > > ****** > " This e-mail and any attached documents may contain confidential or > proprietary information. If you are not the intended recipient, you are > notified that any dissemination, copying of this e-mail and any > attachments thereto or use of their contents by any means whatsoever is > strictly prohibited. If you have received this e-mail in error, please > advise the sender immediately and delete this e-mail and all attached > documents from your computer system." > # > > > ----------------------------------------------------------------------- > ------- > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Imtoolkit-users mailing list > Imt...@li... > https://lists.sourceforge.net/lists/listinfo/imtoolkit-users ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Imtoolkit-users mailing list Imt...@li... https://lists.sourceforge.net/lists/listinfo/imtoolkit-users # " Ce courriel et les documents qui lui sont joints peuvent contenir des informations confidentielles ou ayant un caractère privé. S'ils ne vous sont pas destinés, nous vous signalons qu'il est strictement interdit de les divulguer, de les reproduire ou d'en utiliser de quelque manière que ce soit le contenu. Si ce message vous a été transmis par erreur, merci d'en informer l'expéditeur et de supprimer immédiatement de votre système informatique ce courriel ainsi que tous les documents qui y sont attachés." ****** " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, you are notified that any dissemination, copying of this e-mail and any attachments thereto or use of their contents by any means whatsoever is strictly prohibited. If you have received this e-mail in error, please advise the sender immediately and delete this e-mail and all attached documents from your computer system." # |