Borrar filtros
Borrar filtros

Enter values into a FIFO array

9 visualizaciones (últimos 30 días)
Alber
Alber el 20 de Abr. de 2020
Editada: Alber el 22 de Abr. de 2020
Hello,
I have an array called
frameBuffer = zeros (height, width, numChannels, framesPerSymbol);
and a video. The parameters of the frameBuffer are height, width, number of color channels and framesPerSymbol, which will be the number of frames that my symbol lasts.My goal is to insert frames of the video in the array as if it were a FIFO queue, that is, if framesPerSymbol is 5:
F = frames E = empty
1) E E E E E
2) F E E E E
3) F F E E E
4) F F F E E
5) F F F F E
6) F F F F F
Thanks in advance.

Respuesta aceptada

Mehmed Saad
Mehmed Saad el 20 de Abr. de 2020
Editada: Mehmed Saad el 20 de Abr. de 2020
I think you are trying to save last five frames in a buffer, but a for loop is not required for that purpose
frameBuffer=zeros (height, width, numChannels, framesPerSymbol);
framesInBuffer = 0;
While loop
while hasFrame(videoObject)
frame = double(readFrame(videoObject));
I made a change here
frameBuffer = shiftBuffer(frameBuffer,frame);
framesInBuffer = framesInBuffer + 1;
if framesInBuffer > framesPerSymbol
framesInBuffer = framesPerSymbol;
bypassEncoding = false;
else
bypassEncoding = true;
end
if ~bypassEncoding
if canWeEncode(frameBuffer,alpha,threshold)
encodedBuffer = steganographicEncoding(frameBuffer,width,height,codeRows,codeCols,alpha,sigma);
writeBufferToFinalVideo(encodedBuffer,100);
else
writeFrameToFinalVideo(squeeze(frameBuffer(:,:,:,1)));
end
end
end
and a change here
function frameBuffer = shiftBuffer (frameBuffer,frame)
frameBuffer = circshift(frameBuffer,1,4);
frameBuffer(:,:,:,1) = frame;
end
  1 comentario
Alber
Alber el 20 de Abr. de 2020
Editada: Alber el 20 de Abr. de 2020
Yes, my idea is that when the buffer is full, to see if I can encode and after this is done it will take me another 5 frames, so until I complete all the frames of the video and can you explain this part?
function frameBuffer = shiftBuffer (frameBuffer,frame)
frameBuffer = circshift(frameBuffer,1,4);
frameBuffer(:,:,:,1) = frame;
end
I want to take 5 frames, I encode (the whole loop below) and I will take another 5, like this until I complete all the frames of the video.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by