Ask Your Question
-1

ValueError: could not broadcast input array from shape (0,60,3) into shape (7,60,3)

asked 2018-10-20 09:58:49 -0600

Shantanu Nandan gravatar image

I am a newbie to openCV. I am tryying to implement image ROI by following this tutorial . Numpy version - 1.15.2 openCv Version - 3.4.3 Python - 3.4.3

Code i am using is -

import cv2
import numpy as np

img = cv2.imread("roi.jpg")
k = img.shape
print("Shape of Image in terms of Row, Column and Pattern i.e, BGR : ",k)
print("Type of Image : ",img.dtype)
ball = img[280:340, 330:390]
img[273:333, 100:160] = ball

Output Produced is -

Shape of Image in terms of Row, Column and Pattern i.e, BGR :  (280, 450, 3)
Type of Image :  uint8
Traceback (most recent call last):
  File ".\pixelAccess.py", line 36, in <module>
    img[273:333, 100:160] = nose
ValueError: could not broadcast input array from shape (0,60,3) into shape (7,60,3)
edit retag flag offensive close merge delete

Comments

it says nose not ball , so the code you show here is not the one you use.

and the error says: your nose has 0 rows, so a bad fit.

berak gravatar imageberak ( 2018-10-21 03:14:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-09-30 10:28:37 -0600

Check the image shape on your system, on the web the shape was (342, 548, 3), but on my system when I downloaded the image it was (280, 450, 3). So you need to resize the location of ball according to it. image description like this!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-20 09:58:49 -0600

Seen: 6,954 times

Last updated: Oct 20 '18