Common errors using the Raspberry Pi camera module

Figure 2: The strange blank/black frame error.

Today’s blog post will take a short diversion from our recent trend of Deep Learning tutorials here on the PyImageSearch blog and instead focus on a topic that I’ve been receiving a ton of emails about lately — common errors when using the Raspberry Pi camera module.

I want to start this post by mentioning Dave Jones, the maintainer and chief contributor to the picamera library. Dave is one of the most active open source contributors that I’ve had the privilege to interact with (and he’s a hell of a nice guy too).

A few months ago, I was using the (at the time) latest picamera==1.11  library and was running in to a few errors. After checking the picamera  GitHub, I noticed an Issue had been posted regarding my problem. I confirmed the existence of the bug, which Dave then sought out — and fixed before the day was over, even releasing a new, updated version to the PyPI repository.

It goes without saying that without Dave, computer vision and OpenCV on the Raspberry Pi wouldn’t be nearly as fun — or half as accessible.

Over the past few years I’ve encountered a few “common” errors when using the Raspberry Pi and the picamera  library. My goal here today is to document some of these errors so you can easily fix them.

In fact, most of the issues I’m documenting here today are not real “errors” at all — they are simply misunderstandings on how the picamera  library works in conjunction with your Raspberry Pi setup.

Looking for the source code to this post?
Jump right to the downloads section.

Common errors using the Raspberry Pi camera module

Before we can look at common errors when using the Raspberry Pi camera module, let’s first discuss how we can simply access the picamera  video stream.

How to access your picamera video stream

To start, I am going to assume that you’ve already followed the instructions in Accessing the Raspberry Pi Camera with OpenCV and Python and installed the picamera  library on your Pi.

If you haven’t installed picamera , this can be accomplished using pip :

We add the [array]  portion to the command to ensure we can read frames as NumPy arrays, thus making the module compatible with OpenCV.

After pip  has finished installing picamera , you can check the version number using the following command:

The reported version of picamera should be at least 1.12.

A quick note on Python virtual environments

If you’re a frequent reader of the PyImageSearch blog, you’ll know that I use Python virtual environments a lot — and because of this, you likely do as well.

Before we continue, take a second to see if you are using Python virtual environments by source ‘ing your ~/.profile  file and listing all the available virtual environments on your system:

If you get an error related to the lsvirtualenv  command not being found, then you are not utilizing Python virtual environments (or you have potentially made a mistake editing your ~/.profile  file). If you’re not using Python virtual environments, then you can skip the next paragraph and move to the next sub-section.

Assuming you are using Python virtual environments, you can execute the workon  command to access each of the individual Python virtual environments on your system. In most install tutorials on the PyImageSearch blog, we name our Python virtual environment cv , short for “computer vision”:

A Python template for accessing your Raspberry Pi camera module

In order to access the picamera  video stream, I’ve created a simple, extendible template which I’ll detail for you below.

Open up a new file, name it , and insert the following code:

Lines 2-5 handle importing our required Python packages.

We then initialize our camera  object on Line 8, which allows us to access the Raspberry Pi camera module. We’ll define the resolution of the video stream to be 640 x 480 with a maximum frame rate of 32 FPS (Lines 9 and 10).

From there, we initialize our PiRGBArray  object on Line 11, passing in the original camera  object and then explicitly re-stating the resolution as well. This PiRGBArray  object allows us to actually read frames from the Raspberry Pi camera module in NumPy format, thereby making the frames compatible with OpenCV.

Finally, we wait 0.1 seconds to allow the Raspberry Pi camera sensor to warmup.

Our next code block handles actually capturing frames from our Raspberry Pi camera sensor:

On Line 17 we start looping over frames captured from the camera  using the capture_continuous  function. We pass three parameters into this method.

The first is rawCapture , the format in which we want to read each frame. We then specify the format  to be bgr  since OpenCV expects image channels to be in BGR order rather than RGB. Finally, the use_video_port  boolean indicates that we are treating the stream as video.

