movement-tracking icon indicating copy to clipboard operation
movement-tracking copied to clipboard

Getting 215 assertion failed!! on line 81!!

Open pawanline opened this issue 3 years ago • 9 comments

Hi , I am newbie to python.I just saw linkedin and try to setup and run this code. getting an error searched Stackoverlow not solved yet.

Traceback (most recent call last): File "movement-v2.py", line 81, in img, nose_cords = detect_nose(img, faceCascade) File "movement-v2.py", line 10, in detect_nose gray_img = cv2.cvtColor(img, cv2.COLOR_BAYER_BG2RGB) cv2.error: OpenCV(4.3.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

can you please help?

Thanks in Advance.

pawanline avatar Jul 26 '20 14:07 pawanline

Unable to get camera on -1 Go to line 67 video_capture = cv2.VideoCapture(-1) try to change -1 to 0 or 1 it will work for you

surya-veer avatar Jul 26 '20 15:07 surya-veer

Hii, I tried to run your script its giving error. Can you please tell how to fix . I am new to python. ERROR Traceback (most recent call last): File "F:\movement-tracking-master\movement-v2.py", line 83, in img, nose_cords = detect_nose(img, faceCascade) File "F:\movement-tracking-master\movement-v2.py", line 11, in detect_nose gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Thanks In Advance

gaurav45 avatar Jul 26 '20 16:07 gaurav45

Since your camera is not capturing video and returning None which is raising an exception in typecast. You need to set the correct camera path to resolve this.

LINUX/MAC: run this in your console ls -ltrh /dev/video* it will show you the list of video device in your computer like /dev/video0 then replace line 67: video_capture = cv2.VideoCapture(-1) to video_capture = cv2.VideoCapture('dev/video0')

WINDOWS: Run this following camera code and check available device id and use that in cv2.VideoCapture(id)

cams_test = 10
for id in range(0, cams_test): //if you don't find it please check your camera if it is working or not
    cap = cv2.VideoCapture(id)
    test, frame = cap.read()
    if test:
        print("id : "+str(id)+" /// result: "+str(test))
    cap.release()

surya-veer avatar Jul 26 '20 17:07 surya-veer

Since your camera is not capturing video and returning None which is raising an exception in typecast. You need to set the correct camera path to resolve this.

LINUX/MAC: run this in your console ls -ltrh /dev/video* it will show you the list of video device in your computer like /dev/video0 then replace line 67: video_capture = cv2.VideoCapture(-1) to video_capture = cv2.VideoCapture('dev/video0')

WINDOWS: Run this following camera code and check available device id and use that in cv2.VideoCapture(id)

cams_test = 10
for id in range(0, cams_test): //if you don't find it please check your camera if it is working or not
    cap = cv2.VideoCapture(id)
    test, frame = cap.read()
    if test:
        print("id : "+str(id)+" /// result: "+str(test))
    cap.release()

try 0 as argument... In linux it take 0 for webcam

cbhushan051 avatar Jul 27 '20 09:07 cbhushan051

Sir its fix now that's why i delete that comment and i want to thanks to you and give req ti you on linkdin but now i thanks to you on email😅😅

On Mon, 27 Jul 2020, 15:10 CHANDRA BHUSHAN, [email protected] wrote:

Since your camera is not capturing video and returning None which is raising an exception in typecast. You need to set the correct camera path to resolve this.

LINUX/MAC: run this in your console ls -ltrh /dev/video* it will show you the list of video device in your computer like /dev/video0 then replace line 67: video_capture = cv2.VideoCapture(-1) to video_capture = cv2.VideoCapture('dev/video0')

WINDOWS: Run this following camera code and check available device id and use that in cv2.VideoCapture(id)

cams_test = 10 for id in range(0, cams_test): //if you don't find it please check your camera if it is working or not cap = cv2.VideoCapture(id) test, frame = cap.read() if test: print("id : "+str(id)+" /// result: "+str(test)) cap.release()

try 0 as argument... In linux it take 0 for webcam

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/surya-veer/movement-tracking/issues/4#issuecomment-664243140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOLCTZERN6SBZXFPYDJUBDTR5VDSRANCNFSM4PIACULA .

sahilcool321 avatar Jul 27 '20 09:07 sahilcool321

C:\Users\Dell\Desktop\new web\movement-tracking-master>movement-v1.py Traceback (most recent call last): File "C:\Users\Dell\Desktop\new web\movement-tracking-master\movement-v1.py", line 78, in img, nose_cords = detect_nose(img, faceCascade) File "C:\Users\Dell\Desktop\new web\movement-tracking-master\movement-v1.py", line 10, in detect_nose gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

I am facing this problem please help

Hasnainajmal avatar Jul 27 '20 18:07 Hasnainajmal

@Hasnainajmal https://github.com/surya-veer/movement-tracking/issues/4#issuecomment-664018021

surya-veer avatar Jul 27 '20 19:07 surya-veer

I was having similar issues and the solutions above did not resolve this alone. In order to get this to work, I needed to install opencv-python-headless instead of opencv-python and change the -1 to 1. Sharing here in case others run into the same thing.

eftanzer avatar Jul 29 '20 16:07 eftanzer

Hiii, Yes i already tried it by passing 0 as argument it is working fine now. Thanks

On Mon, 27 Jul 2020, 1:52 pm Sahil Sharma, [email protected] wrote:

hii, down and right keys doing great function but left and up are not perform well well, can you tell me how can I optimized it because most of the time it goes for down key

can you please me?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/surya-veer/movement-tracking/issues/4#issuecomment-664196143, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFC7JFVQFE4PUXB3GL2BBSLR5U2NVANCNFSM4PIACULA .

gaurav45 avatar Jul 30 '20 13:07 gaurav45