Adaptive Threshold in OpenCV (Version 1 - the swig version)

Posted by Neil Benn on Stack Overflow See other posts from Stack Overflow or by Neil Benn
Published on 2010-04-19T15:29:47Z Indexed on 2010/04/19 15:33 UTC
Read the original article Hit count: 1441

Filed under:
|

Hello

I'm trying to get adaptive thresholding working in the python binding to opencv (the swig one - cannot get opencv 2.0 working as I am using a beagleboard as the cross compiling is not working yet). I have a greyscale image (ccg.jpg) and the following code

import opencv
from opencv import highgui
img = highgui.cvLoadImage("ccg.png")
img_bw = opencv.cvCreateImage(opencv.cvGetSize(img), opencv.IPL_DEPTH_8U, 1)
opencv.cvAdaptiveThreshold(img, img_bw, 125, opencv.CV_ADAPTIVE_THRESH_MEAN_C, opencv.CV_THRESH_BINARY, 7, 10)

When I run this I get the error:

RuntimeError:  openCV Error:
    Status=Formats of input arguments do not match
    function name=cvAdaptiveThreshold
    error messgae=
    file_name=cvadapthresh.cpp
    line=122

I've also tried having both the source and dest arguments both the same (greyscale) and I get the error 'Unsupported format or combination of formats'.

Does anyone have any clues as to where I could be going wrong?

Cheers,

Neil

© Stack Overflow or respective owner

Related posts about opencv

Related posts about python