Closed JN-Jones closed 6 years ago
% get default parameters pChns
if(nargin==2), pChns=varargin{1}; else pChns=[]; end
if( ~isfield(pChns,'complete') || pChns.complete~=1 || isempty(I) )
p=struct('enabled',{},'name',{},'hFunc',{},'pFunc',{},'padWith',{});
pChns = getPrmDflt(varargin,{'shrink',4,'pColor',{},'pGradMag',{},...
'pGradHist',{},'pCustom',p,'complete',1},1);
pChns.pColor = getPrmDflt( pChns.pColor, {'enabled',1,...
'smooth',1, 'colorSpace','luv'}, 1 );
pChns.pGradMag = getPrmDflt( pChns.pGradMag, {'enabled',1,...
'colorChn',0,'normRad',5,'normConst',.005,'full',0}, 1 );
pChns.pGradHist = getPrmDflt( pChns.pGradHist, {'enabled',1,...
'binSize',[],'nOrients',6,'softBin',0,'useHog',0,'clipHog',.2}, 1 );
nc=length(pChns.pCustom); pc=cell(1,nc);
for i=1:nc, pc{i} = getPrmDflt( pChns.pCustom(i), {'enabled',1,...
'name','REQ','hFunc','REQ','pFunc',{},'padWith',0}, 1 ); end
if( nc>0 ), pChns.pCustom=[pc{:}]; end
end
if(nargin==0), chns=pChns; return; end
I believe isInit
should be the C++ equivalent of the matlab condition that trigger the final line above if(nargin==0), chns=pChns; return; end
.
That's probably what should happen here:
if (!pChnsIn.complete.has || (pChnsIn.complete.get() != 1) || IIn.empty())
{
// Create default structures and merge:
{
// top level
Options::Pyramid::Chns dfs;
dfs.shrink = { "shrink", 4 };
dfs.complete = { "complete", 1 };
pChns.merge(dfs, 1);
}
// <SNIP>
//std::cout << pChns << std::endl;
// TODO
}
Ah. TODO :)
This lib was created as part of an effort to get a few trained models running on a phone, so only some subset of the functionality has been tested. I'm not too surprised there are a number of use case gaps. Thanks for reporting. If you have a fix, feel free to send it. Otherwise, I can take a look later. We can add some GTests to cover some of this behavior as the issues come up.
The tests are here:
TEST_F(ACFTest, ACFchnsCompute_isInit)
{
// some test for expected default values with isInit here
}
Don't have any proper fix as I'm handling the options on my own for now. There's a similar construct in chnsPyramid
though which seems to work:
https://github.com/elucideye/acf/blob/master/src/lib/acf/chnsPyramid.cpp#L179-L183
To be true to the reference implementation I suppose we should aim for the following:
>> result = chnsCompute
result =
shrink: 4
pColor: [1x1 struct]
pGradMag: [1x1 struct]
pGradHist: [1x1 struct]
pCustom: [0x0 struct]
complete: 1
>> result.pColor
ans =
enabled: 1
smooth: 1
colorSpace: 'luv'
>> result.pGradMag
ans =
enabled: 1
colorChn: 0
normRad: 5
normConst: 0.0050
full: 0
>> result.pGradHist
ans =
enabled: 1
binSize: []
nOrients: 6
softBin: 0
useHog: 0
clipHog: 0.2000
>> result.pCustom
is empty
>> result.complete
ans =
1
>> result = chnsPyramid
result =
pChns: [1x1 struct]
nPerOct: 8
nOctUp: 0
nApprox: 7
lambdas: []
pad: [0 0]
minDs: [16 16]
smooth: 1
concat: 1
complete: 1
w/ >> result.pChns
same as above
This should be consistent with the Matlab toolbox code now (after PR #40). I've added a couple tests to ensure that the default parameter retrieval is working and returning expected values. Closing ...
https://github.com/elucideye/acf/blob/master/src/lib/acf/chnsCompute.cpp ignores the
isInit
-param so the options aren't returned. This seems to cause an issue withDetector::initializeOpts()
and later with functions likeDetector::computePyramid
which try to use the options.