Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

No idea why the script gets this error code

Hello everybody,

I've written a script for detection of edges, but the problem is that my script get an error which i have added in the following. Whenever i want to run the script the shell appears for 1-2 seconds and after that it closes itself. I have no idea what it could be, i hope someone have an idea which would help me. The script is this here and the error code ist also in the following :

Script : import cv2 import numpy as np

cap = cv2.VideoCapture(0)

while(1):

_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

lower_red = np.array([30,150,50])
upper_red = np.array([255,255,180])

mask = cv2.inRange(hsv, lower_red, upper_red)
res = cv2.bitwise_and(frame,frame, mask= mask)

cv2.imshow('Original',frame)
edges = cv2.Canny(frame,100,200)
cv2.imshow('Edges',edges)

k = cv2.waitKey(5) & 0xFF
if k == 27:
    break

cv2.destroyAllWindows() cap.release()

The Error Code:

hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) cv2.error: C:\build\2_4_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:3961: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cv::cvtColor

No idea why the script gets this error code

Hello everybody,

I've written a script for detection of edges, but the problem is that my script get an error which i have added in the following. Whenever i want to run the script the shell appears for 1-2 seconds and after that it closes itself. I have no idea what it could be, i hope someone have an idea which would help me. The script is this here and the error code ist also in the following :

Script :

import cv2
import numpy as np

np cap = cv2.VideoCapture(0)

while(1):

cv2.VideoCapture(0)

while(1):

    _, frame = cap.read()
 hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

 lower_red = np.array([30,150,50])
 upper_red = np.array([255,255,180])

 mask = cv2.inRange(hsv, lower_red, upper_red)
 res = cv2.bitwise_and(frame,frame, mask= mask)

 cv2.imshow('Original',frame)
 edges = cv2.Canny(frame,100,200)
 cv2.imshow('Edges',edges)

 k = cv2.waitKey(5) & 0xFF
 if k == 27:
     break

cv2.destroyAllWindows()
cap.release()

cv2.destroyAllWindows() cap.release()

The Error Code:

hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
cv2.error: C:\build\2_4_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:3961: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cv::cvtColor

cv::cvtColor