Invalid number of channels in input image

前端 未结 2 1291
猫巷女王i
猫巷女王i 2021-01-18 07:22

I am receiving an error when running my program, I think specifically about color manipulation in the OpenCV library.

I\'m trying to build a program that takes a vid

2条回答
  •  再見小時候
    2021-01-18 07:54

    As error message said, the image given in input to the color conversion function has an invalid number of channels.

    The point is that you are acquiring frames as single 8bit channel

    Camera.set(cv::CAP_PROP_FORMAT, CV_8UC1)
    

    and then you try to convert this frame in grayscale

    cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY)
    

    You have 2 easy options to solve this issue:

    1. you change the camer acquisition format in order to have color informations in your frames, for example using CV_32S or CV_32F
    2. you skip the color conversion as you already have grayscale image, thus no need to convert it.

    Take a look to this link for OpenCV color manipulation

提交回复
热议问题