Video player not showing using videoReader function

1 visualización (últimos 30 días)
Yeiry Chaverra Cordoba
Yeiry Chaverra Cordoba el 9 de Nov. de 2021
Respondida: T.Nikhil kumar el 8 de Abr. de 2024
I am trying to display a video using convualion nerual networks. This is my code. It translates from speech to video but when I run the code the video does not show. On top of that it does not give me any error.
%% CNN predicts the translation
cnn_prediction = CNN_Predict(recObj, cnn_trained);
%diretory for pages
full_ref_path_ASLVid = fullfile(ref_dir, output_lang, char(cnn_prediction),append(char(cnn_prediction),'_asl_vid.mp4'));
full_ref_path_FSLVid = fullfile(ref_dir, output_lang, char(cnn_prediction),append(char(cnn_prediction),'_fsl_vid.mp4'));
full_ref_path_BSLVid = fullfile(ref_dir, output_lang, char(cnn_prediction),append(char(cnn_prediction),'_bsl_vid.mp4'));
full_ref_path_SSLVid = fullfile(ref_dir, output_lang, char(cnn_prediction),append(char(cnn_prediction),'_ssl_vid.mp4'));
%select which video to play
if strcmp(output_lang, 'American Sign language')
videoReaderASL = VideoReader(full_ref_path_ASLVid);
videoPlayerASL =vision.VideoPlayer('Name', cnn_prediction);
while hasFrame (videoReaderASL)
frame = readFrame(videoReaderASL);
step(videoPlayerASL, frame);
pause(0.05);
end
elseif strcmp(output_lang, 'British Sign language')
videoReaderBSL = VideoReader(full_ref_path_BSLVid);
videoPlayerBSL =vision.VideoPlayer('Name', cnn_prediction);
while hasFrame (videoReaderASL)
frame = readFrame(videoReaderBSL);
step(videoPlayerBSL, frame);
pause(0.05);
end
release(videoPlayer);
elseif strcmp(output_lang, 'French Sign language')
videoReaderFSL = VideoReader(full_ref_path_FSLVid);
videoPlayerFSL =vision.VideoPlayer('Name', cnn_prediction);
while hasFrame (videoReaderFSL)
frame = readFrame(videoReaderFSL);
step(videoPlayerFSL, frame);
pause(0.05);
end
release(videoPlayer);
elseif strcmp(output_lang, 'Spanish Sign language')
videoReaderSSL = VideoReader(full_ref_path_SSLVid);
videoPlayerSSL =vision.VideoPlayer('Name', cnn_prediction);
while hasFrame (videoReaderSSL)
frame = readFrame(videoReaderSSL);
step(videoPlayerFSL, frame);
pause(0.05);
end
release(videoPlayer);
else
end

Respuestas (1)

T.Nikhil kumar
T.Nikhil kumar el 8 de Abr. de 2024
Hello,
As per your question, I get that you’re trying to play a video based on the value of the ‘output_lang’ variable but are facing some issues with it.
Based on my understanding of the above code snippet, I can see some misnaming issues that might be causing the video not to display properly:
  1. In the ‘elseif’ block of ‘British Sign language’, the while loop is checking for frames using ‘hasFrame(videoReaderASL)’ instead of ‘hasFrame(videoReaderBSL)’. This may cause the unexpected behavior since ‘videoReaderASL’ object might not be defined if the ‘output_lang’ is not "American Sign language".
  2. In the ‘elseif’ block of ‘Spanish Sign language’, you are using step(videoPlayerFSL, frame); but it should instead be step(videoPlayerSSL, frame);
I also assume that you have used the ‘release’ function to release system resources for the ‘videoPlayer’ object but note that ‘videoPlayer’ is not defined anywhere. You should instead release the specific video player instance you created for each language, like ‘release(videoPlayerASL);’ for American Sign Language, and so on for each language.
I will also suggest you to check if the file exists before trying to open it with ‘videoReader’. In some cases, if the file specified does not exist, ‘videoReader’ will not be able to open it, but it won't throw an error directly in your script.
Hope this helps you proceed with your work!

Categorías

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

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by