Exemplo n.º 1
0
class ImageBasedAffordanceFit(object):

    def __init__(self, imageView=None, numberOfPoints=1):

        self.imageView = imageView or cameraview.CameraImageView(cameraview.imageManager, 'CAMERA_LEFT', 'image view')
        self.imagePicker = ImagePointPicker(self.imageView, numberOfPoints=numberOfPoints)
        self.imagePicker.connectDoubleClickEvent(self.onImageViewDoubleClick)
        self.imagePicker.annotationFunc = self.onImageAnnotation
        self.imagePicker.start()

        self.pointCloudSource = 'lidar'
        self.pickLineRadius = 0.05
        self.pickNearestToCamera = True

    def getPointCloud(self):
        assert self.pointCloudSource in ('lidar', 'stereo')
        if self.pointCloudSource == 'stereo':
            return segmentation.getDisparityPointCloud(decimation=1, removeOutliers=False)
        else:
            return segmentation.getCurrentRevolutionData()

    def onImageAnnotation(self, *points):
        polyData = self.getPointCloud()
        points = [self.getPointCloudLocationFromImage(p, self.imageView, polyData) for p in points]
        self.fit(polyData, points)

    def getPointCloudLocationFromImage(self, imagePixel, imageView, polyData):
        cameraPos, ray = imageView.getWorldPositionAndRay(imagePixel)
        return segmentation.extractPointsAlongClickRay(cameraPos, ray, polyData, distanceToLineThreshold=self.pickLineRadius, nearestToCamera=self.pickNearestToCamera)

    def onImageViewDoubleClick(self, displayPoint, modifiers, imageView):
        pass

    def fit(self, pointData, points):
        pass
Exemplo n.º 2
0
    def __init__(self, imageView=None, numberOfPoints=1):

        self.imageView = imageView or cameraview.CameraImageView(
            cameraview.imageManager, 'CAMERA_LEFT', 'image view')
        self.imagePicker = ImagePointPicker(self.imageView,
                                            numberOfPoints=numberOfPoints)
        self.imagePicker.connectDoubleClickEvent(self.onImageViewDoubleClick)
        self.imagePicker.annotationFunc = self.onImageAnnotation
        self.imagePicker.start()

        self.pointCloudSource = 'lidar'
        self.pickLineRadius = 0.05
        self.pickNearestToCamera = True
Exemplo n.º 3
0
class ImageBasedAffordanceFit(object):
    def __init__(self, imageView=None, numberOfPoints=1):

        self.imageView = imageView or cameraview.CameraImageView(
            cameraview.imageManager, 'CAMERA_LEFT', 'image view')
        self.imagePicker = ImagePointPicker(self.imageView,
                                            numberOfPoints=numberOfPoints)
        self.imagePicker.connectDoubleClickEvent(self.onImageViewDoubleClick)
        self.imagePicker.annotationFunc = self.onImageAnnotation
        self.imagePicker.start()

        self.pointCloudSource = 'lidar'
        self.pickLineRadius = 0.05
        self.pickNearestToCamera = True

    def getPointCloud(self):
        assert self.pointCloudSource in ('lidar', 'stereo')
        if self.pointCloudSource == 'stereo':
            return segmentation.getDisparityPointCloud(decimation=1,
                                                       removeOutliers=False)
        else:
            return segmentation.getCurrentRevolutionData()

    def onImageAnnotation(self, *points):
        polyData = self.getPointCloud()
        points = [
            self.getPointCloudLocationFromImage(p, self.imageView, polyData)
            for p in points
        ]
        self.fit(polyData, points)

    def getPointCloudLocationFromImage(self, imagePixel, imageView, polyData):
        cameraPos, ray = imageView.getWorldPositionAndRay(imagePixel)
        return segmentation.extractPointsAlongClickRay(
            cameraPos,
            ray,
            polyData,
            distanceToLineThreshold=self.pickLineRadius,
            nearestToCamera=self.pickNearestToCamera)

    def onImageViewDoubleClick(self, displayPoint, modifiers, imageView):
        pass

    def fit(self, pointData, points):
        pass
Exemplo n.º 4
0
    def show(self):

        if self.imageView:
            return

        imageView = cameraview.views[self.viewName]
        self.imageView = imageView
        self._prevParent = imageView.view.parent()

        imageView.view.hide()
        imageView.view.setParent(view)
        imageView.view.resize(self.size, self.size)
        imageView.view.move(*self.position)
        imageView.view.show()

        if self.usePicker:
            self.imagePicker = ImagePointPicker(imageView)
            self.imagePicker.start()
Exemplo n.º 5
0
    def __init__(self, imageView=None, numberOfPoints=1):

        self.imageView = imageView or cameraview.CameraImageView(cameraview.imageManager, 'CAMERA_LEFT', 'image view')
        self.imagePicker = ImagePointPicker(self.imageView, numberOfPoints=numberOfPoints)
        self.imagePicker.connectDoubleClickEvent(self.onImageViewDoubleClick)
        self.imagePicker.annotationFunc = self.onImageAnnotation
        self.imagePicker.start()

        self.pointCloudSource = 'lidar'
        self.pickLineRadius = 0.05
        self.pickNearestToCamera = True
Exemplo n.º 6
0
class ImageOverlayManager(object):

    def __init__(self):
        self.viewName = 'CAMERA_LEFT'
        #self.viewName = 'KINECT_RGB'
        self.size = 400
        self.position = [0, 0]
        self.usePicker = False
        self.imageView = None
        self.imagePicker = None
        self._prevParent = None

    def show(self):

        if self.imageView:
            return

        imageView = cameraview.views[self.viewName]
        self.imageView = imageView
        self._prevParent = imageView.view.parent()

        imageView.view.hide()
        imageView.view.setParent(view)
        imageView.view.resize(self.size, self.size)
        imageView.view.move(*self.position)
        imageView.view.show()

        if self.usePicker:
            self.imagePicker = ImagePointPicker(imageView)
            self.imagePicker.start()

    def hide(self):
        if self.imageView:
            self.imageView.view.hide()
            self.imageView.view.setParent(self._prevParent)
            self.imageView.view.show()
            self.imageView = None
        if self.imagePicker:
            self.imagePicker.stop()