FITS image processing with OpenCV Python

I want to detect stars on fits astronomical image. For detection I need to use OpenCV library. But have problems with data formats and converting. How can I open FITS file (data format float32) for working with OpenCV, which works in format uint8? How to convert float32 to uint8?

Sorry a bit late, but i think you’d want something like this for the image array itself:

def float01to8bit(im):
return (im*255).astype(np.uint8)

Also might make sense to normalize to 0-1 first with something like:

im = cv.normalize(im, None, 0,1, cv.NORM_MINMAX)