Unable to perform color correction from opencv tutorial

Hi all! I’m trying to use the example code in OpenCV: Color Correction Model
but I want to do it in Python instead of C++. I see at least one other person with this issue: Converting Color Correction opencv module example from C++ to python - Stack Overflow

I tried looking up the bindings and re implementing and have the issue with not being able to run the model. I read in an image of a macbeth 3x24 to produce the “src” input variable, and it has dimensions 3x24 ( also tried 24x3) Here is the code:

import cv2 as cv
model1 = cv.ccm_ColorCorrectionModel(src, cv.ccm.COLORCHECKER_Vinyl)
model1.run()

The error is returned from .run():
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-vijyisc5\opencv\modules\core\src\arithm.cpp:234: error: (-209:Sizes of input arguments do not match) The operation is neither ‘array op array’ (where arrays have the same size and type), nor ‘array op scalar’, nor ‘scalar op array’ in function ‘cv::binary_op’

where the numpy array source is:
src =
array([[4.43137255e-01, 3.17647059e-01, 2.66666667e-01],
[7.33333333e-01, 5.92156863e-01, 5.05882353e-01],
[4.03921569e-01, 4.78431373e-01, 6.35294118e-01],
[3.52941176e-01, 4.27450980e-01, 2.47058824e-01],
[5.21568627e-01, 5.05882353e-01, 7.01960784e-01],
[4.51363429e-01, 7.37637939e-01, 6.63128135e-01],
[8.07843137e-01, 4.86274510e-01, 4.70588235e-02],
[3.25490196e-01, 3.60784314e-01, 6.70588235e-01],
[7.33333333e-01, 3.33333333e-01, 3.84313725e-01],
[3.64705882e-01, 2.39215686e-01, 4.35294118e-01],
[6.31372549e-01, 7.33333333e-01, 1.49019608e-01],
[8.47633379e-01, 6.31372549e-01, 1.91518468e-04],
[2.27450980e-01, 2.43137255e-01, 6.00000000e-01],
[3.21568627e-01, 5.88235294e-01, 2.62745098e-01],
[6.58823529e-01, 1.80392157e-01, 2.23529412e-01],
[8.94117647e-01, 7.68627451e-01, 0.00000000e+00],
[7.01778386e-01, 3.29229366e-01, 5.95896033e-01],
[2.19786096e-01, 5.33511586e-01, 6.62923351e-01],
[9.45098039e-01, 9.45098039e-01, 9.45098039e-01],
[7.80392157e-01, 7.80392157e-01, 7.80392157e-01],
[6.31372549e-01, 6.31372549e-01, 6.31372549e-01],
[4.78431373e-01, 4.78431373e-01, 4.78431373e-01],
[3.37254902e-01, 3.37254902e-01, 3.37254902e-01],
[2.03921569e-01, 2.03921569e-01, 2.03921569e-01]])

welcome.

you probably need src.shape to be (-1, 1, 3) (simply assign that)

that’s (height, width, channels). cv::Mat / np.array mapping behaves like this.