ContentFull

PyCV on OSX

June 17th, 2009

PyCV is not supported on the Mac, and for that it is no surprise that it does not successfully compile. (These are hacks to make it work, not elegant solutions that are endorsed by the people who make PyCV) There were two major hurdles to making it work.

First is error that happens in the system_info.py which reads something like:

File "/sw/lib/python2.6/site-packages/numpy/distutils/cpuinfo.py"
line 79, in __getattr__
raise AttributeError,name
AttributeError: _has_sse2

To fix this you must edit the file system_info.py lines 107-114 to becoming:

#if cpu._has_sse2() and (dcomp  'mingw32' or dcomp  'gcc'):
extra_args = ['-arch x86_64', '-O3', '-msse2', '-mfpmath=sse', '-malign-double']
#    if get_gcc_version() >= '4.2':
extra_args.append('-mtune=generic')
#    else:
#        extra_args.append('-march=pentium4')
#        extra_args.append('-mtune=pentium4')
#info['extra_compiler_args'].extend(extra_args)}}}

This fixes the above error and also fixes an assembly error that happens later when compiling Blas bindings. The error:

error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’

The error is fixed by specifying the architecture of the computer, in this case x86_64.

Comments(0)

Matlab 2009a

May 29th, 2009

While Matlab, regardless of version, may be very slow on the Mac, the new version (which claims to be more Mac friendly) indeed has a small, but noticeable increase in performance.

Note: These values were generated on different processors and no attempt was made to see which one was ultimately faster. The idea was to see how, independently, each environment performed under complex matrix operations. All values are in seconds and averaged over 100 iterations.

Addition

MxM Matlab 2009a (Mac) Matlab 2008b (Mac) Matlab 2008b (Linux)
121 .05 .15 .015
961 .37 2.21 .22

Multiplication

MxM Matlab 2009a (Mac) Matlab 2008b (Mac) Matlab 2008b (Linux)
121 .06 .47 .061
961 2.14 12.19 2.49

QR

MxM Matlab 2009a (Mac) Matlab 2008b (Mac) Matlab 2008b (Linux)
121 .12 .57 .07
961 2.53 12.19 2.49

As you can see, the Mac version is finally starting to get numbers closer to that of Linux and Windows. With a better GUI (Cocoa based) I will finally stop writing C++ code for good.

Category: Programming

Comments(0)

Video playback in C++

April 20th, 2009

Video (as well as audio) are very hairy things in C++ usually forcing one to revert back to C if not even Assembly as the SDL audio library does. FFMPEG is no exception, it is designed fully intentionally with a C mentality, full of pointers and structures. I only do not complain more due to the fact that it is the only video playback library that works for C++. Getting started is very daunting and there is only about one tutorial that seems to work and even that is not very useful.

For the face tracking project I have been involved in I need something that could open a movie file and as quickly as possible return matrix of the current frame in RGB format. Since it took me two days to get the results I wanted I thought I would make it publicly available so other projects can benefit from it in the future. (I am sure I will be using it again!)

The code is documented and only depends on the FFMPEG library. There is some usage of the Eigen library, but that can be easily removed for it is only used at the last step of getting a frame (for creating the RGB matrix).

The code can be downloaded from here

Category: Programming

Comments(0)

Linear Algebra revisited

March 23rd, 2009

Two weeks ago I wrote on how different platforms perform when doing extensive matrix operations. Today I discovered that the iPhone is actually faster than previously thought. Using the command “-mno-thumb” (which enables the usage of special float point instructions) one can easily get improvements in the 2x region! This means that the iPhone performs about 1/4 the speed of a slightly old MacBook Pro.

For those involved in scientifically programming, this should indicate that any reasonable algorithm can not only be run on an iPhone, but it will only slow down by a factor of 4, great given the fact that the phone is many more times smaller than a PC.

Category: Programming

Comments(0)

Linear Algebra on different platforms

March 23rd, 2009

In a recent project which required to be cross-platform I had the fun experience of seeing how different each platform is at doing basic (and not so basic) matrix operations. The current project had been originally written in Matlab and I have since then rewritten the project in C++ so that it could be enjoyed on Mac, Linux and iPhone. Clearly all three machines (MacBook Pro, Dell, and iPhone) have different processing speeds, however,  what I discovered is that for some things speed alone is not the issue.

