KinectCommonBridge icon indicating copy to clipboard operation
KinectCommonBridge copied to clipboard

Failed loadLibrary KCBv2 in Matlab

Open ADNewbie opened this issue 10 years ago • 5 comments

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?

ADNewbie avatar Aug 27 '14 00:08 ADNewbie

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 avatar Aug 29 '14 12:08 mkostin

Please let me know if this is still an issue.

mkostin avatar Sep 19 '14 10:09 mkostin

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.

ADNewbie avatar Sep 21 '14 21:09 ADNewbie

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.

cdowen avatar Oct 21 '15 15:10 cdowen

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.

jmarkow avatar Feb 24 '16 16:02 jmarkow