<div dir="ltr"><div dir="ltr">I came across a similar problem when I was working on a VTK application in Python. There are few examples of how to do this (if any).<div><br></div><div>Take a look at this excerpt of code that I use to load in RGB data. In short, the answer to your problem is to have the data is NxM where N is the product of the size of the data (i.e. 10x10x10 => N = 1000) and M is the number of color channels you have (1 for grayscale, 3 for RGB, 4 for RGBA).</div><div><br></div><div><div># Use VTK support function to convert Numpy to VTK array</div><div># The data is reshaped to one long 2D array where the first dimension is the data and the second dimension is</div><div># the color channels (1, 3 or 4 typically)</div><div># Note: Fortran memory ordering is required to import the data correctly</div><div># Type is not specified, default is to use type of Numpy array</div><div>vtkArray = numpy_support.numpy_to_vtk(self.data.reshape((-1, self.channels), order='F'), deep=False)</div><div><br></div><div># Create image, set parameters and import data</div><div>self.vtkImage = vtkImageData()</div><div><br></div><div># For vtkImage, dimensions, spacing and origin is assumed to be 3D. VTK images cannot be larger than 3D and if</div><div># they are less than 3D, the remaining dimensions should be set to default values. The function padRightMinimum</div><div># adds default values to make the list 3D.</div><div>self.vtkImage.SetDimensions(padRightMinimum(self.size, 3, 1))</div><div>self.vtkImage.SetSpacing(padRightMinimum(self.spacing, 3, 1))</div><div>self.vtkImage.SetOrigin(padRightMinimum(self.origin, 3, 0))</div><div><br></div><div># Import the data (vtkArray) into the vtkImage</div><div>self.vtkImage.GetPointData().SetScalars(vtkArray)</div><div><br></div>On Sun, Oct 28, 2018 at 6:33 AM Andreas Pedroni <<a href="mailto:anpedroni@gmail.com">anpedroni@gmail.com</a>> wrote:<br>><br>> Dear list<br>><br>> My final goal is to render a movie (read by the openCV method VideoCapture) on a plane in 3D space (using VTK).<br>><br>> As a first step I tried to map a single RGB-frame (a numpy nd.array (1020, 720,3)  ) as texture on a plane (see the code snippet below).<br>> However this does not work. What I don’t get is how to create a 2D color image to map to the texture. Now it is recognized as a 3D texture map and returns the error: "3D texture maps currently are not supported!“.<br>><br>> As I am very new to VTK and do not know anything about C++, I find it difficult to orient myself in VTK through the C++ examples.<br>> So, any hints would be greatly appreciated!<br>><br>> Best<br>> Andreas<br>><br>><br>> # Python 3.6, VTK 8.1.1, OpenCV 3.4.2)<br>><br>> # Create a video capture object to read videos<br>> cap = cv2.VideoCapture(VIDEOPATH)<br>><br>> # Read first frame<br>> success, frame = cap.read()<br>><br>> frame_shape = frame.shape<br>> vtk_array  = numpy_support.numpy_to_vtk(frame.transpose(2, 0, 1).ravel(), deep=True, array_type=vtk.VTK_UNSIGNED_CHAR)<br>><br>> # Convert vtkFloatArray to vtkImageData<br>> vtk_image_data = vtk.vtkImageData()<br>> vtk_image_data.SetDimensions(frame.shape)<br>> vtk_image_data.SetSpacing([1,1,1])<br>> vtk_image_data.GetPointData().SetScalars(vtk_array)<br>> vtk_image_data.SetOrigin(0,0,0)<br>><br>> # create the texture<br>> atext = vtk.vtkTexture()<br>> atext.SetInputData(vtk_image_data)<br>> atext.InterpolateOn()<br>><br>> plane = vtk.vtkPlaneSource()<br>> …<br>><br>><br>><br>> _______________________________________________<br>> Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>><br>> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>><br>> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>><br>> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br>><br>> Follow this link to subscribe/unsubscribe:<br>> <a href="https://public.kitware.com/mailman/listinfo/vtkusers">https://public.kitware.com/mailman/listinfo/vtkusers</a></div></div></div>