I'm calling this function on my laptop with (python version 2.72) and it works well; but when I move it to my PI (python ver 3.2.3) I get:
Traceback (most recent call last):
File "/usr/src/scripts/areadetect_movie_pi_17.py", line 337, in <module>
save_frame_deque(reduced, 10)
File "/usr/src/scripts/areadetect_movie_pi_17.py", line 65, in save_frame_deque
cv2.imwrite('/home/pi/Desktop/frame_2.jpg', q.popleft())
TypeError: <unknown> is not a numpy array
The code:
max_qlength = 10
q = deque ([0,max_qlength])
def save_frame_deque(picture, max_qlen):
max_qlength = max_qlen
q.append(picture)
print(len(q))# actual length of que
print (max_qlength)# max length of que
if len(q) > (max_qlength+1): # if actual length of q is bigger than 11
#cv2.imwrite('/home/pi/Desktop/frame_1.jpg', picture)
#cv2.imshow("frame", q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_2.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_3.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_4.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_5.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_6.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_7.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_8.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_9.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_10.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_11.jpg', q.popleft())
when I change the code to:
max_qlength = 10
q = deque ([0,max_qlength])
def save_frame_deque(picture, max_qlen):
max_qlength = max_qlen
q.append(picture)
print(len(q))# actual length of que
print (max_qlength)# max length of que
if len(q) > (max_qlength+1): # if actual length of q is bigger than 11
cv2.imwrite('/home/pi/Desktop/frame_1.jpg', picture)
#cv2.imshow("frame", q.popleft())
'''
cv2.imwrite('/home/pi/Desktop/frame_2.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_3.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_4.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_5.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_6.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_7.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_8.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_9.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_10.jpg', q.popleft())
cv2.imwrite('/home/pi/Desktop/frame_11.jpg', q.popleft())
'''
it works, so this would appear that my pi doesn't like popleft()
1) Is this the case, i'm not sure how to check if popleft is available in Python 3.2.3? 2) How do I fix this? 3) if poleft isn't available in the newer version of python, then is there an equivalent? there an