python CreateHist() does not work with ranges set to None (Bug #990)


Added by Pieter-Jan Busschaert almost 14 years ago. Updated almost 14 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:python bindings
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

from opencv_svn import cv
histogram = cv.CreateHist(r256, cv.CV_HIST_ARRAY)

Traceback (most recent call last):
. File "<pyshell#13>", line 1, in <module>
. . histogram = cv.CreateHist(r256, cv.CV_HIST_ARRAY)
error: NULL ranges pointer

This happens because the pycvCreateHist() function in modules\python\cv.cpp. It does not call the normal C/C++ cvCreateHist(), but has copied it partially. Notable difference is the call to cvSetHistBinRanges(), which is not executed in the C/C++ version if ranges is NULL, but is always executed in the Python version.

It would be easy to just make it conditional too in python, but I don't know if the "uniform" parameter will still work then.


Associated revisions

Revision 2c1e913b
Added by Vadim Pisarevsky almost 14 years ago

added 16-bit support to Bayer2RGB & Bayer2Gray (ticket #686); fixed bug in cv.CreateHist() when no ranges are passed (ticket #990)

Revision 130794d4
Added by Roman Donchenko over 11 years ago

Merge pull request #990 from asmorkalov:pthread_build_fix

History

Updated by Pieter-Jan Busschaert almost 14 years ago

sorry, code should be:

 1>>> from opencv_svn import cv
 2>>> cv.CreateHist(r1, cv.CV_HIST_ARRAY)
 3
 4Traceback (most recent call last):
 5  File "<pyshell#37>", line 1, in <module>
 6    histogram = cv.CreateHist(r1, cv.CV_HIST_ARRAY)
 7error: NULL ranges pointer
 8
 9>>> cv.CreateHist(r1, cv.CV_HIST_ARRAY, [[0, 255]])
10<cv.cvhistogram object at 0x01325148>

Updated by Vadim Pisarevsky almost 14 years ago

thanks! fixed in r5349

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

Also available in: Atom PDF