(wg) 64 bit failure for test_CreateImage (Bug #11)


Added by James Bowman over 15 years ago. Updated over 15 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:build/install
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

build python bindings, then run

python ../tests/python/test.py test_CreateImage


===================================================================
FAIL: test_CreateImage (+main+.TestDirected)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../tests/python/test.py", line 145, in test_CreateImage
    self.assert_(a.depth == d)
[[AssertionError]]

----------------------------------------------------------------------

this test works fine on 32-bit, but on 64-bit Linux it fails.


Associated revisions

Revision 99e5dc32
Added by Andrey Kamaev about 12 years ago

Merge pull request #11 from Daniil-Osokin/sanityData4CalcHist

Added sanity data for calcHist() perf tests

History

Updated by Vadim Pisarevsky over 15 years ago

fixed; SVN r2373

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Updated by Vadim Pisarevsky over 15 years ago

here is more info about the bug provided by request.

The problem was not in the core OpenCV libraries, it was in the Python wrapper.

here is why it happened:

IplImage::depth is 32-bit int, it can be one of IPL_DEPTH_...

The constants IPL_DEPTH_8S, IPL_DEPTH_16S or IPL_DEPTH_32S are defined as
0x80000000 + 8, 0x80000000 + 16 or 0x80000000 + 32 respectively, i.e. 31-th bit (sign bit on 32-bit architectures) is 1.

When the constants IPL_DEPTH_8S, IPL_DEPTH_16S, IPL_DEPTH_32S are "exported" to Python, they are exported as unsigned integers (which is correct, IMO). however, IplImage "get depth" property in Python returned the depth as signed integer.
so the assert

self.assert_(a.depth d)

was "expanded" to the following (on 64-bit platforms):

assert ((int64)(int)depth (int64)(unsigned)depth);

which is not true when depth == 0x8xxxxxxx

The problem was fixed by changing IplImage get_depth property so that it always returns a positive integer, regardless of the native integer size.

Updated by James Bowman over 15 years ago

Fix broke test_CreateImage for 32-bit...
Test passes again (both 32 and 64 bit) in r2380.

Also available in: Atom PDF