Reputation: 103
I am currently planning on splitting my image into 3 channels so i can get the RGB values of an image to plot a scatter graph so i can model is using a normal distribtion calculating the covariance matrix, mean, etc. then calculate distance between the background points and the actual image to segment the image.
Now in my first task, i have wrote the following code.
VideoCapture cam(0);
//int id=0;
Mat image, Rch,Gch,Bch;
vector<Mat> rgb(3); //RGB is a vector of 3 matrices
namedWindow("window");
while(1)
{
cam>>image;
split(image,rgb);
Bch = rgb[0];
Gch = rgb[1];
Rch = rgb[2];
but as soon as it reaches the split function, i step through it, it causes a unhandled exception error. access violation writing location 0xfeeefeee
i am still new to opencv, so am not used to dealing with unhandled exception error.
thanks
Upvotes: 1
Views: 1361
Reputation: 169
Although this is an old issue I would like to share the solution that worked for me. Instead of vector<Mat> rgb(3);
I used Mat channels[3];
. I realized there is something wrong with using vector when I was not able to use split even on an image loaded with imread. Unfortunately, I cannot explain why this change works, but if someone can that would be great.
Upvotes: 0
Reputation: 6638
It sounds as if split expects there to be three instances of Mat
in the rgb
vector.
But you have only prepared it to hold three items - it is actually empty.
Try adding three items to the vector and run again.
Upvotes: 1