I have a 2.8 inch touch screen that plugs into the GPIO pins on my Raspberry Pi 3. https://www.adafruit.com/product/1601. I have a raspberry pi camera that I attached to the pi. I am using the start_ preview command and there aren't any errors. It doesn't seem to show the previews onto the touch screen and I do not have an extra monitor to connect to. It's there any way to display the previews on the touch screen?

  • Does it work if you have a normal HDMI monitor hooked up? If it does then seems like you need to set the output screen for the camera. Hopefully that is easy enough to fix. Not sure what the command may be – Piotr Kula Nov 9 '16 at 8:42
  • Something is tickling my brain about GPIO screens and camera previews. I think I've read that there's something funny about the way the previews are handled by software (possibly written up somewhere by Dave Jones?) that makes it awkward. I'll post back if I can track the reference down. – goobering Nov 9 '16 at 10:50
  • @ppumkin I don't have any spare monitors to use. – Geeoon Chung Nov 9 '16 at 14:54
  • Friend ? School? IT shop ? Buy a cheap 2nd hand 16.5" for 20bux? Just saying ... – Piotr Kula Nov 9 '16 at 22:36
  • @ppumkin It needs to be portable. – Geeoon Chung Nov 13 '16 at 23:43

I don't think this works as intended. At least, the docs for the Python picamera library state that:

The camera’s preview system directly overlays the Pi’s output on the HDMI or composite video ports. At this time, it will not operate with GPIO-driven displays like the PiTFT. Some projects, like the Adafruit Touchscreen Camera project, have approximated a preview by rapidly capturing unencoded images and displaying them on the PiTFT instead.

You can take a look at the relevant chunk of screen refreshing code for the Adafruit Touchscreen Camera project here on Adafruit's Github page:

# Refresh display
  if screenMode >= 3: # Viewfinder or settings modes
    stream = io.BytesIO() # Capture into in-memory stream
    camera.capture(stream, use_video_port=True, format='raw')
    stream.readinto(yuv)  # stream -> YUV buffer
    yuv2rgb.convert(yuv, rgb, sizeData[sizeMode][1][0],
    img = pygame.image.frombuffer(rgb[0:
      (sizeData[sizeMode][1][0] * sizeData[sizeMode][1][1] * 3)],
      sizeData[sizeMode][1], 'RGB')
  elif screenMode < 2: # Playback mode or delete confirmation
    img = scaled       # Show last-loaded image
  else:                # 'No Photos' mode
img = None # You get nothing, good day sir
  • 1
    Yup, GPIO screens are unsupported for preview and from what I understand, it's unlikely to change (I can't remember the fine details but it was something about the speed of the interfaces). There is a faster method of updating the preview these days which is demonstrated in this gist I whipped up for someone wanting to do delayed previews (sorry, there's plenty you don't need in there, but you can prise out the important bits) – Dave Jones Nov 10 '16 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.