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')
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'))
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")
def make_graph(k, sigma, debug): video = highgui.VideoCapture(video_device=0) g = imgproc.GaussianBlur(sigma=sigma) graph = [] graph += [video['image'] >> g['input']] for x in range(k): nextg = imgproc.GaussianBlur(sigma=sigma) graph += [g['out'] >> nextg['input']] g = nextg fps = highgui.FPSDrawer() graph += [ g['out'] >> fps[:], fps[:] >> highgui.imshow("megagauss", name="megagauss", waitKey=10)[:] ] return graph
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
#!/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(
obs_ids += models.find_all_observations_for_session( observations, session.id) if len(obs_ids) == 0: raise RuntimeError("There are no observations available.") db_reader = capture.ObservationReader('db_reader', db_params=ObjectDbParameters({ 'type': 'CouchDB', 'root': db_url, 'collection': 'observations' })) #observation dealer will deal out each observation id. observation_dealer = ecto.Dealer(tendril=db_reader.inputs.at('observation'), iterable=obs_ids) fps = highgui.FPSDrawer('FPS drawer') plasm = ecto.Plasm() #View all of the observations. plasm.connect( observation_dealer[:] >> db_reader['observation'], db_reader['image'] >> fps[:], fps[:] >> highgui.imshow('image display', name='image')[:], db_reader['depth'] >> highgui.imshow('depth display', name='depth')[:], db_reader['mask'] >> highgui.imshow('mask display', name='mask')[:], ) from ecto.opts import doit doit(plasm, "View observations from the database.", locals=vars())
from ecto_openni import Capture, ResolutionMode, Device return Capture('ni device', rgb_resolution=ResolutionMode.VGA_RES, depth_resolution=ResolutionMode.VGA_RES, rgb_fps=30, depth_fps=30, device_number=device_n, registration=True, synchronize=True, device=Device.ASUS_XTION_PRO_LIVE ) device = 0 #capture = xtion_highres(device) capture = xtion_vga(device) #capture = kinect_vga(device) #capture = kinect_highres(device) verter = highgui.NiConverter('verter') fps = highgui.FPSDrawer('fps') plasm = ecto.Plasm() plasm.connect(capture[:] >> verter[:], verter['image'] >> fps[:], fps[:] >> highgui.imshow('image display', name='image')[:], verter['depth'] >> highgui.imshow('depth display', name='depth')[:], ) if __name__ == '__main__': sched = ecto.schedulers.Singlethreaded(plasm) sched.execute()