Getting an “integer is required (got type tuple)” error, drawing a rectangle using cv2

前端 未结 3 1695
日久生厌
日久生厌 2021-01-15 01:19

I have written a basic Python code to create an image and then putting a rectangle on the boundaries. This doesn\'t seem to work. I have checked multiple sites and this is t

3条回答
  •  遥遥无期
    2021-01-15 01:43

    Found the solution. Thanks @Martijn Pieters

    import cv2
    import numpy as np
    from PIL import Image
    
    img = Image.new('RGB', (800, 900), color= (171, 183, 255))
    open_cv_image = np.array(img) 
    
    cv2.rectangle(open_cv_image,(0,0),(800,900),(0,0,0),30)
    img2 = Image.fromarray(open_cv_image, 'RGB')
    

提交回复
热议问题