[Motmot] motmot.cam_iface + isight + snowleopard
Laurent Perrinet
laurent.perrinet at gmail.com
Wed Feb 3 16:10:24 UTC 2010
Hi list!
I'm trying to grab frames from the iSight of a macbook. This was working well with pysight (*) but broke with the advent of Snow Leopard.
I was trying the motmot.cam_iface library since it appears to be implementing all I need. It seems to work in Leopard, but I thought I should share my adventures in trying to make it work on my platform (snow leopard) which drops support for Carbon and tries to push 64-bit forward.
First I tried the compiled version on:
http://code.astraw.com/libcamiface/download/libcamiface-0.5.9-Darwin.dmg
the /usr/bin/liveview-glut-quicktime and /usr/bin/liveview-glut-mega work just fine. they apparently run in 32-bit mode:
$ file /usr/bin/liveview-glut-mega
/usr/bin/liveview-glut-mega: Mach-O executable i386
now, I try to use the python interface. obviously, using macports or apple's 64-bit version says:
$ /opt/local/bin/python
Python 2.6.4 (r264:75706, Oct 31 2009, 11:56:27)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>> sys.maxint
9223372036854775807
>>> import motmot.cam_iface
>>> # Also the example in ../README.rst -- so keep in sync
... import pkg_resources
>>> import motmot.cam_iface.cam_iface_ctypes as cam_iface
import numpy as np
mode_num = 0
device_num = 0
num_buffers = 32
Could not open shared library for backend "libcam_iface_mega.dylib"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/motmot.cam_iface-0.5.0-py2.6.egg/motmot/cam_iface/cam_iface_ctypes.py", line 55, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libcam_iface_mega.dylib, 6): no suitable image found. Did find:
/usr/lib/libcam_iface_mega.dylib: mach-o, but wrong architecture
So I tried to compile myself (that is in 64-bit mode) using the latest code in http://github.com/motmot/libcamiface
::
sudo port install glew
mkdir build
cd build
cmake .. -DCMAKE_GENERATOR=Xcode
make
cpack
However I could not compile whatever combinaison I tried (except pretending I was on Leopard 32-bit in xCode... certainly a problem with carbon which is dicontinued in SL). I was clueless whether I would see any other alternative than switching back to Leopard?
So I gave a try to the python distributed by enthought : 'Enthought Python Distribution Academic Download' : http://www.enthought.com/products/edudownload.php , that is 'only' 32-bit... sounded like an asset to me...
it comes with all batteries inluded (numpy, scipy, matplotlib) + some bonus (mayavi, ...), but in particular easy_install:
sudo easy_install motmot.cam_iface
then in ipython:
import pkg_resources
import motmot.cam_iface.cam_iface_ctypes as cam_iface
import numpy as np
mode_num = 0
device_num = 0
num_buffers = 32
cam = cam_iface.Camera(device_num,num_buffers,mode_num)
cam.start_camera()
frame = np.asarray(cam.grab_next_frame_blocking())
print 'grabbed frame with shape %s'%(frame.shape,)
just ... works!
so the moral is: early optimization (= 64-bit) is evil!
you may see a dummy demo: http://www.incm.cnrs-mrs.fr/LaurentPerrinet/SimpleCellDemo
cheers,
Laurent
* http://livingcode.blogspot.com/2005/10/pysight-preview.html
----
Laurent Perrinet - INCM (UMR6193)/CNRS
http://incm.cnrs-mrs.fr/LaurentPerrinet
More information about the Motmot
mailing list