Effacer les filtres
Effacer les filtres

Enter values into a FIFO array

9 vues (au cours des 30 derniers jours)
Alber
Alber le 20 Avr 2020
Modifié(e) : Alber le 22 Avr 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.

Réponse acceptée

Mehmed Saad
Mehmed Saad le 20 Avr 2020
Modifié(e) : Mehmed Saad le 20 Avr 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 commentaire
Alber
Alber le 20 Avr 2020
Modifié(e) : Alber le 20 Avr 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by