Here is solved RGB to HSV in numpy conversion, and here is a formula from opencv documentation for RGB to HSV convertion:
But how to reverse this formula to get H