Ask Your Question

Revision history [back]

why do i get this error

masked = cv2.bitwise_and(img,img,mask=mask[:,:,2])
cv2_imshow(masked)                   

cv2.waitKey(0)                            # Cleanup after any key is pressed
cv2.destroyAllWindows()

This is my code 👆🏽

error                                     Traceback (most recent call last)
<ipython-input-49-5e3cd31dccb0> in <module>()
      1 #layer 2 is the red layer. Rememeber (B,G,R)
----> 2 masked = cv2.bitwise_and(img,img,mask=mask[:,:,2])
      3 cv2_imshow(masked)
      4 
      5 cv2.waitKey(0)                            # Cleanup after any key is pressed

error: OpenCV(4.1.2) /io/opencv/modules/core/src/arithm.cpp:245: error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function 'binary_op'

And the error 👆🏽 P.S. I am using Google Colaboratory