0

I've been running my camera for nearly over a month now, with brief halting throughout the past month, but recently I noticed my picamera was not taking any pictures, I checked the script and it was failing at:

PiCameraValueError: Incorrect buffer length for resolution 128x80

Here is my python 2.7 code:

testWidth = 128
testHeight = 80

def takeDayImage(imageWidth, imageHeight, filename):
    if verbose:
        print "takeDayImage - Working ....."
    with picamera.PiCamera() as camera:
        camera.resolution = (imageWidth, imageHeight)
        # camera.rotation = cameraRotate #Note use imageVFlip and imageHFlip variables
        if imagePreview:
            camera.start_preview()
        camera.vflip = imageVFlip
        camera.hflip = imageHFlip
        # Day Automatic Mode
        camera.exposure_mode = 'auto'
        camera.iso = dayISO
        camera.awb_mode = 'auto'
        camera.capture(filename)
        camera.led = True #False
    if verbose:
        print "takeDayImage - Captured %s" % (filename)
        camera.truncate(0) #added 07-30-17
    return filename

def motionDetection():
    print "Scanning for Motion threshold=%i sensitivity=%i ......"  % (threshold, sensitivity)
    print "Successfully loaded detectmotion.py"
    isDay = True
    currentCount= 1000
    while True:
        if scanMotion(testWidth, testHeight, isDay):
            filename = getFileName(imagePath, imageNamePrefix, currentCount)
            if numberSequence:
                currentCount += 1
            if isDay:
                takeDayImage( imageWidth, imageHeight, filename )
            else:
                takeNightImage( imageWidth, imageHeight, filename )

I had read to call the .truncate() method and have implemented it, after researching this exact error (as stated above), but it still seems to be having this same error.

Can someone please help?

  • Have you tried changing the width and height to 1080x720 and then crop it? It could be that the camera has a minimum size. – kuzeyron Jul 31 '17 at 9:49
  • @MathiasLindström tried that but the error changes then to: PiCameraValueError: Incorrect buffer length for resolution 1080x720 . any other thoughts? still stuck – Jshee Jul 31 '17 at 23:06
  • Could you pastebin the whole code? – kuzeyron Aug 1 '17 at 20:39
1

Your problem seems to be:

imageDir = "westmontavecamimage"
imagePath = "/media/pi/StoyAveCamStorag/" + imageDir

Does a great job on my Pi. You could check if Python has read/write rights if that doesn't solve the problem for you.

  • how does thus present a problem? the full path of imagePath doesnt end with / – Jshee Aug 3 '17 at 21:02
  • @Jshee: If the path isn't correct. It won't be able to save the pictures. – kuzeyron Aug 4 '17 at 8:54

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.