コード例 #1
0
    def _action(self, context):
        lane = context.get(self.lane_input)
        if lane is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.lane_input))
        img = context.get(self.img_input)
        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.img_input))

        curv = lane.get_curv()

        offset = lane.get_offset()

        img_ar = img.copy()

        h = img_ar.shape[0]
        font = cv2.FONT_HERSHEY_DUPLEX
        text = 'Curve radius: {:4.0f}m'.format(np.absolute(curv))
        cv2.putText(img_ar, text, (40, 70), font, 1.5, (200, 255, 155), 2,
                    cv2.LINE_AA)

        offset_dir = 'right' if offset > 0 else 'left'
        text = '{:04.2f}m {} of center'.format(np.absolute(offset), offset_dir)
        cv2.putText(img_ar, text, (40, 120), font, 1.5, (200, 255, 155), 2,
                    cv2.LINE_AA)

        context[self.output] = img_ar
        return img_ar
コード例 #2
0
    def _action(self, context):
        img1 = context.get(self.input1)
        if img1 is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input1))
        img2 = context.get(self.input2)
        if img2 is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input2))

        out_img = cv2.addWeighted(img1, 1, img2, self.alpha, 0)

        context[self.output] = out_img
        return out_img
コード例 #3
0
 def _action(self, context):
     img = context.get(self.input)
     if img is None:
         raise exceptions.PipeException(
             "missing context parameter: {}".format(self.input))
     img_cvt = cv2.cvtColor(img, self.mode)
     context[self.output] = img_cvt
     return img_cvt
コード例 #4
0
 def _action(self, context):
     img = context.get(self.input)
     if img is None:
         raise exceptions.PipeException(
             "missing context parameter: {}".format(self.input))
     img_cal = calibration.undistort(img, self.mtx, self.dist)
     context[self.output] = img_cal
     return img_cal
コード例 #5
0
    def _action(self, context):
        lane = context.get(self.input)
        if lane is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))

        if self.mode == 'fit':
            vis_img = lane.plot_fitted_lane()
        elif self.mode == 'area':
            vis_img = lane.draw_lane()
        else:
            raise exceptions.PipeException(
                "unsupported mode argument in DrawLaneNode: {}".format(
                    self.mode))

        context[self.output] = vis_img

        return vis_img
コード例 #6
0
    def _action(self, context):
        img = context.get(self.input)
        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))
        cut = transform.cut_roi(img, self.roi_pts)
        context[self.output] = cut

        return cut
コード例 #7
0
    def _action(self, context):
        img = context.get(self.input)
        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))
        img_thresh = transform.combined_threshold(img)
        context[self.output] = img_thresh

        return img_thresh
コード例 #8
0
    def _action(self, context):
        img = context.get(self.input)
        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))
        img = img.copy()
        pts = np.array(self.roi_pts, dtype=np.int32).reshape((-1, 1, 2))
        cv2.polylines(img, [pts], True, (0, 0, 255), 2)
        context[self.output] = img

        return img
コード例 #9
0
    def _action(self, context):
        img = context.get(self.input)
        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))

        img_thresh = np.zeros_like(img, dtype=np.uint8)
        img_thresh[img > self.thresh] = 1

        context[self.output] = img_thresh
        return img_thresh
コード例 #10
0
    def _action(self, context):
        binary_img = context.get(self.input)
        if binary_img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))

        prior_lane = context.get(
            self.prior_lane_input
        ) if self.prior_lane_input is not None else None

        lane = detect.detect_llines(binary_img, prior_lane)

        context[self.output] = lane

        return lane
コード例 #11
0
    def _action(self, context):
        img = context.get(self.input)

        if self.dtype is not None:
            img = img.astype(self.dtype)

        if img is None:
            raise exceptions.PipeException(
                "missing context parameter: {}".format(self.input))
        if not self.inv:
            warped = transform.warpPerspective(img, self.M)
        else:
            warped = transform.warpPerspective(img, self.Minv)

        context[self.output] = warped

        return warped