Error in "runtime issue checking" in MATLAB Coder: Error using VideoReade​r>>createC​hannel (line 679) Video stream in the file is not supported.

2 次查看(过去 30 天)
Hi,
I am trying to convert following code to C++ using MATLAB Coder:
function [frames] = Android5(Vrecorded)
%#codegen
% Loads and created pretrained YOLO v4 DL NW detector customized
% to detect LED array.
vidObj = VideoReader(char(Vrecorded)); % lê o vídeo capturado pela câmera e o divide em quadros
% Read video properties
numFrames = vidObj.NumFrames;
height = vidObj.Height;
width = vidObj.Width;
% Preallocate the 3D array to store the video frames
videoArray = zeros(height, width, 3, numFrames,'uint8');
% Iterate through each frame and store it in the array
for frameIdx = 1:numFrames
frame = readFrame(vidObj);
videoArray(:, :, :, frameIdx) = frame;
end
% Read all frames as grayscale images
frames = reshape(videoArray(:,:,1,:), size(videoArray,1), size(videoArray,2), []);
% extrai o número de quadros do vídeo capturado (NoF - Number of Frames)
NoF = size(frames,3);
%Detect objects in an unknown image / video by using the pretrained YOLO v4
FrameForDetection = zeros(size(frames,1),size(frames,2),3);
FrameForDetection(:,:,:) = videoArray(:,:,:,1);
I did the following test bench code to test Android5 function:
addpath('C:\Users\Fortu\OneDrive\Área de Trabalho\OCC\OCC\ARDUINO_2021_2022\16042023');
video = "video2.mp4";
[frames] = Android5(video);
This code works fine in MATLAB workspace, giving me the desired frame matrix as output.
However, when I run the "Check for Run-time issues" section of MATLAB Coder, even tough MEX trial code is generated, the "running test file with MEX" fails accusing following run-time errors:
>>> testeAndroid5
Error using VideoReader>>createChannel (line 679)
Video stream in the file is not supported.
Error in VideoReader (line 151)
createChannel(obj, fileName, isComputeTSOnObjCreation);
Error in VideoReader>>initReader (line 105)
obj.VidReader = matlab.internal.VideoReader( fileName, ...
Error in IVideoReader (line 136)
initReader(obj, fileName, currentTime);
Error in VideoReader (line 25)
obj@audiovideo.internal.IVideoReader(fileName, varargin{:});
Error in Android5 (line 7)
vidObj = VideoReader(char(Vrecorded)); % lê o vídeo capturado pela câmera e o divide em quadros
Error in testeAndroid5 (line 6)
[frames] = Android5(video);
Nonetheless, when I try to convert the code using a sample video from MATLAB (like xylophone.mp4, located at C:\Program Files\MATLAB\R2023a\toolbox\matlab\audiovideo) instead of my own, the error does not occur anymore.
So I went checking codec info from both videos, and as you can see on attached picture, they are basically the same (only resolution changes). So why my video does not pass "running test file with MEX" test?
  2 个评论
Abhi Baruah
Abhi Baruah 2023-9-26
Hello Matheus,
Since the generated code works with xylophone.mp4, I am wondering if this is a limitation with the video you are using.
To investigate this further, we will need access to your video so that we can try and reproduce this on our end.
Can you reach out to MathWorks Technical Support (https://www.mathworks.com/help/matlab/matlab_env/contact-technical-support.html) with details regarding the issue and the video file to reproduce the same?
Thanks,
Abhi
Matheus Fortunato Alves
编辑:Matheus Fortunato Alves 2023-9-26
Thanks for respons!
I agree with you, I believe it may be related to codecs or something like that, but I need help in debugging it to be shure that it's not related to MATLAB Video Reader function.
I tried creating the service request by MATLAB app, however when I click "submit" button, following error occurs:
Please note that I've already opened a Service Request by MATLAB website, but it seems it is redirected to my local country MATLAB support Opencadd. Can you reach out them to check this issue?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by