MATLAB Answers

BLOCKPROC encountered an error while evaluating the user-supplied function handle, FUN. Caused by: Undefined function or variable 'net'.

8 views (last 30 days)
Samir khan
Samir khan on 26 Jul 2018
Commented: Samir khan on 30 Jul 2018
can anyone suggest a way out of this and explain why is this error is occuring.
allcount=Inf;
I = imread('frame1359.jpg');
count=0;
myFilterHandle = @myFilter;
blockyImage = blockproc(I,[20 20], myFilterHandle);
allcount(2,1)=count;
disp(count);
function singleValue = myFilter(blockStruct)
s=(blockStruct.data);
r=imresize(s,[227 227]);
% net is a classifier already trained and loaded
pred=classify(net,r);
if pred =='1'
count=count+1;
end
% this is just for blockproc to keep running this is line (imresize) is not important
%if i dont use this blockproc wont proceed to next iteration.
singleValue=imresize(blockStruct.data,0.5);
end

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Jul 2018
% net is a classifier already trained and loaded
However, it is not loaded in the workspace of the function myFilter .

  3 Comments

Samir khan
Samir khan on 26 Jul 2018
thanks Walter Roberson for answering, but i am not able to think how i can load the "net" into the workspace of myFilter (however it is loaded in matlab workspace). the documentation is for loading a function. can you suggest a way? thankyou.
Walter Roberson
Walter Roberson on 26 Jul 2018
myFilterHandle = @(blockStruct) myFilter(blockStruct, net);
together with
function singleValue = myFilter(blockStruct, net)

Sign in to comment.

More Answers (0)

Sign in to answer this question.