# Path: timestream/manipulate/pipecomponents.py
# LOG = logging.getLogger("timestreamlib")
#             TLC = self.backgroundWindow[0:2]
#             BRC = self.backgroundWindow[2:]
#             W = 2.0*np.tan(self.fieldOfView[0]/2.0/180.0*np.pi)
#             H = 2.0*np.tan(self.fieldOfView[1]/2.0/180.0*np.pi)
#             H, T = os.path.split(fpath)
# class PipeComponent (object):
# class ImageMarginAdder(PipeComponent):
# class ImageUndistorter (PipeComponent):
# class ColorCardDetector (PipeComponent):
# class ImageColorCorrector (PipeComponent):
# class TrayDetector (PipeComponent):
# class PotDetector (PipeComponent):
# class PotDetectorGlassHouse (PipeComponent):
# class PlantExtractor (PipeComponent):
# class FeatureExtractor (PipeComponent):
# class ResultingFeatureWriter(PipeComponent):
# class ResultingImageWriter (PipeComponent):
# class ResizeImage (PipeComponent):
# class DerandomizeTimeStreams (PipeComponent):
# class ResizeAndWriteImage (PipeComponent):
#     def __init__(self, *args, **kwargs):
#     def __call__(self, context, *args):
#     def __chkExcept__(self, context, *args):
#     def __exec__(self, context, *args):
#     def info(cls, _str=True):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def padlocal(self, vector, pad_width, iaxis, kwargs):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __call__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def segAllPots(self):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __chkExcept__(self, context, *args):
#     def _guessTimeStamp(self, img):
#     def _addErrStr(self, timestamp, filename):
#     def _recoverFromPrev(self, timestamp, featName):
#     def _initHeaders(self, fPath, ipm, potIds):
#     def _initPrevCsvIndex(self):
#     def _appendToAudit(self, ts, val):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def createCompoundImage(self, timestamp):
#     def getMidGrpImg(self, mid, potList, maxPotRect, numPotPerMidSize):
#     def refreshMids(self, timestamp=None):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):


import csv
import glob
import docopt
import sys, os
import timestream
import logging
import timestream.manipulate.configuration as pipeconf
import timestream.manipulate.pipeline as pipeline
import yaml
import datetime
from timestream.manipulate.pipecomponents import PCExBrakeInPipeline
    ignored_timestamps = list(ts_set)
    print('ignored_timestamps = ', ignored_timestamps)

    # We put everything else that is not an time series into outputroot.
    ctx.setVal("outputroot", os.path.abspath(outputRootPath) + '-results')

    if not os.path.exists(ctx.outputroot):
        os.mkdir(ctx.outputroot)

    # Dictionary where we put all values that should be added with an image as soon
    # as it is output with the TimeStream
    ctx.setVal("outputwithimage", {})

    # initialise processing pipeline
    pl = pipeline.ImagePipeline(plConf.pipeline, ctx)

#    for img in ts.iter_by_files():
    for img in ts.iter_by_files(ignored_timestamps):

        if len(img.pixels) == 0:
            print('Missing image at {}'.format(img.datetime))
            continue

        # Detach img from timestream. We don't need it!
        img.parent_timestream = None
        print("Process", img.path, '...'),
        print("Time stamp", img.datetime)
        ctx.setVal("origImg", img)
        try:
            result = pl.process(ctx, [img], visualise)

# Path: timestream/manipulate/pipecomponents.py
# LOG = logging.getLogger("timestreamlib")
#             TLC = self.backgroundWindow[0:2]
#             BRC = self.backgroundWindow[2:]
#             W = 2.0*np.tan(self.fieldOfView[0]/2.0/180.0*np.pi)
#             H = 2.0*np.tan(self.fieldOfView[1]/2.0/180.0*np.pi)
#             H, T = os.path.split(fpath)
# class PipeComponent (object):
# class ImageMarginAdder(PipeComponent):
# class ImageUndistorter (PipeComponent):
# class ColorCardDetector (PipeComponent):
# class ImageColorCorrector (PipeComponent):
# class TrayDetector (PipeComponent):
# class PotDetector (PipeComponent):
# class PotDetectorGlassHouse (PipeComponent):
# class PlantExtractor (PipeComponent):
# class FeatureExtractor (PipeComponent):
# class ResultingFeatureWriter(PipeComponent):
# class ResultingImageWriter (PipeComponent):
# class ResizeImage (PipeComponent):
# class DerandomizeTimeStreams (PipeComponent):
# class ResizeAndWriteImage (PipeComponent):
#     def __init__(self, *args, **kwargs):
#     def __call__(self, context, *args):
#     def __chkExcept__(self, context, *args):
#     def __exec__(self, context, *args):
#     def info(cls, _str=True):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def padlocal(self, vector, pad_width, iaxis, kwargs):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __call__(self, context, *args):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def segAllPots(self):
#     def show(self):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __chkExcept__(self, context, *args):
#     def _guessTimeStamp(self, img):
#     def _addErrStr(self, timestamp, filename):
#     def _recoverFromPrev(self, timestamp, featName):
#     def _initHeaders(self, fPath, ipm, potIds):
#     def _initPrevCsvIndex(self):
#     def _appendToAudit(self, ts, val):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def createCompoundImage(self, timestamp):
#     def getMidGrpImg(self, mid, potList, maxPotRect, numPotPerMidSize):
#     def refreshMids(self, timestamp=None):
#     def __init__(self, context, **kwargs):
#     def __exec__(self, context, *args):
#     def show(self):


# Path: scripts/tscli/pipelineGlasshouse.py
import csv
import glob
import docopt
import sys, os
import timestream
import logging
import timestream.manipulate.configuration as pipeconf
import timestream.manipulate.pipeline as pipeline
import yaml
import datetime
from timestream.manipulate.pipecomponents import PCExBrakeInPipeline

    ignored_timestamps = list(ts_set)
    print('ignored_timestamps = ', ignored_timestamps)

    # We put everything else that is not an time series into outputroot.
    ctx.setVal("outputroot", os.path.abspath(outputRootPath) + '-results')

    if not os.path.exists(ctx.outputroot):
        os.mkdir(ctx.outputroot)

    # Dictionary where we put all values that should be added with an image as soon
    # as it is output with the TimeStream
    ctx.setVal("outputwithimage", {})

    # initialise processing pipeline
    pl = pipeline.ImagePipeline(plConf.pipeline, ctx)

#    for img in ts.iter_by_files():
    for img in ts.iter_by_files(ignored_timestamps):

        if len(img.pixels) == 0:
            print('Missing image at {}'.format(img.datetime))
            continue

        # Detach img from timestream. We don't need it!
        img.parent_timestream = None
        print("Process", img.path, '...'),
        print("Time stamp", img.datetime)
        ctx.setVal("origImg", img)
        try:
            result = pl.process(ctx, [img], visualise)

        except PCExBrakeInPipeline as bip: