Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

wow, tested your code on 2.4.2:

a.size = 45, b.size = 45
idx=0 ? 0 = 0.026906
a.size = 80, b.size = 45
idx=0 ? 1 = 0.134866
a.size = 57, b.size = 45
idx=0 ? 2 = 0.19551
a.size = 45, b.size = 58
idx=2 ? 0 = 0.159511
a.size = 80, b.size = 58
idx=2 ? 1 = 0.015596
a.size = 57, b.size = 58
idx=2 ? 2 = 0.345972
a.size = 45, b.size = 53
idx=3 ? 0 = 0.199465
a.size = 80, b.size = 53
idx=3 ? 1 = 0.34338
a.size = 57, b.size = 53
idx=3 ? 2 = 0.0130037

the first thing matchShapes() does, is to calculate the hu-moments for both contours, and , as of 2.4.9, they're both all 0.

pretty sure, you found a bug.

wow, tested your code on 2.4.2:

a.size = 45, b.size = 45
idx=0 ? 0 = 0.026906
a.size = 80, b.size = 45
idx=0 ? 1 = 0.134866
a.size = 57, b.size = 45
idx=0 ? 2 = 0.19551
a.size = 45, b.size = 58
idx=2 ? 0 = 0.159511
a.size = 80, b.size = 58
idx=2 ? 1 = 0.015596
a.size = 57, b.size = 58
idx=2 ? 2 = 0.345972
a.size = 45, b.size = 53
idx=3 ? 0 = 0.199465
a.size = 80, b.size = 53
idx=3 ? 1 = 0.34338
a.size = 57, b.size = 53
idx=3 ? 2 = 0.0130037

the first thing matchShapes() does, is to calculate the hu-moments for both contours, and , as of 2.4.9, they're both all 0.

pretty sure, you found a bug.


Update:

the bug seems to be in :

void cv::HuMoments( const Moments& m, double hu[7] )

m.nu30 , m.nu12, m.nu21, m.nu03, etc are taken for granted, but never got initialized properly

i think, some code-fragment similar to cvGetHuMoments() went awol.