示例#1
0
def run_calibration(args):
    calibration_info = {
        "model_name":
        args.model_name,
        "in_prototxt":
        './{}/deploy.prototxt'.format(args.model_name),
        "in_caffemodel":
        './{}/{}.caffemodel'.format(args.model_name, args.model_name),
        "iteration":
        100,
        "enable_memory_opt":
        args.memory_opt,
        "histogram_bin_num":
        2048,
        "math_lib_path":
        '../../calibration_tool/lib/calibration_math.so'
    }
    print(calibration_info)

    calib = Calibration(calibration_info)
    calib.calc_tables()
    calib.export_model('./{}/bmnet_{}_int8.caffemodel'.format(
        args.model_name, args.model_name))
    calib.export_calirabtion_pb2('./{}/bmnet_{}_calibration_table'.format(
        args.model_name, args.model_name))
示例#2
0
    def createKittiFormatedDataset(self, sampleCounter, configurations):
        # generate file name
        n_digits = len(str(sampleCounter))
        output_file_name = ""  # ex: 000000.txt
        for i in range(0, 6 - n_digits):
            output_file_name = output_file_name + "0"

        if len(output_file_name) is not 6:
            output_file_name = output_file_name + str(sampleCounter)

        # create the hierarchy of directories
        Path(self.kittiOutputSamplesDir).mkdir(parents=True, exist_ok=True)
        Path(self.kittiViewsDir).mkdir(parents=True, exist_ok=True)
        Path(self.kittiVelodyneDir).mkdir(parents=True, exist_ok=True)
        Path(self.kittiLabelsDir).mkdir(parents=True, exist_ok=True)
        Path(self.kittiCalibDir).mkdir(parents=True, exist_ok=True)

        # save image
        self.gtaSample.imageView.saveImage(self.gtaSample.imageView.kittiImage,
                                           self.kittiViewsDir,
                                           output_file_name + ".png")

        if configurations.includeIntensity[0]:
            # save point cloud - the full rotated point cloud
            saveKittiVelodyneFile(
                addIntensityToPointCloud(
                    self.gtaSample.pcData.list_rotated_raw_pc,
                    dummy_value=self.configurations.includeIntensity[1]),
                output_file_name + ".bin", self.kittiVelodyneDir)
        else:
            saveKittiVelodyneFile(self.gtaSample.pcData.list_rotated_raw_pc,
                                  output_file_name + ".bin",
                                  self.kittiVelodyneDir)

        # save calibration info
        calib = Calibration((self.gtaSample.imageView.kittiImage.shape[1],
                             self.gtaSample.imageView.kittiImage.shape[0]),
                            self.configurations.fov)
        calib.saveCalibrationFile(self.kittiCalibDir,
                                  output_file_name + ".txt")

        # labels info
        label = Labeling(self.gtaSample,
                         calib,
                         self.kittiLabelsDir,
                         output_file_name + ".txt",
                         configurations,
                         fv_only_entities=True)

        if label.isEmpty:
            self.isEmpty = True
            print("Gta Sample doesn't have entities! It will be ignored.")
            # remove sample with empty label file
            os.remove(self.kittiVelodyneDir + output_file_name + ".bin")
            os.remove(self.kittiViewsDir + output_file_name + ".png")
            os.remove(self.kittiCalibDir + output_file_name + ".txt")
示例#3
0
def main(machine):
    # Load calibration file
    calibration = Calibration()
    table = calibration.load_calibration_file(calibration_file)

    # Preparation:
    machine.connect()
    machine.home()

    # Movements:
    # --------------------------------------------------------------------------------------
    # Setup initial configuration
    setup_movements = [('A1', 'B4'), ('A8', 'B7'), ('H8', 'E6'), ('D1', 'D2')]
    for origin, destination in setup_movements:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Capture attacking piece
    out_point = chess_to_coord(
        'B0', table)  #[0], calibration.real_points['out_white'][1])
    pick_and_place(machine, chess_to_coord('B4', table), out_point)
    t.sleep(1)

    # Simple movements
    movement_list = [('B7', 'B4'), ('E6', 'D5'), ('H1', 'H5'), ('D5', 'D6'),
                     ('B4', 'B6'), ('D6', 'C7'), ('B6', 'F6'), ('C7', 'D7'),
                     ('H5', 'H7'), ('D7', 'D8'), ('F6', 'F8')]

    for origin, destination in movement_list:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # Restore initial position
    cleanup_movements = [('H7', 'H1'), ('D2', 'D1'), ('B0', 'A1'),
                         ('F8', 'F4'), ('D8', 'H8'), ('F4', 'A8')]
    for origin, destination in cleanup_movements:
        pick_and_place(machine, chess_to_coord(origin, table),
                       chess_to_coord(destination, table))
        t.sleep(5)
    machine.home()

    # End
    machine.home()

    try:
        cxy.save_to_file('chess.gcode')
    except AttributeError:
        pass
    machine.disconnect()
示例#4
0
    def __init__(self):

        self.cal = Calibration()
        self.last_integration_mjd_timestamp = None
        self.last_requested_freq_ghz = None
        self.zenith_opacity = None
        self.opacity_coeffs = None
        self.L_BAND_ZENITH_TAU = .008
        self.frequency_range = None
        self.time_range = None
        self.db_time_range = None
        self.log = None
    def __init__(self):
        #self.__src = np.float32([[490, 482], [820, 482], [1280, 670], [20, 670]])
        #self.__dst = np.float32([[0, 0], [1280, 0], [1280, 720], [0, 720]])

        #self.__src = np.float32([[490, 482], [810, 482], [1250, 720], [0, 720]])
        #self.__dst = np.float32([[0, 0], [1280, 0], [1250, 720], [40, 720]])

        self.__src = np.float32([[190, 720], [589, 457], [698, 457],
                                 [1145, 720]])
        self.__dst = np.float32([[340, 720], [340, 0], [995, 0], [995, 720]])
        self.__mtx, self.__dist = Calibration().get_from_pickle()
        self.__wraped_binary_image = None
        self.M = None
        self.converseM = None
