|
From: Xavier G. <gn...@ob...> - 2006-12-16 18:42:54
|
Hi, Each time I'm working on C++ codes using vector or valarray, I would like to be able to plot them. The problem is that there is no straitforward way to do that in C++. My goal is not to code a QT or GTK application but only to be able to plot 1D and 2D things from one given large C++ code without having to add lots of lines of codes in my code (let say it is intend to be used in debug phase). Questions : Is there a way to call pylab plot and imshow from a C++ code ? In this case, I do not care if we have to copy the array and it can be sl= ow. It would be a so nice feature to debug C++ image processing codes. Any example of code is welcome even they are not calling matplotlib but anthing else in python. Xavier. ps : In my codes, 2D images are stored as in a class derived from valarray (1D array) adding the size of the image along the 2 directions as private members. --=20 ############################################ Xavier Gnata CRAL - Observatoire de Lyon 9, avenue Charles Andr=E9 69561 Saint Genis Laval cedex Phone: +33 4 78 86 85 28 Fax: +33 4 78 86 83 86 E-mail: gn...@ob... ############################################=20 |
|
From: yardbird <yar...@ne...> - 2006-12-18 14:48:15
|
On Saturday 16 December 2006 19:42, Xavier Gnata wrote: > Hi, > > Each time I'm working on C++ codes using vector or valarray, I would > like to be able to plot them. > The problem is that there is no straitforward way to do that in C++. > My goal is not to code a QT or GTK application but only to be able to > plot 1D and 2D things from one given large C++ code without having to > add lots of lines of codes in my code (let say it is intend to be used > in debug phase). > > Questions : > Is there a way to call pylab plot and imshow from a C++ code ? > In this case, I do not care if we have to copy the array and it can be > slow. It would be a so nice feature to debug C++ image processing codes. > Any example of code is welcome even they are not calling matplotlib but > anthing else in python. > > Xavier. > ps : In my codes, 2D images are stored as in a class derived from > valarray (1D array) adding the size of the image along the 2 directions > as private members. Hi Xavier, you should really check out the Boost::Python libraries. They allow you, among other things, to expose your C++ container classes as python objects. I'm using them heavily in my project and I'm very satisfied. Check them out here: http://www.boost.org/libs/python/doc/ HTH, Francesco |
|
From: Christopher B. <Chr...@no...> - 2006-12-18 18:31:29
|
yardbird wrote: > On Saturday 16 December 2006 19:42, Xavier Gnata wrote: >> Each time I'm working on C++ codes using vector or valarray, I would >> like to be able to plot them. > you should really check out the Boost::Python libraries. They allow you, among > other things, to expose your C++ container classes as python objects. I'm > using them heavily in my project and I'm very satisfied. What this means is that you'd be using python to drive your C++ code, rather than using C++ code to drive a python/mpl code. In addition to Boost::Python, there are some other options to consider: pyrex, Cxx, SWIG. The other option is to use your C++ code to drive Python. This can be done by embedding a python interpreter in your C++ app. See the odfficial pyhton docs, and lots of other stuff online. You also might want to check out Elmer: http://elmer.sourceforge.net/ I've never used it, but it looks pretty cool. It's a tool that provides the infrastructure for calling python from C/C++. Honestly, though, I'd go with the first approach -- drive your C++ code from Python -- I think that in addition to making it easy to plot results, etc, you'll be able to write unit tests, etc in python, and even get a full scripting engine, which could turn out to be very useful.. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
|
From: Xavier G. <gn...@ob...> - 2006-12-19 13:16:32
|
Christopher Barker wrote: > yardbird wrote: > =20 >> On Saturday 16 December 2006 19:42, Xavier Gnata wrote: >> =20 > > =20 >>> Each time I'm working on C++ codes using vector or valarray, I would >>> like to be able to plot them. >>> =20 > > =20 >> you should really check out the Boost::Python libraries. They allow yo= u, among=20 >> other things, to expose your C++ container classes as python objects. = I'm=20 >> using them heavily in my project and I'm very satisfied. >> =20 > > What this means is that you'd be using python to drive your C++ code,=20 > rather than using C++ code to drive a python/mpl code. In addition to=20 > Boost::Python, there are some other options to consider: > > pyrex, Cxx, SWIG. > > The other option is to use your C++ code to drive Python. This can be=20 > done by embedding a python interpreter in your C++ app. See the=20 > odfficial pyhton docs, and lots of other stuff online. > > You also might want to check out Elmer: > > http://elmer.sourceforge.net/ > > I've never used it, but it looks pretty cool. It's a tool that provides= =20 > the infrastructure for calling python from C/C++. > > Honestly, though, I'd go with the first approach -- drive your C++ code= =20 > from Python -- I think that in addition to making it easy to plot=20 > results, etc, you'll be able to write unit tests, etc in python, and=20 > even get a full scripting engine, which could turn out to be very usefu= l.. > > -Chris > =20 Hi, I do agree that driving C++ from python looks easier thant driving python from C++. However, I really would like to inclue python code into my C++ code and not the opposite (I have special needs so I really have to do that). I'm going to have a look at embedding python. Has anyone experience with that? =20 Xavier --=20 ############################################ Xavier Gnata CRAL - Observatoire de Lyon 9, avenue Charles Andr=E9 69561 Saint Genis Laval cedex Phone: +33 4 78 86 85 28 Fax: +33 4 78 86 83 86 E-mail: gn...@ob... ############################################=20 |