OpenCV - Numpy Error

Hello,
I have been trying to plot a point on a frame in openCV.
It is not working and I am getting this error:

Traceback (most recent call last):
  File "/home/pi/Fair/Code/Software/Curve.py", line 84, in <module>
    frame,mask,warp,warpThresh,roi,histogram,complete = getCurve(frame)
  File "/home/pi/Fair/Code/Software/Curve.py", line 48, in getCurve
    basePoint, histogram = getHistogram(warpThresh,display=True)
  File "/home/pi/Fair/Code/Software/Curve.py", line 26, in getHistogram
    cv2.line(img,x,img.shape[0],x,intensity//255,(255,0,255),1)
cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
>  - Can't parse 'pt1'. Input argument doesn't provide sequence protocol
>  - Can't parse 'pt1'. Input argument doesn't provide sequence protocol```

I am relatively new and a. basing my project on another tutorial, what did I do wrong?
OS: Raspberrian 64 Bit
Python:3.9.2
OpenCV: 4.5.3

#1/15/23
import cv2
import numpy as np
import Thresh
import ROI

def empty(x):
    pass

def getHistogram(img,minPer = 0.1,display = False):

    histValues = np.sum(img,axis=0)
    maxValue = np.max(histValues)
    minValue = minPer*maxValue


    indexArray = np.where(histValues>=minValue)
    basePoint = np.average(indexArray)
    basePoint = int(basePoint)
    print(basePoint)

    if display:
        imgHist = np.zeros((img.shape[0],img.shape[1],3),np.uint8)
        for x,intensity in enumerate(histValues):
            cv2.line(img,x,img.shape[0],x,intensity//255,(255,0,255),1)
        return basePoint,imgHist
    return basePoint

def getCurve(frame):

   
    # Step 1: Threhold Paper
    frame,mask,result = Thresh.thresh(frame)

    frameWPoints = frame.copy()
    warpThresh = mask.copy()
    warpFrame = frame.copy()

    # Step 2: Define ROI
    hT, wT, c = frame.shape
    points = ROI.valTrackbars()
    # Step 3: Warp Image
    warpFrame = ROI.warpImg(warpFrame,points,wT,hT)
    warpThresh = ROI.warpImg(warpThresh,points,wT,hT)
    imgWarpPoints = ROI.drawPoints(frameWPoints,points)
    # Step 4: Apply Histogram - Summation of Pixels
    basePoint, histogram = getHistogram(warpThresh,display=True)

    # Step 5: Calculate Curve
 
    # Step 6: Filter Curve
  
    # Step 7: Display

    
    complete = frame

    return frame,mask,warpFrame,warpThresh,imgWarpPoints,histogram,complete





if __name__ == "__main__":
    

    cv2.namedWindow("HSV")
    cv2.resizeWindow("HSV", 640, 240)
    cv2.createTrackbar("HUE Min", "HSV", 0, 255, empty)
    cv2.createTrackbar("HUE Max", "HSV", 179, 255, empty)
    cv2.createTrackbar("SAT Min", "HSV", 0, 255, empty)
    cv2.createTrackbar("SAT Max", "HSV", 255, 255, empty)
    cv2.createTrackbar("VALUE Min", "HSV", 113, 255, empty)
    cv2.createTrackbar("VALUE Max", "HSV", 255, 255, empty)
    
    intialTrackBarVals = [50, 108, 0, 140]
    ROI.initializeTrackbars(intialTrackBarVals)
    
    vid = cv2.VideoCapture(0)
    while(1):
        _,frame = vid.read()
        frame = cv2.resize(frame,(480,240))
        frame,mask,warp,warpThresh,roi,histogram,complete = getCurve(frame)
        
        l1 =np.concatenate((frame,mask),axis=1)
        l2 =np.concatenate((roi,warp,warpThresh),axis=1)
        l3 =np.concatenate((histogram,complete),axis=1)
        cv2.imshow("THRESH",l1)
        cv2.imshow("TRANSFORM",l2)
        cv2.imshow("RESULT",l3)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    

    vid.release()

    cv2.destroyAllWindows()

all coords must be integer, not float
manually cast all 4 of them: int(x) , etc

Hi,
I tried that and it did not work. I might have converted the wrong arguments. May you show me which ones?

Thanks,
Dev_101

there’s always more than one error, right ?

look here, you need 2 (x y) points (tuples) not 4 single integers

https://docs.opencv.org/4.x/d6/d6e/group__imgproc__draw.html#ga7078a9fae8c7e7d13d24dac2520ae4a2

Ok, that helped. Thank you so much.

I would very much recommend that you learn how to use Python’s debugger. Learn this.