How to interpret c++ opencv Assertion error messages due to an error in cvtColor function?

后端 未结 2 1253
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 06:43

Following is an Assertion Error report (displayed on console) when calling cvtColor() function in opencv giving the argument CV_GRAY2BGR on a Mat object which is already a

2条回答
  •  失恋的感觉
    2020-12-18 07:28

    calling cvtColor() function in opencv giving the argument CV_GRAY2BGR on a Mat object which is already a BGR image

    You have already answered your own question here. The assertion will have originally have been something like:

    CV_Assert( scn == 1 && (dcn == 3 || dcn == 4));

    Since you're using a BGR Mat, scn - which is the number of channels in the source Mat - will be 3 causing the whole expression to evaluate to false, and the assertion to fail.

    The operation you are performing makes no sense. Omit it, and your code will probably work.

提交回复
热议问题