Undefined function or variable 'img'. The first assignment to a local variable determines its class.
Afficher commentaires plus anciens
Hello, I am trying to convert matlab code to simulink model for image processing project. I am adding the R,G,B outputs from android camera and taking the sum as the image input - 'img_in' in my function block and doing the processing. here is a snippet to show how i tried declaring the image, and other variables to 0.
function lambda = my_function(img_in)
img = zeros(size(img_in));
Ro = 0;
Co = 0;
interestRo = 0;
interestCo = 0;
width = 0;
height = 0;
BW = zeros(height+1,width+1);
% read input image
img = imread(img_in);
img = imresize(img, [480 640]);
% rgb to grayscale conversion
img = rgb2gray(img);
[Ro, Co] = size(img);
%%Dividing in 4*4 and taking the lower mid one
interestRo = round(Ro/10);
interestCo = round(Co/4);
width = 10*interestRo;
height = 2*interestCo;
BW = imcrop(img,[interestCo interestRo width height]);
But I still get lost of errors of the type:
### Generating code into build folder :----Simulink\proj_grt_rtw
The file name or URL argument must be a character vector.
Function 'MATLAB Function' (#23.199.213), line 14, column 7:
"imread(img_in)"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'img'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.231.234), line 15, column 16:
"img"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'img'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.293.296), line 17, column 16:
"img"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'img'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.316.319), line 19, column 17:
"img"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'Ro'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#23.301.303), line 19, column 2:
"Ro"
Please help me in understanding what I could do to get rid of the errors.
Thanks.
1 commentaire
Image Analyst
le 8 Oct 2017
What is the value of img_in? Are you sure it's a character string?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Run on Android Device dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
