1
cv2.namedWindow("Trackbars")
cv2.resize("Trackbars", 640 ,420)
cv2.createTrackbar("Hue Min","Trackbars",0,179,empty)

I am using this code to create and resize the new window but its showing giving me following error: what am doing wrong here ?

Overload resolution failed:

  • src is not a numpy array, neither a scalar
  • Expected Ptr<cv::UMat> for argument 'src'

what is wrong here ?

2 Answers2

0

There are two slightly different ways to do this.

I would recommend changing resize to resizeWindow. cv2.WINDOW_KEEPRATIO keeps the correct ratio of an image (if you have one).

cv2.namedWindow("Trackbars", cv2.WINDOW_KEEPRATIO)
cv2.resizeWindow("Trackbar", 640, 420)

You could also resize the window in a ratio form instead of a specific pixel - this is if you have the media input as a variable (image).

cv2.resize(frame, (0,0), fx=0.4, fy=0.4)

TerminalFlow
  • 230
  • 2
  • 11
0

cv2.resize("Trackbars", 640 ,420)
"Trackbars" is not an numpy array. Add an image here. hence src error. Use cv2.imread to read your image or from another source.
Secondly, 640, 420 should be a tuple (640,420) i.e dimensions.

booyaakaashaa
  • 105
  • 12
  • 1
    Documentation for cv2.namedWindow() https://docs.opencv.org/3.4/d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b – booyaakaashaa Jun 19 '21 at 16:22