简体   繁体   中英

OpenCV 3.0 - error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor

I have simple OpenCV code that I am using to load an image and convert it to grayscale. I have a folder with images that I have replicated. It's just the same frame over and over again with different file names, the content of the files are exactly the same.

I run a loop and try to convert the images and it runs for 1020 frames and stops on that specific frame every time with the error:

"error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor"

popping up every time. I don't understand this, if the code works for the first image, in theory it should work for all the other images in the folder as they are the same file just with different file names. I am running OpenCV 3.0 and also receive the specific error that says:

"OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor,file/home/blah/OpenCV3.0/opencv/modules/imgproc/src/color.cpp, line 7453"

when the program stops.

My code is:

char * baseImagePath; //these are updated as the program iterates
char * nextImagePath; //they contain the full path of the image

Mat baseImage, nextImage;
Mat grayImage1,grayImage2;

baseImage = imread(baseImagePath, CV_LOAD_IMAGE_COLOR);

if(baseImage.empty()){

    printf("%s EMPTY!\n", baseImagePath);

}

cvtColor(baseImage, grayImage1, COLOR_BGR2GRAY);

nextImage = imread(nextImagePath, CV_LOAD_IMAGE_COLOR);

if(nextImage.empty()){

    printf("%s EMPTY!\n", nextImagePath);

}

cvtColor(nextImage, grayImage2, COLOR_BGR2GRAY);

So, this is very odd. When I run my code, I confirm that my program thinks the image at a specific frame is empty, but when I run:

display frame.jpg

were frame.jpg is the frame that my program claims is empty, imageMagick displays the video just fine.

The problem was not with the OpenCV code, but with the C code I was using to iterate through the files. I had too many files open and that caused the program to fail. This was confirmed with the errno code I received upon program termination.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM