<?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>depth first search &#187; swig</title>
	<atom:link href="http://www.depthfirstsearch.net/blog/tag/swig/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.depthfirstsearch.net/blog</link>
	<description>“We can only see a short distance ahead, but we can see plenty there that needs to be done.&#34;</description>
	<lastBuildDate>Sun, 05 Feb 2012 13:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My First SWIG Experience</title>
		<link>http://www.depthfirstsearch.net/blog/2008/07/11/my-first-swig-experience/</link>
		<comments>http://www.depthfirstsearch.net/blog/2008/07/11/my-first-swig-experience/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 22:27:14 +0000</pubDate>
		<dc:creator>JS</dc:creator>
				<category><![CDATA[computer science]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[swig]]></category>

		<guid isPermaLink="false">http://www.depthfirstsearch.net/blog/?p=486</guid>
		<description><![CDATA[A day of reading the SWIG manual and grokking the examples resulted in the following interface file. What does it do? It adds this to Python. %module blobs &#160; %exception &#123; try &#123; $action &#125; catch &#40;...&#41; &#123; return NULL; &#125; &#125; &#160; &#160; %include &#34;exception.i&#34; &#160; %typemap&#40;in&#41; IplImage * &#40;IplImage header&#41;&#123; void * vptr; [...]]]></description>
			<content:encoded><![CDATA[<p>A day of reading the SWIG manual and grokking the examples resulted in the following interface file. What does it do? It adds <a href="http://opencvlibrary.sourceforge.net/cvBlobsLib">this</a> to Python.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #000040;">%</span>module blobs
&nbsp;
<span style="color: #000040;">%</span>exception
    <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">try</span> <span style="color: #008000;">&#123;</span> $action <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">catch</span> <span style="color: #008000;">&#40;</span>...<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000040;">%</span>include <span style="color: #FF0000;">&quot;exception.i&quot;</span>
&nbsp;
<span style="color: #000040;">%</span>typemap<span style="color: #008000;">&#40;</span>in<span style="color: #008000;">&#41;</span> IplImage <span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span>IplImage header<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">void</span> <span style="color: #000040;">*</span> vptr<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> res <span style="color: #000080;">=</span> SWIG_ConvertPtr<span style="color: #008000;">&#40;</span>$input, <span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>vptr<span style="color: #008000;">&#41;</span>, $descriptor<span style="color: #008000;">&#40;</span> CvMat <span style="color: #000040;">*</span> <span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> res <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		SWIG_exception<span style="color: #008000;">&#40;</span> SWIG_TypeError, <span style="color: #FF0000;">&quot;%%typemap(in) IplImage * : could not convert to CvMat&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		SWIG_fail<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	$<span style="color:#800080;">1</span> <span style="color: #000080;">=</span> cvGetImage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>CvMat <span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>vptr, <span style="color: #000040;">&amp;</span>header<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #000040;">%</span>typemap<span style="color: #008000;">&#40;</span>in<span style="color: #008000;">&#41;</span> IplImage <span style="color: #000040;">*</span>mask<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>$input <span style="color: #000080;">==</span> Py_None<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	   $<span style="color:#800080;">1</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		SWIG_exception<span style="color: #008000;">&#40;</span> SWIG_TypeError, <span style="color: #FF0000;">&quot;%%typemap(in) IplImage *mask : masks not supported yet.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		SWIG_fail<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #000040;">%</span>typecheck<span style="color: #008000;">&#40;</span>SWIG_TYPECHECK_POINTER<span style="color: #008000;">&#41;</span> IplImage <span style="color: #000040;">*</span> <span style="color: #008000;">&#123;</span>
  <span style="color: #0000ff;">void</span> <span style="color: #000040;">*</span>ptr<span style="color: #008080;">;</span>
  <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>SWIG_ConvertPtr<span style="color: #008000;">&#40;</span>$input, <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span> <span style="color: #000040;">**</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span>ptr, $descriptor<span style="color: #008000;">&#40;</span> CvMat <span style="color: #000040;">*</span> <span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    $<span style="color:#800080;">1</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
    PyErr_Clear<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
    $<span style="color:#800080;">1</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #000040;">%</span><span style="color: #008000;">&#123;</span>
<span style="color: #339900;">#include &quot;BlobResult.h&quot;</span>
<span style="color: #339900;">#include &quot;Blob.h&quot;</span>
<span style="color: #000040;">%</span><span style="color: #008000;">&#125;</span>
<span style="color: #000040;">%</span>include <span style="color: #FF0000;">&quot;BlobResult.h&quot;</span>
<span style="color: #000040;">%</span>include <span style="color: #FF0000;">&quot;Blob.h&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.depthfirstsearch.net/blog/2008/07/11/my-first-swig-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/9 queries in 0.177 seconds using disk: basic
Object Caching 326/338 objects using disk: basic

Served from: www.depthfirstsearch.net @ 2012-02-07 14:16:05 -->
