the type of that temporary Mat instance is CV_8S because image_data_test
has type char
, which is signed.
the API expects CV_8U
(same as CV_8UC1), not CV_8S
it’s best to use uint8_t
to be absolutely clear about the type.
it’s also a good idea to remove as many “conversion steps” as possible… if they’re superfluous, their only effect is to give more chance for bugs to happen.