Once we have the frame , we can access the raw NumPy array via the .array  attribute (Line 20).

We display the frame to our screen on Lines 23 and 24 using OpenCV GUI functions.

But before we can move on to the next frame, we first need to prepare our stream by calling the .truncate  method on the rawCapture  object. If you do not do this, your Python script will throw an error — the exact error we’ll review later in this guide.

Finally, if the q  key is pressed (Lines 30 and 31), we break from the loop.

To execute the  script, just open up a terminal/command line prompt and execute the following command:

Note: If you’re using Python virtual  environments, you’ll want to use the workon  command to switch to the Python environment that has your OpenCV + picamera library installed.

If all goes well, you should see the Raspberry Pi video stream displayed to your feed:

Figure 1: Displaying the Raspberry Pi video stream to our screen.

Figure 1: Displaying the Raspberry Pi video stream to our screen.

Otherwise, if you get an error — keep reading. I’ve detailed the most common error messages that I run in to below.

Can’t connect to your picamera module?

Does the following error message look familiar?

If you are getting this error message, then you likely forgot to (1) run raspi-config , 92) enable the camera, and (3) reboot your Pi.

If you are still getting an error message after running raspi-config , then your camera is likely installed incorrectly. In this case, I would suggest giving this install video a watch and then trying to install your Raspberry Pi camera module again (be sure to power down your Pi first!)

Truncation problems

Truncation errors are fairly easy to identify since they always end with the text   Incorrect buffer length for resolution . An example of such an error message can be found below:

If you are getting this error message, you likely forgot to call .truncate  after you were done processing your frame. Line 27 of our  script above demonstrates how to use the .truncate  method.

In short: Go back to your script and ensure you have called .truncate  before .capture_continuous  is called again.

The picamera==1.11 and Python 3 specific error

The v1.11 release of the picamera  library introduced a Python 3 specific error. It was particularly hard to diagnose, but as Dave Jones points out, the issue was due to a mis-configuration in his test suite, leading to no Python 3 tests being performed.

This error is often diagnosed by seeing the text TypeError: startswith first arg must be bytes or a tuple of bytes, not str  as the final line in the error message. A full example of this error message is shown below:

The easiest solution is to either upgrade or downgrade your picamera  module by one point version.

To upgrade to v1.12 (or whatever the current version of picamera  is), use the following command:

To downgrade to v1.10, just use this commands:

Make sure you are being mindful of whether you’re using Python virtual environments or not. If you are, execute the workon  command before running pip to ensure picamera  is installed in to your virtual environment.

Blank and/or black frame

Figure 2: The strange blank/black frame error.

Figure 2: The strange blank/black frame error.

The blank/black frame is a particularly strange problem — frames are being read from the video stream, they are just not being decoded and displayed properly.

First, run the rpi-update  to grab the latest firmware updates for your Raspberry Pi:

After your Pi reboots, try re-executing your Python script.

If the frame retrieved by the Raspberry Pi camera is still blank/black, then downgrade your picamera  installation to v1.10:

I’ve encountered situations where I’ve only had to run rpi-update  to resolve the issue. And I’ve also needed to both upgrade my firmware and downgrade my picamera  version. I’m not sure what the common underlying thread is (I think it’s related to using the newer version of the Raspberry Pi camera hardware + picamera  versioning, but I haven’t been able to nail that down yet).


In this blog post, I reviewed common error messages that you may encounter when using your Raspberry Pi camera module and the picamera library.

These errors can be quite frustrating to debug, especially if you’re just getting started. My hope is that this guide helps point you in the right direction if you run in to any of these problems — I’ve certainly had my share of long nights trying to track these errors down!

Finally, I would like to mention again the wonderful work and contribution of Dave Jones, the maintainer and chief contributor to the picamera library. Without him, we wouldn’t be able to have near as much computer vision fun with our Pi’s!


