11

I currently have a raspberry pi model B with a raspberry pi camera connected to it. The raspberry pi is connected to my router via an Ethernet cable, I control the raspberry pi through VNC viewer on my laptop. The issue I have is when controlling the camera through something like python code using camera.start_preview the preview is opened in a preview window which is only viewable if a monitor is connected to the raspberry pi.

Is there a way of sending a live camera preview over my network so that a preview window is opened in my VNC Viewer window on my laptop?

Darth Vader
  • 4,206
  • 24
  • 45
  • 69

2 Answers2

15

See @Andrew Wedgbury 's comment to the accepted answer. " It is now possible to do this over VNC. If you're using the RealVNC server on the Pi, go to VNC options > troubleshooting and enable "experimental direct capture mode", then you'll be able to view the camera preview image over the vnc connection. – Andrew Wedgbury May 31 at 8:53 " This worked and is a great solution as no additional software is required.

thestevenbell
  • 151
  • 1
  • 2
  • it is working, but either the resolution got doubled or went half. Now the vnc output is half in size, not able to read letters that are too small – Midhun KM Dec 01 '18 at 06:05
8

The camera preview seems to be handled on a low level in the GPU, and is visible only on a monitor connected directly to the Pi. Any program that shows the camera image in a regular X window should be viewable over VNC.

If you want the video sent over the network, you might consider stream the video instead. Streaming is easy, the only issue is that that the streaming seems to cause a delay of several seconds. Here is a blog post suggesting to stream video as mjpeg, viewable in almost any browser. Here are instructions for streaming using netcat, with some tricks to reduce the latency. This SO post discusses streaming as well.

Frepa
  • 2,261
  • 19
  • 17
  • Had a feeling it would involve streaming I think I recall seeing in some of the raspberry pi camera docs a way of setting up a stream using python, which would be my preferred method. As for the delay I'm not really bothered it would just be nice to have some idea of what I am about to take a picture of. – Darth Vader Apr 12 '15 at 18:45
  • @Darth Vader, there is the picamera python module. The examples show how to set up streaming. I haven't tried but it looks promising. A crude alternative could be to just take a photo either with picamera or the raspistill program, save it as a file on a shared network drive, then look at the file at the remote machine. – Frepa Apr 13 '15 at 11:01
  • 2
    Yes, the Pi's camera module draws the preview directly over the output from the GPU, so it's only viewable via the HDMI or composite output ports. It's worth noting that even screens directly attached to the Pi via other channels (like the Adafruit PiTFTs which attaches via the GPIO ports) can't see the preview – Dave Jones Apr 13 '15 at 21:13
  • 9
    It is now possible to do this over VNC. If you're using the RealVNC server on the Pi, go to VNC options > troubleshooting and enable "experimental direct capture mode", then you'll be able to view the camera preview image over the vnc connection. – Andrew Wedgbury May 31 '17 at 08:53