When i try to run this code :
import cv2
import vlc
cam = cv2.VideoCapture(0)
m = vlc.MediaPlayer('D:\faith-42201.mp3')
fd = cv2.CascadeClassifier(r'C:\Users\Shivani Khare\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\cv2\data\haarcascade_frontalface_alt.xml')
m.play()
flag=1
m.audio_set_volume(100)
while(True):
r,i = cam.read()
#i[0:10,:,:]=255
#for adding rows
j = cv2.cvtColor(i,cv2.COLOR_BGR2GRAY)
face = fd.detectMultiScale(j,1.3,7)
for (x,y,w,h) in face:
cv2.rectangle(i,(x,y),(x+w,y+h),(0,0,0),-1)
t = w*h
m.audio_set_volume(100-int(t/500))
l = len(face)
if(l>0):
m.play()
flag = 0
elif(flag==0):
m.pause()
flag = 1
print("no of faces are : ",len(face),face)
cv2.imshow('image1',i)
k = cv2.waitKey(5)
print(k)
if(k==27):
cv2.destroyAllWindows()
break
I keep getting this error :
Traceback (most recent call last):
File "C:\Users\Shivani Khare\AppData\Local\Programs\Python\Python36\hi.py", line 5, in m = vlc.MediaPlayer('D:\faith-42201.mp3') File "C:\Users\Shivani Khare\AppData\Local\Programs\Python\Python36\lib\site-packages\vlc.py", line 3184, in new o.set_media(instance.media_new(*args)) File "C:\Users\Shivani Khare\AppData\Local\Programs\Python\Python36\lib\site-packages\vlc.py", line 1788, in media_new m._instance = self AttributeError: 'NoneType' object has no attribute '_instance'
Please help