python CreateHist() does not work with ranges set to None (Bug #990)
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.
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