def extract(self, img):
        """
        This method takes in a image and returns some basic morphology
        characteristics about the largest blob in the image. The
        if a color image is provided the threshold operation is applied.
        """
        retVal = None
        if (self.mThresholdOpeation is not None):
            bwImg = self.mThresholdOpeation(img)
        else:
            bwImg = img.binarize()

        if (self.mBlobMaker is None):
            self.mBlobMaker = BlobMaker()

        fs = self.mBlobMaker.extractFromBinary(bwImg, img)
        if (fs is not None and len(fs) > 0):
            fs = fs.sortArea()
            retVal = []
            retVal.append(fs[0].mArea / fs[0].mPerimeter)
            retVal.append(fs[0].mAspectRatio)
            retVal.append(fs[0].mHu[0])
            retVal.append(fs[0].mHu[1])
            retVal.append(fs[0].mHu[2])
            retVal.append(fs[0].mHu[3])
            retVal.append(fs[0].mHu[4])
            retVal.append(fs[0].mHu[5])
            retVal.append(fs[0].mHu[6])
        return retVal
예제 #2
0
    def __init__(self,
                 history=200,
                 nMixtures=5,
                 backgroundRatio=0.7,
                 noiseSigma=15,
                 learningRate=0.7):

        try:
            import cv2
        except ImportError:
            raise ImportError(
                "Cannot load OpenCV library which is required by SimpleCV")
            return
        if not hasattr(cv2, 'BackgroundSubtractorMOG'):
            raise ImportError("A newer version of OpenCV is needed")
            return

        self.mError = False
        self.mReady = False
        self.mDiffImg = None
        self.mColorImg = None
        self.mBlobMaker = BlobMaker()

        self.history = history
        self.nMixtures = nMixtures
        self.backgroundRatio = backgroundRatio
        self.noiseSigma = noiseSigma
        self.learningRate = learningRate

        self.mBSMOG = cv2.BackgroundSubtractorMOG(history, nMixtures,
                                                  backgroundRatio, noiseSigma)
예제 #3
0
 def __init__(self, grayOnly=False, threshold=(10, 10, 10)):
     self.mGrayOnlyMode = grayOnly
     self.mThreshold = threshold
     self.mError = False
     self.mCurrImg = None
     self.mLastImg = None
     self.mDiffImg = None
     self.mColorImg = None
     self.mBlobMaker = BlobMaker()
 def __init__(self, thresholdOperation=None):
     """
     The threshold operation is a function of the form
     binaryimg = threshold(img)
     
     the simplest example would be:
     def binarize_wrap(img):
         
     """
     self.mNBins = 12
     self.mBlobMaker = BlobMaker()
     self.mThresholdOpeation = thresholdOperation
 def __init__(self, alpha=0.7, thresh=(20,20,20)):
     """
     Create an running background difference.
     alpha - the update weighting where:
     accumulator = ((1-alpha)input_image)+((alpha)accumulator)
     
     threshold - the foreground background difference threshold. 
     """
     self.mError = False
     self.mReady = False
     self.mAlpha = alpha
     self.mThresh = thresh
     self.mModelImg = None
     self.mDiffImg = None
     self.mColorImg = None
     self.mBlobMaker = BlobMaker()
예제 #6
0
 def __setstate__(self, mydict):
     self.__dict__ = mydict
     self.mBlobMaker = BlobMaker()
예제 #7
0
 def __init__(self):
     self.mColorModel = ColorModel()
     self.mError = False
     self.mCurImg = Image()
     self.mTruthImg = Image()
     self.mBlobMaker = BlobMaker()