Repository navigation
Add Operator overload for multi-channel Mat with literal constant. - #13586
Conversation
|
I'm prefer to forbid that cases at all - detect them and emit the error for multi-channel Mats with single constant. For example, |
|
@alalek If so, should we prohibit all operator overloading when it is a literal constant with a multi-channel Mat? I think it would be nice to add operator overloading for a literal constant and assert it if it is not for 1 channel. |
Right, adding overloads for "float" / "double" / "int" arguments should help avoiding of implicit In tests you can use this: |
be71286 to
3661760
Compare
| Mat input; | ||
| resize(sample, input, Size(224, 224)); | ||
| input -= 128; // mean sub | ||
| input -= Scalar(128); // mean sub |
There was a problem hiding this comment.
@dkurt, Scalar::all(128) ?
BTW, Test doesn't test inference result, only loading is tested here.
There was a problem hiding this comment.
Actually, I'm not sure about mean values for this model.
There was a problem hiding this comment.
Scalar(128) is similar to Scalar(128, 0, 0, 0)
Scalar::all(128) is Scalar(128, 128, 128, 128)
There was a problem hiding this comment.
Yea, I just not sure if we really need to pass [128, 128, 128] or [0, 0, 0] (from accuracy test below it). From the origin repo, they use different value:
https://github.com/petewarden/tf_ios_makefile_example/blob/880c92d2a15d65b32319d43cca5987481069b574/RunModelViewController.mm#L175L209.
So I think we can replace it even to Scalar::all(117).
|
Operations Also this patch breaks compatibility, so I'm going to revert it. |
* Add Operator override for multi-channel Mat with literal constant. * simple test * Operator overloading channel constraint for primitive types * fix some test for opencv#13586
This reverts commit f2f6c0f except changes in modules/dnn/test/test_tf_importer.cpp
Add Operator override for multi-channel
Matwith literal constant.When performing
*=or/=operation on a multi-channelMatwith a literal constant, it is performed normally on all channels.However, in the case of
+=-=, the operation result is applied to only one channel.The reason is that literal constants are converted to
Scalardatatypes, then they only apply to one channel.So I added operator overrides for literal constants.
Simple test