# OpenCV - Numpy Error

**URL:** <https://forum.opencv.org/t/opencv-numpy-error/11866>\
**Category:** Python\
**Tags:** numpy, raspberrypi, programming\
**Created:** [February 3, 2023, 9:17pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866 "2023-02-03T21:17:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev\_101](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dev_101/32/6486_2.png) [@Dev\_101](https://forum.opencv.org/u/Dev_101)\
**Post date:** [February 3, 2023, 9:17pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/1 "2023-02-03T21:17:57Z")

</div>

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

````auto
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

```auto
#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()

```

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 3, 2023, 9:20pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/2 "2023-02-03T21:20:28Z")

</div>

> [@Dev\_101](#):
>
> ```auto
> cv2.line(img,x,img.shape[0],x,intensity//255,(255,0,255),1)
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![Dev\_101](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dev_101/32/6486_2.png) [@Dev\_101](https://forum.opencv.org/u/Dev_101)\
**Post date:** [February 3, 2023, 9:27pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/3 "2023-02-03T21:27:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 3, 2023, 9:50pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/4 "2023-02-03T21:50:55Z")

</div>

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](https://docs.opencv.org/4.x/d6/d6e/group __imgproc__ draw.html#ga7078a9fae8c7e7d13d24dac2520ae4a2)

---

<div class="post-metadata">

**Author:** ![Dev\_101](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dev_101/32/6486_2.png) [@Dev\_101](https://forum.opencv.org/u/Dev_101)\
**Post date:** [February 3, 2023, 10:00pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/5 "2023-02-03T22:00:58Z")

</div>

Ok, that helped. Thank you so much.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 3, 2023, 10:32pm UTC](https://forum.opencv.org/t/opencv-numpy-error/11866/6 "2023-02-03T22:32:04Z")

</div>

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