I have a phone and it's HSV histogram like blow,and I want to track this phone's movement.Based on it's histogram,I set image range like this:
greenLower = (300, 0, 50)
greenUpper = (50, 128,250 )
cv2.inRange(hsv, greenLower, greenUpper)
But nothing got detected out when waving the phone,and I am pretty sure it is because color range is wrong,would you tell me how to get color rang setting right?Especially,when HUE values are between [300~50],should I set it to (50~300) or (300~50) due to HUE is a cirle.
Phone
HSV histogram:
You have wrongly set the upper and lower bounds, they must be:
Also make sure that
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
as OpenCV follows theBGR
convention.EDIT:
To segment colors in multiple ranges
0~50
and300~359
, you can performcv2.inRange()
twice for two ranges as: