microsoftarchive / KinectCommonBridge

Other
113 stars 43 forks source link

Failed loadLibrary KCBv2 in Matlab #16

Open ADNewbie opened 10 years ago

ADNewbie commented 10 years ago

I am trying to load KCBv2 into Matlab (2014a on Windows 8.1). The library compiles fine on MS VS2013, but fails using loadLibrary following the procedure here: Matlab Link Errors: Function pointer types are unsupported in structures extern "C" { found in file. C++ files are not supported. Use #ifdef __cplusplus to protect

Any suggestions?

mkostin commented 10 years ago

Hi @ADNewbie

The MATLAB® shared library interface supports C library routines only. ... The shared library interface does not support C++ classes or overloaded functions elements. However, you can apply one of the following methods to load a C++ library using loadlibrary

You could follow official workaround

The most simple approach is to use macro to wrap extern definition here just as it is suggested in the error message you've referred to.

#ifdef __cplusplus
extern "C" {
#endif
mkostin commented 10 years ago

Please let me know if this is still an issue.

ADNewbie commented 10 years ago

Hi mkostin, Apologies for the delayed reply. Yes, the issue still exist. I have tried various approaches including your proposal above for about a week, to no avail. Admittedly I have given up. Looks like I currently don't have the skill set to solve this. It is a shame, as this could be so useful to so many people.

cdowen commented 8 years ago

I wonder if it is too late. But I think I find a way to use Kinect v2 in matlab without KinectCommonBridge.

The "kinect.h" in Kinect SDK actually has a C interface. Just define CINTERFACE before including "kinect.h" then you can avoid the C++ part. Of course you still need to write some code to convert data between Kinect SDK and matlab matrix and compile a library so that the interface is properly warped. But it shouldn't be too difficult. After that, you can use loadlibrary to load the library and call the functions.

I already tried the initialization part and the Kinect light up. So I believe the rest should also work.

jmarkow commented 8 years ago

Hopefully I'm not too late on this but I've gotten it to work in MATLAB2015b on a Windows 8 machine,

https://github.com/jmarkow/kinect-acquisition

Not well documented but the k2 scripts in the helpers folder may help you get started.