Beispiel #1
0
def drawCoreCircle(img):
    SET = SETTING()
    corecore = SET.get("corepoint", (1296, 972))
    core = [corecore, 1]
    # print "corecorex, corecorey", corecorex, corecorey
    minRange, maxRange = SET.get("coreRange")
    # cv2.circle(img, (int(core[0][0]), int(core[0][1])), int(maxRange), (255, 255, 255), 4)
    cv2.circle(img, (int(core[0][0]), int(core[0][1])), int(minRange),
               (0, 0, 0), 4)
    x0, y0 = corecore
    x1, y1 = x0 + minRange, y0
    x2, y2 = x0 + maxRange, y0
    cv2.line(img, (x1, y1), (x2, y2), (255, 0, 0), 4)
    x1, y1 = x0, y0 + minRange
    x2, y2 = x0, y0 + maxRange
    cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 4)
    x1, y1 = x0 - minRange, y0
    x2, y2 = x0 - maxRange, y0
    cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 4)
    x1, y1 = x0, y0 - minRange
    x2, y2 = x0, y0 - maxRange
    cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 4)
    if SET.get("draw_clad", False):
        minRange, maxRange = SET.get("cladRange")
        cv2.circle(img, (int(core[0][0]), int(core[0][1])), int(maxRange),
                   (0, 0, 0), 4)
        cv2.circle(img, (int(core[0][0]), int(core[0][1])), int(minRange),
                   (255, 255, 255), 4)
    return img
Beispiel #2
0
def test_updatekeys():
    s = SETTING()
    s.keyUpdates('20/400')
    assert s.get('fiberType') == "20/400"
    s.keyUpdates('octagon')
    assert s.get('fiberType') == "octagon"
    s.keyUpdates('G652')
    assert s.get('fiberType') == "G652"
Beispiel #3
0
def test_other_set():
    s = SETTING('G652')
    print s.store
    assert 'G652' == s.get('fiberType')
    s = SETTING('octagon')
    print s.store
    print 'singleton2', id(s)
    assert 'octagon' != s.get('fiberType')
Beispiel #4
0
def test_updateSets_args():
    s = SETTING("Default")
    s.updates()
    assert "set" not in s.keys()
    assert "testsetdict" not in s.keys()
    s.updates("set", {"testsetdict": "dict"})
    assert s.get("testset") == ".json"
    assert s.get("testsetdict") == "dict"
Beispiel #5
0
class MetaClassify(CV2MethodSet):
    """docstring for MetaClassify"""
    def __init__(self, ):
        super(MetaClassify, self).__init__()
        # self.arg = arg
        self.result = {}
        self.SET = SETTING()
        self.ampRatio = self.SET.get("ampPixSize", 1)
        self.medianlimitFilterCore = MedianFilter()
        self.medianlimitFilterClad = MedianFilter()

    # @timing
    def find(self, img):
        contours, hierarchys = cv2.findContours(img, cv2.RETR_TREE,
                                                cv2.CHAIN_APPROX_NONE)
        self._filter(contours, hierarchys)
        return self.result

    def _filter(self, contours, hierarchys):
        pass

    def getResult(self):
        coreResult = self.result.get('coreResult', False)
        cladResult = self.result.get('cladResult', False)
        if coreResult and cladResult:
            coreCore = coreResult["corePoint"].tolist()[0]
            cladCore = cladResult["corePoint"].tolist()[0]
            coreRadius = (coreResult["longAxisLen"] +
                          coreResult["shortAxisLen"]) / 2
            cladRadius = (cladResult["longAxisLen"] +
                          cladResult["shortAxisLen"]) / 2
            concentricity = ((coreCore[0] - cladCore[0])**2 +
                             (coreCore[1] - cladCore[1])**2)**0.5
            concentricity = concentricity * self.ampRatio
            coreMidRadius = self.ampRatio * coreRadius
            # self.medianlimitFilterCore.append(coreMidRadius)
            # coreMidRadius = self.medianlimitFilterCore.get()
            cladMidRadius = self.ampRatio * cladRadius
            # cladMidRadius = self.medianlimitFilterClad.append(cladMidRadius)
            # cladMidRadius = self.medianlimitFilterClad.get()
            # cladMidRadius = (cladRadius[0] + cladRadius[1])
            coreRness = self.ampRatio * abs(coreResult["longAxisLen"] -
                                            coreResult["shortAxisLen"])
            cladRness = self.ampRatio * abs(cladResult["longAxisLen"] -
                                            cladResult["shortAxisLen"])
            return (concentricity, coreMidRadius, cladMidRadius, coreRness,
                    cladRness)
        else:
            print 'error find core or clad'
            return ()
Beispiel #6
0
import time
from threading import Thread

from PyQt4.QtCore import QObject, pyqtSignal

from setting.orderset import SETTING

Set = SETTING()
setGet = Set.get('ifcamera', False)
from SDK.oceanoptics import OceanOpticsTest
from util.toolkit import Cv2ImShow, Cv2ImSave


class ModelOp(Thread, QObject):
    """docstring for Model"""
    returnImg = pyqtSignal(object, object)

    def __init__(self, ):
        Thread.__init__(self)
        QObject.__init__(self)
        super(ModelOp, self).__init__()
        self.setDaemon(True)
        self.show = Cv2ImShow()
        self.save = Cv2ImSave()
        self.oceanoptics = OceanOpticsTest()

    def run(self):
        while True:
            wave, powers = self.oceanoptics.getData(25)
            time.sleep(0.5)
            self.returnImg.emit(wave, powers)
Beispiel #7
0
def test_updateSets_kwargs():
    s = SETTING("Default")
    assert 'testkwargs' not in s.keys()
    s.updates(testkwargs='get')
    assert s.get('testkwargs') == 'get'
Beispiel #8
0
def test_get_new_value():
    s = SETTING("printline")
    s["newkey"] = True
    assert s.get("newkey")
Beispiel #9
0
#coding:utf-8
import collections
import time
from threading import Thread
import cv2
import copy
import numpy as np
from PyQt4.QtCore import QObject, pyqtSignal
from .datahand import session_add, ResultSheet
from setting.orderset import SETTING
from pattern.exception import ClassCoreError, ClassOctagonError

Set = SETTING('octagon')
setGet = Set.get('ifcamera', False)
fiberType = Set.get('fiberType', "G652")
print 'fibertype', fiberType, 'setget', setGet
if setGet:
    from SDK.mdpy import GetRawImg
else:
    #from SDK.mdpytest import DynamicGetRawImgTest as GetRawImg
    # from  SDK.mdpy import GetRawImgTest as GetRawImg
    #当摄像头关闭时,图像从文件夹读取
    from imgserver.model import DynamicGetRawImgTest as GetRawImg
    print 'script don\'t open camera'

from pattern.edge import ExtractEdge
from report import pdf
from pattern.classify import classifyObject

from pattern.sharp import IsSharp
from pattern.draw import DecorateImg, drawCoreCircle, decorateMethod