Ask Your Question

Revision history [back]

SimpleBlobDetection set blobColor Python

Hello,

for my Technician exam project i have to do a blobDetection with openCV in Python. I use the simpleBlobDetection algorithem. here a code sample

import cv2

b = cv2.SimpleBlobDetector()

#set parameter if GetValue('Blob_Detection.blob_color') == 0: b.setInt('blobColor',0) else: b.setInt('blobColor',255) b.setDouble('maxArea',GetValue('Blob_Detection.maxArea')) b.setDouble('maxCircularity',GetValue('Blob_Detection.maxCircularity')) b.setDouble('maxConvexity',GetValue('Blob_Detection.maxConvexity')) b.setDouble('maxInertiaRatio',GetValue('Blob_Detection.maxInertiaRatio')) b.setDouble('maxThreshold',GetValue('Blob_Detection.maxThreshold')) b.setDouble('minDistBetweenBlobs',GetValue('Blob_Detection.minDistbetweenBlobs')) b.setDouble('minRepeatability',GetValue('Blob_Detection.minRepeatability')) b.setDouble('minThreshold',GetValue('Blob_Detection.minThreshold')) b.setDouble('thresholdStep',GetValue('Blob_Detection.thresholdStep'))

blob = b.detect(img)

To set the parameters whitout 'blobColor' works fine. But if i try to set the blobColor i get a strange error message.

Blockquote

cv2.error: ......\src\opencv\modules\core\src\algorithm.cpp:654: error: (-5) Argument error: the setter method was called for the parameter 'blobColor' of the algorithm 'Feature2D.SimpleBlob', the parameter has unsigned char type, so it should be set by i nteger, unsigned integer, uint64, unsigned char, boolean, float or double value, but the setter was called with integer value

Python exception in "Blob_Detection.execute" - error: ......\src\opencv\modules\core\src\algorithm.cpp:654: error: (-5) Argument error: the setter method was called for the parameter 'blobColor' of the algorithm 'Feature2D.SimpleBlob', the parameter has unsigned char type, so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, but the setter was called with integer value

Blockquote

I tried different set methodes. But every time i get the same error. I don´t know where´s the mistake

Can someone help me???

click to hide/show revision 2
please use the 10101 button to format code.

updated 2014-01-09 08:06:30 -0600

berak gravatar image

SimpleBlobDetection set blobColor Python

Hello,

for my Technician exam project i have to do a blobDetection with openCV in Python. I use the simpleBlobDetection algorithem. here a code sample

import cv2

cv2 b = cv2.SimpleBlobDetector()

cv2.SimpleBlobDetector() #set parameter if GetValue('Blob_Detection.blob_color') == 0: b.setInt('blobColor',0) else: b.setInt('blobColor',255) b.setDouble('maxArea',GetValue('Blob_Detection.maxArea')) b.setDouble('maxCircularity',GetValue('Blob_Detection.maxCircularity')) b.setDouble('maxConvexity',GetValue('Blob_Detection.maxConvexity')) b.setDouble('maxInertiaRatio',GetValue('Blob_Detection.maxInertiaRatio')) b.setDouble('maxThreshold',GetValue('Blob_Detection.maxThreshold')) b.setDouble('minDistBetweenBlobs',GetValue('Blob_Detection.minDistbetweenBlobs')) b.setDouble('minRepeatability',GetValue('Blob_Detection.minRepeatability')) b.setDouble('minThreshold',GetValue('Blob_Detection.minThreshold')) b.setDouble('thresholdStep',GetValue('Blob_Detection.thresholdStep'))

b.setDouble('thresholdStep',GetValue('Blob_Detection.thresholdStep')) blob = b.detect(img)

b.detect(img)

To set the parameters whitout 'blobColor' works fine. But if i try to set the blobColor i get a strange error message.

Blockquote

cv2.error: ......\src\opencv\modules\core\src\algorithm.cpp:654: ..\..\..\src\opencv\modules\core\src\algorithm.cpp:654: error: (-5) Argument error: the setter method was called for the parameter 'blobColor' of the algorithm 'Feature2D.SimpleBlob', the parameter has unsigned char type, so it should be set by i
nteger, unsigned integer, uint64, unsigned char, boolean, float or double value, but the setter was called with integer value

value Python exception in "Blob_Detection.execute" - error: ......\src\opencv\modules\core\src\algorithm.cpp:654: ..\..\..\src\opencv\modules\core\src\algorithm.cpp:654: error: (-5) Argument error: the setter method was called for the parameter 'blobColor' of the algorithm 'Feature2D.SimpleBlob', the parameter has unsigned char type, so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, but the setter was called with integer value

Blockquote

value

I tried different set methodes. But every time i get the same error. I don´t know where´s the mistake

Can someone help me???