Ask Your Question

Kepano's profile - activity

2018-03-19 08:03:24 -0600 received badge  Famous Question (source)
2016-08-12 02:43:05 -0600 received badge  Notable Question (source)
2016-03-14 06:22:43 -0600 received badge  Popular Question (source)
2014-10-20 09:04:20 -0600 commented question Saving video from webam stream - no file created

Now I have tried 'M','J','P','G' and 'M','P','E','G' and 'X','2','6','4' and none works. I found on a different forum that mjpg and mpeg should work on raspbian. I have used this guide to build opencv: http://robertcastle.com/2014/02/installing-opencv-on-a-raspberry-pi/

I don't think I chould miss anything.

2014-10-20 08:09:54 -0600 commented question Saving video from webam stream - no file created

Using the code: fourcc = cv2.VideoWriter_fourcc(*'XVID') gives me the following error:

Traceback (most recent call last): File "savingvideo.py", line 7, in <module> fourcc = cv2.VideoWriter_fourcc(*'XVID') AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

2014-10-20 04:51:10 -0600 commented question Saving video from webam stream - no file created

That is a mistake in this post. The slash is in the code (I will edit the OP post to the correct path).

Editing the path to be 'output.avi' does solve the problem either, so it is not the path that is wrong.

2014-10-20 04:02:15 -0600 commented question Saving video from webam stream - no file created

I tried removing the 2 ' -signs, but that only results in a syntax error. The tutoial use them too.

2014-10-18 09:27:49 -0600 received badge  Editor (source)
2014-10-18 09:27:09 -0600 asked a question Saving video from webam stream - no file created

I have followed the tutorial from this site about saving video streams to a file: Link to tutorial

The code starts streaming from the webcam, but when I press 'Esc' no avi-file is created

My code:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

#fourcc = cv2.VideoWriter_fourcc(*'XVID') <-- this line results in an error 
fourcc = cv2.cv.CV_FOURCC('X','V','I','D')

out = cv2.VideoWriter('/home/pi/video/output.avi',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        frame = cv2.flip(frame,0)

        out.write(frame)

        cv2.imshow('frame',frame)
        if cv2.waitKey(10) == 27:
            break
    else:
        break

cap.release()
out.release()
cv2.destroyAllWindows()

I am using python 2.7 and OpenCV-2.4.10 on my raspberry Pi.

Also, I have tried to use 2 or 3 different codes on blogs used for the same purspose, and none of them saves a video file, eventhough the rest of the code works well.

Do I need to install some packages,or how can I solve this issue?

Best regards

edit: added / to the file-path.