I am writing a Python program for image tracking in which I receive input BGR values for min and max values and then filter a live video feed to only show values between those min and max values. While the input is in BGR, I need to filter the video using HSV. However, I am having trouble figuring out how to convert my single BGR input arrays into HSV arrays in numpy without having to use the cvtColor function on the entire image.
From my understanding, it seems like the cv2.cvtColor() function will only work on the entire image but I need to be able to convert just these select min and max BGR arrays to HSV before I do the color tracking.
Whenever I run this code I get the following error from the OpenCV code from the cvtColor function call.
OpenCV Error: Assertion failed (depth == CV_8U || depth == CV_16U || depth == CV_32F) in cv::cvtColor, file D:\Build\OpenCV\opencv-3.2.0\modules\imgproc\src\color.cpp, line 9710
I have tried using the BGR arrays, which works but I specifically need to use HSV here.
What is the cleanest way to solve this problem? Please let me know if I can provide more information, thanks. I'm still pretty new to Python.
minBGR = np.array([minB, minG, minR])
maxBGR = np.array([maxB, maxG, maxR])
minHSV = cv2.cvtColor(minBGR, cv2.COLOR_BGR2HSV)
maxHSV = cv2.cvtColor(maxBGR, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(hsvFrame, minHSV, maxHSV)