error:Undefined function or variable 'values'.

1 Ansicht (letzte 30 Tage)
barath V
barath V am 3 Mär. 2020
Kommentiert: Walter Roberson am 21 Mär. 2020
clc;
clear all;
CAMERA = videoinput('pointgrey', '1');%camera initialization
start(CAMERA);
a = serial('COM3','BaudRate',9600); %arduino initialization
fopen(a);
pause(1);
for a = 1:8
automate(CAMERA)
pause(8)
end
plot(values); %plotting values just for our visual understanding
[m,index] = max(values)
fprintf(a,'%d',index) %"here is where we send the position of image to arduino"
fclose(a)
hold on
plot(index,m,'*')
hold off
title("bodekke with spot images")
stop(CAMERA); %stop camera acquisition
function[addition] = bodekke(imagename) %bodekke function mathematics behind the autofocus detection
im = double(imread(imagename))
bd = [-1 0 1]
cbd = conv2(im,bd)
squaredcbd = cbd.^2
addition = sum(squaredcbd(:))
end
function automate(CAMERA)
for i = 1:30 %to capture images
filename = sprintf('testtry%02d.jpg',i);
img = im2double(getsnapshot(CAMERA)); %captures images
img = rgb2gray(img);
imwrite(img,filename)
end
D = 'C:\Users\PRL\Desktop\just'; %location where image is stored
S = dir(fullfile(D,'*.jpg'));
for k = 1:numel(S) %applies bodekke to all images
F = fullfile(D,S(k).name);
queen(k) = bodekke(F); %bodekke function call
end
end
  26 Kommentare
Walter Roberson
Walter Roberson am 9 Mär. 2020
For the purpose of debugging, after
title("bodekke with spot images")
add
fprintf('%d of %d elements in addition are finite', nnz(isfinite(addition)), numel(addition));
barath V
barath V am 20 Mär. 2020
i want to thank mr.walter roberson and matlab people for continuously supporting my projects,thanks mr.walter

Melden Sie sich an, um zu kommentieren.

Antworten (1)

barath V
barath V am 9 Mär. 2020
hi deleting the arduino object solved the pblm,thanlks.
how can i capture a video?
  3 Kommentare
barath V
barath V am 21 Mär. 2020
Yes,i capture imagea and analyse it using bodekke,later these images are overwritten. Iam trying to capture a video after i send a value to Arduino,that will be permanent and wont be overwritten or analysed.
Walter Roberson
Walter Roberson am 21 Mär. 2020
Use different folders instead of always using
D = 'C:\Users\PRL\Desktop\just';
You could use uigetdir to have the user tell you the directory. Or you could look in the folder and see what subfolders already exist and use the next available one.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by