示例#6
0
    def parseMessage(self, client, message):
        """
        Check who is the message from to redirect it to User / Tag / Camera / Calibration
        or create a new instance of User / Tag / Camera / Calibration
        :param client:
        :param message:
        :return:
        """
        if self.cameras.has_key(str(client['address'])):
            #print "Message from Camera"
            self.cameras[str(client['address'])].push(message)

        elif self.users.has_key(str(client['address'])):
            print "Message from User"

        elif self.tags.has_key(str(client['address'])):
            print "Message from Tag"

        elif self.calibration.has_key(str(client['address'])):
            self.calibration[str(client['address'])].push(message)
            print "Message from Calibration"

        # This message is coming from an unknown client
        else:
            if message.split("-")[0] == "camera":
                self.cameras[str(client['address'])] = Camera(client, message.split("-")[1])
                # Add Observers linking every user to every camera's update
                for key in self.users:
                    if isinstance(self.users[key], User):
                        self.cameras[str(client['address'])].new2DPointNotifier.addObserver(self.users[key].position.newPoint2DObserver)
                        self.cameras[str(client['address'])].point2DdeletedNotifier.addObserver(self.users[key].position.point2DDeletedObserver)

            elif message.split("-")[0] == "tag":
                print "Hello TAG"
                # TODO

            elif message.split("-")[0] == "user":
                user = User(client, self.server, message.split("-")[1])
                self.users[str(client['address'])] = user
                # Add Observers linking every user to every camera's update
                for key in self.cameras:
                    if isinstance(self.cameras[key], Camera):
                        self.cameras[key].new2DPointNotifier.addObserver(user.position.newPoint2DObserver)
                        self.cameras[key].point2DdeletedNotifier.addObserver(user.position.point2DDeletedObserver)

            elif message == "calibration":
                self.calibration[str(client['address'])] = Calibration(self.cameras, self.server, client)
示例#7
0
    def setup(self):

        # load in the observation file for this object
        self.obs = Observation(self.filename)

        self.display = loupe()  #''mosasaurus',
        # xsize=self.obs.xsize*self.obs.displayscale,
        # ysize=self.obs.ysize*self.obs.displayscale)

        # create a night object, associated with this observation
        self.night = Night(self.obs)

        # set up the Calibration
        self.calib = Calibration(self)

        # create a mask
        self.mask = Mask(self)
示例#8
0
    def onLoadButtonClicked(self):
        calibration_filename = self.calibrationFileLineEdit.text()
        points_filename = self.pointsFileLineEdit.text()

        if calibration_filename and points_filename:
            # Ask the user for a file
            filename, ext = QtGui.QFileDialog.getOpenFileName(
                None, "Select SVG file", filter='*.svg')

            if filename:
                try:
                    # Load image data from calibration file
                    calibration = Calibration()
                    calibration.load_zipfile(calibration_filename)
                    self.loadImage(calibration)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(
                        self, 'Error', 'Calibration file not compatible!')
                    return False

                try:
                    # Load points data from points file
                    self.limits = Calibration.load_calibration_file(
                        points_filename)
                except Calibration.LoadException, e:
                    QtGui.QMessageBox().critical(
                        self, 'Error', 'Points file not compatible!')
                    return False

                try:
                    # Load data from files
                    self.trajectory.load_paths_from_svg(filename)

                    # Set trajectories on controls
                    trajectory_choices = [
                        "Trajectory #%d" % i
                        for i, path in enumerate(self.trajectory.paths)
                    ]
                    self.trajectoryComboBox.clear()
                    self.trajectoryComboBox.addItems(trajectory_choices)
                    self.setTrajectoryControlsEnabled(True)

                    self.update()
                except TrajectoryController.TrajectoryException, e:
                    pass
def run_calibration(arg):
    calibration_info = {
        "model_name": arg.model_name,
        "in_prototxt": os.path.join(arg.model_path, 'deploy_2x.prototxt'),
        "in_caffemodel": os.path.join(arg.model_path, 'espcn.caffemodel'),
        "iteration": 100,
        "enable_memory_opt": arg.memory_opt,
        "histogram_bin_num": 2048,
        "math_lib_path": "../../calibration_tool/build/calibration_math.so"
    }
    print(calibration_info)

    calib = Calibration(calibration_info)
    calib.calc_tables()
    calib.export_model(
        os.path.join(arg.model_path, 'bmnet_espcn_int8.caffemodel'))
    calib.export_calirabtion_pb2(
        os.path.join(arg.model_path, 'bmnet_espcn_calibration_table'))
    def __init__(self):
        self.stream_parent_conn, self.stream_child_conn = mp.Pipe()

        model_path = '../data/faster_rcnn_inception_v2_coco_2018_01_28/frozen_inference_graph.pb'
        self.odapi = DetectorAPI(path_to_ckpt=model_path)

        self.cal = Calibration()
        self.comm = Comm()

        self.stream = Stream(self.stream_child_conn)
        self.str = mp.Process(target=self.stream.run, args=())
        self.eat = None
        self.socket_update  = None

        self.frame_lock = mp.RLock()

        self.coords_lock = mp.RLock()

        self.coords = []
示例#11
0
    def getReferenceIntegration(self, cal_on, cal_off, scale):

        cal = Calibration()
        cal_ondata = cal_on['DATA']
        cal_offdata = cal_off['DATA']
        cref, exposure = cal.total_power(cal_ondata, cal_offdata,
                                         cal_on['EXPOSURE'],
                                         cal_off['EXPOSURE'])

        tcal = cal_off['TCAL'] * scale
        tsys = cal.tsys(tcal, cal_ondata, cal_offdata)

        dateobs = cal_off['DATE-OBS']
        timestamp = self.pu.dateToMjd(dateobs)

        tambient = cal_off['TAMBIENT']
        elevation = cal_off['ELEVATIO']

        return cref, tsys, exposure, timestamp, tambient, elevation
示例#12
0
def run_calibration(in_proto,
                    in_caffemodel,
                    out_table,
                    out_caffemodel,
                    thresholds=None):
    calibration_info = {
        "model_name": 'tune',
        "in_prototxt": in_proto,
        "in_caffemodel": in_caffemodel,
        "out_prototxt": './deploy_out.prototxt',
        "iteration": 1,
        "enable_memory_opt": 0,
        "math_lib_path": '../../calibration_tool/lib/calibration_math.so'
    }
    print(calibration_info)

    calib = Calibration(calibration_info)
    calib.tune_tables(thresholds)
    calib.export_model(out_caffemodel)
    calib.export_calirabtion_pb2(out_table)
示例#13
0
def run_calibration(args):
    calibration_info = {
        "model_name": args.model_name,
        "in_prototxt": os.path.join(args.model_path, 'deploy.prototxt'),
        "in_caffemodel": os.path.join(args.model_path, 'custom.caffemodel'),
        "iteration": 100,
        "enable_memory_opt": args.memory_opt,
        "enable_calibration_opt": 1,
        "histogram_bin_num": 204800,
        "math_lib_path": './lib/calibration_math.so',
        "enable_concat_quantize": 0
    }
    print(calibration_info)

    calib = Calibration(calibration_info)
    calib.calc_tables()
    calib.export_model('{}/bmnet_{}_int8.caffemodel'.format(
        args.model_path, args.model_name))
    calib.export_calirabtion_pb2('{}/bmnet_{}_calibration_table'.format(
        args.model_path, args.model_name))
示例#14
0
文件: LDSS3C.py 项目: zkbt/mosasaurus
def reduce(filename='wasp94_140801.obs'):
    # generate an observation object
    obs = Observation(filename)
    # load the headers for this observation
    obs.loadHeaders()
    # create a night object, associated with this observation
    night = Night(obs)
    # create an observing log from all the image headers from this night
    night.obsLog()

    # set up the calibration
    calib = Calibration(obs)

    # loop through the CCD's needed for this observation, and make sure they are stitched
    #for n in obs.nNeeded:
    #		ccd = CCD(obs,n=n,calib=calib)
    #	ccd.createStitched(visualize=True)

    mask = Mask(calib)
    for a in mask.apertures:
        a.displayStamps(a.images)
        a.extractAll(remake=True)
    def start(self):
        # Ask the user for a file
        filename, ext = QtGui.QFileDialog.getOpenFileName(
            None, "Select calibration file", filter='*.zip')

        if filename:
            # Try to open the calibration file
            try:
                self.calibration = Calibration()
                self.calibration.load_zipfile(filename)
                self.calibration.start()
                self.loadImage()
                self.update()
                self.show()
                return True
            except Calibration.LoadException:
                QtGui.QMessageBox().critical(self, 'Error',
                                             'File not compatible!')
                return False
            # except Exception, e:
            #     QtGui.QMessageBox().critical(self, 'Error', str(e))
            #     return False
        else:
            return False
