Example #1
0
    def handle(self, step, x, y, canvas):
        if step == 'Calibrate':
            self.calibrating = True
            if self.append_current_calibration:
                if not self.points:
                    self.points = []
                    canvas.new_calibration_item()
            else:
                canvas.new_calibration_item()
                self.points = []
            return dict(calibration_step='End Calibrate')
#            return 'End Calibrate', None, None, None, None, None

        elif step == 'End Calibrate':
            self.calibrating = False
            d = dict(calibration_step='Calibrate')
            if self.points:
                refpoints, points = zip(*self.points)

                scale, theta, (tx, ty), err = calculate_rigid_transform(refpoints,
                                                                   points)

                # set canvas calibration
                ca = canvas.calibration_item
                ca.cx, ca.cy = tx, ty
                ca.rotation = theta
                ca.scale = 1 / scale
                d.update(dict(cx=tx, cy=ty, rotation=theta, scale=1 / scale, error=err
                            ))
            return d
Example #2
0
    def _calculate_affine_transform(self, pts):
        rps, ps = zip(*pts)
        s, r, t = calculate_rigid_transform(rps, ps)
        self.A = AffineTransform()
        self.A.scale(s, s)
        self.A.rotate(r)
        self.A.translate(-t[0], -t[1])

        print self.A
Example #3
0
    def _calculate_affine_transform(self, pts):
        rps, ps = zip(*pts)
        s, r, t = calculate_rigid_transform(rps, ps)
        self.A = AffineTransform()
        self.A.scale(s, s)
        self.A.rotate(r)
        self.A.translate(-t[0], -t[1])

        print self.A
Example #4
0
    def handle(self, step, x, y, canvas):
        if step == 'Calibrate':
            self.calibrating = True
            if self.append_current_calibration:
                if not self.points:
                    self.points = []
                    canvas.new_calibration_item()
            else:
                canvas.new_calibration_item()
                self.points = []
            return dict(calibration_step='End Calibrate')
        # return 'End Calibrate', None, None, None, None, None

        elif step == 'End Calibrate':
            n = 0
            if self.points:
                n = len(self.points)

            if n < 3:
                d = None
                if self.confirmation_dialog(
                        'Need to enter at least 3 calibration points. Current NPoints: {}\n\n'
                        'Are you sure you want to End calibration'.format(n)):
                    self.calibrating = False
                    d = dict(calibration_step='Calibrate')
                return d

            d = dict(calibration_step='Calibrate')
            self.calibrating = False

            refpoints, points = zip(*self.points)

            scale, theta, (tx, ty), err = calculate_rigid_transform(
                refpoints, points)

            # set canvas calibration
            ca = canvas.calibration_item
            ca.cx, ca.cy = tx, ty
            ca.rotation = theta
            ca.scale = 1 / scale
            d.update(
                dict(cx=tx, cy=ty, rotation=theta, scale=1 / scale, error=err))
            return d
Example #5
0
    def handle(self, step, x, y, canvas):
        if step == 'Calibrate':
            self.calibrating = True
            if self.append_current_calibration:
                if not self.points:
                    self.points = []
                    canvas.new_calibration_item()
            else:
                canvas.new_calibration_item()
                self.points = []
            return dict(calibration_step='End Calibrate')
        # return 'End Calibrate', None, None, None, None, None

        elif step == 'End Calibrate':
            n = 0
            if self.points:
                n = len(self.points)

            if n < 3:
                d = None
                if self.confirmation_dialog('Need to enter at least 3 calibration points. Current NPoints: {}\n\n'
                                            'Are you sure you want to End calibration'.format(n)):
                    self.calibrating = False
                    d = dict(calibration_step='Calibrate')
                return d

            d = dict(calibration_step='Calibrate')
            self.calibrating = False

            refpoints, points = zip(*self.points)

            scale, theta, (tx, ty), err = calculate_rigid_transform(refpoints,
                                                                    points)

            # set canvas calibration
            ca = canvas.calibration_item
            ca.cx, ca.cy = tx, ty
            ca.rotation = theta
            ca.scale = 1 / scale
            d.update(dict(cx=tx, cy=ty, rotation=theta, scale=1 / scale, error=err
                          ))
            return d