title: Python / Opencv How to draw a mesh surface having stl file
body: <p>I need to draw the surface triangles from a mesh that I've stored in different formats such as xyz or stl. My final purpose is create a binary image with the triangles in order to be able to overlay other images that I've already produced in another python script.</p>
  
  <p>I don't know what is the best approach. Using the numpy-stl module it is possible extrating the vectors and points, but i'm not being able to produce a opencv code. I tried polylines.</p>
  
  <p>These are my files .</p>
  
  <p>Stl - <a href="https://dl.dropboxusercontent.com/u/7" rel="nofollow">https://dl.dropboxusercontent.com/u/7</a>...</p>
  
  <p>xyz - <a href="https://dl.dropboxusercontent.com/u/7" rel="nofollow">https://dl.dropboxusercontent.com/u/7</a>...</p>
  
  <p>I did some code with opencv without any success.</p>
  
  <pre><code>import numpy as np
  from stl import mesh
  #import stl
  
  from mpl_toolkits import mplot3d
  from matplotlib import pyplot
  import cv2
  
  if __name__ == '__main__':
      your_mesh = mesh.Mesh.from_file('stlMidpoint.stl')
      img= cv2.imread('nimg.jpg')  #an image with the same size, and I'll use the mesh-mask on this image
      imgMask = np.ones(img.shape[:2], dtype="uint8")*255
      m_img= np.ones(imgMask.shape, dtype="uint8") * 255
  
      points = np.array(your_mesh.vectors[0,:,:])
      cv2.polylines( m_img,[points], 1, (255,255,255))
  
      cv2.imwrite('meshTri.jpg', m_img)
  </code></pre>