示例#16
0
class SeekThermal:
    __dev = None
    __rcvmsg = None
    __calib = Calibration()

    def __init__(self):
        self.__dev = usb.core.find(idVendor=0x289d, idProduct=0x0010)
        if None == self.__dev:
            raise ValueError('Device not found')

        # set the active configuration. With no arguments, the first configuration will be the active one
        self.__dev.set_configuration()

        # alias method to make code easier to read
        self.__rcvmsg = self.__dev.ctrl_transfer

        # get an endpoint instance
        cfg = self.__dev.get_active_configuration()
        intf = cfg[(0, 0)]

        custom_match = lambda e: usb.util.endpoint_direction(
            e.bEndpointAddress) == usb.util.ENDPOINT_OUT
        ep = usb.util.find_descriptor(
            intf, custom_match=custom_match)  # match the first OUT endpoint
        assert ep is not None

        self.__setup()

    def __del__(self):
        for i in range(3):
            self.__send(0x41, 0x3C, 0, 0, '\x00\x00')

    def __send(self,
               bmRequestType,
               bRequest,
               wValue=0,
               wIndex=0,
               data_or_wLength=None,
               timeout=None):
        assert (self.__dev.ctrl_transfer(bmRequestType, bRequest, wValue,
                                         wIndex, data_or_wLength,
                                         timeout) == len(data_or_wLength))

    def __setup(self, ini=False):
        if True == ini:
            for i in range(3):
                self.__send(0x41, 0x3C, 0, 0, '\x00\x00')

        try:
            msg = '\x01'
            self.__send(0x41, 0x54, 0, 0, msg)
        except Exception as e:
            for i in range(3):
                self.__send(0x41, 0x3C, 0, 0, '\x00\x00')
            self.__send(0x41, 0x54, 0, 0, '\x01')

        #  Some day we will figure out what all this init stuff is and
        #  what the returned values mean.
        self.__send(0x41, 0x3C, 0, 0, '\x00\x00')
        ret = self.__rcvmsg(0xC1, 0x4E, 0, 0, 4)
        ret = self.__rcvmsg(0xC1, 0x36, 0, 0, 12)

        self.__send(0x41, 0x56, 0, 0, '\x20\x00\x30\x00\x00\x00')
        ret = self.__rcvmsg(0xC1, 0x58, 0, 0, 0x40)

        self.__send(0x41, 0x56, 0, 0, '\x20\x00\x50\x00\x00\x00')
        ret = self.__rcvmsg(0xC1, 0x58, 0, 0, 0x40)

        self.__send(0x41, 0x56, 0, 0, '\x0C\x00\x70\x00\x00\x00')
        ret = self.__rcvmsg(0xC1, 0x58, 0, 0, 0x18)

        self.__send(0x41, 0x56, 0, 0, '\x06\x00\x08\x00\x00\x00')
        ret = self.__rcvmsg(0xC1, 0x58, 0, 0, 0x0C)

        self.__send(0x41, 0x3E, 0, 0, '\x08\x00')
        ret = self.__rcvmsg(0xC1, 0x3D, 0, 0, 2)

        self.__send(0x41, 0x3E, 0, 0, '\x08\x00')
        self.__send(0x41, 0x3C, 0, 0, '\x01\x00')
        ret = self.__rcvmsg(0xC1, 0x3D, 0, 0, 2)

    def __getframe(self):
        while True:
            # Send read frame request
            self.__send(0x41, 0x53, 0, 0, '\xC0\x7E\x00\x00')
            try:
                dat = self.__dev.read(0x81, 0x3F60, 1000)
                dat += self.__dev.read(0x81, 0x3F60, 3000)
                dat += self.__dev.read(0x81, 0x3F60, 3000)
                dat += self.__dev.read(0x81, 0x3F60, 3000)
            except usb.USBError as e:
                # deinit
                self.__setup(True)
                return self.__getframe()

            tf = ThermalFrame(dat)
            # calibration
            ret = self.__calib.execute(tf)
            if False == ret:
                continue

            bmp = Image.new('RGB', (208, 156))
            idx = 0
            for hei in reversed(range(0, 156)):
                for wid in reversed(range(0, 208)):
                    r = self.__calib.bmpdat[idx * 3]
                    g = self.__calib.bmpdat[idx * 3 + 1]
                    b = self.__calib.bmpdat[idx * 3 + 2]
                    bmp.putpixel((wid, hei), (r, g, b))
                    idx += 1

            return bmp

    def getInfo(self):
        frm = self.__getframe()
        maxt = float(self.__calib.max_val - 5950) / 40  # C
        mint = float(self.__calib.min_val - 5950) / 40  # C

        return {'image': frm, 'temperature': {'max': maxt, 'min': mint}}
示例#17
0
import sys
libPathList = ['./lib/Python', './util']
for libPath in libPathList:
    sys.path.insert(0, libPath)
from SetMeUp import SetMeUp
from Calibration import Calibration

setupfile = 'setup.yaml'
calibrationfile = 'calib_params.tbl'

# create the setup instance
setup = SetMeUp(setupfile)
calib = Calibration(setupfile)

