You can see my code in the picture.It was written in the python console.
image = Metashape.app.model_view.captureView(width = 300, height = 150, transparent = False, hide_items = True)image.save(path)