Ask Your Question
1

frame = cv2.VideoCapture.read(capture) AttributeError: 'builtin_function_or_method' object has no attribute 'read'

asked 2013-07-01 08:24:35 -0500

iftheqhar gravatar image

updated 2013-07-01 08:39:27 -0500

berak gravatar image

am trying to capture video from my web cam and display it on my screen my code is

import cv2
import numpy as np
from matplotlib import pyplot as plt

capture = cv2.VideoCapture(0)
def repeat():
   if(capture):
         frame = cv2.VideoCapture.read(capture)
         cv2.imshow("w1",frame)
while True:
   repeat()

am getting this error frame = cv2.VideoCapture.read(capture) AttributeError: 'builtin_function_or_method' object has no attribute 'read'

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-07-02 01:47:00 -0500

berak gravatar image

aw man, try this instead:

cv2.namedWindow("lll")
cap = cv2.VideoCapture(0)
while( cap.isOpened() ) :
    ret,img = cap.read()
    cv2.imshow("lll",img)
    k = cv2.waitKey(10)
    if k == 27:
        break
edit flag offensive delete link more

Comments

thank you its workin

iftheqhar gravatar imageiftheqhar ( 2013-07-02 02:17:33 -0500 )edit

i want to read all videos then, take a single frame from each video

jeevitha gravatar imagejeevitha ( 2019-03-15 04:35:49 -0500 )edit

@jeevitha, and what keeps you from doing such a straightforward thing ?

berak gravatar imageberak ( 2019-03-15 04:37:42 -0500 )edit
0

answered 2013-07-01 08:44:14 -0500

berak gravatar image

here, you create an instance of VideoCapture:

capture = cv2.VideoCapture(0)

then you'd want to use that instance ( not the class! )

ret,frame = capture.read()
// go on processing frame
edit flag offensive delete link more

Comments

am getting this error now

frame = Capture.read(capture) NameError: global name 'Capture' is not defined

iftheqhar gravatar imageiftheqhar ( 2013-07-02 01:41:59 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-07-01 08:24:35 -0500

Seen: 11,401 times

Last updated: Jul 02 '13