how to add an image to render window which had point cloud already

I write following function to add an image to a rendered window which contained point cloud, it failed

void addImageToview(vtkRenderWindowInteractor* interactor,  vtkSmartPointer<vtkRenderWindow> renderWindow, const std::string &imagePath, double &x, double &y, double &x_wide, double &y_wide, double &opaticy)
	   vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();
	   reader->SetFileName(imagePath.c_str());/*no multiple coding format*/

	   vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
        //vtkSmartPointer<vtkRenderWindow> renderWindow = 
        vtkSmartPointer<vtkRenderWindow>::New();  //** comment out this line, the passed  renderWindow will be erased.

        // Create a vtkImageActor to display the image
        vtkSmartPointer<vtkImageActor> imageActor = vtkSmartPointer<vtkImageActor>::New();
	    imageActor->SetPosition(x, y,0);

        // Add the image actor to the renderer as an overlay
        renderer->AddActor2D(imageActor); // AddActor2D adds the actor as an overlay, keeping existing actors intact

where, vtkRenderWindowInteractor* interactor, vtkSmartPointer renderWindow contained point cloud,see blow

if I comment out this line marked by **, the passed renderWindow of function parameter will be erased. only the image showed,

I want to show both an image on the point cloud(put the image at given postion of the screen), like below,


how to implemented this function?


Why are you trying to create another vtkRenderWindow inside the function? Aren’t you supposed to use the one passed as argument?



I want to use the passed renderWindow as argument. my winodow is

  renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

when I try to add a image view,such as
than renderer_lidar is erased by renderer_image

If I addd an image(via vtkImageActor) to renderer_lidar, it is ok, adding to main window failed

So don’t create one inside the function. Just remove New() call from inside addImageToview().

That’s the point here, when I add addImageToview(), the previous point cloud is erased by image, I want show them simutaneously, and image not ratoated with pointcloud