- Accessing a frame of frameBuffer as frameBuffer(i) instead of frameBuffer(:,:,:,i)
- The function shiftBuffer changes the values of frameBuffer locally in the function and in the main code the frameBuffer isn't changed.
Insert elements into a 4D array
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alber
el 9 de Abr. de 2020
Respondida: Srivardhan Gadila
el 12 de Abr. de 2020
Hello,
I have a 4-dimensional buffer called:
frameBuffer = zeros (width, height, numChannels, framesPerSymbol);
in which I want to insert 3-dimensional video frames (width, height, numChannels). The variable framesPerSymbol is the number of frames that will go in the buffer, that is, if framesPerSymbol is 10, my buffer will be 10.
And this is where I run it:
frameBuffer = zeros(width, height, numChannels,framesPerSymbol);
framesInBuffer = 0;
while hasFrame(videoObject)
frame = readFrame(videoObject);
shiftBuffer(frameBuffer,frame); % <--------- THIS IS THE PART
% We update the framesInBuffer counter
framesInBuffer = framesInBuffer + 1;
if framesInBuffer > framesPerSymbol
framesInBuffer = framesPerSymbol;
bypassEncoding = false;
else
bypassEncoding = true;
end
end
The way I was doing the insert was like this, but I don't get results:
function [] = shiftBuffer (frameBuffer,frame)
N = size(frameBuffer,4); % Buffer size
for i = 1:N
frameBuffer(i) = frame;
end
0 comentarios
Respuesta aceptada
Srivardhan Gadila
el 12 de Abr. de 2020
There are 2 mistakes in the above implementation:
I suggest you to make the following changes.
Change the function shiftBuffer as follows:
function frameBuffer = shiftBuffer(frameBuffer,frame,framesInBuffer)
frameBuffer(:,:,:,,framesInBuffer) = frame;
end
and the following lines in your code
frame = readFrame(videoObject);
shiftBuffer(frameBuffer,frame); % <--------- THIS IS THE PART
% We update the framesInBuffer counter
framesInBuffer = framesInBuffer + 1;
to
frame = readFrame(videoObject);
% We update the framesInBuffer counter
framesInBuffer = framesInBuffer + 1;
frameBuffer = shiftBuffer(frameBuffer,frame,framesInBuffer);
0 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!