kyamagu / mexplus

C++ Matlab MEX development kit.
Other
99 stars 49 forks source link

Issues when using mexplus to wrap the dc1394 driver #8

Open jbriales opened 9 years ago

jbriales commented 9 years ago

This question is a little bit specific. Anyway, I would like to tell you about it, just in case you could come up with some idea if you had some similar previous experience.

I'm using MEX functions of Matlab to exploit my own library (MRPT) for Computer Vision, working in Linux (Xubuntu 14.04). Among other functionalities my library reads a generic IEEE1394 camera through the dc1394 driver. When used independently of Matlab and MEX function, everything works fine. However, I found out that when calling the dc1394 library after including mex libraries something fails with the Ring Buffer of frames. The reconstruction of the problem or bug is:

  1. I call the camera setup method, with a Ring Buffer Size of N (say 15).
  2. I call dequeue and enqueue methods to get each frame, and I get the images correctly. The acquired frames id in the Ring Buffer increases with each call as expected, from 0.
  3. When the frame id completes a Ring cycle, going back to first (0, after N captures), the driver keeps waiting a new image arrival, but nothing ever happens.

It seems to me as if the frames in the Ring Buffer are not being set to ENQUEUED state after the enqueue method, but I have checked the error variable returned by all methods and no error is detected.

Since I'm using Linux, the driver implementation which is being used (as I saw through debugging) is that called Juju. The only thing I see is that everything seems to work correctly except for the very low level of Ring Buffer management which I think is done through Juju and/or Video1394, and that this only fails when I introduce the use of mexplus.

Are you aware of some kind of low-level issue which could arise due to some definition or incompatibility?

kyamagu commented 9 years ago

You might be loading Matlab's own libdc1394 instead of system's libdc1394 (and libraw1394). Use ldd tool to check if your dependency is correct. You would need to set LD_PRELOAD variable when launching Matlab. See README of mexopencv.

jbriales commented 9 years ago

I'm afraid that's not the reason. I have checked linked libraries and Matlab is always using the system ones (in fact, it hasn't its own libdc1394 and libraw1394 libraries).