I wrote a Python code for storing a video on the sd-card of my a33 cam. My problem is, that the Filename will be stored, but I cannot write frames after opening the file. Here you can see my Python code. In the line "jevois.sendSerial(str(cap.isOpened()))" i can read, wether the File is opened or not. I always get the answer "false" (that means File not opened). I do not know what is wrong, where is my mistake. Can everybody help me? Every Tipp will be ok. Thank you.
def VideoSpeichern(self, frame):
jevois.sendSerial("VideoSpeichern")
cap = cv2.VideoCapture(0)
# Der Dateiname besteht aus Objekt, Datum und Uhrzeit. Dies wird hier zusammengefuegt.
now = datetime.now() # aktuelles Datum und Uhrzeit
date_object = now.strftime("%Y%m%d") # Heutiges Datum in date_object ablegen
time_object = now.strftime("%H%M%S") # Aktuelle Uhrzeit in time_object ablegen
PfadDatei = ("modules/Dambrowsky/OpenCVObjektErkennungBilderVideo/BilderVideos/ Person"+"_"+str(date_object)+"_"+str(time_object)+".avi")
# codec definieren und VideoWriter Objekt erzeugen
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter(PfadDatei,fourcc, 20.0, (640,480))
jevois.sendSerial(str(cap.isOpened()))
start = time.time()
while(cap.isOpened()):
ret, frame = cap.read()
jevois.sendSerial(str(ret))
if ret==True:
frame = cv2.flip(frame,0)
# frame in Datei schreiben
out.write(frame)
end = time.time()
jevois.sendSerial(end - start)
if (end - start > 30):
key = ord('q')
break
else:
break
# Alles wieder am Ende schliessen
cap.release()
out.release()