calib.AdjustCalibTable()
calib.df.to_csv("updated_calib_params.tbl")
示例#18
0
    def __init__(self):
        super().__init__()

        self.threadpool = QtCore.QThreadPool()
        print("Max thread count " + str(self.threadpool.maxThreadCount()))
        self.worker = SweepWorker(self)

        self.noSweeps = 1  # Number of sweeps to run

        self.serialLock = threading.Lock()
        self.serial = serial.Serial()

        self.dataLock = threading.Lock()
        self.data : List[Datapoint] = []
        self.data21 : List[Datapoint] = []
        self.referenceS11data : List[Datapoint] = []
        self.referenceS21data : List[Datapoint] = []

        self.calibration = Calibration()

        self.markers = []

        self.serialPort = self.getport()
        # self.serialSpeed = "115200"

        self.color = QtGui.QColor(160, 140, 20, 128)
        self.referenceColor = QtGui.QColor(0, 0, 255, 32)

        self.setWindowTitle("NanoVNA Saver")
        layout = QtWidgets.QGridLayout()
        scrollarea = QtWidgets.QScrollArea()
        outer = QtWidgets.QVBoxLayout()
        outer.addWidget(scrollarea)
        self.setLayout(outer)
        scrollarea.setWidgetResizable(True)
        self.resize(1150, 950)
        scrollarea.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
        self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
        widget = QtWidgets.QWidget()
        widget.setLayout(layout)
        scrollarea.setWidget(widget)

        self.s11SmithChart = SmithChart("S11")
        self.s21SmithChart = SmithChart("S21")
        self.s11LogMag = LogMagChart("S11 Return Loss")
        self.s21LogMag = LogMagChart("S21 Gain")

        self.charts : List[Chart] = []
        self.charts.append(self.s11SmithChart)
        self.charts.append(self.s21SmithChart)
        self.charts.append(self.s11LogMag)
        self.charts.append(self.s21LogMag)

        left_column = QtWidgets.QVBoxLayout()
        right_column = QtWidgets.QVBoxLayout()

        layout.addLayout(left_column, 0, 0)
        layout.addLayout(right_column, 0, 1)

        ################################################################################################################
        #  Sweep control
        ################################################################################################################

        sweep_control_box = QtWidgets.QGroupBox()
        sweep_control_box.setMaximumWidth(400)
        sweep_control_box.setTitle("Sweep control")
        sweep_control_layout = QtWidgets.QFormLayout(sweep_control_box)

        self.sweepStartInput = QtWidgets.QLineEdit("")
        self.sweepStartInput.setAlignment(QtCore.Qt.AlignRight)

        sweep_control_layout.addRow(QtWidgets.QLabel("Sweep start"), self.sweepStartInput)

        self.sweepEndInput = QtWidgets.QLineEdit("")
        self.sweepEndInput.setAlignment(QtCore.Qt.AlignRight)

        sweep_control_layout.addRow(QtWidgets.QLabel("Sweep end"), self.sweepEndInput)

        self.sweepCountInput = QtWidgets.QLineEdit("")
        self.sweepCountInput.setAlignment(QtCore.Qt.AlignRight)
        self.sweepCountInput.setText("1")

        sweep_control_layout.addRow(QtWidgets.QLabel("Sweep count"), self.sweepCountInput)

        self.btnColorPicker = QtWidgets.QPushButton("█")
        self.btnColorPicker.setFixedWidth(20)
        self.setSweepColor(self.color)
        self.btnColorPicker.clicked.connect(lambda: self.setSweepColor(QtWidgets.QColorDialog.getColor(self.color, options=QtWidgets.QColorDialog.ShowAlphaChannel)))

        sweep_control_layout.addRow("Sweep color", self.btnColorPicker)

        self.sweepProgressBar = QtWidgets.QProgressBar()
        self.sweepProgressBar.setMaximum(100)
        self.sweepProgressBar.setValue(0)
        sweep_control_layout.addRow(self.sweepProgressBar)

        self.btnSweep = QtWidgets.QPushButton("Sweep")
        self.btnSweep.clicked.connect(self.sweep)
        sweep_control_layout.addRow(self.btnSweep)

        left_column.addWidget(sweep_control_box)

        ################################################################################################################
        #  Marker control
        ################################################################################################################

        marker_control_box = QtWidgets.QGroupBox()
        marker_control_box.setTitle("Markers")
        marker_control_box.setMaximumWidth(400)
        marker_control_layout = QtWidgets.QFormLayout(marker_control_box)

        mouse_marker = Marker("Mouse marker", QtGui.QColor(20, 255, 20))
        mouse_marker.updated.connect(self.dataUpdated)
        self.markers.append(mouse_marker)

        marker1 = Marker("Marker 1", QtGui.QColor(255, 0, 20))
        marker1.updated.connect(self.dataUpdated)
        label, layout = marker1.getRow()
        marker_control_layout.addRow(label, layout)
        self.markers.append(marker1)

        marker2 = Marker("Marker 2", QtGui.QColor(20, 0, 255))
        marker2.updated.connect(self.dataUpdated)
        label, layout = marker2.getRow()
        marker_control_layout.addRow(label, layout)
        self.markers.append(marker2)

        self.s11SmithChart.setMarkers(self.markers)
        self.s21SmithChart.setMarkers(self.markers)

        self.mousemarkerlabel = QtWidgets.QLabel("")
        self.mousemarkerlabel.setMinimumWidth(160)
        marker_control_layout.addRow(QtWidgets.QLabel("Mouse marker:"), self.mousemarkerlabel)

        self.marker1label = QtWidgets.QLabel("")
        marker_control_layout.addRow(QtWidgets.QLabel("Marker 1:"), self.marker1label)

        self.marker2label = QtWidgets.QLabel("")
        marker_control_layout.addRow(QtWidgets.QLabel("Marker 2:"), self.marker2label)

        left_column.addWidget(marker_control_box)

        ################################################################################################################
        #  Statistics/analysis
        ################################################################################################################

        s11_control_box = QtWidgets.QGroupBox()
        s11_control_box.setTitle("S11")
        s11_control_layout = QtWidgets.QFormLayout()
        s11_control_box.setLayout(s11_control_layout)
        s11_control_box.setMaximumWidth(400)

        self.s11_min_swr_label = QtWidgets.QLabel()
        s11_control_layout.addRow("Min VSWR:", self.s11_min_swr_label)
        self.s11_min_rl_label = QtWidgets.QLabel()
        s11_control_layout.addRow("Return loss:", self.s11_min_rl_label)

        left_column.addWidget(s11_control_box)

        s21_control_box = QtWidgets.QGroupBox()
        s21_control_box.setTitle("S21")
        s21_control_layout = QtWidgets.QFormLayout()
        s21_control_box.setLayout(s21_control_layout)
        s21_control_box.setMaximumWidth(400)

        self.s21_min_gain_label = QtWidgets.QLabel()
        s21_control_layout.addRow("Min gain:", self.s21_min_gain_label)

        self.s21_max_gain_label = QtWidgets.QLabel()
        s21_control_layout.addRow("Max gain:", self.s21_max_gain_label)

        left_column.addWidget(s21_control_box)

        tdr_control_box = QtWidgets.QGroupBox()
        tdr_control_box.setTitle("TDR")
        tdr_control_layout = QtWidgets.QFormLayout()
        tdr_control_box.setLayout(tdr_control_layout)
        tdr_control_box.setMaximumWidth(400)

        self.tdr_velocity_dropdown = QtWidgets.QComboBox()
        self.tdr_velocity_dropdown.addItem("Jelly filled (0.64)", 0.64)
        self.tdr_velocity_dropdown.addItem("Polyethylene (0.66)", 0.66)
        self.tdr_velocity_dropdown.addItem("PTFE (Teflon) (0.70)", 0.70)
        self.tdr_velocity_dropdown.addItem("Pulp Insulation (0.72)", 0.72)
        self.tdr_velocity_dropdown.addItem("Foam or Cellular PE (0.78)", 0.78)
        self.tdr_velocity_dropdown.addItem("Semi-solid PE (SSPE) (0.84)", 0.84)
        self.tdr_velocity_dropdown.addItem("Air (Helical spacers) (0.94)", 0.94)
        self.tdr_velocity_dropdown.insertSeparator(7)
        self.tdr_velocity_dropdown.addItem("RG174 (0.66)", 0.66)
        self.tdr_velocity_dropdown.addItem("RG316 (0.69)", 0.69)
        self.tdr_velocity_dropdown.addItem("RG402 (0.695)", 0.695)
        self.tdr_velocity_dropdown.insertSeparator(11)
        self.tdr_velocity_dropdown.addItem("Custom", -1)

        self.tdr_velocity_dropdown.setCurrentIndex(1)  # Default to PE (0.66)

        self.tdr_velocity_dropdown.currentIndexChanged.connect(self.updateTDR)

        tdr_control_layout.addRow(self.tdr_velocity_dropdown)

        self.tdr_velocity_input = QtWidgets.QLineEdit()
        self.tdr_velocity_input.setDisabled(True)
        self.tdr_velocity_input.setText("0.66")
        self.tdr_velocity_input.textChanged.connect(self.updateTDR)

        tdr_control_layout.addRow("Velocity factor", self.tdr_velocity_input)

        self.tdr_result_label = QtWidgets.QLabel()
        tdr_control_layout.addRow("Estimated cable length:", self.tdr_result_label)

        left_column.addWidget(tdr_control_box)

        ################################################################################################################
        #  Calibration
        ################################################################################################################
        calibration_control_box = QtWidgets.QGroupBox("Calibration")
        calibration_control_box.setMaximumWidth(400)
        calibration_control_layout = QtWidgets.QFormLayout(calibration_control_box)
        b = QtWidgets.QPushButton("Calibration ...")
        self.calibrationWindow = CalibrationWindow(self)
        b.clicked.connect(self.calibrationWindow.show)
        calibration_control_layout.addRow(b)
        left_column.addWidget(calibration_control_box)

        ################################################################################################################
        #  Spacer
        ################################################################################################################

        left_column.addSpacerItem(QtWidgets.QSpacerItem(1, 1, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))

        ################################################################################################################
        #  Reference control
        ################################################################################################################

        reference_control_box = QtWidgets.QGroupBox()
        reference_control_box.setMaximumWidth(400)
        reference_control_box.setTitle("Reference sweep")
        reference_control_layout = QtWidgets.QFormLayout(reference_control_box)

        btnSetReference = QtWidgets.QPushButton("Set current as reference")
        btnSetReference.clicked.connect(self.setReference)
        self.btnResetReference = QtWidgets.QPushButton("Reset reference")
        self.btnResetReference.clicked.connect(self.resetReference)
        self.btnResetReference.setDisabled(True)
        self.btnReferenceColorPicker = QtWidgets.QPushButton("█")
        self.btnReferenceColorPicker.setFixedWidth(20)
        self.setReferenceColor(self.referenceColor)
        self.btnReferenceColorPicker.clicked.connect(lambda: self.setReferenceColor(
            QtWidgets.QColorDialog.getColor(self.referenceColor, options=QtWidgets.QColorDialog.ShowAlphaChannel)))

        set_reference_layout = QtWidgets.QHBoxLayout()
        set_reference_layout.addWidget(btnSetReference)
        set_reference_layout.addWidget(self.btnReferenceColorPicker)
        reference_control_layout.addRow(set_reference_layout)
        reference_control_layout.addRow(self.btnResetReference)

        left_column.addWidget(reference_control_box)

        ################################################################################################################
        #  Serial control
        ################################################################################################################

        serial_control_box = QtWidgets.QGroupBox()
        serial_control_box.setMaximumWidth(400)
        serial_control_box.setTitle("Serial port control")
        serial_control_layout = QtWidgets.QFormLayout(serial_control_box)
        self.serialPortInput = QtWidgets.QLineEdit(self.serialPort)
        self.serialPortInput.setAlignment(QtCore.Qt.AlignRight)
        # self.serialSpeedInput = QtWidgets.QLineEdit(str(self.serialSpeed))
        # self.serialSpeedInput.setValidator(QtGui.QIntValidator())
        # self.serialSpeedInput.setAlignment(QtCore.Qt.AlignRight)
        serial_control_layout.addRow(QtWidgets.QLabel("Serial port"), self.serialPortInput)
        # serial_control_layout.addRow(QtWidgets.QLabel("Speed"), self.serialSpeedInput)

        self.btnSerialToggle = QtWidgets.QPushButton("Open serial")
        self.btnSerialToggle.clicked.connect(self.serialButtonClick)
        serial_control_layout.addRow(self.btnSerialToggle)

        left_column.addWidget(serial_control_box)

        ################################################################################################################
        #  File control
        ################################################################################################################

        self.fileWindow = QtWidgets.QWidget()
        self.fileWindow.setWindowTitle("Files")
        file_window_layout = QtWidgets.QVBoxLayout()
        self.fileWindow.setLayout(file_window_layout)

        reference_file_control_box = QtWidgets.QGroupBox("Import file")
        reference_file_control_layout = QtWidgets.QFormLayout(reference_file_control_box)
        self.referenceFileNameInput = QtWidgets.QLineEdit("")
        btnReferenceFilePicker = QtWidgets.QPushButton("...")
        btnReferenceFilePicker.setMaximumWidth(25)
        btnReferenceFilePicker.clicked.connect(self.pickReferenceFile)
        referenceFileNameLayout = QtWidgets.QHBoxLayout()
        referenceFileNameLayout.addWidget(self.referenceFileNameInput)
        referenceFileNameLayout.addWidget(btnReferenceFilePicker)

        reference_file_control_layout.addRow(QtWidgets.QLabel("Filename"), referenceFileNameLayout)
        file_window_layout.addWidget(reference_file_control_box)

        btnLoadReference = QtWidgets.QPushButton("Load reference")
        btnLoadReference.clicked.connect(self.loadReferenceFile)
        btnLoadSweep = QtWidgets.QPushButton("Load as sweep")
        btnLoadSweep.clicked.connect(self.loadSweepFile)
        reference_file_control_layout.addRow(btnLoadReference)
        reference_file_control_layout.addRow(btnLoadSweep)

        file_control_box = QtWidgets.QGroupBox()
        file_control_box.setTitle("Export file")
        file_control_box.setMaximumWidth(400)
        file_control_layout = QtWidgets.QFormLayout(file_control_box)
        self.fileNameInput = QtWidgets.QLineEdit("")
        btnFilePicker = QtWidgets.QPushButton("...")
        btnFilePicker.setMaximumWidth(25)
        btnFilePicker.clicked.connect(self.pickFile)
        fileNameLayout = QtWidgets.QHBoxLayout()
        fileNameLayout.addWidget(self.fileNameInput)
        fileNameLayout.addWidget(btnFilePicker)

        file_control_layout.addRow(QtWidgets.QLabel("Filename"), fileNameLayout)

        self.btnExportFile = QtWidgets.QPushButton("Export data S1P")
        self.btnExportFile.clicked.connect(self.exportFileS1P)
        file_control_layout.addRow(self.btnExportFile)

        self.btnExportFile = QtWidgets.QPushButton("Export data S2P")
        self.btnExportFile.clicked.connect(self.exportFileS2P)
        file_control_layout.addRow(self.btnExportFile)

        file_window_layout.addWidget(file_control_box)

        file_control_box = QtWidgets.QGroupBox()
        file_control_box.setTitle("Files")
        file_control_box.setMaximumWidth(400)
        file_control_layout = QtWidgets.QFormLayout(file_control_box)
        btnOpenFileWindow = QtWidgets.QPushButton("Files ...")
        file_control_layout.addWidget(btnOpenFileWindow)
        btnOpenFileWindow.clicked.connect(lambda: self.fileWindow.show())

        left_column.addWidget(file_control_box)

        ################################################################################################################
        #  Right side
        ################################################################################################################

        self.lister = QtWidgets.QPlainTextEdit()
        self.lister.setFixedHeight(80)
        charts = QtWidgets.QGridLayout()
        charts.addWidget(self.s11SmithChart, 0, 0)
        charts.addWidget(self.s21SmithChart, 1, 0)
        charts.addWidget(self.s11LogMag, 0, 1)
        charts.addWidget(self.s21LogMag, 1, 1)

        self.s11LogMag.setMarkers(self.markers)
        self.s21LogMag.setMarkers(self.markers)

        right_column.addLayout(charts)
        right_column.addWidget(self.lister)

        self.worker.signals.updated.connect(self.dataUpdated)
        self.worker.signals.finished.connect(self.sweepFinished)
