Read video using VideoReader function in Matlab? - matlab

I want to read a video from a folder and extract the frames from it.I used VidoeReader function.But it gives error.My code is shown below along with the error.
mov=VideoReader('11.mp4');
vidFrames=read(mov);
nFrames=mov.NumberOfFrames;
for i=1:nFrames
imshow(vidFrames(:,:,i),[]);
end
and the error show is as given below
Error using VideoReader/init
The file does not appear to have any video
data.
Error in VideoReader (line 147)
obj.init(fileName);
Error in video (line 7)
mov=VideoReader('11.mp4');

I think this is a MATLAB version related problem. I faced the same problem when I was using MATLAB 2013a. However, when I changed to MATLAB 2014b the problem just disappeared.

Related

iptPointerManager error when using roipoly (MATLAB)

I'm trying to use roipoly(I) to allow user selection of a region within an image. When I run the example code from MATLAB documentation:
img = imread('eight.tif')
imshow(img)
bw = roipoly(img)
I'm getting the following error:
Undefined function or variable 'iptPointerManager'.
with several other error lines after, but i'm quite convinced that the one above is the issue.
I have MATLAB R2016a on Windows 7 with image processing toolbox installed and working.
Resetting the path using restoredefaultpath worked.

using xlswrite inside a loop and an error when using mac

I am trying to use the xlswrite inside a loop to put the results in each iteration
my function is like this
xlswrite('results',results(1,i).A,'results',data);
I get the following errors,
Error using xlswrite (line 187)
An error occurred on data export in CSV format.
Error in myalgorithm (line 178)
xlswrite('results',results(1,i).A,'results',data);
Caused by:
Error using dlmwrite (line 112)
The input cell array cannot be converted to a matrix.
I am using Matlab 2015b and also I am using mac
I also tried to use csvwrite instead xlswrite but no success. is there any one who can help me with it?

Issues related to SVR in MATLAB

I am working on support vector regression for aerospace applications. I need to implement SVR in MATLAB. On the internet, I found this link, which gives detailed information with examples. When I try running the example codes in matlab, I am getting this error,
Error using classreg.learning.FitTemplate/fillIfNeeded (line 604)
OptimizeHyperparameters is not a valid parameter name.
Error in classreg.learning.FitTemplate.make (line 124)
temp = fillIfNeeded(temp,type);
Error in RegressionSVM.template (line 349)
temp = classreg.learning.FitTemplate.make('SVM','type','regression',varargin{:});
Error in RegressionSVM.fit (line 343)
temp = RegressionSVM.template(varargin{:});
Error in fitrsvm (line 235)
obj = RegressionSVM.fit(X,Y,varargin{:});
I am using MATLAB R2016a. Kindly let me know, how to solve this issue.
I had a similar issue today. Just upgrade Matlab to Matlab 2016b and it should work. Maybe it's a new parameter that they just introduced.

video to frames in matlab

I have a code to extract frames from a video.The code is given below
addpath('E:\project\coding\wrk_ongoing\Images');
obj = mmreader('ace.mp4');
vid = read(obj);
frames = obj.NumberOfFrames; %Read the Total number of frames and displyed in command window
ST='.jpg';
cd frames
for x = 1:5 % extracting the 5 frames from video
Sx=num2str(x);
Strc=strcat(Sx,ST);
Vid=vid(:,:,:,x);
imwrite(Vid,Strc);
end
cd ..
This code works only for some videos.I tested for different videos with .mp4 extension.Some of them works well. But input videos shows error as
??? Error using ==> vid2frame at 6
Initialization failed. (No combination of intermediate filters could be found to make the
connection.)
how can I solve this ?
That error is due to your video file itself. From the looks of it, MATLAB has a problem reading that file probably because the file is badly encoded or the video was encoded with a codec that is not supported by MATLAB or does not exist on your computer.. See this question for a similar problem: no combination of intermediate filters could be found
This has nothing to do with MATLAB, but the error was what you encountered and the answer was to essentially re-encode the video file in a format that is compatible with your operating system and MATLAB.
Good luck!

adftest function error in lagmatrix

Using the adftest function in MATLAB's econometrics toolbox, I'm receiving the following error:
>> [h1,pVal1] = adftest(y1,'model','ARD')
Error using lagmatrix (line 25)
lagmatrix: wrong # of input arguments
Error in adftest>runReg (line 705)
yLags = lagmatrix(y,0:(testLags+1));
Error in adftest (line 417)
testReg = runReg(i,y,testT,testLags,testModel,needRegOut);
y1 is a <41x1> vector of doubles.
Has anyone received this error or have any thoughts on what the issue is? I am using this code right out of the box so I'm not sure what is going on. I'd post to MATLAB's site, but it is down for maintenance.
This is either a bug in Matlab, in which case you should submit it on the Matlab support site. Before you do that, you should check that you don't have a function lagmatrix on your path that shadows the built-in function. Type
which lagmatrix
on the command line. If the path does not point to your Matlab installation, you should move lagmatrix off the Matlab search path.
Also note that y1 should not contain all NaN, or be otherwise degenerate, so you may want to check the function using the sample data as suggested in the help to be sure it's a bug and not just your data.
I had the same problem with this function. In my case, the problem was the function lagmatrix (older version) in my MATLAB path and the adftest function was the newest version. The soluction was delete the older version of lagmatrix.