Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Probably because you are modifying an external variable and only putting its reference into the array?
-
hitko31455ySince it looks like you're using OpenCV I'm guessing the problem is that you're doing
Mat currentFrame = new Mat();
while(videoCapture.read()) {
videoCapture.retrieve(currentFrame);
matArray[frameCounter] = currentFrame;
}
This basically puts each new frame into the same Mat object, and then sets all items in the array to point to that object - try something like
@highlight
Mat currentFrame = new Mat();
int frameCounter = 0;
while(videoCapture.read(currentFrame))) {
matArray[frameCounter] = currentFrame;
currentFrame = new Mat();
frameCounter++;
} -
Thanks for all replies, it's a really dumb mistake on my side.
I'll see if it works tomorrow.
And now I've run into a whole another issue which is really fucking strange.
Has it ever occured that a Object in java looses all it's values after being put into an array of same type?
My problem:
[code...]
Mat[] matArray = new Mat[totalFramesOfVideo];
videoCapture.open();
Mat currentFrame = new Mat();
int frameCounter = 0;
while(videoCapture.read()) {
currentFrame = (last read frame as a Mat)
matArray[frameCounter] = currentFrame;
frameCounter++;
}
then, after filling the array and accessing elements, they lose all their object values.
Eg. Before currentFrame's dimensions were 1080*1920, but matArray[index] dimensions are suddenly 0*0.
rant