示例#19
0
from Calibration import Calibration


configDir = "../../config"
Ref_Calib_Back = configDir + "/BackReference0.032Corners_sorted.pickle" 
AP_Road_32 = "/media/sf_UbuntuWinShare/refRoad/AprilRoadRef.csv"
KabaschRotTransBack = configDir + "/KabaschRotTransRefRoadToRefBack32.pickle"
OutDoorTagID = 300  
noRotationFlag = 0

Calibration(AP_Road_32, Ref_Calib_Back, KabaschRotTransBack, OutDoorTagID, noRotationFlag)
# Paths
results_directory = './results'

calibration_src_images = './camera_cal'
calibration_dst_images = 'Calibration_results'

test_images_src = './test_images'
test_images_des = 'test_images_results'

test_vedios_src = './test_vedios'
test_vedios_des = './output_vedios'

# Calibration
logger_obj = Logger(str(results_directory))
calibration_obj = Calibration(calibration_src_images, calibration_dst_images,
                              (9, 6), logger_obj)
## Get calibration data
camera_matrix, distortion_coefficent = calibration_obj.get_calibration_parameters(
)

## Get Parameters
pipeline_params = Parameters(logger_obj, camera_matrix, distortion_coefficent)

# Get Pipeline object
Runner = Pipeline(pipeline_params)


def main():
    # Images
    Runner.process_test_images(test_images_src)
def main():
    args = get_args()
    Calibration(args.AP_BackHatCalib, args.Ref_Calib_Back,
                args.KabaschRotTransBack)
    plt.rc('ytick', labelsize=14)
    plt.rc('lines', lw=2)

    base_folder = '2016-07-26/'
    ambient_folder = base_folder + 'ambient/600um/'
    dark_folder = base_folder + 'dark/'
    agitated_folder = base_folder + 'single/600um/agitated/'
    unagitated_folder = base_folder + 'single/600um/unagitated/'
    ext = '.fit'

    nf = {}
    ff = {}

    nf['calibration'] = Calibration(
        [dark_folder + 'nf_dark_' + str(i).zfill(3) + ext for i in xrange(10)],
        None, [
            ambient_folder + 'nf_ambient_' + str(i).zfill(3) + '_0.1' + ext
            for i in xrange(10)
        ])
    print 'NF calibration initialized'
    ff['calibration'] = Calibration(
        [dark_folder + 'ff_dark_' + str(i).zfill(3) + ext for i in xrange(10)],
        None, [
            ambient_folder + 'ff_ambient_' + str(i).zfill(3) + '_0.1' + ext
            for i in xrange(10)
        ])
    print 'FF calibration initialized'

    empty_data = {'images': [], 'fft': [], 'freq': []}
    for test in ['agitated', 'unagitated', 'baseline']:
        nf[test] = deepcopy(empty_data)
        ff[test] = deepcopy(empty_data)
    REF_VIS = OutputsDir + OutputFolderName + "/visualize_frames_ref_32.csv"
    REF_ROAD = OutputsDir + OutputFolderName + "/road_normalized_ref.csv"

    # Output files
    OP_R2B = OutputsDir + OutputFolderName + "/road_proj_to_back.csv"
    OP_intialLabeling = OutputsDir + OutputFolderName + "/ContGazeIntialLabelsAllFrames_32_V4.csv"
    OP_VIS = VisualizeDir + "/meshsave_back_2.mat"
    OutDoorTagID = 300
    B_R_offset = 0  # sync Offset in frame number between the back and the road videos
    F_offset = 0
    noRotationFlag = 0  #1

    print(
        "Calculating the rotation and translation matrices for the back camera"
    )
    Calibration(AP_HAT_Calib_BACK, Ref_Calib_Back, KabaschRotTransBack,
                OutDoorTagID, noRotationFlag)

    print(
        "Calculating the rotation and translation matrices for the road camera"
    )
    Calibration(AP_Road_calib, Ref_Calib_Road, KabaschRotTransRoad,
                OutDoorTagID, noRotationFlag)

    print(
        "Standardizing visualize and converting coordinates back to AprilTag format"
    )
    standardize_visualizeT2(AP_HAT_Calib_BACK, OP_VIS, STD_VIS)

    print(
        "Standardizing AP_ROAD by considering only AprilTag marker frames and changing file schema"
    )
