When I am running script facerec_on_raspberry_pi.py it gives me following error:
ValueError: buffer object must be one-dimensional and have unsigned byte format ("B")
Solved with setting a writable flag using array.setflags(write=True)
Hi, can you post the fixed example code? I have the same issue and is not resolved setting the array to write=true.
I am using PiCamera for capturing frames and I am using it like this
with picamera.PiCamera() as camera:
with picamera.array.PiRGBArray(camera) as stream:
for frame in camera.capture_continuous(stream, 'bgr', use_video_port=True):
frame_array = frmae.array
frame_array.setflags(write=True)
# rest of the process
Hi @smitshilu, I have seen the same issue. Follow your fix, i still cannot run the code successfully. is that possible to attach the full file here ? Thank you so much in advance.
It's probably using python2. If you check picamera doc(Chapter Capture to a numpy array) ( doc link), you'll find for python 2.X, the buffer object must be 1-dimensional. For the case, the solution is remove output = np.empty((240, 320, 3), dtype=np.uint8) and change a few lines in the while loop like this
output = np.numpy((240*320*3,),dtype=np.uint8)
camera.capture(output, format='rgb')
output = output.reshape((240,320,3))
Hi @smitshilu, I have seen the same issue. Follow your fix, i still cannot run the code successfully. is that possible to attach the full file here ? Thank you so much in advance.
Hello,
My code is something like this. For more information regarding your issue please attach what error are you getting to debug the program.
with picamera.PiCamera() as camera:
with picamera.array.PiRGBArray(camera) as stream:
for frame in camera.capture_continuous(stream, 'bgr', use_video_port=True):
frame_array = frmae.array
frame_array.setflags(write=True)
dets = detector(frame_array, 1)
for i, d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(i, d.left(), d.top(), d.right(), d.bottom()))
cv2.rectangle(img, (d.left(),d.top()), (d.right(), d.bottom()), (0, 0, 255), 3)