def addOffsetStamp(self, leftFit, rightFit, image, origin, color=(255, 255, 255), fontScale=1.0, thickness=1):
        """
        Evaluating camera offset and adding it to a given image
        :param thickness: line thickness
        :param leftFit: left curve polynomial parameters
        :param rightFit: right curve polynomial parameters
        :param image: image where data being added
        :param origin: upper-left corner of the offset stamp
        :param color: stamp color
        :param fontScale: font scale
        :return: void (adds text to passed image)
        """

        imgW = image.shape[1]
        imgH = image.shape[0]

        yBottom = imgH - 1
        cameraCenter = imgW / 2
        lBottomX = aux.funcSpace(argSpace=yBottom, fitParams=leftFit) - self.imgMarginWidth
        rBottomX = aux.funcSpace(argSpace=yBottom, fitParams=rightFit) - self.imgMarginWidth
        laneWidth = rBottomX - lBottomX
        scaleX = 3.7 / laneWidth
        laneCenter = (lBottomX + rBottomX) / 2
        offSet = (cameraCenter - laneCenter) * scaleX
        aux.putText(img=image, text='Estimated Vehicle Offset: {:.2f} m'.format(offSet),
                    origin=origin, color=color, scale=fontScale, thickness=thickness)
Exemple #2
0
 def addOffsetStamp(self, leftFit, rightFit, image, origin, color=(255, 255, 255), fontScale=1.0, thickness=1):
     imgW = image.shape[1]
     imgH = image.shape[0]
     yBottom = imgH - 1
     cameraCenter = imgW / 2
     lBottomX = aux.funcSpace(argSpace=yBottom, fitParams=leftFit) - self.imgMarginWidth
     rBottomX = aux.funcSpace(argSpace=yBottom, fitParams=rightFit) - self.imgMarginWidth
     laneWidth = rBottomX - lBottomX
     scaleX = 3.7 / laneWidth
     laneCenter = (lBottomX + rBottomX) / 2
     offSet = (cameraCenter - laneCenter) * scaleX
     aux.putText(img=image, text='Смещение объекта автомобиля: {:.2f} m'.format(offSet),
                 origin=origin, color=color, scale=fontScale, thickness=thickness)
    def addCurvatureStamp(leftFit, rightFit, image, origin, color=(255, 255, 255), fontScale=1.0):

        """
        Evaluating lane curvature and adding it to a given image
        :param leftFit: left curve polynomial parameters
        :param rightFit: right curve polynomial parameters
        :param image: image where data being added
        :param origin: upper-left corner of the offset stamp
        :param color: stamp color
        :param fontScale: font scale
        :return: void (adds text to passed image)
        """

        imgH = image.shape[0]

        yBottom = imgH-1
        scaleY = 27 / imgH  # meters per pixel
        leftCurvature = aux.curvature(fitParams=leftFit, variable=yBottom, scale=scaleY)
        rightCurvature = aux.curvature(fitParams=rightFit, variable=yBottom, scale=scaleY)
        curvature = (leftCurvature + rightCurvature) / 2
        aux.putText(img=image, text='Estimated Lane Curvature: {:.1f} m'.format(round(curvature / 100, 1) * 100),
                    origin=origin, color=color, scale=fontScale)