- 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".
- In the ‘elseif’ block of ‘Spanish Sign language’, you are using step(videoPlayerFSL, frame); but it should instead be step(videoPlayerSSL, frame);
Video player not showing using videoReader function
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
T.Nikhil kumar
2024-4-8
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:
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!