If you would like to download the code and images used in this post, please enter your email address in the form below. Not only will you get a .zip of the code, I’ll also send you a FREE 17-page Resource Guide on Computer Vision, OpenCV, and Deep Learning. Inside you'll find my hand-picked tutorials, books, courses, and libraries to help you master CV and DL! Sound good? If so, enter your email address and I’ll send you the code immediately!

, ,

75 Responses to Common errors using the Raspberry Pi camera module

  1. Ryan August 29, 2016 at 11:34 am #

    Seriously, shout out to Dave. He’s a one man army solving picamera issues.

    • Adrian Rosebrock August 29, 2016 at 1:51 pm #

      He really is. I wish he had a GitTip account so I could buy him some cups of coffee.

  2. Saeed Razazzadeh August 29, 2016 at 12:23 pm #

    Hi, Adrian how are you?
    Thanks man, this is very usful for me.
    I wait for your cool posts.
    Thank you and best for you.

  3. enliteneer August 29, 2016 at 1:41 pm #

    Great timing, just yesterday I updated my accountability thread regarding issues with the webcam!

    I’m using a usb webcam (on the Beaglebone black and on a OpenCV virtual machine), and was having issues with the linux drivers (GSPCA / SPCA5xx)… I found that once the driver for the webcam is loaded, getting it to work in OpenCV is straightforward.

    So curious for those with an RPi and/or the Guru VM, does plugging in a usb webcam get recognized immediately (i.e. /dev/video0)?

    • Adrian Rosebrock August 29, 2016 at 1:51 pm #

      It really depends on your webcam if it is recognized immediately. For the Logitech C920, I know that it is automatically recognized and there is no need to probe for it. You can see a complete list of Pi compatible webcams here.

  4. Jasper August 29, 2016 at 5:07 pm #

    Another thing to check if you are having trouble connecting to the RPI camera is that the little brown pad connector on the front side of the camera module just next to the lens of the camera is firmly seated. This connector is labelled “SUNNY” in small print.

    On a couple of cameras, mine was not seated properly which caused the errors. This is easily corrected by applying a little finger pressure to the pad until it clicks into place and sits flush.

    • Adrian Rosebrock August 30, 2016 at 12:45 pm #

      This is a great tips Jasper, thanks for sharing!

    • Daniel August 22, 2019 at 6:07 am #

      I checked the connection and I pressed the connector as you said, but I still get the same message ” Camera is not enabled “. If you know any other tip pleas let me know as soon as possible. Thank you very much

  5. Sebastián H. August 30, 2016 at 12:30 am #

    Hello Adrian!

    Thanks! “rpi-update” did it for me!

    • Adrian Rosebrock August 30, 2016 at 12:41 pm #

      Fantastic, I’m glad it worked! 🙂

  6. Jack Cardozo August 30, 2016 at 5:42 pm #

    Here is one s/w problem I encountered when running using the raspicam on a rpi-3 and it was attributed to the fact that motioneye (variation of the program, motion) was active.
    After I stopped the service (sudo service motioneye stop), the video displayed just fine. This reminded me to check for any programs that are using the video device (/dev/video0 in my case).

    • Adrian Rosebrock August 31, 2016 at 1:41 pm #

      Wow, that’s a great tip Jack! I would have never thought to check that.

  7. Umesh September 2, 2016 at 11:30 am #

    As you have mentioned in the page to overcome the problem should needed to update the firmware by using “sudo rpi-update”. but when i do that and reboot my pi after logging into desktop taskbar is flickering. cannot access anything in the taskbar. what can i do??????

    • Adrian Rosebrock September 5, 2016 at 8:11 am #

      I’m sorry to hear about the strange error Umesh! But I honestly have not encountered that particular problem before. Have you tried posting it on the official Raspberry Pi forums?

  8. vivek borse September 3, 2016 at 2:46 am #

    how to save capture video as in various file format?

    • Adrian Rosebrock September 5, 2016 at 8:09 am #

      You can learn more about writing videos to file in this tutorial.

  9. Tom_Neverwinter October 6, 2016 at 4:50 pm #

    How about a Facial recognition, automatic license plate recognition system based on a different system as well, such as the orangepi or banannapi.

    • Adrian Rosebrock October 7, 2016 at 7:26 am #

      I don’t cover the OrangePi or the BannanaPi, but I do cover face recognition as well as Automatic License Plate Recognition inside the PyImageSearch Gurus course.

  10. Ekhwan Islam October 22, 2016 at 1:24 pm #

    Hey Adrian! it’s me,again.well,I solved the black screen in the video output window following this post you directed me to.However,the FPS is extremely low,maybe around 10 or so and then I can sort of see the frame being updated from the top left corner row by row.Any suggestion on that?In short the video stream isn’t satisfying at all.Waiting on your reply.

  11. Dayle November 10, 2016 at 2:46 pm #

    Hi Adrian,

    Firstly, I can’t say thanks enough. Your work is simply brilliant.

    I’ve been wanting to develop a motion detection approach for several years now, but ‘conventional wisdom’ was saying it couldn’t be done without using expensive hardware and going back to college to learn ‘everything’. Then I read about your missing beer and everything changed for me. In less than two weeks, I went through your book, companion case studies and a number of web tutorials and now I’m well on my way to developing a motion detection system on a Raspberry Pi that only existed on paper a month ago.

    To put my experience in perspective, it’s been 30 years since I did any real programming back in university and that was using Fortran and Pascal on a VAX terminal (look it up). Other than Adrian’s tutorials and some Googling, I had no exposure to Python, OpenCV or Raspberry Pi’s for that matter. For anyone considering diving in to image processing, I can’t recommend Adrian’s books and tutorials enough.



    • Adrian Rosebrock November 14, 2016 at 12:19 pm #

      Thank you for the kind words Dayle, I really appreciate them. It’s comments like these that reaffirm that PyImageSearch is well worth the effort of running! Have a great day my friend.

      • gourav February 21, 2017 at 10:33 am #

        hi adrian as we are using virtual env for opencv in raspberrypi when i write imshow in python run the code in terminal i am unable to view the image ca please help me with th one plss

        • Adrian Rosebrock February 22, 2017 at 1:38 pm #

          Are you executing the code over SSH or locally on the Pi? In either case, put a cv2.waitKey(0) call after cv2.imshow

  12. veer kumar November 14, 2016 at 12:22 pm #

    hello sir. i am using the pi 3. i wrote the same code to take a picture, camera also starts by glowing red led, but after few seconds
    it gets this error

    piCameraRuntimeError: no data received from sensor. check all connections including the sunny chip on camera board.

    now what to do to solve this problem.

    • Adrian Rosebrock November 14, 2016 at 12:25 pm #

      That seems to be a very specific Raspberry Pi camera error, one that I have not run into before. It sounds like your camera might not be hooked up correctly OR you may have not enabled it via raspi-config. If you continue to get this error I would suggest posting on the picamera GitHub issues page.

  13. Sasha November 15, 2016 at 12:03 pm #

    Hi Adrian,

    Thanks for your tutorials!! I am still getting “Incorrect buffer length for resolution” error even though I truncate the frame at every capture, as you suggested. Could you please suggest any other ways to fix it?

    • Adrian Rosebrock November 16, 2016 at 1:42 pm #

      I’m willing to bet that you’re forgetting to truncate your stream at the bottom of the while loop:


      Otherwise, you have initialized your camera to read a specific frame size but a different size is being read instead. I would suggest starting with this blog post on accessing the Raspberry Pi camera.

  14. Hafsah November 19, 2016 at 3:37 am #

    thx adrian..
    i was downgrade the picamera from picamer 1.12 to 1.10.
    and worked..
    tq very much..

  15. stuartiannaylor November 30, 2016 at 3:58 am #

    Dumb noob question here but is there any difference or advantage over…

    video_capture = cv2.VideoCapture(0)

    Is it better to specify the picamera lib?# Load the BCM V4l2 driver for /dev/video0
    os.system(‘sudo modprobe bcm2835-v4l2’)
    # Set the framerate ( not sure this does anything! )
    os.system(‘v4l2-ctl -p 8’)

    # Frame Size. Smaller is faster, but less accurate.
    # Wide and short is better, since moving your head
    # vertically is kinda hard!
    FRAME_W = 180
    FRAME_H = 100


    • Adrian Rosebrock December 1, 2016 at 7:35 am #

      I tend to get better performance out of the picamera library when I am using the actual Raspberry Pi camera module. However, that is just from personal experience. The only disadvantage that I would say is that V4L2 adds in extra steps.

  16. Jason Xu December 15, 2016 at 9:28 am #

    Hi Adrian. Thanks for the great work.

    I am following your code to grab frame from camera, using raspberry pi 3 and camera module. There are 2 things I want to ask.

    Firstly, I am getting blank white image box. I thought it was caused by “RGB” format, but I double checked that I am using “BGR” and opencv. I have downgrade pycamera to 1.10 but it did not work. When I am trying to run rpi-update, it shows “command not found”.

    Secondly, since I am doing quite intense computation for one frame, I set the framerate to be 1 (although the processing takes 10 seconds… ). For every loop, am I getting the latest frame or the last frame in the queue?

    Thank you. 🙂

    • Adrian Rosebrock December 18, 2016 at 9:07 am #

      That’s very strange that the rpi-update command is not being found. Are you using a recent version of Raspbian? I would suggest starting by resolving this issue first.

      As for the threading, that (realistically) doesn’t matter. Setting the framerate to 1 is fine, even if it takes longer for you to process each individual frame. The most recent frame will also be available from the streamer class.

  17. suhail February 2, 2017 at 11:51 am #

    I have a question that I can stream the video in another computer browser with the ip address of raspberry and I get a blank screen. I can’t view the video with streaming. I am using vnc for viewing the desktop not having a monitor. So my question is, can I view the video with streaming. camera is working, that I can take pictures and can view but only the video. can any one help me?

  18. Hayden February 12, 2017 at 4:58 pm #

    This solution worked brilliantly for me when I first setup according to Adrian’s recommendations. This man is truly a pioneer in the field of computer vision and to incorporate it in the $35 computer the raspberry pi is extremely commendable. I doubt the portability of bleeding-edge research and implementation for the layman in this field of study is on the TO-DO list for many academics. My many thanks and praise to Dr. A R.

    My second thought is has anyone had success with either of the 8 MP camera’s? the NOIR and the IR. I recently had to resort to a backup and had an error when running my program.

    The error didn’t offer much other than something about a “_core” in the message. I assume it has to do with the new 8 MP camera I had in. Running the older camera the 6 MP had no problems at all.

    • Adrian Rosebrock February 13, 2017 at 1:41 pm #

      Thanks Hayden, I appreciate the kind words 🙂

      As for the IR camera, I haven’t ran into the error message you are describing; however, I haven’t tried the new 8MP camera.

  19. Murad February 25, 2017 at 10:46 am #

    Thanks a lot Adrian! You are rock! Solve the black framed problem after rpi-update, uninstall picamera v1.12 and install v1.10. First try, I cannot uninstall v1.12 but after typed the “source ~/.profile” and “workon cv”, managed to uninstall it. Thankss

    • Adrian Rosebrock February 27, 2017 at 11:16 am #

      Congrats on resolving the error Murad, great job!

      • Jorge January 15, 2018 at 10:42 am #

        I cannot uninstall v1.13 :((((. More instructions for this please 🙁

        • Adrian Rosebrock January 15, 2018 at 11:00 am #

          Can you provide more information on what the error is? Are you getting a certain error message?

  20. Charl Pienaar April 18, 2017 at 4:28 am #

    Good day Adrian

    I am having the blank/black frame problem when using python and a webcam, no Raspberry Pi. What could be the problem? Your site is awesome and and help will be greatly appreciated.


    • Adrian Rosebrock April 19, 2017 at 12:50 pm #

      Hmm, I’m not sure why that issue would happen with a standard USB webcam. Perhaps it is a driver issue? I would try re-compiling OpenCV.

  21. Nathan Wallace May 22, 2017 at 11:45 am #

    Hi Adrian,

    I have come across your OpenCV knowledge in a quest to utilise SimpleCV for a process I need to work out. You seem like the man that might be able to help me with my question. I was trying to get SimpleCV to work on a raspi, so I could learn how to identify a mixed tray load of brass rifle cases, their size (calibre and designation), physical orientation in a tray and physical location (all one at a time), so the case can be picked up with a machine arm or similar. This will be a hobby type machine for a home user (just me LOL), nothing industrial sized. I was trying to see if the actual process would work. I am a TOTAL noob at linux/raspi, (having real trouble trying to get the camera to work with SimpleCV, driving me nuts!) and I was wondering if you would be able to determine whether this above stated intended application is feasible or not with this software? It seems as though OpenCV/SimpleCV is a very powerful piece of software. If it is possible, I want to learn it properly so I can do it, and get this device underway, as I need it! As they say, necessity is the mother of all invention. Thanks Adrian. Let me know what you think.

    • Adrian Rosebrock May 25, 2017 at 4:37 am #

      SimpleCV is a wrapper around OpenCV that makes it easier to work with. In general, I don’t recommend spending too much time studying SimpleCV as you’ll likely end up using OpenCV in the future once you learn the fundamentals. My suggestion would be for you to start with OpenCV and skip SimpleCV. If you need help learning the fundamentals of OpenCV and image processing, definitely take a look at my book, Practical Python and OpenCV.

      Regarding your specific question, if you can share a few images of the brass cases, I can help you determine if the project is feasible or not.

  22. abel December 12, 2017 at 11:02 pm #

    i keep getting ImportError: no module named cv2

    any ideas on what to do?

    • Adrian Rosebrock December 15, 2017 at 8:37 am #

      Hey Abel, it sounds like OpenCV has not been properly installed on your system. Please see my install guides to help you get up and running.

  23. Franz Mann January 19, 2018 at 7:53 pm #

    Connected the cam cable the wrong way,
    ie. the side with the blue markings is next to
    the HDMI-socket.
    It seems as if I have destroyed the cam – is that so?

    Can it eventually be recovered/revived? How?

    Thanks in advance BR Franz

    • Adrian Rosebrock January 22, 2018 at 6:37 pm #

      Turn off the Pi. Take out the ribbon. Flip it. And reboot. I accidentally have done this one or twice before as well. It shouldn’t hurt your Pi or camera.

  24. Stefan Gabriel February 11, 2018 at 1:39 am #

    I have a question and it might sound stupid but does the for loop get every frame from the camera? I’m wondering if the camera puts out more frames than the loop can take. Hope i’ve made my concern clear.
    Thank you.

    • Adrian Rosebrock February 12, 2018 at 6:30 pm #

      It’s not a stupid question, it’s a good question, and it’s not exactly easy to answer either. It all depends on the implementation inside the picamera module. I recommend using my VideoStream which always returns the next available frame.

  25. Sriram March 8, 2018 at 1:22 pm #

    Hi Adrian, I have installed opencv in my Raspberry pi 3 and when I try to run the program I am getting the following error:

    File “/home/pi/”, line 9, in
    import cv2
    ImportError: No module named ‘cv2’

    Please help.

    • Adrian Rosebrock March 9, 2018 at 9:03 am #

      Which tutorial did you use to install OpenCV on your Raspberry Pi? If you used a PyImageSearch tutorial I think you are missing the “workon” command to enter your Python virtual environment:

  26. Alex April 28, 2018 at 4:40 am #

    Hello Adrian.
    I have a Raspberry Pi 3 B+ with the Rasspberry Pi camera v2 module. I have built a ball tracking robot, based on your post, and I am using your threaded class for reading frames from the camera. The problem is, i have nearly 55 fps in 320×240 resolution, but if I try to run it with 640×480, the framerate drops down to 12 fps. Can you please help me with this? The robot is running quite well with 320×480, but it has a very small FOV, so that’s why I would like bigger resolution.


    • Adrian Rosebrock April 28, 2018 at 6:00 am #

      If you increase the resolution of the frame, the more data there is to process. The more data there is to process, the longer it will take to process a single frame. Unfortunately you will see quite the dip in FPS throughput as your spatial resolution increases.

  27. Lorenzo Leandro July 11, 2018 at 5:39 am #

    Hi Adrian,
    I am new to Raspberry and I am trying to use a Github code to make a Beam profiler using a pi noir camera.

    when I run it it opens it, gets the very first data, then shuts down saying segmentation fault. Sometimes (1/5 of the times-ish) it stays open with blank screen.
    I know that the data is correctly taken from the camera (because the beam analysis is shown correctly) but the video is always blank and anyway the program only starts once in a while.

    I tried the advices in this post but it did not improve. Do you have any word of advice on how to troubleshoot this segmentation fault? The code is too difficult for me to recreate from scratch…

    • Lorenzo Leandro July 11, 2018 at 6:07 am #

      update: if I run it with very low resolution (64×48 pixels) everything works fine and I even see the video…

      • Adrian Rosebrock July 13, 2018 at 5:18 am #

        Hm, that is indeed quite odd. Can you insert some print statements or use “pdb” to figure out which line exactly is causing the segmentation fault?

  28. Nitesh Adhikari September 9, 2018 at 3:06 am #

    No data received from sensor. Check all connections, including the Sunny one on the camera board
    i am getting this error.. can you please help me??

    • Adrian Rosebrock September 11, 2018 at 8:19 am #

      Hi Nitesh — what do you mean by the “sunny one on the camera board”?

  29. Shashank November 21, 2018 at 8:48 am #

    Hi Adrian,

    PyImageSearch has helped me a lot in my projects. Your work is great! I just cannot thank you enough for it.

    Currently, I am facing an issue with using picamera that… after some interval of time, the camera feed freezes and returns the same frame over and over. I was storing the frames from picamera as 1-minute video files and it was working properly earlier. Now, on running the same code, i am getting the same frame in all videos, except the 1st video. Also, while viewing the camera, the camera feed is also returning the same frame after working properly for some duration. I am not sure if it is a hardware problem. If you have any idea regarding this, it will really be helpful!

    • Adrian Rosebrock November 21, 2018 at 9:19 am #

      Wow, how strange! If your code has not changed and you haven’t updated your Pi then it’s likely a hardware problem. If you can, try using a different camera to see if it resolves the issue.

  30. Joseph Rasanjana February 14, 2019 at 2:17 pm #

    Thanks sir … You always saves my day… <3

    • Adrian Rosebrock February 14, 2019 at 3:08 pm #

      You are welcome, Joseph!

  31. vipulnath March 8, 2019 at 1:54 am #

    hai adrian , i have the same error of buffer length. i tried everything. but when ever i plug on my camera, the red indication led glows which is meant to go on only when camera works. so whenever i run a code the program gets stuck

    • Adrian Rosebrock March 8, 2019 at 5:19 am #

      You are almost certainly missing the call to “.truncate” (as I discuss in this post). Double-check and triple-check your code.

  32. Anant April 11, 2019 at 9:59 am #

    i was having a black screen for the camera as well. but changing the warm up time from .1 to .5 solved that issue.

  33. Anant April 11, 2019 at 10:03 am #

    Also i had a question. i wanted to take pics from the pi camera after turning a stepper motor in fifteen degree intervals till the complete 360 degree. I dont need to save the images just need some data from the images to be saved. Should i use capture method or continuous capture.

    • Adrian Rosebrock April 12, 2019 at 11:25 am #

      What type of data are you trying to extract from the input frames?

  34. Werner May 5, 2019 at 11:15 am #

    Hi Adrian,

    Can’t thank you enough for all the work and time your put into this. I’ll buy your book (a man’s got to eat ;)) even though Scamstarter scares the $#!# out of me nowadays.

    I was struggling with my camera not showing streams but the test-photos were OK, puzzling me. I found that there is another possible cause after I tried all the troubleshooting options you mentioned above…:
    DO NOT USE THE EXPERIMENTAL GL DRIVER – when you go through all the raspi-config options after a fresh install.

    So now my cam is working, I’ll move back to picamera v1.13 again, after downgrading it to 1.10, LOL.

    Kind regards,

    • Adrian Rosebrock May 8, 2019 at 1:16 pm #

      Thanks for sharing that Werner!

  35. Jay Franklin June 5, 2019 at 12:20 am #

    Hi Adrian,
    This is good stuff. I am trying to figure out a weird issue. I have a simple python script that snaps a photo using picamera. The script runs and the image is created. I need to automate this, so when I put the job in cron, it will never seem to snap the photo. I run the script manually as the pi user, and the cron job runs from pi’s cron. Can you recommend a way to trap for an error that I am not seeing? Have you every seen this type of issue before? All other aspects of the script seem to execute, until the function that snaps the photo runs.


    Jay Franklin

    • Adrian Rosebrock June 6, 2019 at 6:46 am #

      It actually sounds like an issue with cron. Try creating a shell script that launches the Python script and then redirects all output (both stdout and stderr) to an output file. Then launch that script via cron.

  36. Jon July 30, 2019 at 7:50 pm #

    Hello Adrian,

    I’ve tried everything under the sun to fix the “camera is not enabled” error on my raspberry pi. I tried downgrading, rpi-upgrade, uninstall, reinstalls, rapsi-config is always set to enable…out of ideas. Are there any other options?

    Thank you!

    • Jon July 30, 2019 at 8:04 pm #

      Nevermind, i had the camera plugged into the Display port. Rookie mistake!

      • Adrian Rosebrock August 7, 2019 at 12:49 pm #

        Congrats on resolving the issue, Jon!

Before you leave a comment...

Hey, Adrian here, author of the PyImageSearch blog. I'd love to hear from you, but before you submit a comment, please follow these guidelines:

  1. If you have a question, read the comments first. You should also search this page (i.e., ctrl + f) for keywords related to your question. It's likely that I have already addressed your question in the comments.
  2. If you are copying and pasting code/terminal output, please don't. Reviewing another programmers’ code is a very time consuming and tedious task, and due to the volume of emails and contact requests I receive, I simply cannot do it.
  3. Be respectful of the space. I put a lot of my own personal time into creating these free weekly tutorials. On average, each tutorial takes me 15-20 hours to put together. I love offering these guides to you and I take pride in the content I create. Therefore, I will not approve comments that include large code blocks/terminal output as it destroys the formatting of the page. Kindly be respectful of this space.
  4. Be patient. I receive 200+ comments and emails per day. Due to spam, and my desire to personally answer as many questions as I can, I hand moderate all new comments (typically once per week). I try to answer as many questions as I can, but I'm only one person. Please don't be offended if I cannot get to your question
  5. Do you need priority support? Consider purchasing one of my books and courses. I place customer questions and emails in a separate, special priority queue and answer them first. If you are a customer of mine you will receive a guaranteed response from me. If there's any time left over, I focus on the community at large and attempt to answer as many of those questions as I possibly can.

Thank you for keeping these guidelines in mind before submitting your comment.

Leave a Reply