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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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
EDIT: i tried adding items into the vector still error, either via push_back or general assignment i.e. rgb[0] = Rch or Bch still error.
i did and it still resulted in an error
i think its something to do with the split function i don't know
I have gaussian distribution for my background model i want to remove and want to access each pixel and enter it into gaussian formula to calculate probability if it belongs in background or not.
so i thought split it and check the value of each channel. then i was told a better way was to access each pixel directly without split using vector which i did.
it doesn't work, gives 0 value, but when i do run it, which image taken from camera, the terminal shows wierd characters if i replace pixel[0] with cout << or most of the time it prints out blank characters.
@ne555
when i say i did i tried initializing the vector still got error. I stepped through the code line by line via debug and it crashes trying to execute split()
@xkcd83
i think it is the same thing. i am using a matrix and the vector contains matrix so i am using a matrix not a vector. but use vector to hold matrix.