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

Can't make fakenect working with python wrappers #509

Closed
rguillome opened this issue Jun 9, 2017 · 3 comments
Closed

Can't make fakenect working with python wrappers #509

rguillome opened this issue Jun 9, 2017 · 3 comments

Comments

@rguillome
Copy link
Contributor

Hi,

Here is the output I get while trying to launch the python demo_cv_aysnc.py with fakenect. I specified the LD_PRELOAD and FAKENECT_PATH env var :

Traceback (most recent call last):
  File "demo_cv_async.py", line 2, in <module>
    import freenect
ImportError: /usr/local/lib/libfreenect_sync.so.0.5: undefined symbol: freenect_camera_to_world

I investigated a little bit since this wiki page presents a sample with this python demo, it should be my mistake ...

So I dig into the freenect import build from C libs with cython : the libfreenect_sync.h (and so on libfreenect_sync.c) declares a freenect_sync_camera_to_world and its implementation makes a call to freenect_camera_to_world. But fakenect.c which should fake the call to the real kinect I/O doesn't implements this method but moreover, the libfreenect.h doesn't declares this signature...

Why this method isn't overrided or just cloned under the fakenect.c source code?
I will try a fork but It should be nice to have your return BTW.

Regards,
Guillaume

@piedar
Copy link
Contributor

piedar commented Jun 12, 2017

The method freenect_sync_camera_to_world() is declared in freenect_registration.h, but your observation is correct: it has not yet been implemented in fakenect. A patch is always welcome!

@rguillome
Copy link
Contributor Author

rguillome commented Jun 12, 2017

I dig deeper and found that my first analysis was Wrong. Indeed, a patch has already been made adding the header lib_registration.h to the c_sync wrappers which is the synchronous bridge between python wrappers and the libfreenect (which by design is asynchronous).
With the LD_PRELOAD env var, the fakenect resulting libs only overrides a couple of target functions that make real call to the device. So freenect_camera_to_world should be offered by the usual libfreenect.so.

I finally expected a mistake in the libraries linking configuration.

Two tests that shows that having the same library name between the fakenect one and the usual one is (now?), a mistake :

± |debian U:2 ?:1 ✗|export LD_PRELOAD=

± |debian U:2 ?:1 ✗| → ldd freenect.so 
	linux-vdso.so.1 (0x00007ffda99b8000)
	libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f49e531f000)
	libfreenect.so.0.5 => /usr/local/lib/libfreenect.so.0.5 (0x00007f49e5110000)
	libfreenect_sync.so.0.5 => /usr/local/lib/libfreenect_sync.so.0.5 (0x00007f49e4f0c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f49e4cef000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f49e4950000)
	libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f49e492d000)
	/lib64/ld-linux-x86-64.so.2 (0x000055ea25885000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f49e4725000)

But of course, without the LD_PRELOAD, it expects the connected device...
So with the documented LD_PRELOAD :

± |debian U:2 ?:1 ✗|export LD_PRELOAD="$LIBFREENECT_SRC_PATH/libfreenect/build/lib/fakenect/libfreenect.so"

± |debian U:2 ?:1 ✗| → ldd freenect.so 
	linux-vdso.so.1 (0x00007fff5edbd000)
	LIBFREENECT_SRC_PATH/libfreenect/build/lib/fakenect/libfreenect.so (0x00007f5019c80000)
	libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f5019a37000)
	libfreenect_sync.so.0.5 => /usr/local/lib/libfreenect_sync.so.0.5 (0x00007f5019833000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5019616000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5019277000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5018f71000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5018d6d000)
	libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f5018d4c000)
	/lib64/ld-linux-x86-64.so.2 (0x00005606cedcd000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5018b44000)

As shown, the libfreenect.so.0.5 => /usr/local/lib/libfreenect.so.0.5 (0x00007f49e5110000) line disappear, probably by the fakenect lib overriding...

Altering the generated fakenect lib from libfreenect.so to libfreenect_fake.so does the job.
The change in the file fakenect/CMakeLists.txt (change the OUTPUT_NAME):

set_target_properties ( fakenect PROPERTIES
  VERSION ${PROJECT_VER}
  SOVERSION ${PROJECT_APIVER}
  OUTPUT_NAME freenect_fake)

and us the libfreenect_fake.so as the preloaded library with LD_PRELOAD.

I will create a patch tomorrow

@rguillome
Copy link
Contributor Author

This issue is corrected by the Pull request : #511

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

No branches or pull requests

2 participants