Thanks for the reply, I tried adding import_array(); to my BOOST_PYTHON_MODULE block but I still got an error when importing my library into python, the same same error I mentioned above.<div><br><div class="gmail_quote">On Wed, Sep 21, 2011 at 9:43 AM, Jim Bosch <span dir="ltr">&lt;<a href="mailto:talljimbo@gmail.com">talljimbo@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 09/21/2011 09:31 AM, Kevin Hughes wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am trying to create a python library from a class which uses opencv<br>
2.3. I want to be able to pass numpy array&#39;s into the class where they<br>
will be converted into cv::Mat&#39;s processed then converted back to numpy<br>
array&#39;s and returned.<br>
<br>
Here is a simple test class I am working on to get this working before<br>
wrapping my own class. Currently I am just trying to receive a numpy<br>
array concert to a cv::Mat, process it and then write it to file. After<br>
this is working I will work on returning the processed array to python.<br>
<br>
</blockquote>
<br></div>
Without digging too deeply or getting into possibly better solutions, try adding:<br>
<br>
import_array();<br>
<br>
inside your BOOST_PYTHON_MODULE block.  Or maybe there&#39;s some opencv initialization function you need to call that will do that for you.  The NumPy C-API (which I assume the numpy_to_mat function uses internally) needs to be initialized when your module is imported, or you&#39;ll get segfaults.  The above call to import_array() is how you&#39;d do it if you were using the NumPy C-API headers directly.  In any case, you need to make sure it gets called somehow.<br>

<br>
HTH<br><font color="#888888">
<br>
Jim Bosch<br>
______________________________<u></u>_________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org" target="_blank">Cplusplus-sig@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/cplusplus-sig</a><br>
</font></blockquote></div><br></div>