How can i pass 'MinSize' and 'MaxSize' name-value pairs into the object's constructor?

2 vues (au cours des 30 derniers jours)
I am using cascade object detector, and i want to pass a minsize and maxsize but i don't know how to implement it in my matlab code
For minsize For h=w=20
[ h w]=MinSize(I) MinSize(h/4, w/4)=x MinSize[x x]
And for max
MaxSIze(h,w)=y MaxSize[y y]
  4 commentaires
Geoff Hayes
Geoff Hayes le 13 Juin 2014
What have you attempted so far? What do you want h and w to vary between?
Misrak Seifu
Misrak Seifu le 13 Juin 2014
This is what i tried so far...
% % Load Image test_image=im2double(imread([image_path,img_list(i).name])); imshow(test_image);hold on;
disp(['Detecting Face in ' ,img_list(i).name]);
*faceDetector = vision.CascadeObjectDetector( h=20,w=20, [h w]=MinSize(test_image),MinSize(h/4, w/4)=x, 'MinSize'[20, 20]);*
bbox = step(faceDetector, test_image);
test_init_shape = InitShape(bbox,refShape);
test_init_shape = reshape(test_init_shape,49,2);
plot(test_init_shape(:,1),test_init_shape(:,2),'ro');
if size(test_image,3) == 3
test_input_image = im2double(rgb2gray(test_image));
else
test_input_image = im2double((test_image));
end
disp(['Fitting ' img_list(i).name]);

Connectez-vous pour commenter.

Réponse acceptée

dpb
dpb le 13 Juin 2014
Modifié(e) : dpb le 15 Juin 2014
I've no clue on what vision.CascadeObjectDetector is, but
faceDetector = vision.CascadeObjectDetector( h=20,w=20, ...
[h w]=MinSize(test_image), ...
MinSize(h/4, w/4)=x, ...
'MinSize'[20, 20]);
isn't even close to any recognizable Matlab syntax. An assignment inside an argument list is verboten entirely, and the object will accept only whatever named parameters it's been coded to accept in the form it expects.
As the doc indicates, the 'MinSize' parameter is a 2-vector so it would be something like
faceDetector = vision.CascadeObjectDetector('MinSize',[20 20], ...
You can include previously defined variables and computations in the creation of the values, but the results have to be written as vectors or scalars depending on the parameter with which they're being associated.
for details altho I agree it could stand with a few examples. It presumes the reader has enough experience with basic Matlab that he understands implicitly what is meant by the phrase "specify these properties as one or more name-value pair arguments".
ADDENDUM
I hadn't seen the previous. In this case you can have your cake and eat it too... :)
IFF MinSize is a function which returns a 2-vector, then you can write
[h w]=MinSize(I);
faceDetector = vision.CascadeObjectDetector('MinSize',[h/4 w/4], ...
which is equivalent to
faceDetector = vision.CascadeObjectDetector('MinSize',[h w]/4, ...
and you can even dispense with the intermediary variables if they're not needed elsewhere--
faceDetector = vision.CascadeObjectDetector('MinSize',MinSize(I)/4, ...
The latter takes advantage of the definition of MinSize as being the vector of length two required. Similarly for the other parameters.
Oh, one last minor pertubation--
If you were to want different scaling for the two values it would still be possible with some care--
% make minimum h==2w
faceDetector = vision.CascadeObjectDetector('MinSize',MinSize(I)./[2 4], ...

Plus de réponses (0)

Catégories

En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by