<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ContentFull &#187; Programming</title>
	<atom:link href="http://www.contentfull.com/category/andre-2009/programming-current/feed" rel="self" type="application/rss+xml" />
	<link>http://www.contentfull.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 28 Dec 2009 16:57:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OpenCV 2.0 for OSX 10.6</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/opencv-2-0-for-osx-10-6</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/opencv-2-0-for-osx-10-6#comments</comments>
		<pubDate>Mon, 28 Dec 2009 16:57:42 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=506</guid>
		<description><![CDATA[There are plenty of people lost after discovering that OpenCV no longer fully functions with OSX 10.6. I have been working on making changes to update OpenCV 2.0 to work with 10.6 at 32/64 bit. This meant deprecating the use of Carbon (who uses that anymore anyway) and updating the Quicktime implementation which now must [...]]]></description>
			<content:encoded><![CDATA[<p>There are plenty of people lost after discovering that OpenCV no longer fully functions with <span class="caps">OSX</span> 10.6. I have been working on making changes to update OpenCV 2.0 to work with 10.6 at 32/64 bit. This meant deprecating the use of Carbon (who uses that anymore anyway) and updating the Quicktime implementation which now must use QTKit framework. Nick Butko was nice enough to have already implemented the Quicktime features, so it was a matter of just merging all the changes.</p>
<p>A fork of OpenCV 2.0 can be found at https://code.google.com/p/opencv-cocoa/ which has both the Cocoa and Quicktime updates. This is completely tested so use it with caution. Any help and suggestions are greatly appreciated.</p>
<p>Because Cocoa functions strictly inside a <span class="caps">MVC</span> framework there is a small change that you must make at initializing HighGUI that is found <a href="https://code.google.com/p/opencv-cocoa/wiki/UsingCocoaWithOpenCV" target="_blank">here</a>. It boils down to the fact that your code cannot run in the main thread, because Cocoa needs to run there. So to update any existing projects you must remove your code from the main function and place it in an auxiliary function which is called by cvInitSystem.</p>
<p>I have not yet made any benchmarks, so there is a chance that using Cocoa and QTKit at either 32 or 64 bit is not imperative for improving performance of your code. The main purpose is to allow the usage of other libraries in conjunction with OpenCV which already work at 64bit and may depend on Cocoa.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/opencv-2-0-for-osx-10-6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The reason Matlab persists</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/the-reason-matlab-persists</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/the-reason-matlab-persists#comments</comments>
		<pubDate>Sun, 27 Sep 2009 21:39:31 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Andre (2009-?)]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=500</guid>
		<description><![CDATA[While Matlab may not be in the cutting edge of computing, it does have one great qualitiy: amazing service. While I still have major gripes towards using it due to its slowness, antiquated programming language, and lack of Mac support, they did an honest effort in fixing a bug I filed. Within 24 hours someone [...]]]></description>
			<content:encoded><![CDATA[<p>While Matlab may not be in the cutting edge of computing, it does have one great qualitiy: amazing service. While I still have major gripes towards using it due to its slowness, antiquated programming language, and lack of Mac support, they did an honest effort in fixing a bug I filed. Within 24 hours someone contacted me asking for more information about the bug, and a week later I was told files were available that would fix the issue. While the fix didn&#8217;t fix much, and it was not in an easy to use patch, they did try. Never would an open source solution be so helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/the-reason-matlab-persists/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image warping with OpenCL</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/image-warping-with-opencl</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/image-warping-with-opencl#comments</comments>
		<pubDate>Tue, 08 Sep 2009 21:56:06 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=493</guid>
		<description><![CDATA[Finally image warping is no longer painful. In previous projects warping images was the slowest component in the algorithm. In face tracking for instance a good 1/3 to 2/3 of the time was just warping them. OpenCL finally changes all of this. With just a hundred lines you can warp +12,000 images (each 48&#215;48) in [...]]]></description>
			<content:encoded><![CDATA[<p>Finally image warping is no longer painful. In previous projects warping images was the slowest component in the algorithm. In face tracking for instance a good 1/3 to 2/3 of the time was just warping them. OpenCL finally changes all of this. With just a hundred lines you can warp +12,000 images (each 48&#215;48) in under 1 second! It could take up to a 1 sec to do 300 samples without <span class="caps">GPU</span> processing.</p>
<p>It is extremely easy to write OpenCL kernels (although there is room for improvement) and <a href="http://www.contentfull.com/?attachment_id=497">here</a> is the warping kernel I have written.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/image-warping-with-opencl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matlab and Snow Leopard Compatability</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/matlab-and-snow-leopard</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/matlab-and-snow-leopard#comments</comments>
		<pubDate>Fri, 28 Aug 2009 22:55:14 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=482</guid>
		<description><![CDATA[Matlab has been trying to catchup OSX for some time now. First releasing a rather bad version of Matlab for the Intel processor, and subsequently releasing a 64bit version. Both showed signs of commitment, however, today after installing Snow Leopard I was slightly annoyed that some of the functionality had become broken.
mmreader, which I depend [...]]]></description>
			<content:encoded><![CDATA[<p>Matlab has been trying to catchup <span class="caps">OSX</span> for some time now. First releasing a rather bad version of Matlab for the Intel processor, and subsequently releasing a 64bit version. Both showed signs of commitment, however, today after installing Snow Leopard I was slightly annoyed that some of the functionality had become broken.</p>
<p>mmreader, which I depend on for reading avi movie files no longer works. Images seem to be garbled by some sort of offset and data conversion. I suspect this stems from some 32 to 64 bit conversion that Matlab is not aware of. Anyway, so now I can&#8217;t read movies files until they fix Matlab which god knows when it will be.</p>
<p>Update for those thinking of installing Snow Leopard: 2008a, 2009a, 2009b (32 and 64 bit) all work fine. Aside from some bugs that must exist like the one above in specific packages, the general Matlab environment is fully functional.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/matlab-and-snow-leopard/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The great Matlab to Python Bridge</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/the-great-matlab-to-python-bridge</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/the-great-matlab-to-python-bridge#comments</comments>
		<pubDate>Sun, 23 Aug 2009 19:16:45 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=479</guid>
		<description><![CDATA[Currently Matlab is undergoing some major changes. While it slept for the past 5 years other programming languages have stepped up to take its place. Python, C++, Java amongst others have become as easy to use and as efficient as Matlab. The current  problem, however, is that not all projects and libraries exist in all [...]]]></description>
			<content:encoded><![CDATA[<p>Currently Matlab is undergoing some major changes. While it slept for the past 5 years other programming languages have stepped up to take its place. Python, C++, Java amongst others have become as easy to use and as efficient as Matlab. The current  problem, however, is that not all projects and libraries exist in all these languages. So what happens when you have a great program in Matlab and a great program in Python and you want to tie the two together? Here is my experience this weekend:</p>
<p>Day 1: This will be great. I&#8217;ll use the Python C <span class="caps">API</span> to call python from Matlab. I&#8217;ll save the Python state as a Matlab variable and I can always start up my Python session where I left off.</p>
<p>Day 2: Alright.. maybe not. But let&#8217;s just try calling Python from C, I just want to make it work, not have it running efficiently.</p>
<p>Day 3: Ok, clearly Python has a crappy <span class="caps">API</span>. Moving to the client/server socket communication approach. Phew.. must it be this hard?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/the-great-matlab-to-python-bridge/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matlab and movies</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/matlab-and-movies</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/matlab-and-movies#comments</comments>
		<pubDate>Mon, 10 Aug 2009 21:09:48 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=470</guid>
		<description><![CDATA[Animations of how 2D matrixes change over time can sometimes be helpful in detecting trends. Bellow is a small bit of code, very trivial, that converts a set of 2D matrixes to a avi movie.
% Images = set of 2D matrixes that we want to convert to a movie (values range from 0-255)
% Frames = [...]]]></description>
			<content:encoded><![CDATA[<p>Animations of how 2D matrixes change over time can sometimes be helpful in detecting trends. Bellow is a small bit of code, very trivial, that converts a set of 2D matrixes to a avi movie.</p>
<pre><code>% Images = set of 2D matrixes that we want to convert to a movie (values range from 0-255)
% Frames = Pseudo RGB version Frames
% Mov = Matlab structure that holds the movie
Width = 48; Height = 48;
NumberOfFrames = size(Images, 2);
Frames = zeros([Width, Height, 3, NumberOfFrames]);
for i=1:NumberOfFrames,
Frames(:,:,1,i) = Images{i};
Frames(:,:,2,i) = Images{i};
Frames(:,:,3,i) = Images{i};
end
Mov = immovie(Frames);
movie2avi(Mov, &#39;movie.avi&#39;);
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/matlab-and-movies/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyCV on OSX</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/pycv-on-osx</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/pycv-on-osx#comments</comments>
		<pubDate>Wed, 17 Jun 2009 14:51:29 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Andre (2009-?)]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=461</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www3.ntu.edu.sg/home5/pham0004/pycv/">PyCV</a> 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.</p>
<p>First is error that happens in the system_info.py which reads something like:</p>
<pre><code>File &#34;/sw/lib/python2.6/site-packages/numpy/distutils/cpuinfo.py&#34;
line 79, in __getattr__
raise AttributeError,name
AttributeError: _has_sse2</code></pre>
<p>
To fix this you must edit the file system_info.py lines 107-114 to becoming:</p>
<pre><code>#if cpu._has_sse2() and (dcomp  'mingw32' or dcomp  &#39;gcc&#39;):
extra_args = [&#39;-arch x86_64&#39;, &#39;-O3&#39;, &#39;-msse2&#39;, &#39;-mfpmath=sse&#39;, &#39;-malign-double&#39;]
#    if get_gcc_version() &#38;gt;= &#39;4.2&#39;:
extra_args.append(&#39;-mtune=generic&#39;)
#    else:
#        extra_args.append(&#39;-march=pentium4&#39;)
#        extra_args.append(&#39;-mtune=pentium4&#39;)
#info[&#39;extra_compiler_args&#39;].extend(extra_args)}}}</code></pre>
<p>
This fixes the above error and also fixes an assembly error that happens later when compiling Blas bindings. The error:</p>
<pre><code>error: can&#39;t find a register in class ‘GENERAL_REGS’ while reloading ‘asm’</code></pre>
<p>
The error is fixed by specifying the architecture of the computer, in this case x86_64.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/pycv-on-osx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matlab 2009a</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/matlab-2009a</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/matlab-2009a#comments</comments>
		<pubDate>Fri, 29 May 2009 23:52:28 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=445</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p><em>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.</em></p>
<p><strong>Addition</strong></p>
<table>
<tr>
<th>MxM </th>
<th>Matlab 2009a (Mac) </th>
<th>Matlab 2008b (Mac) </th>
<th>Matlab 2008b (Linux) </th>
</tr>
<tr>
<td> 121 </td>
<td> .05 </td>
<td> .15 </td>
<td> .015 </td>
</tr>
<tr>
<td> 961 </td>
<td> .37 </td>
<td> 2.21 </td>
<td> .22 </td>
</tr>
</table>
<p><strong>Multiplication</strong></p>
<table>
<tr>
<th>MxM </th>
<th>Matlab 2009a (Mac) </th>
<th>Matlab 2008b (Mac) </th>
<th>Matlab 2008b (Linux) </th>
</tr>
<tr>
<td> 121 </td>
<td> .06 </td>
<td> .47 </td>
<td> .061 </td>
</tr>
<tr>
<td> 961 </td>
<td> 2.14 </td>
<td> 12.19 </td>
<td> 2.49 </td>
</tr>
</table>
<p><strong>QR</strong></p>
<table>
<tr>
<th>MxM </th>
<th>Matlab 2009a (Mac) </th>
<th>Matlab 2008b (Mac) </th>
<th>Matlab 2008b (Linux) </th>
</tr>
<tr>
<td> 121 </td>
<td> .12 </td>
<td> .57 </td>
<td> .07 </td>
</tr>
<tr>
<td> 961 </td>
<td> 2.53 </td>
<td> 12.19 </td>
<td> 2.49 </td>
</tr>
</table>
<p>As you can see, the Mac version is finally starting to get numbers closer to that of Linux and Windows. With a better <span class="caps">GUI</span> (Cocoa based) I will finally stop writing C++ code for good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/matlab-2009a/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video playback in C++</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/video-playback-in-c</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/video-playback-in-c#comments</comments>
		<pubDate>Mon, 20 Apr 2009 14:09:12 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=439</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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 <span class="caps">SDL</span> audio library does. <span class="caps">FFMPEG</span> 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.</p>
<p>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 <span class="caps">RGB</span> 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!)</p>
<p>The code is documented and only depends on the <span class="caps">FFMPEG</span> 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 <span class="caps">RGB</span> matrix).</p>
<p>The code can be downloaded from <a href="http://andrecohen.com/Upload/video.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/video-playback-in-c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linear Algebra revisited</title>
		<link>http://www.contentfull.com/andre-2009/programming-current/linear-matrix-revisited</link>
		<comments>http://www.contentfull.com/andre-2009/programming-current/linear-matrix-revisited#comments</comments>
		<pubDate>Mon, 23 Mar 2009 18:03:25 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.contentfull.com/?p=432</guid>
		<description><![CDATA[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 &#8220;-mno-thumb&#8221; (which enables the usage of special float point instructions) one can easily get improvements in the 2x region! This means that the iPhone performs [...]]]></description>
			<content:encoded><![CDATA[<p>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 &#8220;-mno-thumb&#8221; (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.</p>
<p>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.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.contentfull.com/andre-2009/programming-current/linear-matrix-revisited/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
