Reputation: 1
I need to do use bitAnd operation with img1 and each image of the directory. I read each image as img2.
img1 = np.zeros((600, 400, 3), np.uint8)
center_coordinates = (320, 200)
axesLength = (300, 80)
angle = 150
startAngle = 0
endAngle = 360
color = (255, 255, 255)
thickness = -1
img1 = cv2.ellipse(img1,center_coordinates,axesLength,angle,startAngle,endAngle, color, thickness)
i =1
for filename in glob.glob(r'C:/Users/HRMini/MY PRACTICE/Background Removal/PalmReading/croppedCHD_FM/Critical1/*.jpg'):
img2 = cv2.imread(filename)
bitAnd = cv2.bitwise_and(img2, img1)
cv2.imshow("img1", img1)
cv2.imshow("img2", img2)
cv2.imshow('bitAnd',bitAnd)
cv2.waitKey(1)
cv2.destroyAllWindows()
i +=1
My code is not working:
Traceback (most recent call last)
<ipython-input-58-d9a04cb32013> in <module>
13 img2 = cv2.imread(filename)
14
---> 15 bitAnd = cv2.bitwise_and(img2, img1)
16
17 cv2.imshow("img1", img1)
error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\core\src\arithm.cpp:229: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and type), nor 'array op scalar', nor 'scalar op array' in function 'cv::binary_op'
Upvotes: 0
Views: 292