def declare_io(self, p, i, o):
        self.gray_image = ecto.Passthrough('gray Input')
        self.rgb_image = ecto.Passthrough('rgb Input')
        self.camera_info = ecto.Passthrough('K')
        self.gather = calib.GatherPoints("gather", N=2)
        #TODO parameterize the quantizer
        #abuse saturated Arithmetics http://opencv.itseez.com/modules/core/doc/intro.html?highlight=saturated.
        self.quantizer = imgproc.Quantize('Quantizer', alpha=1, beta=0)
        self.invert = imgproc.BitwiseNot()
        self.debug = p.debug
        offset_x = -.3095  #TODO: FIXME hard coded
        offset_y = -.1005
        self.cd_bw = calib.PatternDetector(
            'Dot Detector, B/W',
            rows=p.rows,
            cols=p.cols,
            pattern_type=p.pattern_type,
            square_size=p.square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        offset_x = .1505  #TODO: FIXME hard coded
        self.cd_wb = calib.PatternDetector(
            'Dot Detector, W/B',
            rows=p.rows,
            cols=p.cols,
            pattern_type=p.pattern_type,
            square_size=p.square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        self.pose_calc = calib.FiducialPoseFinder('Pose Calc')
        self.circle_drawer = calib.PatternDrawer('Circle Draw',
                                                 rows=p.rows,
                                                 cols=p.cols)
        self.circle_drawer2 = calib.PatternDrawer('Circle Draw',
                                                  rows=p.rows,
                                                  cols=p.cols)
        self.pose_draw = calib.PoseDrawer('Pose Draw')
        self.fps = highgui.FPSDrawer()

        #inputs
        i.declare('image', self.gray_image.inputs.at('in'))
        i.declare('color_image', self.rgb_image.inputs.at('in'))
        i.declare('K', self.camera_info.inputs.at('in'))

        #outputs
        o.declare('R', self.pose_calc.outputs.at('R'))
        o.declare('T', self.pose_calc.outputs.at('T'))
        o.declare('found', self.gather.outputs.at('found'))
        o.declare('debug_image', self.fps.outputs.at('image'))
Пример #2
0
 def __init__(self,
              plasm,
              rows,
              cols,
              pattern_type,
              square_size,
              debug=True):
     ecto.BlackBox.__init__(self, plasm)
     self.video_cap = ecto.Passthrough('Image Input')
     self.rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)
     self.circle_detector = calib.PatternDetector('Dot Detector',
                                                  rows=rows,
                                                  cols=cols,
                                                  pattern_type=pattern_type,
                                                  square_size=square_size)
     self.pose_calc = calib.FiducialPoseFinder('Pose Calc')
     self.camera_info = calib.CameraIntrinsics('Camera Info',
                                               camera_file="camera.yml")
     self.debug = debug
     if self.debug:
         self.fps = highgui.FPSDrawer()
         self.circle_drawer = calib.PatternDrawer('Circle Draw',
                                                  rows=rows,
                                                  cols=cols)
         self.circle_display = highgui.imshow('Pattern show',
                                              name='Pattern',
                                              waitKey=2,
                                              autoSize=True)
         self.pose_draw = calib.PoseDrawer('Pose Draw')
Пример #3
0
def calibration(rows, cols, square_size, pattern_type, n_obs, video):
    plasm = ecto.Plasm()
    pattern_show = highgui.imshow(name="pattern", waitKey=10, autoSize=True)
    rgb2gray = imgproc.cvtColor(flag=7)
    circle_detector = calib.PatternDetector(rows=rows,
                                            cols=cols,
                                            pattern_type=pattern_type,
                                            square_size=square_size)
    ecto.print_module_doc(circle_detector)
    circle_drawer = calib.PatternDrawer(rows=rows, cols=cols)
    camera_calibrator = calib.CameraCalibrator(output_file_name="camera.yml",
                                               n_obs=n_obs)

    plasm.connect(video, "image", rgb2gray, "input")
    plasm.connect(rgb2gray, "out", circle_detector, "input")
    plasm.connect(video, "image", circle_drawer, "input")
    plasm.connect(video, "image", camera_calibrator, "image")
    plasm.connect(circle_detector, "out", circle_drawer, "points")
    plasm.connect(circle_detector, "found", circle_drawer, "found")
    plasm.connect(circle_drawer, "out", pattern_show, "input")
    plasm.connect(circle_detector, "ideal", camera_calibrator, "ideal")
    plasm.connect(circle_detector, "out", camera_calibrator, "points")
    plasm.connect(circle_detector, "found", camera_calibrator, "found")

    print plasm.viz()
    ecto.view_plasm(plasm)

    while (pattern_show.outputs.out != 27
           and camera_calibrator.outputs.calibrated == False):
        plasm.execute(1)
    def __init__(self,
                 plasm,
                 rows,
                 cols,
                 pattern_type,
                 square_size,
                 offset_x=0,
                 offset_y=0,
                 offset_z=0,
                 debug=True):
        ecto.BlackBox.__init__(self, plasm)
        self.video_cap = ecto.Passthrough('Image Input')
        self.camera_info = ecto.Passthrough('K')

        self.circle_detector = calib.PatternDetector('Dot Detector',
                                                     rows=rows,
                                                     cols=cols,
                                                     pattern_type=pattern_type,
                                                     square_size=square_size,
                                                     offset_x=offset_x,
                                                     offset_y=offset_y,
                                                     offset_z=offset_z)
        self.pose_calc = calib.FiducialPoseFinder('Pose Calc')
        self.debug = debug
        self.circle_drawer = calib.PatternDrawer('Circle Draw',
                                                 rows=rows,
                                                 cols=cols)
        self.pose_draw = calib.PoseDrawer('Pose Draw')
Пример #5
0
    def declare_cells(p):
        #TODO parameterize the quantizer
        #abuse saturated Arithmetics http://opencv.itseez.com/modules/core/doc/intro.html?highlight=saturated.
        cells = {
            'gray_image': ecto.Passthrough('gray Input'),
            'rgb_image': ecto.Passthrough('rgb Input'),
            'camera_info': ecto.Passthrough('K_image'),
            'gather': calib.GatherPoints("gather", N=2),
            'quantizer': imgproc.Quantize('Quantizer', alpha=1, beta=0),
            'invert': imgproc.BitwiseNot()
        }

        offset_x = -.3095  #TODO: FIXME hard coded
        offset_y = -.1005
        cells['cd_bw'] = calib.PatternDetector(
            'Dot Detector, B/W',
            rows=p.rows,
            cols=p.cols,
            pattern_type=p.pattern_type,
            square_size=p.square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        offset_x = .1505  #TODO: FIXME hard coded
        cells['cd_wb'] = calib.PatternDetector(
            'Dot Detector, W/B',
            rows=p.rows,
            cols=p.cols,
            pattern_type=p.pattern_type,
            square_size=p.square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        cells['pose_calc'] = calib.FiducialPoseFinder('Pose Calc')
        cells['circle_drawer'] = calib.PatternDrawer('Circle Draw',
                                                     rows=p.rows,
                                                     cols=p.cols)
        cells['circle_drawer2'] = calib.PatternDrawer('Circle Draw',
                                                      rows=p.rows,
                                                      cols=p.cols)
        cells['fps'] = highgui.FPSDrawer()

        return cells
    def __init__(self,
                 plasm,
                 rows,
                 cols,
                 pattern_type,
                 square_size,
                 debug=True):
        ecto.BlackBox.__init__(self, plasm)
        self.gray_image = ecto.Passthrough('gray Input')
        self.rgb_image = ecto.Passthrough('rgb Input')
        self.camera_info = ecto.Passthrough('K')

        self.gather = calib.GatherPoints("gather", N=2)
        self.invert = imgproc.BitwiseNot()
        offset_x = -.310
        offset_y = -.101099
        self.cd_bw = calib.PatternDetector(
            'Dot Detector, B/W',
            rows=rows,
            cols=cols,
            pattern_type=pattern_type,
            square_size=square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        offset_x = .150
        self.cd_wb = calib.PatternDetector(
            'Dot Detector, W/B',
            rows=rows,
            cols=cols,
            pattern_type=pattern_type,
            square_size=square_size,
            offset_x=offset_x,
            offset_y=offset_y,
        )
        self.pose_calc = calib.FiducialPoseFinder('Pose Calc')
        self.circle_drawer = calib.PatternDrawer('Circle Draw',
                                                 rows=rows,
                                                 cols=cols)
        self.pose_draw = calib.PoseDrawer('Pose Draw')
Пример #7
0
 def __init__(self, plasm):
     ecto.BlackBox.__init__(self, plasm)
     self.video_cap = highgui.VideoCapture(video_device=0)
     self.fps = highgui.FPSDrawer()
     self.rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)
     self.circle_detector = calib.PatternDetector('Dot Detector',
                                             rows=7, cols=3, pattern_type="acircles",
                                             square_size=0.03)
     self.circle_drawer = calib.PatternDrawer('Circle Draw',
                                         rows=7, cols=3)
     self.circle_display = highgui.imshow('Pattern show',
                                     name='Pattern', waitKey=2, maximize=True)
     self.pose_calc = calib.FiducialPoseFinder('Pose Calc')
     self.pose_draw = calib.PoseDrawer('Pose Draw')
     self.camera_info = calib.CameraIntrinsics('Camera Info', camera_file="camera.yml")
Пример #8
0
#!/usr/bin/env python
# add pose estimation
import ecto
from ecto_opencv import highgui, calib, imgproc

plasm = ecto.Plasm()
sched = ecto.schedulers.Singlethreaded(plasm)

video_cap = highgui.VideoCapture(video_device=0)

fps = highgui.FPSDrawer()

rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)

circle_detector = calib.PatternDetector(rows=7,
                                        cols=3,
                                        pattern_type="acircles",
                                        square_size=0.03)
circle_drawer = calib.PatternDrawer(rows=7, cols=3)
circle_display = highgui.imshow('Pattern show',
                                name='Pattern',
                                waitKey=2,
                                maximize=True)

pose_calc = calib.FiducialPoseFinder('Pose Calc')

pose_draw = calib.PoseDrawer('Pose Draw')

camera_info = calib.CameraIntrinsics('Camera Info', camera_file="camera.yml")

plasm.connect(
    video_cap['image'] >> circle_drawer['input'],
Пример #9
0
#!/bin/python
import ecto
#import ecto_opencv.cv_bp as opencv
from ecto_opencv import highgui, calib, imgproc

debug = True

plasm = ecto.Plasm()
rows = 7
cols = 3
square_size = 0.03 # in millis

pattern_show = highgui.imshow(name="pattern", waitKey=10, autoSize=True)
rgb2gray = imgproc.cvtColor(flag=7)
video = highgui.VideoCapture(video_device=0)
circle_detector = calib.PatternDetector(rows=rows, cols=cols, pattern_type="acircles", square_size=square_size)
circle_drawer = calib.PatternDrawer(rows=rows, cols=cols)
poser = calib.FiducialPoseFinder()
pose_drawer = calib.PoseDrawer()
camera_intrinsics = calib.CameraIntrinsics(camera_file="camera.yml")


plasm.connect(video, "image", rgb2gray, "input")
plasm.connect(rgb2gray, "out", circle_detector, "input")
plasm.connect(video, "image", circle_drawer, "input")
plasm.connect(circle_detector, "out", circle_drawer, "points")
plasm.connect(circle_detector, "found", circle_drawer, "found")
plasm.connect(camera_intrinsics, "K", poser, "K")
plasm.connect(circle_detector, "out", poser, "points")
plasm.connect(circle_detector, "ideal", poser, "ideal")
plasm.connect(circle_detector, "found", poser, "found")
Пример #10
0
#!/usr/bin/env python
import ecto
from ecto_opencv import highgui, calib, imgproc

plasm = ecto.Plasm()
sched = ecto.schedulers.Threadpool(plasm)

video_cap = highgui.VideoCapture(video_device=0)
fps = highgui.FPSDrawer()
rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)

display_strand = ecto.Strand()

checker_detector = calib.PatternDetector('Checker Detector',
                                         rows=5, cols=4,
                                         pattern_type="chessboard",
                                         square_size=0.03)
circle_detector = calib.PatternDetector('Dot Detector',
                                        rows=7, cols=3, pattern_type="acircles",
                                        square_size=0.03)
circle_drawer = calib.PatternDrawer('Circle Draw',
                                    rows=7, cols=3)
checker_drawer = calib.PatternDrawer('Checker Draw',
                                     rows=5, cols=4)
circle_display = highgui.imshow('Pattern show',
                                name='Pattern', waitKey= 2, maximize=True,
                                strand=display_strand)

plasm.connect(video_cap['image'] >> circle_drawer['input'],
               circle_drawer['out'] >> checker_drawer['input'],
               checker_drawer['out'] >> fps['image'],