Ask Your Question
0

SimpleBlobDetection set blobColor Python

asked 2014-01-09 08:00:04 -0500

Boba-Fett gravatar image

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

berak gravatar image

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.

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

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???

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
2

answered 2014-01-09 08:38:18 -0500

berak gravatar image

updated 2014-01-09 09:23:31 -0500

hooray, you found a bug !

the error is reproducable in c++ even:

#include "opencv2/features2d/features2d.hpp"

SimpleBlobDetector sb;
sb.setInt("blobColor",3);
// same err as in python above.

digging deeper, i found this(opencv\modules\core\src\algorithm.cpp:631):

   if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL
            || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
    {
        if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
                || p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR) )
        {
            String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
            CV_Error(CV_StsBadArg, message);
        }

so, that clearly should be p->type instead of argType there at the end of line 4.

[update:] seems it was fixed a week ago.

edit flag offensive delete link more
0

answered 2014-02-10 07:59:49 -0500

Boba-Fett gravatar image

Hello again,

i tryed it with version 2.4.8 and i get the same error as above.

Blockquote

Python exception in "Blob_Detection.execute" - error: ........\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 in function cv::AlgorithmInfo::set

Blockquote

if i print the cv version with

print cv2.__version__

i get printet the version 2.4.8

Now i would look i the algorithm.cpp file, but i can´t find it because the directory structure is different

The path who is schowen in the error text does´t exist.

Can someone help me??

edit flag offensive delete link more

Comments

going to take a look ..

berak gravatar imageberak ( 2014-02-10 08:26:29 -0500 )edit

looking at the source on github, it looks fixed.

might be a case of bad luck, where you got the code before it was done ?

(your line numbers don't differ to the original problem, but they do now, so i'm suspecting that)

berak gravatar imageberak ( 2014-02-11 04:38:39 -0500 )edit
0

answered 2014-01-11 17:55:19 -0500

Boba-Fett gravatar image

Thank you for your fast response!!

That means that if i would download the newes version of opencv this bug was fixed??

edit flag offensive delete link more

Comments

1

yes, just make sure you get 2.4.8

berak gravatar imageberak ( 2014-01-12 02:48:13 -0500 )edit

Question Tools

Stats

Asked: 2014-01-09 08:00:04 -0500

Seen: 3,475 times

Last updated: Feb 10 '14