コード例 #1
0
 def doSuccessExecDcraw(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlDevelopRawv1_0.doSuccessExecDcraw")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginControlDevelopRawv1_0.doSuccessExecDcraw")
     self.xsdTempFile = _edPlugin.getDataOutput().getOutputPath()
     xsdin = XSDataInputExecThumbnail()
     xsdin.setInputImagePath(self.xsdTempFile)
     self.xsdfJpeg = XSDataFile(XSDataString(self.strJpegFile))
     xsdin.setOutputPath(self.xsdfJpeg)
     self.__edPluginExecThumbnail.setDataInput(xsdin)
     self.__edPluginExecThumbnail.connectSUCCESS(self.doSuccessExecThumbnail)
     self.__edPluginExecThumbnail.connectFAILURE(self.doFailureExecThumbnail)
     self.__edPluginExecThumbnail.executeSynchronous()
コード例 #2
0
    def preProcess(self):
        """
        PreProcess of the execution test: download an EDF file from http://www.edna-site.org
        and remove any existing output file, i.e. /tmp/diff6105.edf 
        """
        EDTestCasePluginExecute.preProcess(self)

        xsDataInput = XSDataInputExecThumbnail.parseString(self.readAndParseFile (self.getDataInputFile()))
        self.loadTestImage([ os.path.basename(xsDataInput.getInputImagePath().getPath().getValue())])
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultExecThumbnail.parseString(strExpectedOutput)
        outputFileName = xsDataResultReference.getThumbnailPath().getPath().getValue()
        EDVerbose.DEBUG(" Output file is %s" % outputFileName)
        if os.path.isfile(outputFileName):
            EDVerbose.DEBUG(" Output file exists %s, I will remove it" % outputFileName)
            os.remove(outputFileName)
コード例 #3
0
 def doSuccessExecDcraw(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlDevelopRawv1_0.doSuccessExecDcraw")
     self.retrieveSuccessMessages(
         _edPlugin, "EDPluginControlDevelopRawv1_0.doSuccessExecDcraw")
     self.xsdTempFile = _edPlugin.getDataOutput().getOutputPath()
     xsdin = XSDataInputExecThumbnail()
     xsdin.setInputImagePath(self.xsdTempFile)
     self.xsdfJpeg = XSDataFile(XSDataString(self.strJpegFile))
     xsdin.setOutputPath(self.xsdfJpeg)
     self.__edPluginExecThumbnail.setDataInput(xsdin)
     self.__edPluginExecThumbnail.connectSUCCESS(
         self.doSuccessExecThumbnail)
     self.__edPluginExecThumbnail.connectFAILURE(
         self.doFailureExecThumbnail)
     self.__edPluginExecThumbnail.executeSynchronous()
コード例 #4
0
    def preProcess(self):
        """
        PreProcess of the execution test: download an EDF file from http://www.edna-site.org
        and remove any existing output file, i.e. /tmp/diff6105.edf 
        """
        EDTestCasePluginExecute.preProcess(self)

        xsDataInput = XSDataInputExecThumbnail.parseString(
            self.readAndParseFile(self.getDataInputFile()))
        self.loadTestImage([
            os.path.basename(
                xsDataInput.getInputImagePath().getPath().getValue())
        ])
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultExecThumbnail.parseString(
            strExpectedOutput)
        outputFileName = xsDataResultReference.getThumbnailPath().getPath(
        ).getValue()
        EDVerbose.DEBUG(" Output file is %s" % outputFileName)
        if os.path.isfile(outputFileName):
            EDVerbose.DEBUG(" Output file exists %s, I will remove it" %
                            outputFileName)
            os.remove(outputFileName)
コード例 #5
0
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     EDVerbose.DEBUG("EDPluginControlPyarchThumbnailGeneratorv1_0.preProcess")
     # Check that the input image exists and is of the expected type
     strPathToDiffractionImage = self.getDataInput().getDiffractionImage().getPath().getValue()
     strImageFileNameExtension = os.path.splitext(strPathToDiffractionImage)[1]
     if not strImageFileNameExtension in [".img", ".marccd", ".mccd", ".cbf"]:
         print strImageFileNameExtension
         EDVerbose.error("Unknown image file name extension for pyarch thumbnail generator: %s" % strPathToDiffractionImage)
         self.setFailure()
     else:
         # Load the waitFile plugin
         xsDataInputWaitFile = XSDataInputWaitFile()
         xsDataInputWaitFile.setExpectedSize(XSDataInteger(self.__iExpectedSize))
         xsDataInputWaitFile.setExpectedFile(self.getDataInput().getDiffractionImage())
         if self.getDataInput().getWaitForFileTimeOut():
             xsDataInputWaitFile.setTimeOut(self.getDataInput().getWaitForFileTimeOut())
         self.__edPluginWaitFile = EDPluginWaitFile()
         self.__edPluginWaitFile.setDataInput(xsDataInputWaitFile)
         # Load the execution plugin
         self.__edPluginExecThumbnail = self.loadPlugin(self.__strExecThumbnailPluginName)
         xsDataInputExecThumbnail = XSDataInputExecThumbnail()
         xsDataInputExecThumbnail.setInputImagePath(self.getDataInput().getDiffractionImage())
         xsDataInputExecThumbnail.setLevelsInvert(XSDataBoolean(True))
         xsDataInputExecThumbnail.setLevelsMin(XSDataDoubleWithUnit(0.0))
         xsDataDoubleWithUnitLevelsMax = XSDataDoubleWithUnit(99.95)
         xsDataDoubleWithUnitLevelsMax.setUnit(XSDataString("%"))
         xsDataInputExecThumbnail.setLevelsMax(xsDataDoubleWithUnitLevelsMax)
         xsDataInputExecThumbnail.setFilterDilatation([XSDataInteger(4)])
         xsDataInputExecThumbnail.setLevelsColorize(XSDataBoolean(False))
         xsDataInputExecThumbnail.setThumbHeight(XSDataInteger(1024))
         xsDataInputExecThumbnail.setThumbWidth(XSDataInteger(1024))
         xsDataInputExecThumbnail.setKeepRatio(XSDataBoolean(False))
         # Output path
         strImageNameWithoutExt = os.path.basename(os.path.splitext(strPathToDiffractionImage)[0])
         strImageDirname = os.path.dirname(strPathToDiffractionImage)
         if self.getDataInput().getForcedOutputDirectory():
             strForcedOutputDirectory = self.getDataInput().getForcedOutputDirectory().getPath().getValue()
             if not os.access(strForcedOutputDirectory, os.W_OK):
                 EDVerbose.error("Cannot write to forced output directory : %s" % strForcedOutputDirectory)
                 self.setFailure()
             else:
                 self.strOutputPathWithoutExtension = os.path.join(strForcedOutputDirectory, strImageNameWithoutExt)
         else:
             # Try to store in the ESRF pyarch directory
             strOutputDirname = EDHandlerESRFPyarchv1_0.createPyarchFilePath(strImageDirname)
             # Check that output pyarch path exists and is writeable:
             bIsOk = False
             if strOutputDirname:
                 if not os.path.exists(strOutputDirname):
                     # Try to create the directory
                     try:
                         os.makedirs(strOutputDirname)
                         bIsOk = True
                     except BaseException, e:
                         EDVerbose.WARNING("Couldn't create the directory %s" % strOutputDirname)
                 elif os.access(strOutputDirname, os.W_OK):
                     bIsOk = True
             if not bIsOk:
                 EDVerbose.warning("Cannot write to pyarch directory: %s" % strOutputDirname)
                 strOutputDirname = tempfile.mkdtemp("", "EDPluginPyarchThumbnailv10_", "/tmp")
                 EDVerbose.warning("Writing thumbnail images to: %s" % strOutputDirname)
             self.strOutputPathWithoutExtension = os.path.join(strOutputDirname, strImageNameWithoutExt)
         self.strOutputPath = os.path.join(self.strOutputPathWithoutExtension + ".jpeg")
         xsDataInputExecThumbnail.setOutputPath(XSDataFile(XSDataString(self.strOutputPath)))
         self.__edPluginExecThumbnail.setDataInput(xsDataInputExecThumbnail)
コード例 #6
0
 def doSuccessExecThumbnail(self, _edPlugin=None):
     EDVerbose.DEBUG("EDPluginControlPyarchThumbnailGeneratorv1_0.doSuccessExecThumbnail")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginControlPyarchThumbnailGeneratorv1_0.doSuccessExecThumbnail")
     # Retrieve the output path
     self.__xsDataFilePathToThumbnail = self.__edPluginExecThumbnail.getDataOutput().getThumbnailPath()
     # Run the plugin again, this time with the first thumbnail as input
     self.__edPluginExecThumbnail2 = self.loadPlugin(self.__strExecThumbnailPluginName)
     xsDataInputExecThumbnail = XSDataInputExecThumbnail()
     xsDataInputExecThumbnail.setInputImagePath(self.__edPluginExecThumbnail.getDataOutput().getThumbnailPath())
     xsDataInputExecThumbnail.setThumbHeight(XSDataInteger(256))
     xsDataInputExecThumbnail.setThumbWidth(XSDataInteger(256))
     xsDataInputExecThumbnail.setKeepRatio(XSDataBoolean(False))
     xsDataInputExecThumbnail.setOutputPath(XSDataFile(XSDataString(self.strOutputPathWithoutExtension + ".thumb.jpeg")))
     self.__edPluginExecThumbnail2.setDataInput(xsDataInputExecThumbnail)
     self.__edPluginExecThumbnail2.connectSUCCESS(self.doSuccessExecThumbnail2)
     self.__edPluginExecThumbnail2.connectFAILURE(self.doFailureExecThumbnail2)
     self.__edPluginExecThumbnail2.executeSynchronous()
コード例 #7
0
ファイル: edna-JpegColor.py プロジェクト: kif/edna
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
コード例 #8
0
ファイル: edna-Pilatus.py プロジェクト: rentreg/edna
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        #        xsd.setLevelsColorize(XSDataBoolean(True))
        #        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsEqualize(XSDataBoolean(True))

        #        xsd.setLevelsGamma(XSDataDouble(gamma))
        xsd.setLevelsMin(XSDataDouble(0.0))
        xsdMax = XSDataDoubleWithUnit()
        xsdMax.setValue(99.9)
        xsdMax.setUnit(XSDataString("""%"""))
        xsd.setLevelsMax(xsdMax)
        #        xsd.setLevelsAutoContrast(XSDataDouble(1.0))
        xsd.setFilterBlur([XSDataInteger(5)])
        xsd.setFilterDilatation([XSDataInteger(10)])
        #xsd.setCropBorders(XSDataInteger(), XSDataInteger())
        xsd.setLevelsInvert(XSDataBoolean(True))
        xsd.setThumbHeight(XSDataInteger(256))
        xsd.setThumbWidth(XSDataInteger(256))
        xml = xsd.marshal()
    return xml
コード例 #9
0
ファイル: edna-JpegColor.py プロジェクト: gbourgh/edna
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
               os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
コード例 #10
0
ファイル: edna-Pilatus.py プロジェクト: gbourgh/edna
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        #        xsd.setLevelsColorize(XSDataBoolean(True))
        #        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsEqualize(XSDataBoolean(True))

        #        xsd.setLevelsGamma(XSDataDouble(gamma))
        xsd.setLevelsMin(XSDataDouble(0.0))
        xsdMax = XSDataDoubleWithUnit()
        xsdMax.setValue(99.9)
        xsdMax.setUnit(XSDataString("""%"""))
        xsd.setLevelsMax(xsdMax)
        #        xsd.setLevelsAutoContrast(XSDataDouble(1.0))
        xsd.setFilterBlur([XSDataInteger(5)])
        xsd.setFilterDilatation([XSDataInteger(10)])
        # xsd.setCropBorders(XSDataInteger(), XSDataInteger())
        xsd.setLevelsInvert(XSDataBoolean(True))
        xsd.setThumbHeight(XSDataInteger(256))
        xsd.setThumbWidth(XSDataInteger(256))
        xml = xsd.marshal()
    return xml
コード例 #11
0
    def process(self, _edObject=None):
        """
        """
        for  i in range(2):
            execPlugin = self.loadPlugin(self.__strControlledPluginThumbnail)
            xsdin = XSDataInputExecThumbnail()
            xsdin.setInputArray(self.xsdImages[i])
            xsdFile = XSDataFile()
            xsdFile.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), "image%i.jpg" % self.xsdIdx[i].getValue())))
            xsdin.setOutputPath(xsdFile)
            xsdin.setLevelsColorize(XSDataBoolean(1))
            xsdin.setLevelsEqualize(XSDataBoolean(1))

            execPlugin.setDataInput(xsdin)
            execPlugin.connectSUCCESS(self.doSuccessThumb)
            execPlugin.connectFAILURE(self.doFailureThumb)
            self.ACThumbnail.addAction(execPlugin)
        self.ACThumbnail.execute()

        while len(self.xsdThumb) < 2:
            time.sleep(1)

        for  oneImage in self.xsdThumb:
            execPlugin = self.loadPlugin(self.__strControlledPluginSift)
            xsdin = XSDataInputSiftDescriptor()
            xsdin.setImage(oneImage)
            execPlugin.setDataInput(xsdin)
            execPlugin.connectSUCCESS(self.doSuccessSift)
            execPlugin.connectFAILURE(self.doFailureSift)
            self.ACSift.addAction(execPlugin)
        self.ACSift.execute()
#
#        else:
#            strError = "There are only %s images in self.xsdThumb" % len(self.xsdThumb)
#            EDVerbose.ERROR(strError)
#            self.setFailure()
#            raise RuntimeError(strError)

################################################################################
# This should be executed only after the Sift actions cluster finishes 
################################################################################
        while len(self.xsdKeys) < 2:
            time.sleep(1)

        execPlugin = self.loadPlugin(self.__strControlledPluginAutopano)
        xsdin = XSDataInputMeasureOffsetSift()
        xsdin.setDescriptorFile(self.xsdKeys)
        execPlugin.setDataInput(xsdin)
        execPlugin.connectSUCCESS(self.doSuccessAutopano)
        execPlugin.connectFAILURE(self.doFailureAutopano)
        execPlugin.executeSynchronous()