0

Hey when i am running code i got this annoying error

#!/usr/bin/env python

import numpy as np
import cv2 as cv
import os
from pantilthat import *

os.system('sudo modprobe bcm2835-v4l2')

cascade =  cv.CascadeClassifier('/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml')
#cascade = cv.Load('/usr/share/opencv/lbpcascades/lbpcascade_frontalface.xml')

cam_pan = 90
cam_tilt = 45

# Turn the camera to the default position
pan(cam_pan-90)
tilt(cam_tilt-90)
light_mode(WS2812)

def lights(r,g,b,w):
    for x in range(18):
        set_pixel_rgbw(x,r if x in [3,4] else 0,g if x in [3,4] else 0,b,w if x in [0,1,6,7] else 0)Traceback (most recent call last):
  File "facetracker_haar.py", line 45, in <module>
    frame = cv.VideoCapture.read(cap)
AttributeError: 'builtin_function_or_method' object has no attribute 'read'
    show()

lights(0,0,0,50)

min_size = (15, 15)
image_scale = 5
haar_scale = 1.2
min_neighbors = 2
haar_flags = cv.CASCADE_DO_CANNY_PRUNING

cap = cv.VideoCapture(0)
cv.namedWindow("Tracker", 1)

if cap:
    frame_copy = None

while(True):
    # Capture frame-by-frame
    frame = cv.VideoCapture.read(cap)
    if not frame:
        cv.WaitKey(0)
        break
    if not frame_copy:
        frame_copy = cv.CreateImage((frame.width,frame.height),
                                            cv.IPL_DEPTH_8U, frame.nChannels)
    if frame.origin == cv.IPL_ORIGIN_TL:
        cv.Flip(frame, frame, -1)

i get this error:

Traceback (most recent call last):
  File "facetracker_haar.py", line 45, in <module>
    frame = cv.VideoCapture.read(cap)
AttributeError: 'builtin_function_or_method' object has no attribute 'read'

any suggestion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.