calcHist has wrong documetation?

115 views
Skip to first unread message

info gabor

unread,
Jul 29, 2010, 3:11:07 AM7/29/10
to ctypes...@googlegroups.com
I had some difficulties with the calcHist interface, using the one given in the API documentation:

calcHist( (object)images, (Mat)channels, (Mat)mask, (SparseMat)hist, (Mat)histSize, (object)ranges [, (bool)uniform=True [, (bool)accumulate=False]]) -> None :

with, e.g. 
    Argument 'images':
        C/C++ type: ::cv::Mat const *.
        Python type: list of MatND, e.g. [MatND(), MatND(), MatND()].

Following the error report of Python I got it working. Example follows:
Starting with some single-chanel image img0 and a corresponding mask msk0

    imgs=cv.vector_Mat()
    imgs.append(img0)
    channels=cv.vector_int()
    channels.append(0)
    mask=msk
    hist=cv.MatND()
    histSize=cv.vector_int()
    histSize.append(255)
    f=cv.vector_float32()
    f.append(0.)
    f.append(255.)
    ranges=cv.vector_vector_float32()
    ranges.append(f)

    cv.calcHist(imgs,channels,mask,hist,histSize,ranges)



Minh-Tri Pham

unread,
Jul 29, 2010, 9:06:50 AM7/29/10
to ctypes...@googlegroups.com
The API documentation on the web has not been updated, sorry. The docstring
of each function is, however, always up to date. :)

Cheers,
Minh-Tri

On 29/07/2010 08:11, info gabor wrote:
> I had some difficulties with the calcHist interface, using the one given in
> the API documentation:
>

> /calcHist( (object)images, (Mat)channels, (Mat)mask, (SparseMat)hist,


> (Mat)histSize, (object)ranges [, (bool)uniform=True [,

> (bool)accumulate=False]]) -> None :/
>
> with, e.g.
> / Argument 'images':/
> / C/C++ type: ::cv::Mat const *./
> / Python type: list of MatND, e.g. [MatND(), MatND(), MatND()]./


>
> Following the error report of Python I got it working. Example follows:
> Starting with some single-chanel image img0 and a corresponding mask msk0
>

> / imgs=cv.vector_Mat()/
> / imgs.append(img0)/
> / channels=cv.vector_int()/
> / channels.append(0)/
> / mask=msk/
> / hist=cv.MatND()/
> / histSize=cv.vector_int()/
> / histSize.append(255)/
> / f=cv.vector_float32()/
> / f.append(0.)/
> / f.append(255.)/
> / ranges=cv.vector_vector_float32()/
> / ranges.append(f)/
> /
> /
> / cv.calcHist(imgs,channels,mask,hist,histSize,ranges)/
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ctypes-opencv" group.
> To post to this group, send email to ctypes...@googlegroups.com.
> To unsubscribe from this group, send email to
> ctypes-openc...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ctypes-opencv?hl=en.

--
Dr. Minh-Tri Pham
Research Fellow, University of Surrey, UK
Email: t.p...@surrey.ac.uk or pmt...@gmail.com
Mob: +44 (0) 778 774 1089 | Tel: +44 (0) 148 368 4711

info gabor

unread,
Jul 29, 2010, 8:26:46 PM7/29/10
to ctypes...@googlegroups.com
I mixed up 2 inconsistencies, of the API doc and of the docstring. 
The wrong interface I reported came actually from the docstring. 

Minh-Tri, allow me to use this opportunity and thank you for your fantastic code. 
Today I needed the cvBlob library (which is not implemented yet in pyopencv). I had to resort to C++ opencv after few months of being spoiled by your pyopencv. I dearly missed it ! 
Thanks alot!
Reply all
Reply to author
Forward
0 new messages