Python Image data is not accessible for write


I am trying to visualize, with visualization.Visualizer, depth data frames from an Analog Devices camera continuously. I figure I cannot do that because in python you do not give access to changing the data from Image buffers.

In cpp, I can do that with: std::vector<uint8_t> data_, but I see no possibility in python.

Is there any way I can modify data from an Image without transforming it in np.array and copying in another Image. I want to do it in the same Image.

Thank you


Here is an example of code that does not work properly. I create a visualizer window where I want to display frame to frame 3 pictures. When displayed it only shows the first image.

I attach the 3 images I trying to display: depth1 depth2 depth3


Does anyone had time to look into this?

Thank you

Hi, one way to access raw buffer is using np.array(depth_image). I will check how to update it in a rendering loop properly and be back.


Yes, I used np.array(depth_image) for accessing the data, for view or for copy in another Image. My problem is that I cannot change the data directly in my Image.

Please let me know if you succeed with the rendering loop.

Thank you,


Did you have some time to look into the rendering loop problem?

Thank you

Sorry for coming back late. Attached is a code snippet that works for me.
Press SPACE to load next image; press ESC to exit; I didn’t add border check in this simple file (like file not found).
Please let me know if you have further problems.

import open3d as o3d
import numpy as np

class ImLoader:
    def __init__(self, base_path, base_index=0):
        # path to the indexed files
        self.path = base_path
        self.index = base_index

    def next(self):
        self.index += 1

        # Or other format you desire
        return'{}/{}.png'.format(self.path, self.index))

class Visualizer:
    def __init__(self, imloader):
        # Global flags
        self.flag_exit = False
        self.flag_next = False
        self.imloader = imloader
        self.curr_im =

    def escape_callback(self, vis):
        self.flag_exit = True
        return False

    def space_callback(self, vis):
        lhs = np.asarray(self.curr_im)
        rhs = np.asarray(
        lhs[:] = rhs[:]
        return False

    def run(self):
        glfw_key_escape = 256
        glfw_key_space = 32
        vis = o3d.visualization.VisualizerWithKeyCallback()
        vis.register_key_callback(glfw_key_escape, self.escape_callback)
        vis.register_key_callback(glfw_key_space, self.space_callback)

        vis.create_window('recorder', 1920, 540)

        vis_geometry_added = False
        while not self.flag_exit:

if __name__ == '__main__':
    imloader = ImLoader('.')
    vis = Visualizer(imloader)

1 Like