<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I reproduced the error. I am looking into fixing it.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 12, 2017 at 4:02 PM, D'Isidoro  Fabio <span dir="ltr"><<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="DE-CH" link="blue" vlink="purple">
<div class="m_1861944868048138576WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Ok, thanks. Moe specifically I am using now
<u>Visual Studio 2017 Preview</u>.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Fabio.</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Dženan Zukić [mailto:<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>]
<br>
<b>Sent:</b> Mittwoch, 12. </span><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">April 2017 21:54<span class=""><br>
<b>To:</b> D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>><br>
</span><b>Cc:</b> Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>>; <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a></span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [ITK-users] ITK Python: numpy to itk image (and viceversa)<u></u><u></u></div></div><p></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif">Hi Fabio,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif">let me give it a try with VS2017 and Wrapping+NumPy. I will report back when I have an update.<u></u><u></u></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif">Regards,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Verdana",sans-serif">Dženan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)<u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Apr 12, 2017 at 2:16 PM, D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Thank you. I am trying to build ITK Wrap Python with Module_BridgeNumPy=ON with Visual Studio 2017.<br>
<br>
I get the following type of errors:<br>
<br>
12>C:/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/<wbr>Tools/MSVC/14.10.25017/<wbr>include\xstring(1905,26): error G3F63BFAE: constexpr variable '_Memcpy_move_offset' must be initialized by a constant expression<br>
12>        static constexpr size_t _Memcpy_move_offset = offsetof(_Mydata_t, _Bx);<br>
12>                                ^                     ~~~~~~~~~~~~~~~~~~~~~~~~<br>
12>C:/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/<wbr>Tools/MSVC/14.10.25017/<wbr>include\stdexcept:23:21: note: in instantiation of template class 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' requested here<br>
12>                : _Mybase(_Message.c_str())<br>
12>                                  ^<br>
12>C:/Program Files (x86)/Microsoft Visual Studio/Preview/Community/VC/<wbr>Tools/MSVC/14.10.25017/<wbr>include\xstring:1905:48: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression<br>
12>        static constexpr size_t _Memcpy_move_offset = offsetof(_Mydata_t, _Bx);<br>
12>                                                      ^<br>
12>C:/Program Files (x86)/Windows Kits/10/Include/10.0.10586.0/<wbr>ucrt\stddef.h:38:32: note: expanded from macro 'offsetof'<br>
12>        #define offsetof(s,m) ((size_t)&reinterpret_cast<<wbr>char const volatile&>((((s*)0)->m)))<br>
<br>
<br>
The build worked with Visual Studio 2015 instead.<br>
<br>
Can I fix this issue with Visual Studio 2017 somehow?<br>
<br>
Thank you.<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
Fabio D’Isidoro - PhD Student<br>
Institute of Biomechanics<br>
HPP O 14<br>
Hönggerbergring 64<br>
8093 Zürich, Switzerland<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
-----Original Message-----<br>
From: Matt McCormick [mailto:<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@<wbr>kitware.com</a>]<br>
Sent: Montag, 3. April 2017 20:41<br>
To: D'Isidoro Fabio <<a href="mailto:fisidoro@ethz.ch" target="_blank">fisidoro@ethz.ch</a>><br>
Cc: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
Subject: Re: [ITK-users] ITK Python: numpy to itk image (and viceversa)<br>
<br>
Hallo Fabio,<br>
<br>
<br>
> I use ITK with Python Wrap. I need to interface my Python code with a<br>
> Cython-wrapped C++ code that takes only numpy array as input and<br>
> returns numpy array as output.<br>
<br>
Cool. By the way, you may be interested in scikit-build [1], which is a good way to build Cython-wrapped C++ code. We are using it for the ITK and SimpleITK Python packages, and it has good Cython and CMake support.<br>
<br>
<br>
> Hence, I need to convert the Python itk images into numpy array to be<br>
> given as input to the wrapped C++ code, and then convert the numpy<br>
> array in output from the wrapped C++ code back into python itk images.<br>
><br>
><br>
><br>
> Question 1) How can I do that in an efficient way? I found some posts<br>
> on itk.PyBuffer but I could not find anywhere any reference on how to<br>
> install it on my itk wrap build.<br>
<br>
Yes, itk.PyBuffer works great for that. Please review a PR for some additional documentation:<br>
<br>
  <a href="https://github.com/InsightSoftwareConsortium/ITKBridgeNumPy/pull/18" target="_blank">
https://github.com/<wbr>InsightSoftwareConsortium/<wbr>ITKBridgeNumPy/pull/18</a><br>
<br>
This has been available in ITK for a few releases as a Remote module, which can be enabled by setting<br>
<br>
  Module_BridgeNumPy=ON<br>
<br>
in ITK's CMake configuration.<br>
<br>
<br>
Since ITK 4.11.0, it is easier to build since it does not require the NumPy headers.<br>
<br>
<br>
In current ITK Git master (to be 4.12.0) the module is enabled by default.<br>
<br>
<br>
Nightly ITK Python packages for ITK Git master are now being built:<br>
<br>
  <a href="https://github.com/InsightSoftwareConsortium/ITKPythonPackage" target="_blank">
https://github.com/<wbr>InsightSoftwareConsortium/<wbr>ITKPythonPackage</a><br>
<br>
macOS and Linux are available. Windows packages will be available over the coming weeks.<br>
<br>
<br>
<br>
> Question 2) The purpose of writing a part of my algorithm in C++ is to<br>
> speed up the code. If the conversion between python itk images and<br>
> numpy arrays is slow, I would lose all the speed gain obtained with the C++ implementation.<br>
> Are there better ways to deal with that?<br>
<br>
The newer versions ITKBridgeNumPy use a NumPy array view, which does not do any copies during the conversion, and it is very fast.<br>
<br>
<br>
HTH,<br>
Matt<br>
<br>
<br>
[1] <a href="http://scikit-build.org/" target="_blank">http://scikit-build.org/</a><br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>