Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add (untested) SWIG interface file for Java bindings #427

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

floe
Copy link
Contributor

@floe floe commented Oct 15, 2015

Starting point for fixing #417, not yet finished & untested. /cc @jonnius @xlz

@floe floe added this to the 0.2 milestone Oct 15, 2015
@RyanGordon
Copy link
Contributor

I like this approach. I've been working to get this to compile a golang binding. There are just a couple of incompatibilities, but the biggest thing is this:

../include/libfreenect2/libfreenect2.hpp:76: Warning 325: Nested struct not currently supported (ColorCameraParams ignored)
../include/libfreenect2/libfreenect2.hpp:82: Warning 325: Nested struct not currently supported (IrCameraParams ignored)

It seems like Swig doesn't support converting nested struct's at this time. We could always flatten it, or use something else

@floe
Copy link
Contributor Author

floe commented Nov 29, 2015

@RyanGordon you can still pass the nested structs around as opaque objects, which should be sufficient for most use cases...

@RyanGordon
Copy link
Contributor

@floe That is what I hoped too, but when I go to compile the generated golang code, I end up with this:

swig -c++ -DLIBFREENECT2_API -intgosize 64 -go -cgo freenect2.i
../include/libfreenect2/libfreenect2.hpp:76: Warning 325: Nested struct not currently supported (ColorCameraParams ignored)
../include/libfreenect2/libfreenect2.hpp:82: Warning 325: Nested struct not currently supported (IrCameraParams ignored)
../include/libfreenect2/libfreenect2.hpp:94: Warning 325: Nested struct not currently supported (Config ignored)
cd freenect && go get
Undefined symbols for architecture x86_64:
  "libfreenect2::Registration::Registration(libfreenect2::Freenect2Device::IrCameraParams, libfreenect2::Freenect2Device::ColorCameraParams)", referenced from:
      __wrap_new_Registration_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Registration::~Registration()", referenced from:
      __wrap_delete_Registration_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::FrameListener::~FrameListener()", referenced from:
      SwigDirector_FrameListener::~SwigDirector_FrameListener() in freenect2_wrap.cxx.o
  "libfreenect2::PacketPipeline::PacketPipeline()", referenced from:
      __wrap_new_PacketPipeline_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2Device::~Freenect2Device()", referenced from:
      SwigDirector_Freenect2Device::~SwigDirector_Freenect2Device() in freenect2_wrap.cxx.o
  "libfreenect2::CpuPacketPipeline::CpuPacketPipeline()", referenced from:
      __wrap_new_CpuPacketPipeline_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDevice(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      __wrap_Freenect2_openDevice__SWIG_2_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDevice(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, libfreenect2::PacketPipeline const*)", referenced from:
      __wrap_Freenect2_openDevice__SWIG_3_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDevice(int)", referenced from:
      __wrap_Freenect2_openDevice__SWIG_0_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDevice(int, libfreenect2::PacketPipeline const*)", referenced from:
      __wrap_Freenect2_openDevice__SWIG_1_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::enumerateDevices()", referenced from:
      __wrap_Freenect2_enumerateDevices_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDefaultDevice(libfreenect2::PacketPipeline const*)", referenced from:
      __wrap_Freenect2_openDefaultDevice__SWIG_1_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::openDefaultDevice()", referenced from:
      __wrap_Freenect2_openDefaultDevice__SWIG_0_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::getDeviceSerialNumber(int)", referenced from:
      __wrap_Freenect2_getDeviceSerialNumber_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::getDefaultDeviceSerialNumber()", referenced from:
      __wrap_Freenect2_getDefaultDeviceSerialNumber_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Freenect2::Freenect2(void*)", referenced from:
      __wrap_new_Freenect2__SWIG_0_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
      __wrap_new_Freenect2__SWIG_1_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Registration::getPointXYZRGB(libfreenect2::Frame const*, libfreenect2::Frame const*, int, int, float&, float&, float&, float&) const", referenced from:
      __wrap_Registration_getPointXYZRGB_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Registration::apply(libfreenect2::Frame const*, libfreenect2::Frame const*, libfreenect2::Frame*, libfreenect2::Frame*, bool, libfreenect2::Frame*, int*) const", referenced from:
      __wrap_Registration_apply__SWIG_1_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
      __wrap_Registration_apply__SWIG_2_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
      __wrap_Registration_apply__SWIG_3_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
      __wrap_Registration_apply__SWIG_4_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "libfreenect2::Registration::apply(int, int, float, float&, float&) const", referenced from:
      __wrap_Registration_apply__SWIG_0_libfreenect2_a7e1cfaf56dc8f3a in freenect2_wrap.cxx.o
  "typeinfo for libfreenect2::FrameListener", referenced from:
      typeinfo for SwigDirector_FrameListener in freenect2_wrap.cxx.o
  "typeinfo for libfreenect2::Freenect2Device", referenced from:
      typeinfo for SwigDirector_Freenect2Device in freenect2_wrap.cxx.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/freenect] Error 2

@floe
Copy link
Contributor Author

floe commented Nov 30, 2015

Hm, this does look more like a linker problem to me? E.g. the fact that it can't find libfreenect2::Freenect2::enumerateDevices(). There have been some internal changes post-RC1, I haven't updated the SWIG file since. It may be possible that there's just some internal includes missing?

@RyanGordon RyanGordon mentioned this pull request Dec 2, 2015
@floe
Copy link
Contributor Author

floe commented Dec 3, 2015

#490 has been merged, do your Go bindings work now?

@RyanGordon
Copy link
Contributor

@floe Not quite, it looks like we use a variable called "type" in a couple of places, but that is a reserved symbol in Go and SWIG isn't smart enough to rename it. Should I make a separate PR for that change?

@floe
Copy link
Contributor Author

floe commented Dec 3, 2015

If it's part of a public interface, then it probably needs to be renamed. Otherwise, SWIG can also be told to explicitly rename certain identifiers.

@RyanGordon
Copy link
Contributor

It looks like the "type" argument on "OnNewFrame" is causing the trouble. I was able to rename it by adding "#define type _type" to the SWIG file.

I'm now getting a bunch of linking errors. I'll try working through some of them but not sure how far I'll get tonight.

@xlz
Copy link
Member

xlz commented Jan 25, 2016

In order for this to be merged, we need at least one test case in Go or Java.

@floe
Copy link
Contributor Author

floe commented Jan 26, 2016

I'd go with Java, as that would open up the route to Processing. Haven't done a lot with that recently, though.

@RyanGordon
Copy link
Contributor

I've tried to get it working in Go but I keep getting stuck - Converting to go with SWIG is pretty messy and doesn't seem to compile due to reversed keywords being used and other syntax problems that seem to be not straightforward to fix

@floe
Copy link
Contributor Author

floe commented Jan 27, 2016

Yeah, I think support for Go in SWIG is still pretty fresh, and Java is more mature. I'd suggest to get Java running first, and then see how other languages can be added.

@xlz
Copy link
Member

xlz commented Jan 29, 2016

@xlz xlz modified the milestones: 0.2, 0.3 Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants