def doSuccessExecAccumultor(self, _edPlugin=None):
        with self.semAccumulator:
            self.DEBUG("EDPluginControlAlignStackv1_0.doSuccessExecAccumultor")
            self.retrieveSuccessMessages(_edPlugin, "EDPluginControlAlignStackv1_0.doSuccessExecAccumultor")
            for query in _edPlugin.dataOutput.getQuery():
                self.addExtraTime(60)
                _edPlugin.addExtraTime(60)
                accType = query.getItem()[0].getValue().split()[0]
                listInt = [int(i.getValue().split()[1]) for i in query.getItem()]
                if accType == "raw":
                    listFrame = [self.getFrameRef(i) for i in listInt]

                    xsdata = XSDataInputMeasureOffset(image=listFrame)
                    doSIFT = False
                    if self.xsdMeasureOffset is not None:
                        xsdata.setCropBorders(self.xsdMeasureOffset.getCropBorders())
                        xsdata.setSmoothBorders(self.xsdMeasureOffset.getSmoothBorders())
                        xsdata.setBackgroundSubtraction(self.xsdMeasureOffset.getRemoveBackground())
                        if self.xsdMeasureOffset.useSift is not None:
                            doSIFT = self.xsdMeasureOffset.useSift.value
                    if max(listInt) > EDPluginControlAlignStackv1_0.__iRefFrame:
                        listInt.sort()
                    else:
                        listInt.sort(reverse=True)
                    xsdata.setIndex([XSDataInteger(i) for i in listInt ])
                    if doSIFT:
                        edPluginExecMeasure = self.loadPlugin(self.__strControlledPluginMeasureSIFT)
                    else:
                        edPluginExecMeasure = self.loadPlugin(self.__strControlledPluginMeasureFFT)
                    edPluginExecMeasure.setDataInput(xsdata)
                    edPluginExecMeasure.connectSUCCESS(self.doSuccessExecMeasureOffset)
                    edPluginExecMeasure.connectFAILURE(self.doFailureExecMeasureOffset)
                    self.queue.put(edPluginExecMeasure)

                elif accType == "shift":
                    shift_1 = 0.0
                    shift_2 = 0.0

                    for frame in listInt:
                        shift_1 += EDPluginControlAlignStackv1_0.__dictRelShift[frame][0]
                        shift_2 += EDPluginControlAlignStackv1_0.__dictRelShift[frame][1]
                    if listInt[0] > EDPluginControlAlignStackv1_0.__iRefFrame:
                        iFrameShift = max(listInt)
                    else:
                        iFrameShift = min(listInt)
                    EDPluginControlAlignStackv1_0.__dictAbsShift[iFrameShift] = (shift_1, shift_2)
                    self.screen("Frame number %i has absolute offset of %.3f,%.3f" % (iFrameShift, shift_1, shift_2))

                    edPluginExecShift = self.loadPlugin(self.__strControlledPluginShift)
                    edPluginExecShift.dataInput = XSDataInputShiftImage(index=XSDataInteger(iFrameShift),
                                                   offset=[XSDataDouble(shift_1), XSDataDouble(shift_2)],
                                                   inputImage=self.getFrameRef(iFrameShift),
                                                   outputImage=XSDataImageExt(shared=XSDataString("Shifted-%06i" % iFrameShift)))

                    edPluginExecShift.connectSUCCESS(self.doSuccessExecShiftImage)
                    edPluginExecShift.connectFAILURE(self.doFailureExecShiftImage)
                    self.queue.put(edPluginExecShift)
            self.DEBUG("Items: %s" % EDPluginAccumulatorv1_0.getItems())
            self.DEBUG("Queries: %s" % EDPluginAccumulatorv1_0.getQueries())
示例#2
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlStitchImagev1_0.process")
        for idx1, im1 in enumerate(self.lInputFiles[:-1]):
            for idx2, im2 in enumerate(self.lInputFiles[idx1 + 1:]):
                plugin = self.loadPlugin(self.__strControlledPluginMeasure)
                xsd = XSDataInputMeasureOffset()
                xsd.setImage([
                    XSDataImageExt(XSDataString(im1)),
                    XSDataImageExt(XSDataString(im2))
                ])
                xsd.setIndex(
                    [XSDataInteger(idx1),
                     XSDataInteger(idx2 + idx1 + 1)])
                xsd.setCenter(self.xCenter)
                xsd.setWidth(self.xWidth)
                plugin.setDataInput(xsd)
                plugin.connectSUCCESS(self.doSuccessExecMeasure)
                plugin.connectFAILURE(self.doFailureExecMeasure)
                plugin.execute()
        self.synchronizePlugins()
        d = (self.ndaDistance**2).sum(axis=-1).sum(axis=-1)
        ref = d.argmin()
        self.DEBUG("Offsets= %s\n Sum distances = %s\n using ref=%s " %
                   (self.ndaDistance, d, ref))
        pluginStitch = self.loadPlugin(self.__strControlledPluginStitch)
        xsdIn = XSDataInputStitchOffsetedImage(autoscale=self.xAutoscale,
                                               blending=self.xBlending,
                                               dummyValue=self.xDummy,
                                               outputImage=self.xOutFile,
                                               centerROI=self.xCenter,
                                               widthROI=self.xWidth,
                                               mask=self.xMask)
        xsdImgs = []
        for idx, img in enumerate(self.lInputFiles):
            offsetedImg = OffsetedImage(dummyValue=self.xDummy,
                                        deltaDummy=self.xDeltaDummy)
            offsetedImg.setOffset([
                XSDataDouble(self.ndaDistance[ref, idx, 0]),
                XSDataDouble(self.ndaDistance[ref, idx, 1])
            ])
            offsetedImg.setFile(file=XSDataImageExt(path=XSDataString(
                value=img)))

            xsdImgs.append(offsetedImg)
        xsdIn.setInputImages(xsdImgs)
        pluginStitch.setDataInput(xsdIn)
        pluginStitch.connectSUCCESS(self.doSuccessExecStitch)
        pluginStitch.connectFAILURE(self.doFailureExecStitch)
        pluginStitch.executeSynchronous()
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlStitchImagev1_0.process")
        for idx1, im1 in enumerate(self.lInputFiles[:-1]):
            for idx2, im2 in enumerate(self.lInputFiles[idx1 + 1:]):
                plugin = self.loadPlugin(self.__strControlledPluginMeasure)
                xsd = XSDataInputMeasureOffset()
                xsd.setImage([XSDataImageExt(XSDataString(im1)), XSDataImageExt(XSDataString(im2))])
                xsd.setIndex([XSDataInteger(idx1), XSDataInteger(idx2 + idx1 + 1)])
                xsd.setCenter(self.xCenter)
                xsd.setWidth(self.xWidth)
                plugin.setDataInput(xsd)
                plugin.connectSUCCESS(self.doSuccessExecMeasure)
                plugin.connectFAILURE(self.doFailureExecMeasure)
                plugin.execute()
        self.synchronizePlugins()
        d = (self.ndaDistance ** 2).sum(axis= -1).sum(axis= -1)
        ref = d.argmin()
        self.DEBUG("Offsets= %s\n Sum distances = %s\n using ref=%s " % (self.ndaDistance, d, ref))
        pluginStitch = self.loadPlugin(self.__strControlledPluginStitch)
        xsdIn = XSDataInputStitchOffsetedImage(autoscale=self.xAutoscale,
                                               blending=self.xBlending,
                                               dummyValue=self.xDummy,
                                               outputImage=self.xOutFile,
                                               centerROI=self.xCenter,
                                               widthROI=self.xWidth,
                                               mask=self.xMask)
        xsdImgs = []
        for idx, img in  enumerate(self.lInputFiles):
            offsetedImg = OffsetedImage(dummyValue=self.xDummy, deltaDummy=self.xDeltaDummy)
            offsetedImg.setOffset([XSDataDouble(self.ndaDistance[ref, idx, 0]), XSDataDouble(self.ndaDistance[ref, idx, 1])])
            offsetedImg.setFile(file=XSDataImageExt(path=XSDataString(value=img)))

            xsdImgs.append(offsetedImg)
        xsdIn.setInputImages(xsdImgs)
        pluginStitch.setDataInput(xsdIn)
        pluginStitch.connectSUCCESS(self.doSuccessExecStitch)
        pluginStitch.connectFAILURE(self.doFailureExecStitch)
        pluginStitch.executeSynchronous()
 def testCheckParameters(self):
     xsDataInput = XSDataInputMeasureOffset()
     edPluginExecMeasureOffset = self.createPlugin()
     edPluginExecMeasureOffset.setDataInput(xsDataInput)
     edPluginExecMeasureOffset.checkParameters()
示例#5
0
    def doSuccessExecAccumultor(self, _edPlugin=None):
        with self.semAccumulator:
            self.DEBUG("EDPluginControlAlignStackv1_0.doSuccessExecAccumultor")
            self.retrieveSuccessMessages(
                _edPlugin,
                "EDPluginControlAlignStackv1_0.doSuccessExecAccumultor")
            for query in _edPlugin.dataOutput.getQuery():
                self.addExtraTime(60)
                _edPlugin.addExtraTime(60)
                accType = query.getItem()[0].getValue().split()[0]
                listInt = [
                    int(i.getValue().split()[1]) for i in query.getItem()
                ]
                if accType == "raw":
                    listFrame = [self.getFrameRef(i) for i in listInt]

                    xsdata = XSDataInputMeasureOffset(image=listFrame)
                    doSIFT = False
                    if self.xsdMeasureOffset is not None:
                        xsdata.setCropBorders(
                            self.xsdMeasureOffset.getCropBorders())
                        xsdata.setSmoothBorders(
                            self.xsdMeasureOffset.getSmoothBorders())
                        xsdata.setBackgroundSubtraction(
                            self.xsdMeasureOffset.getRemoveBackground())
                        if self.xsdMeasureOffset.useSift is not None:
                            doSIFT = self.xsdMeasureOffset.useSift.value
                    if max(listInt
                           ) > EDPluginControlAlignStackv1_0.__iRefFrame:
                        listInt.sort()
                    else:
                        listInt.sort(reverse=True)
                    xsdata.setIndex([XSDataInteger(i) for i in listInt])
                    if doSIFT:
                        edPluginExecMeasure = self.loadPlugin(
                            self.__strControlledPluginMeasureSIFT)
                    else:
                        edPluginExecMeasure = self.loadPlugin(
                            self.__strControlledPluginMeasureFFT)
                    edPluginExecMeasure.setDataInput(xsdata)
                    edPluginExecMeasure.connectSUCCESS(
                        self.doSuccessExecMeasureOffset)
                    edPluginExecMeasure.connectFAILURE(
                        self.doFailureExecMeasureOffset)
                    self.queue.put(edPluginExecMeasure)

                elif accType == "shift":
                    shift_1 = 0.0
                    shift_2 = 0.0

                    for frame in listInt:
                        shift_1 += EDPluginControlAlignStackv1_0.__dictRelShift[
                            frame][0]
                        shift_2 += EDPluginControlAlignStackv1_0.__dictRelShift[
                            frame][1]
                    if listInt[0] > EDPluginControlAlignStackv1_0.__iRefFrame:
                        iFrameShift = max(listInt)
                    else:
                        iFrameShift = min(listInt)
                    EDPluginControlAlignStackv1_0.__dictAbsShift[
                        iFrameShift] = (shift_1, shift_2)
                    self.screen(
                        "Frame number %i has absolute offset of %.3f,%.3f" %
                        (iFrameShift, shift_1, shift_2))

                    edPluginExecShift = self.loadPlugin(
                        self.__strControlledPluginShift)
                    edPluginExecShift.dataInput = XSDataInputShiftImage(
                        index=XSDataInteger(iFrameShift),
                        offset=[XSDataDouble(shift_1),
                                XSDataDouble(shift_2)],
                        inputImage=self.getFrameRef(iFrameShift),
                        outputImage=XSDataImageExt(
                            shared=XSDataString("Shifted-%06i" % iFrameShift)))

                    edPluginExecShift.connectSUCCESS(
                        self.doSuccessExecShiftImage)
                    edPluginExecShift.connectFAILURE(
                        self.doFailureExecShiftImage)
                    self.queue.put(edPluginExecShift)
            self.DEBUG("Items: %s" % EDPluginAccumulatorv1_0.getItems())
            self.DEBUG("Queries: %s" % EDPluginAccumulatorv1_0.getQueries())