error:Undefined function or variable 'values'.

2 visualizzazioni (ultimi 30 giorni)
barath V
barath V il 3 Mar 2020
Commentato: Walter Roberson il 21 Mar 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 Commenti
Walter Roberson
Walter Roberson il 9 Mar 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 il 20 Mar 2020
i want to thank mr.walter roberson and matlab people for continuously supporting my projects,thanks mr.walter

Accedi per commentare.

Risposte (1)

barath V
barath V il 9 Mar 2020
hi deleting the arduino object solved the pblm,thanlks.
how can i capture a video?
  3 Commenti
barath V
barath V il 21 Mar 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 il 21 Mar 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.

Accedi per commentare.

Categorie

Scopri di più su MATLAB Support Package for USB Webcams in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by