1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenCVで画像処理してたら実行中の途中で、OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor,みたいなエラーがでた場合

Last updated at Posted at 2018-05-27

何が起こったか

フォルダの中の画像全てを対象に、画像処理のプログラムをいつも通り実行したら何枚か実行中に途中で 「OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor,」とエラーがでた。 途中でエラーがでるってどういうことなんですかねぇ、、、って思いました。

ググったら色々記事が出たが、私の場合の解決方法とはならなかった。

プログラムの部分には問題はないはず、、、って思ってフォルダの中とか色々見てたら、気づいてしまった。
それは、、、

スクリーンショット 2018-05-27 15.18.04.png

処理対象の画像の中に、一枚だけ壊れている画像があった。
プログラムの実行中に途中でエラーがでた原因がこれではっきり納得できた。
なので、自動収集した場合、問題のある画像があるかどうかを意識する

この画像を取り除いたら、うまく最後まで処理できました。

なので、プログラムの実行途中にこのエラーがでた場合は、これも原因の一つかもしれません。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?