@@ -0,0 +1,1918 @@
+import cv2%0Afrom numpy import *%0Aimport math%0A%0Afrom EmeraldAI.Logic.Singleton import Singleton%0A%0Adef CameraDistanceProcessor(object)%0A    __metaclass__ = Singleton%0A%0A    def __init__(self, camID):%0A        self.__imageWidth = 640%0A        self.__imageHeight = 480%0A%0A        self.__camera = cv2.VideoCapture(camID)%0A        self.__camera.set(3, self.__imageWidth)%0A        self.__camera.set(4, self.__imageHeight)%0A%0A        self.__colorThreshold = 220%0A%0A        # office%0A        self.__distanceInPixel = %5B2, 4, 5, 7, 9, 10, 12, 16, 20, 27, 43, 76, 178%5D%0A        self.__distanceInMM = %5B380, 320, 280,230, 200, 180, 150, 120, 100, 80, 50, 30, 10%5D%0A%0A        # home%0A        # self.__distanceInPixel = %5B0, 2, 6.5, 9.5, 12.5, 16, 27.5, 45.5, 98, 106, 160%5D%0A        # self.__distanceInMM = %5B663, 440, 286, 222, 173, 136, 90, 57, 30, 22, 16%5D%0A%0A%0A        def SetPixelDistance(self, pixel, distance):%0A            self.__distanceInPixel = pixel%0A            self.__distanceInMM = distance%0A%0A%0A        def GetDistanceByPixel(self, pixel):%0A            return interp(pixel, self.__distanceInPixel, self.__distanceInMM)%0A%0A%0A        def Process(self, returnPixel=False):%0A            if (self.__camera.isOpened() != 0):%0A%0A                rval, frame = self.__camera.read()%0A                %0A                if frame is None:%0A                    return -1%0A%0A                frame = frame%5B(self.__imageHeight/2-20):(self.__imageHeight/2+25), 0:self.__imageWidth%5D%0A%0A                num = (frame%5B...,...,2%5D %3E self.__colorThreshold)%0A                xy_val =  num.nonzero()%0A%0A                x_val = median(xy_val%5B1%5D)%0A%0A                if(math.isnan(x_val)):%0A                    return -1%0A%0A                distInPixel = abs(x_val - self.__imageWidth/2) # distance of dot from center x_axis%0A%0A                if returnPixel:%0A                    return distInPixel%0A                else:%0A                    return self.GetDistanceByPixel(distInPixel)%0A%0A            return -1%0A

add cv laser script