'**SUMMARY**
This method attempts to convert the image to the HSV colorspace.
If the color space is unknown we assume it is in the BGR format
**RETURNS**
Returns the converted image if the conversion was successful,
otherwise None is returned.
**EXAMPLE**
>>> img = Image("lenna")
>>> HSVImg = img.toHSV()
**SEE ALSO**
:py:meth:`isHSV`'

def toHSV(self):

    retVal = self.getEmpty()
    if ((self._colorSpace == ColorSpace.BGR) or (self._colorSpace == ColorSpace.UNKNOWN)):
        cv.CvtColor(self.getBitmap(), retVal, cv.CV_BGR2HSV)
    elif (self._colorSpace == ColorSpace.RGB):
        cv.CvtColor(self.getBitmap(), retVal, cv.CV_RGB2HSV)
    elif (self._colorSpace == ColorSpace.HLS):
        cv.CvtColor(self.getBitmap(), retVal, cv.CV_HLS2RGB)
        cv.CvtColor(retVal, retVal, cv.CV_RGB2HSV)
    elif (self._colorSpace == ColorSpace.XYZ):
        cv.CvtColor(self.getBitmap(), retVal, cv.CV_XYZ2RGB)
        cv.CvtColor(retVal, retVal, cv.CV_RGB2HSV)
    elif (self._colorSpace == ColorSpace.YCrCb):
        cv.CvtColor(self.getBitmap(), retVal, cv.CV_YCrCb2RGB)
        cv.CvtColor(retVal, retVal, cv.CV_RGB2HSV)
    elif (self._colorSpace == ColorSpace.HSV):
        retVal = self.getBitmap()
    else:
        logger.warning('Image.toHSV:    There    is    no    supported    conversion    to    HSV    colorspace')
        return None
    return Image(retVal, colorSpace=ColorSpace.HSV)
