Issue 1:
System information (version)

OpenCV => 4.0.0

Operating System / Platform => Windows7

Compiler => VS

Detailed description

In haarfeatures.cpp in OpenCV I see the following implementation for V & J Haar features:

void CvHaarEvaluator::generateFeatures()
{
int mode = ((const CvHaarFeatureParams*)((CvFeatureParams*)featureParams))->mode;
int offset = winSize.width + 1;
for( int x = 0; x < winSize.width; x++ )
{
for( int y = 0; y < winSize.height; y++ )
{
for( int dx = 1; dx <= winSize.width; dx++ )
{
for( int dy = 1; dy <= winSize.height; dy++ )
{
// haar_x2
if ( (x+dx*2 <= winSize.width) && (y+dy <= winSize.height) )
{
features.push_back( Feature( offset, false,
x, y, dx*2, dy, -1,
x+dx, y, dx , dy, +2 ) );
}
// haar_y2
if ( (x+dx <= winSize.width) && (y+dy*2 <= winSize.height) )
{
features.push_back( Feature( offset, false,
x, y, dx, dy*2, -1,
x, y+dy, dx, dy, +2 ) );
}
// haar_x3
if ( (x+dx*3 <= winSize.width) && (y+dy <= winSize.height) )
{
features.push_back( Feature( offset, false,
x, y, dx*3, dy, -1,
x+dx, y, dx , dy, +3 ) );
}
// haar_y3
if ( (x+dx <= winSize.width) && (y+dy*3 <= winSize.height) )
{
features.push_back( Feature( offset, false,
x, y, dx, dy*3, -1,
x, y+dy, dx, dy, +3 ) );
}
// x2_y2
if ( (x+dx*2 <= winSize.width) && (y+dy*2 <= winSize.height) )
{
features.push_back( Feature( offset, false,
x, y, dx*2, dy*2, -1,
x, y, dx, dy, +2,
x+dx, y+dy, dx, dy, +2 ) );
}

}
}
}
}
numFeatures = (int)features.size();
}

Where each feature is represented by two (haar_x2, haar_y2, haar_x3, haar_y3) or three (x2_y2) rectangles and corresponding weights in order to compute the feature from the integral image.

inline float CvHaarEvaluator::Feature::calc( const cv::Mat &_sum, const cv::Mat &_tilted, size_t y) const
{
const int* img = tilted ? _tilted.ptr<int>((int)y) : _sum.ptr<int>((int)y);
float ret = rect[0].weight * (img[fastRect[0].p0] - img[fastRect[0].p1] - img[fastRect[0].p2] + img[fastRect[0].p3] ) +
rect[1].weight * (img[fastRect[1].p0] - img[fastRect[1].p1] - img[fastRect[1].p2] + img[fastRect[1].p3] );
if( rect[2].weight != 0.0f )
ret += rect[2].weight * (img[fastRect[2].p0] - img[fastRect[2].p1] - img[fastRect[2].p2] + img[fastRect[2].p3] );
return ret;
}

For haar_x2 the configuration is:

so the first rectangle (x, y, dx*2, dy) represents the sum A+B (with weight -1)

and the second rectangle (x+dx, y, dx, dy) represents just B (with weight +2)

summing up with weights gives -(A + B) + 2 * B = B - A as it should. the same holds for haar_y2

for x2_y2 the configuration is:

Here the first rectangle (x, y, dx*2, dy*2) represents (A + B + C + D),

the second rectangle (x, y, dx, dy) represents A

and the third rectangle (x+dx, y+dy, dx, dy) represents D

so with weights we get -(A + B + C + D) + 2 * A + 2 * D = A + D - (B + C)

as we should.

But for haar_x3 (and y3) the configuration is:

so the first rectangle (x, y, dx*3, dy) represents (A + B + C)

and the second rectangle (x+dx, y, dx, dy) represents B.

Now, with weights we get -(A + B + C) + 3*B = 2 * B - (A + C)

while the V & J paper states that

"A three rectangle feature computes the sum within two outside

rectangles substracted from the sum in the center rectangle"

I read this as B - (A + C) and not 2 * B - (A + C)!.

Am I missing something here? or is this a bug? can anyone confirm this?

Steps to reproduce

Issue 2:
Can anyone suggest how to create pbtxt file for architecture other than ssd, mask -rcnn and faster-rcnn.

System information (version)

OpenCV => ❔

Operating System / Platform => ❔

Compiler => ❔

Detailed description

Steps to reproduce