Traceback (most recent call last):
File "/project1/script1_callbacks", line 18, in onCook
cv2.error: OpenCV(4.5.0) /Users/malcolm/Desktop/devel/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Script TOP content:
# me - this DAT
# scriptOp - the OP which is cooking
import cv2
import numpy as np
# press 'Setup Parameters' in the OP to call this function to re-create the parameters.
def onSetupParameters(scriptOp):
return
# called whenever custom pulse parameter is pushed
def onPulse(par):
return
def onCook(scriptOp):
img = op('null1').numpyArray(delayed=True)
gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255,255]
# THIS CODE CALLS THE ERROR BUT NOT WHICH EXPECTED
cv2.imshow('dst',img)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()
# END ERROR AREA
return
I think you need to turn the RGBA into RGB and cast the type to uint8. I also think that the waitKey thing doesn’t work well in TouchDesigner so I disabled it.
# me - this DAT
# scriptOp - the OP which is cooking
import cv2
import numpy as np
cv2.namedWindow('dst',cv2.WINDOW_NORMAL)
# press 'Setup Parameters' in the OP to call this function to re-create the parameters.
def onSetupParameters(scriptOp):
return
# called whenever custom pulse parameter is pushed
def onPulse(par):
return
def onCook(scriptOp):
img = op('null1').numpyArray(delayed=True)
img = img[:,:,:3]
gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
# THIS CODE CALLS THE ERROR BUT NOT WHICH EXPECTED
cv2.imshow('dst',img.astype(np.uint8))
#if cv2.waitKey(0) & 0xff == 27:
# cv2.destroyAllWindows()
# END ERROR AREA
return
I mean the
‘OpenCV(4.5.0) /Users/malcolm/Desktop/devel/opencv/modules/imgproc/src/color.cpp:182: e’
is the absolute path for developer, not for the other users.
That path just get’s baked into the .dlls since that’s where I built it. The error is occurring firing due to the Python code, causing an assert in the .dll to go off. The. dll is reporting where in the original C++ code the assert is located, just cause that’s all it knows. You can ignore the path and just focus on the error message.