Computer Vision: Path for playing video - matlab

I want to use video from following directory
'E:\Multimedia Security\matlab\UCSD_Anomaly_Dataset.v1p2\UCSDped1\Train\Train001'
Following is the code which i wrote
close all
clear all
clc
workingDir = 'E:\Multimedia
Security\matlab\UCSD_Anomaly_Dataset.v1p2\UCSDped1\Train\Train001';
videoofReader = vision.VideoFileReader(dir(fullfile(workingDir, 'abc.avi')));
videoPlayer = vision.VideoPlayer;
while ~isDone(videoofReader)
frame = step(videoofReader);
step(videoPlayer, frame);
end
release(videoofReader);
release(videoPlayer);
Error which i get is
`Error using VideoFileReader.set.Filename (line 139)
Expected Filename to be one of these types:
char
Instead its type was struct.
Error in C:\Program
Files\MATLAB\R2012a\toolbox\matlab\system\+matlab\+system\setProp.p>setProp
(line 14)
Error in
C:\ProgramFiles\MATLAB\R2012a\toolbox\matlab\system+matlab+system\SystemProp.p>SystemProp.set (line
373)
Error in C:\Program Files\MATLAB\R2012a\toolbox\matlab\system+matlab+system\SystemProp.p>SystemProp.parseInputs
(line 635)
Error in C:\Program
Files\MATLAB\R2012a\toolbox\matlab\system+matlab+system\SystemProp.p>SystemProp.setProperties
(line 138)
Error in C:\Program
Files\MATLAB\R2012a\toolbox\vision\vision+vision\VideoFileReader.p>VideoFileReader.VideoFileReader
(line 131)
Error in kl2 (line 18)
videoofReader = vision.VideoFileReader(dir(fullfile(workingDir, 'abc.avi')));

System prompts you Error in kl2 (line 18) so this line has a problem. You do not need to use dir because you already have an absolute path.
Give you two solutions:
videoofReader = vision.VideoFileReader(fullfile(workingDir, 'abc.avi'));
dirstruct = dir(fullfile(workingDir, 'abc.avi'));
videoofReader = vision.VideoFileReader(dirstruct{1});

Related

I'm trying to train the code of Target-Aware Deep Tracking in matlab

I'm for now compiling in CPU version.I am working on matlab 2020a.I've tried to remove the vl_nnconv.m from matconvnet but i still get the following error.
Also the matconvnet i'm using is version matconvnet-1.0-beta25 I'm stuck here since 2 days ,could somebody lease help me out with this issue?
https://github.com/XinLi-zn/TADT
The above is the github code i'm trying to work on.
Foloowing are the errors i'm getting:
Error using vl_nnconv
The option name is not a string (argument number 5)
Error in dagnn.Conv/forward (line 11)
outputs{1} = vl_nnconv(...
Error in dagnn.Layer/forwardAdvanced (line 85)
outputs = obj.forward(inputs, {net.params(par).value}) ;
Error in dagnn.DagNN/eval (line 91)
obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;
Error in get_subwindow_feature (line 37)
net_feat.eval({'input',gpuArray(patch_sw)});
Error in tadt_tracking (line 63)
feat_groups = get_subwindow_feature(net_feat, img, sw_location, input_sz, feat_layer);
Error in Demo_TADT (line 23)
[result, fps]=tadt_tracking(seq_info.img_list, seq_info.gt(1,:), vgg16_model_path, display);
the following are the functions that is causing the error and the argument is obj.pad
function outputs = forward(obj, inputs, params)
if ~obj.hasBias, params{2} = [] ; end
outputs{1} = vl_nnconv(...
inputs{1}, params{1}, params{2}, ...
'pad', obj.pad, ...
'stride', obj.stride, ...
obj.opts{:}) ;
end

How do I use PRtools' forward feature selection in MatLab?

I am trying to apply a forward feature selection on a PRdataset. Following the syntax presented online though produces a bunch of errors that I don't quite understand and haven't been able to solve. Any ideas on what is causing them or how to fix?
Code used and resulting errors shown below:
A=prdataset(data,classes);
[w,r]=featself(A,'NN');
Error using indnn (line 50)
Trainset and testset should by identical for LOO processing
Error in fnnc (line 33)
L = indnn(a,trainset,loo);
Error in prmap (line 231)
[d,varargout{:}] = feval(mapp,a,b);
Error in * (line 14)
d = prmap(a,b);
Error in testk (line 55)
d = a*w;
Error in feateval (line 128)
J = 1 - testk(a,1);
Error in featsellr>plusl (line 182)
critval = feateval(a(:,[state.I Jsub]),crit);
Error in featsellr (line 127)
state = plusl(a,crit,t,state,fid);
Error in featself (line 56)
[w,r] = featsellr(a,crit,ksel,1,0,t);

why following error is occurred when i am trying to read image file by imread?

I have to concatenate the path and file name but the following error is coming as given below:
path = 'E:\Ob_Extraction\peta\PETA dataset\3DPeS\archive\';
allFiles = dir( 'E:\Ob_Extraction\peta\PETA dataset\3DPeS\archive' );
allNames = { allFiles.name };
image = imread(strcat(path,allNames(3)));
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
how do i solve it ?

Error using getImageFromFile (line 11)

My code execute correctly for the digits but it given some errors to the characters. the image presented in that location but it shows image not found like..
Error using getImageFromFile (line 11)
Cannot find the specified file: "C:\Program Files\MATLAB\R2014a\toolbox\vision\visiondemos\characters\handwritten\B\img012-00012".
Error in imageDisplayParseInputs (line 73)
[common_args.CData,common_args.Map] = ...
Error in imshow (line 219)
[common_args,specific_args] = ...
Error in charmodified (line 22)
subplot(2,3,4); imshow(testChar{1,2});

matlab fails deployment in internal code

I want to compile a gui matlab project, but fail because of this error which is not in my code
Subscript indices must either be real positive integers or logicals.
Error in isscript (line 7)
if strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2
Error in matlab.depfun.internal.Schema/move/#(setMembers)setMembers(~isscript(setMembers))
Error in matlab.depfun.internal.Schema>applyMoveFcn (line 987)
keptFiles = fcn(fileList);
Error in matlab.depfun.internal.Schema>#(files,destMap)applyMoveFcn(op,files,destMap,destSet,reason,rule) (line 822)
#(files, destMap)applyMoveFcn(op, files, destMap, ...
Error in matlab.depfun.internal.Schema/applySetRules (line 141)
xformedSet = feval(operations{n}, xformedSet, rMap);
Error in matlab.depfun.internal.Completion/applySetRules (line 1059)
[modifiedList, rMap] = ...
Error in matlab.depfun.internal.Completion/initializeRootSet (line 1142)
[addedFiles, ruleFilter, notes] = ...
Error in matlab.depfun.internal.Completion (line 1601)
obj.RootSet = initializeRootSet(obj, files);
Error in matlab.depfun.internal.requirements (line 166)
c = matlab.depfun.internal.Completion(files, tgt);
Error in appcreate.internal.appbuilder.getDependencyList (line 173)
[dependentfiles, depproducts, ~] = matlab.depfun.internal.requirements(varargin, 'MATLAB');
How can I get matlab (2013b) to compile the package?
The code where matlab fails is (which is NOT my code)
function tf = isscript(files)
% ISSCRIPT Is the file a script file?
tf = false(1,numel(files));
for k=1:numel(files)
pth = files{k};
% Can't be a script if it isn't an M-file.
if strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2
mt = matlab.depfun.internal.cacheMtree(pth);
fcn = mtfind(mt, 'Kind', 'FUNCTION');
tf(k) = isempty(fcn);
end
end
The code will fail for files with a filename of length 1. Either rename all files with such a short filename or change the line to:
if length(pth)>1 && strcmpi(pth(end-1:end), '.m') && exist(pth, 'file') == 2