User Tools

Site Tools


[[FAQ]] [[Tutorials]] [[Topics]]


====== Camera/Vision ====== First you have to create a [[classlpz>Camera]] that has a stack of [[structlpz>ImageProcessor]]s attached to it. Example: <code c++> CameraConf camcfg = Camera::getDefaultConf(); camcfg.width = 256; camcfg.height = 128; camcfg.fov = 120; camcfg.camSize = 0.08; camcfg.processors.push_back(new HSVImgProc(false,1)); // filter only Yellow color camcfg.processors.push_back(new ColorFilterImgProc(true, .5, HSVImgProc::Yellow-10, HSVImgProc::Yellow+10,100)); Camera* cam = new Camera(camcfg); </code> The frames are 256x128 pixels in this case. The ''camSize'' is only for visualization. The first processor converts RGB into Hue/Saturation/Value. The next one is a filter for a specific color, here Yellow resulting a single channel black and white image. The boolean decides whether the processed image is displayed. Now we need a Sensor that converts the frames from the camera into sensor values. An example would be the [[classlpz>MotionCameraSensor]] that return the quantities based on the mean of the bright pixels. <code c++> MotionCameraSensorConf mc = MotionCameraSensor::getDefaultConf(); mc.values = MotionCameraSensor::Position | MotionCameraSensor::Size | MotionCameraSensor::SizeChange; mc.dims = Sensor::XY; mc.avg = 1; mc.window = false; mc.border = 0.25; mc.sizeExponent = 0.5; // square root auto camSensor = std::make_shared<MotionCameraSensor>(mc); camSensor->setInitData(cam, odeHandle, osgHandle, osg::Matrix::rotate(-M_PI/2,0,0,1) * osg::Matrix::translate(0.2,0, 0.40) ); robot->addSensor(camSensor); </code> The sensor here measures the motion(implicit always on), position, size and change in size of the bright pixels. (position is mean and size is essentially the sum of brightnesses) The camera is attaches to the main primitive because no Attachment is give at ''addSensor()''. The relative pose is give to ''setInitData''. That's it. Have fun!

camera.txt · Last modified: 2014/08/22 14:12 by georg