Re: [C++-sig] Conversion problem

2010-01-14 Thread Simon Pickles

Thanks Nicolas,

I learnt a lot from your way of doing it!

Simon

On 13/01/2010 11:17, Nicolas Lelong wrote:

Simon,

it seems that I wrapped the same videoinput library you're using.

I wrapped the getPixels the following way : python script is 
responsible of the memory allocation for pixels buffer (in a correctly 
sized string).


The getPixels function is wrapped as follows :

namespace {

  bool videoInput_getPixels(videoInput& input, int device_id, 
python::object memory_buffer)

  {
PyObject* pyObject = memory_buffer.ptr();
if (PyString_CheckExact(pyObject))
{
  Py_ssize_t string_size = PyString_Size(pyObject);
  if (string_size >= Py_ssize_t(input.getWidth(device_id)) * 
Py_ssize_t(input.getHeight(device_id)) * Py_ssize_t(3))

  {
unsigned char* pixels = reinterpret_castchar*>(PyString_AsString(pyObject));


return input.getPixels(device_id, pixels, false, false);
  }
}
return false;
  }

};

python::class_ klass("VideoInput");
klass.def("getPixels", videoInput_getPixels);

This certainly lacks some error checking for the actual 
'memory_buffer' parameter type, but can give you a clue.


HTH,

Nicolas

___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig



___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Boost and wxWidgets

2010-01-14 Thread Brian O'Kennedy
I suspect your problem is unrelated to boost.python. I've never used
wxWidgets, but a quick google suggests it should be initialised before being
used.

*http://docs.wxwidgets.org/stable/wx_appinifunctions.html*
  int wxEntry(int&
* argc*, wxChar ***argv*)

hope this helps,
 Brian


2010/1/13 Joan Carles Jimenez 

