error:Undefined function or variable 'values'.

조회 수: 1 (최근 30일)
barath V
barath V 2020년 3월 3일
댓글: Walter Roberson 2020년 3월 21일
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
Walter Roberson
Walter Roberson 2020년 3월 9일
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 2020년 3월 20일
i want to thank mr.walter roberson and matlab people for continuously supporting my projects,thanks mr.walter

댓글을 달려면 로그인하십시오.

답변 (1개)

barath V
barath V 2020년 3월 9일
hi deleting the arduino object solved the pblm,thanlks.
how can i capture a video?
  댓글 수: 3
barath V
barath V 2020년 3월 21일
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 2020년 3월 21일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 I2C Devices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by