-1

I'm not really sure how do go about doing this, I think template matching could work but I'm not really sure. Could someone help?

import cv2
import numpy as np

Fishisthere = cv2.imread("FishThere.jpg")

img = Fishisthere[579:600, 850:1360]

hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

lowerrange = np.array([106, 147, 0])
upperrange = np.array([179, 255, 245])

mask = cv2.inRange(hsv, lowerrange, upperrange)

cv2.imshow("edited", mask)
#cv2.imshow("normal1", hsv)
#cv2.imshow("normal1", img)

cv2.waitKey(0)
#cv2.destroyAllWindows()

  • Does this answer your question? [how to know if a color is detected on opencv](https://stackoverflow.com/questions/58288014/how-to-know-if-a-color-is-detected-on-opencv) – Hamid Rasti Aug 06 '22 at 11:49

1 Answers1

0

Did u face any errors? When I run ur code, this appears:

> Overload resolution failed:
>  - img is not a numpy array, neither a scalar
>  - Expected Ptr<cv::UMat> for argument 'img'
>  - img is not a numpy array, neither a scalar
>  - Expected Ptr<cv::UMat> for argument 'img'

I removed the codes on line 6 and it works fine for me:

import cv2
import numpy as np

Fishisthere = cv2.imread("FishThere.jpg")

hsv = cv2.cvtColor(Fishisthere, cv2.COLOR_BGR2HSV)

lowerrange = np.array([106, 147, 0])
upperrange = np.array([179, 255, 245])

mask = cv2.inRange(hsv, lowerrange, upperrange)

cv2.imshow("edited", mask)
#cv2.imshow("normal1", hsv)
#cv2.imshow("normal1", img)

cv2.waitKey(0)
#cv2.destroyAllWindows()
Nado
  • 3
  • 1
  • 5