> Hi.
>
>  I am testing the following source code:
>
>
>
> 
> Canvas.h
> 
>
> #ifndef _CANVAS_H_
> #define _CANVAS_H_
>
> #include 
> #include "wx/wx.h"
>
> class CanvasFrame
> {
>protected:
>wxFrame* _frame;
>
>public:
>CanvasFrame(const std::string& pTitle);
>~CanvasFrame(void);
>
>void Plot(void);
> };
>
> #endif /* _CANVAS_H_ */
>
> --
> Canvas.cpp
> --
>
> #include 
> #include "canvas.h"
>
> CanvasFrame::CanvasFrame(const std::string& pTitle)
> {
>_frame = new wxFrame(NULL, wxID_ANY,
> wxString::FromAscii(pTitle.c_str()));
> }
>
> CanvasFrame::~CanvasFrame(void)
> {
>if(_frame) {
>delete _frame;
>}
> }
>
> void CanvasFrame::Plot(void)
> {
> }
>
> ---
> wrapper.cpp
> ---
>
> #include 
> #include "canvas.h"
>
> using namespace boost::python;
>
> BOOST_PYTHON_MODULE(canvas)
> {
>class_("CanvasFrame", init())
>.def("Plot", &CanvasFrame::Plot)
>;
> }
>
>
>
> And to generate the module "canvas.so" I execute:
>
>
>
> g++ -shared -g -I. -I/usr/include/python2.6 -lpython2.6 canvas.cpp
> wrapper.cpp /usr/lib64/libboost_python.so -fPIC `wx-config --cxxflags`
> `wx-config --libs` -o canvas.so
>
> "canvas.so" is generated without any problems but when I execute in the
> python console the next code:
>
>
>
> >>> import canvas
> >>> a = canvas.CanvasFrame('My Plot Window')
>
>
>
> I have the next errors:
>
>
>
> (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458: initialization
> assertion failed, use IA__g_type_init() prior to this function
>
> (process:3521): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (process:3521): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion
> `GDK_IS_DISPLAY (display)' failed
>
> (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458: initialization
> assertion failed, use IA__g_type_init() prior to this function
>
>
>
> And more, and more, and more. I have watched the examples of
>
> http://wiki.python.org/moin/boost.python/ExportingClasses
>
> but I have not seen any problem. They can help me? Thanks!
>
>
> P.D. Sorry for my english!
>
>
> ___
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Boost and wxWidgets

2010-01-14 Thread Joan Carles Jimenez
Thanks Brian, but do not work. The "canvas.so" is a static library not
an application. My info is:

openSuSE 11.2 64bits
boost 1.39
gcc-c++ 4.4
python 2.6.2




On Thu, 2010-01-14 at 08:53 +, Brian O'Kennedy wrote:
> I suspect your problem is unrelated to boost.python. I've never used
> wxWidgets, but a quick google suggests it should be initialised before
> being used. 
> 
> 
> http://docs.wxwidgets.org/stable/wx_appinifunctions.html
>   int wxEntry(int& argc, wxChar **argv)
> 
> 
> hope this helps, 
>  Brian
> 
> 
> 
> 2010/1/13 Joan Carles Jimenez 
> Hi.
> 
>  I am testing the following source code:
> 
> 
> 
> 
> Canvas.h
> 
> 
> #ifndef _CANVAS_H_
> #define _CANVAS_H_
> 
> #include 
> #include "wx/wx.h"
> 
> class CanvasFrame
> {
>protected:
>wxFrame* _frame;
> 
>public:
>CanvasFrame(const std::string& pTitle);
>~CanvasFrame(void);
> 
>void Plot(void);
> };
> 
> #endif /* _CANVAS_H_ */
> 
> --
> Canvas.cpp
> --
> 
> #include 
> #include "canvas.h"
> 
> CanvasFrame::CanvasFrame(const std::string& pTitle)
> {
>_frame = new wxFrame(NULL, wxID_ANY,
> wxString::FromAscii(pTitle.c_str()));
> }
> 
> CanvasFrame::~CanvasFrame(void)
> {
>if(_frame) {
>delete _frame;
>}
> }
> 
> void CanvasFrame::Plot(void)
> {
> }
> 
> ---
> wrapper.cpp
> ---
> 
> #include 
> #include "canvas.h"
> 
> using namespace boost::python;
> 
> BOOST_PYTHON_MODULE(canvas)
> {
>class_("CanvasFrame", init std::string&>())
>.def("Plot", &CanvasFrame::Plot)
>;
> }
> 
> 
> 
> And to generate the module "canvas.so" I execute:
> 
> 
> 
> g++ -shared -g -I. -I/usr/include/python2.6 -lpython2.6
> canvas.cpp
> wrapper.cpp /usr/lib64/libboost_python.so -fPIC `wx-config
> --cxxflags`
> `wx-config --libs` -o canvas.so
> 
> "canvas.so" is generated without any problems but when I
> execute in the
> python console the next code:
> 
> 
> 
> >>> import canvas
> >>> a = canvas.CanvasFrame('My Plot Window')
> 
> 
> 
> I have the next errors:
> 
> 
> 
> (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458:
> initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:3521): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
> 
> (process:3521): Gdk-CRITICAL **: gdk_cursor_new_for_display:
> assertion
> `GDK_IS_DISPLAY (display)' failed
> 
> (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458:
> initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> 
> 
> And more, and more, and more. I have watched the examples of
> 
> http://wiki.python.org/moin/boost.python/ExportingClasses
> 
> but I have not seen any problem. They can help me? Thanks!
> 
> 
> P.D. Sorry for my english!
> 
> 
> ___
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig
> 
> 
> ___
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig


___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Boost and wxWidgets

2010-01-14 Thread Hans Meine
Am Donnerstag, 14. Januar 2010 11:41:31 schrieb Joan Carles Jimenez:
> On Thu, 2010-01-14 at 08:53 +, Brian O'Kennedy wrote:
> > I suspect your problem is unrelated to boost.python. I've never used
> > wxWidgets, but a quick google suggests it should be initialised before
> > being used.
> [...]
> Thanks Brian, but do not work. The "canvas.so" is a static library not
> an application. 

Yes, but then you should initialize wx/gtk in the actual program using 
canvas.so, before calling the relevant canvas.so functions.

HTH,
  Hans
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Robotics Project Using Boost Python: OpenRAVE

2010-01-14 Thread Rosen Diankov
Dear Boost Python Developers,

We've been using boost.python for about a year now for a robotics
planning and simulation environment called OpenRAVE (developed by
Rosen Diankov):
http://openrave.programmingvision.com

We are very pleased with boost python and it has opened up many new
doors for development. I saw that Boost.Python has a projects page, so
if it openrave is deemed worth of getting mentioned on it, a possible
project description would be:

"OpenRAVE is an open-source, cross-platform, plugin-based robot
planning environment for autonomous robotics. Includes many services
like collision detection, physics, (inverse) kinematics, sensors,
robot controls, complex motion planners, grasping simulation,
manipulation planning, and a powerful python scripting environment
based on boost.python. Boost.Python allows OpenRAVE to export all its
complex C++ functionality into a scripting environment where
researchers can easily test new algorithms and dynamically control the
flow of execution."

thank you,
rosen,
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig