# Path: timestream/manipulate/pipeline.py
# class ImagePipeline (object):
#     def __init__(self, plConf, context):
#     def process(self, contArgs, initArgs, visualise=False):
#     def printCompList(cls):


import sys
import matplotlib.pyplot as plt
import os, shutil
import cv2
import numpy as np
import timestream
import timestream.manipulate.correct_detect as cd
import yaml
from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from timestream.manipulate import pipeline
                potDict['potTemplateFile'] = potTemplateFile
        else:
            potDict = {}
        self.settings['potdetect'] = potDict

        self.settings['plantextract'] = {'meth': 'method1',
                                         'methargs': {'threshold' : 0.6,
                                         'kSize' : 5, 'blobMinSize' : 50} }

        with open(self.settingFileName, 'w') as outfile:
            outfile.write( yaml.dump(self.settings, default_flow_style=None) )
            self.status.append('Saved initial data to ' + self.settingFileName)

    def testPipeline(self):
        ''' try running processing pipeline based on user inputs'''
        if self.tsImages != None:
            # load setting file if missing
            if self.settingFileName == None:
                settingFileName = str(QtGui.QFileDialog.getOpenFileName(self, 'Open pipeline setting file', self.ts.path))
                if len(settingFileName) > 0:
                    self.settingFileName = settingFileName
                else:
                    return
            # initialise pipeline
            if self.pl == None:
                f = file(self.settingFileName)
                self.settings = yaml.load(f)
                self.ts.data["settings"] = self.settings
                self.pl = pipeline.ImagePipeline(self.settings)
                # process only from undistortion to pot detection

# Path: timestream/manipulate/pipeline.py
# class ImagePipeline (object):
#     def __init__(self, plConf, context):
#     def process(self, contArgs, initArgs, visualise=False):
#     def printCompList(cls):


# Path: util/selectColorbarTrayPot.py
import sys
import matplotlib.pyplot as plt
import os, shutil
import cv2
import numpy as np
import timestream
import timestream.manipulate.correct_detect as cd
import yaml
from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from timestream.manipulate import pipeline

                potDict['potTemplateFile'] = potTemplateFile
        else:
            potDict = {}
        self.settings['potdetect'] = potDict

        self.settings['plantextract'] = {'meth': 'method1',
                                         'methargs': {'threshold' : 0.6,
                                         'kSize' : 5, 'blobMinSize' : 50} }

        with open(self.settingFileName, 'w') as outfile:
            outfile.write( yaml.dump(self.settings, default_flow_style=None) )
            self.status.append('Saved initial data to ' + self.settingFileName)

    def testPipeline(self):
        ''' try running processing pipeline based on user inputs'''
        if self.tsImages != None:
            # load setting file if missing
            if self.settingFileName == None:
                settingFileName = str(QtGui.QFileDialog.getOpenFileName(self, 'Open pipeline setting file', self.ts.path))
                if len(settingFileName) > 0:
                    self.settingFileName = settingFileName
                else:
                    return
            # initialise pipeline
            if self.pl == None:
                f = file(self.settingFileName)
                self.settings = yaml.load(f)
                self.ts.data["settings"] = self.settings
                self.pl = pipeline.ImagePipeline(self.settings)
                # process only from undistortion to pot detection

                self.pl.pipeline = self.pl.pipeline[:5]