-1

While running this code, getting the value error:

mask_image_temp = np.zeros((1080,1920), dtype=np.uint8)

ndarray_blue = np.array([[1100,600], [375,600], [520,400], [960,400]], np.int32)

polygon_blue = cv2.fillPoly(mask_image_temp,[ndarray_blue],color=1)

polygon_blue = polygon_blue[:,:,np.newaxis]

polygon_blue = cv2.resize(polygon_blue,(960,540))

blue_color_plate = [255,0,0]

blue_image = np.array(polygon_blue * blue_color_plate,np.uint8)

enter image description hereValueError: operands could not be broadcast together with shapes (540,960) (3,)

Expecting these results:

enter image description here

Varun Singh
  • 63
  • 1
  • 3
  • 13
  • 3
    Does this answer your question? [python numpy ValueError: operands could not be broadcast together with shapes](https://stackoverflow.com/questions/24560298/python-numpy-valueerror-operands-could-not-be-broadcast-together-with-shapes) – Henry Jul 16 '21 at 18:30
  • @Henry i have tried reshaping also but iam doing something wrong there also, can u please tell me using above code – Varun Singh Jul 16 '21 at 18:36
  • 1
    I don't know how to fix that, sorry – Henry Jul 16 '21 at 18:45

2 Answers2

0

From the error message, I deduce that in:

polygon_blue * blue_color_plate

the first is (540,960) shape, and the second, (3,)

The second is (by the previously line), with an obvious shape of 3:

blue_color_plate = [255,0,0]

and the other from the previous csv.resize line

As to correction, we don't know the author's intention, so can't suggest a fix.

hpaulj
  • 221,503
  • 14
  • 230
  • 353
0

Got the solution ,it may be due to resizing polygon_blue before multiplication with blue_color_plate .

Solution enter image description here

Varun Singh
  • 63
  • 1
  • 3
  • 13