示例#24
0
 def setup(self):
     self.cal = Calibration()
示例#25
0
 def __init__(self, setup):
     # same as above ...
     super(self.__class__, self).__init__(setup)
     self.calib = Calibration(setup)  # this is maybe a bad idea
     logger.info(self.calib.df)
示例#26
0
    def parseMessage(self, client, message):
        """
        Check who is the message from to redirect it to User / Tag / Camera / Calibration
        or create a new instance of User / Tag / Camera / Calibration
        :param client:
        :param message:
        :return:
        """
        if self.cameras.has_key(str(client['address'])):
            #print "Message from Camera"
            self.cameras[str(client['address'])].push(message)
            # Update all cameras counters
            #Todo: Change this method for checking all cameras for lost point (auto check inside point2D ?)
            for key in self.cameras.keys():
                self.cameras[key].update()

        elif self.users.has_key(str(client['address'])):
            print "Message from User"

        elif self.tags.has_key(str(client['address'])):
            print "Message from Tag"

        elif self.calibration.has_key(str(client['address'])):
            self.calibration[str(client['address'])].push(message)
            print "Message from Calibration"

        # This message is coming from an unknown client
        else:
            if message.split("-")[0] == "camera":
                self.cameras[str(client['address'])] = Camera(
                    client,
                    message.split("-")[1])
                # Add Observers linking every user to every camera's update
                for key in self.users:
                    if isinstance(self.users[key], User):
                        self.cameras[str(
                            client['address'])].new2DPointNotifier.addObserver(
                                self.users[key].position.newPoint2DObserver)
                        self.cameras[str(
                            client['address']
                        )].point2DdeletedNotifier.addObserver(
                            self.users[key].position.point2DDeletedObserver)

            elif message.split("-")[0] == "tag":
                self.tags[str(client['address'])] = Tag(
                    self.server, client,
                    message.split("-")[1])
                for key in self.users:
                    if isinstance(self.users[key], User):
                        # Assign a Tag to User with no Tag
                        if self.users[key].tag == None:
                            self.users[key].setTag(self.tags[str(
                                client['address'])])

            elif message.split("-")[0] == "user":
                user = User(self.server, client, message.split("-")[1])
                self.users[str(client['address'])] = user
                # Add Observers linking every user to every camera's update
                for key in self.cameras:
                    if isinstance(self.cameras[key], Camera):
                        self.cameras[key].new2DPointNotifier.addObserver(
                            user.position.newPoint2DObserver)
                        self.cameras[key].point2DdeletedNotifier.addObserver(
                            user.position.point2DDeletedObserver)

                for key in self.tags:
                    if isinstance(self.tags[key], Tag):
                        # Assign a Tag to new User
                        if self.tags[key].isAssigned() == False:
                            user.setTag(self.tags[key])

            elif message == "calibration":
                if (len(self.tags) > 0):
                    self.calibration[str(client['address'])] = Calibration(
                        self.server, client, self.cameras,
                        self.tags.values()[0])
                else:
                    self.server.send_message(
                        client,
                        "Please connect a Tag first, and start Calibration again."
                    )