How can i pass 'MinSize' and 'MaxSize' name-value pairs into the object's constructor?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2014-6-13
编辑:dpb
2014-6-15
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], ...
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!