The code can be found in this link
For more information on HSV see this link
Once you perform hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV), the image swaps from BGR to HSV.
- channel 1: changes from blue to hue and is between 0-180 degrees; hue is circular so a value of 0 and 180 will be red.
- channel 2: changes from green to saturation and is between 0-255.
- channel 3: changes from red to value and is between 0-255.