Errror using VideoReader on MATLAB Coder: Error using VideoReader>>createChannel (line 679) Video stream in the file is not supported.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matheus Fortunato Alves
am 9 Jun. 2023
Kommentiert: Matheus Fortunato Alves
am 14 Jun. 2023
Hi all,
I've developed a script for Region of Interest detection/selection using YOLOv4 DL object detection network which finds a LED Matrix and crop it from the rest of the image.
This matrix (which composes the video) is then used for further image processing on an academic project.
My goal is to export this script to an Android app so I can use it as a real-time data application using cameras.
To execute this exportation, I'm using MATLAB Coder to convert .mat script to C++. However, I am getting following error when I use my test function, which works fine when I run it on MATLAB environment:
>>> testeAndroid
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 Android (line 3)
vidObj_recorded = VideoReader(char(Vrecorded));
Error in testeAndroid (line 3)
Android('5.mp4',H,S_m,vgray,4,4,8,8,8)
Below is my code (script to convert to Android and test function). Also please ignore the comments in Portuguese.
function [Amod_aj, Amod_naj, Bmod_aj, Bmod_naj, Cmod_aj, Cmod_naj] = Android(Vrecorded, H, S_m, vgray, S, P, F, J, L)
vidObj_recorded = VideoReader(Vrecorded);
Allframes = read(vidObj_recorded);
% Loads and created pretrained YOLO v4 DL NW detector customized
% to detect LED array.
detector = coder.loadDeepLearningNetwork("trainedDetector_23022023.mat");
% Read all frames as grayscale images
frames = reshape(Allframes(:,:,1,:), size(Allframes,1), size(Allframes,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(Allframes,1),size(Allframes,2),3);
FrameForDetection(:,:,:) = Allframes(:,:,:,1);
%object detector
[bboxes,~,~] = detect(detector,FrameForDetection);
% This cell contains the cropped frames containing RoI after YOLO v4 object
% detection algoritm process the frames
croppedFrameVectors = cell(1,1);
sizes = imcrop(frames(:,:,1),bboxes(1,:));
croppedFrames = zeros(size(sizes,1),size(sizes,2),NoF);
for n = 1:1
croppedFrameVectors{n} = rand(0,0,0);
for k = 1:NoF
% crops the frames in each detected object according to bounding
% boxes results captured on the first frame
croppedFrames(:,:,k) = imcrop(frames(:,:,k),bboxes(1,:));
end
% Insert the cropped frames with bounding boxes within a cell to allow
% multiple cropped objects within the same variable
croppedFrameVectors{n} = croppedFrames;
% Erase variable to crop another object due to bbox different
% dimensions from one object to another (widht x height)
end
I = croppedFrameVectors{1};
Test function:
addpath('C:\Users\Fortu\OneDrive\Área de Trabalho\OCC\OCC_codes\ARDUINO_2021_2022\16042023');
load('parametros_arduino_video_SER_14042023.mat');
videoName = '5.mp4';
Android(videoName,H,S_m,vgray,4,4,8,8,8)
Can someone help me understand why is this error ocurring? The Deep Learning network loading on Coder/MEX generation seems to be fine, and the issue is happening when the script tries to read the videoFile on test function.
Also, trainedDetector is an YOLOv4 trained DL network using LED Matrix images.
0 Kommentare
Antworten (1)
Hariprasad Ravishankar
am 12 Jun. 2023
Hello,
The error seems to suggest that the file could not be successfully read. Which MATLAB version are you using?
Is the filename a constant?
Shot in the dark, but could you try renaming the video file to start with a letter? ('v5.mp4')
I would recommend trying a test example as captured here to debug the issue:
https://www.mathworks.com/help/matlab/ref/videoreader.html?searchHighlight=VideoReader&s_tid=doc_srchtitle#refsect-extended-capabilities
Hari
1 Kommentar
Siehe auch
Kategorien
Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!