backgroundRemoval icon indicating copy to clipboard operation
backgroundRemoval copied to clipboard

'NoneType' object has no attribute 'shape'

Open malikamazayn opened this issue 5 years ago • 10 comments

AttributeError Traceback (most recent call last) in 18 success, img = video.read() 19 success2, bg = oceanVideo.read() ---> 20 bg = resize(bg,ref_img) 21 if flag==0: 22 ref_img = img

in resize(dst, img) 4 5 def resize(dst,img): ----> 6 width = img.shape[1] 7 height = img.shape[0] 8 dim = (width, height)

AttributeError: 'NoneType' object has no attribute 'shape'

malikamazayn avatar Jun 18 '20 09:06 malikamazayn

You are probably running into an issue while reading the image from the webcam. Try printing the"success" and"success2" flags. You'll see if the camera is being read properly or not.

Regards Misbah

On Thu, Jun 18, 2020, 4:00 AM malikamazayn [email protected] wrote:

AttributeError Traceback (most recent call last) in 18 success, img = video.read() 19 success2, bg = oceanVideo.read() ---> 20 bg = resize(bg,ref_img) 21 if flag==0: 22 ref_img = img

in resize(dst, img) 4 5 def resize(dst,img): ----> 6 width = img.shape[1] 7 height = img.shape[0] 8 dim = (width, height)

AttributeError: 'NoneType' object has no attribute 'shape'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/misbah4064/backgroundRemoval/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGX4RXUIK556XG2QSNTVI3RXHJTZANCNFSM4OBL2ZDQ .

misbah4064 avatar Jun 18 '20 09:06 misbah4064

its printing False for success, and true for success 2.

malikamazayn avatar Jun 18 '20 10:06 malikamazayn

It's because there's some issue while reading the image from the camera. See if the camera is working properly, if it is then see if it's available for opencv to detect. One of my videos I went through reading images from camera. See if this helps: https://youtu.be/H-_ou21IXs0

Regards Misbah

On Thu, Jun 18, 2020, 5:06 AM malikamazayn [email protected] wrote:

its printing False for success, and true for success 2.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/misbah4064/backgroundRemoval/issues/1#issuecomment-645920241, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGX4RSBEQ3ZYC5X7UAZ6G3RXHRLZANCNFSM4OBL2ZDQ .

misbah4064 avatar Jun 18 '20 13:06 misbah4064

Change cv2.VideoCapture(1) to cv2.VideoCapture(0). It is a MacOS bug for Coaca applications. Still if your unable to get it. drop comment

sheelarajeshkumar avatar Jun 27 '20 08:06 sheelarajeshkumar

well after changing cv2.VideoCapture(0) , i am only able to see the video rather than video + Web cam image.

malikamazayn avatar Jun 27 '20 10:06 malikamazayn

well after changing cv2.VideoCapture(0) , i am only able to see the video rather than video + Web cam image.

facing the same issue, did you find a solution for it ?

mchulet avatar Jul 19 '20 20:07 mchulet

Run the program and step out of the frame so it is just your background on the screen, then press 'D' on your keyboard and step into the frame.

nabikhalid avatar Jul 20 '20 16:07 nabikhalid

Run the program and step out of the frame so it is just your background on the screen, then press 'D' on your keyboard and step into the frame.

Thanks, that did move the needle but the output video contained lot of background.

image

mchulet avatar Jul 20 '20 19:07 mchulet

How should I use it with Google Meet? If I run the program first, then google meet is not able to detect camera since it is busy and vice versa too.

MangalamPalod avatar Oct 15 '20 12:10 MangalamPalod

In backgroundRemoval_video.py, change line 12 "video = cv2.VideoCapture(1)" to video = cv2.VideoCapture(0)

octaviawfx avatar Oct 26 '20 10:10 octaviawfx