First, an example:
In[1]: import numpy as np
...: import cv2
...: arr = np.random.rand(2000, 2000, 3).astype(np.float32)
In[2]: %timeit cv2.cvtColor(arr, cv2.COLOR_RGB2HSV)
13.1 ms ± 758 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In[3]: %timeit arr*2
13.8 ms ± 172 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
For some reason, this trivial operation in numpy takes longer than performing a full conversion of color model. I'm looking to do realtime image analysis using OpenCV to do most of the heavy lifting and using Numpy to perform some glue operations, but given this it appears like somehow Numpy will be consuming most of the processing time. Is there a reason for this? Is there a way to speed up Numpy to make it on par with OpenCV? Is there ways to use whatever speedups OpenCV provides for general array operations?