ColorCorrectionModel CCM4x3 crashes use of weightsList

I am running a python script using the ColorCorrectionModel. All fine, but… when I try to use the model.setWeightsList(w) function my code crashes, showing the error message:
Error: "cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\core\src\arithm.cpp:214: 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' "
I found the problem in the use of the 4x3 CCM.
So when I set : model.setCCM_TYPE(cv2.ccm.CCM_3x3) the code is running,
but when changing to : model.setCCM_TYPE(cv2.ccm.CCM_4x3) the code crashes.
I can also use CCM4x3 without using the weightsList and the code runs fine.
But CCM4x3 and weightsList seem to crash.
code snippet:


model = cv2.ccm.ColorCorrectionModel(src, ref, cv2.ccm.COLOR_SPACE_sRGB);
#src and ref are of shape(24,1,3,float)
model.setCCM_TYPE(cv2.ccm.CCM_4x3) 
w = np.array(np.ones((24, 1))) # array of shape (24,1) all values 1.0
model.setWeightsList(w)
model.run() # crash

please show resp. code snippet
(what are you using for ‘weights’ here ?)

  • i guess, it’s coming from somewhere here, but – can we get a full stacktrace ?
  • np.array(np.ones((24, 1)))
    w.dtype == np.float64 ! (and why the np.array() ?)

i am just running opencv in a python script using the IDLE shell and all I get is the error message I wrote above.
So is there a way to get a full stacktrace ?
All I see is the crashing method in my code and the crashing point deep inside the python.arithm code. So of course a full stack trace would help a lot. But how to get it ?

no such thing, opencv is in c++

have you tried changing the type to np.float32 ?

sorry, you are right. The error message points to …arthm**.cpp**
Also the traceback modul of python doesn’t give additional info.
So there is no way when using python to get a more detailled traceback ?

your lack of python traceback confuses me. don’t just mark the line with # crash. traceback is customary.

setWeightsList itself doesn’t do much… it should validate its input before assigning it to the member variable. you could file an issue for that.

the error, could (should?) also be tested for and caught by run() itself, not by calls inside of run().

you should ask for that too in the issue you might file.

if you’re prepared to build OpenCV yourself, you could litter the code of the CCM class with some printlines (logging). that does not require any debugger. if you can step into OpenCV library code, you should try that.