Note: These values were generated on different processors and no attempt was made to see which one was ultimately faster. The idea was to see how, independently, each environment performed under complex matrix operations. All values are in seconds and averaged over 100 iterations.

Addition

MxM Matlab(Mac) Matlab(Linux) C++(Mac) C++(iPhone)
121 .15 .015 .0003 .02
961 2.21 .22 .019 1.43

Multiplication

MxM Matlab(Mac) Matlab(Linux) C++(Mac) C++(iPhone)
121 .47 .061 .0007 .04
961 12.19 2.49 .0396 1.87

Off the bat, many things can be seen. First Matlab on a Mac is far slower than on Linux. This is because Matlab basically operates inside an emulator under OSX. Although I do not have a Windows machine, I have strong doubts that Matlab runs even fastest there. Second is the good news that one can technically outperform Matlab using C++. Using the http://eigen.tuxfamily.org/ library basic addition is actually not only faster than Matlab, but the iPhone outperforms Matlab running on OSX! Matlab should be ashamed that its product is slower on a Core 2 Duo than on a 500Mhz Arm chip.

QR

MxM Matlab(Mac) Matlab(Linux) C++(Mac) C++(iPhone)
121 .57 .07 .0076 .73
961 13.72 2.46 3.26 351.83

There are some clear shortcomings of Eigen as can be seen with the 351sec processing time on the iPhone. Having implemented QR by hand once I can attest that it is not the easiest thing to do, even if doing the text book method. There is clearly something fishy about Eigen’s implementation for it should technically be as fast Matlab (addition and multiplication times being proof of that).

It was in this last part that my project become unfeasible to be done on the iPhone. Although most of the math I needed was lightening fast, QR and those functions that depend on it became too torturous to be run and waited upon. Stay tuned to how the same platforms perform when doing quadrangulations!

Category: Programming

Comments(0)

cordiais saudaçoes… (cordial salutations…)

March 22nd, 2009

O assunto é música popular: discos, movemento de gente mais ou menos popular no ambiente de música idem. Possíveis entrevistas com alguns figurões da música brasileira etc. etc. De vez em quando, muito etcetera. Os discos serão comentados regularmente e, para não escapar à regra geral, receberão contaçoes veriáveis entre uma e três estrelinhas: mau, bom, excelente. Com isso pretende-se oferecer ao leitor uma orientação do que pode ou não ser tomada a sério. [...] Um ofício novo para quem assina (e escreve, pois não) estas notas de hoje em diante diárias. [...] E, no mais, como isso tudo foi apenas uma conversa inicial para apresentaoes mútuas, terminamos por aqui. Cordiais suadações… (By Torquato Neto)

“The topic is popular music: albums, movement of people more or less popular in the musical scene. Possible interviews with some of the figures of brazilian music etc. etc. One in awhile, many etcetera. The albums will be commented on regularly and, so not to escape the general rule, will be given varied scores between one and three stars: bad, good, excellent. The intent is to offer an orientation that could or not be taken seriously. [...] A new task for those who subscribe (and write, for sure) these notes from today onwards. [...] And on this note, since this was but an introductory conversation to introduce ourselves, we conclude here. Cordial salutations.”

In this manner Torquato begins his first journalistic experience. It was during this time that the first conflicts over whether Brazilians should sponsor their own culture over that of the much more stream lined American culture was emerging. Although the Beatles had already begun their fame and their popularity had already reached Brazil, many believed that foreign cultures were only promoting the demise of Brazil’s own unique culture. For this reason, perhaps, Torquato is apprehensive of how to judge popular music for in the promoting of Brazilian music or American music at least one reader would undoubtedly furious.

The purpose of this site, unfortunately, is not to comment on popular music. (Although comments on culture as a whole are not entirely out of question.) Rather the aim is note and annotate the experiences of living with the interest of machine learning and comparative (literature) philosophies. The merging of these two seemingly independent interests hopefully will give rise to order in the theories and aesthetics in the logic.

Category: Comparative

Comments(0)

Crafted and populated by André Cohen