Ejemplo n.º 1
0
    global y
    global sposx
    global sposy
    global posx
    global posy
    global newx
    global newy
    if (opencvData.getBoundingBoxArray().size() > 0) :
     rect = opencvData.getBoundingBoxArray().get(0)
     posx = rect.x
     posy = rect.y
     
     w = rect.width
     h = rect.height
     sposx = (w/2)
     sposy = (h/2)
     x = (posx + sposx)
     y = (posy + sposy)
     print x
     print y
     newx = (x/320.0)
     newy = (y/240.0)
     print newx
     print newy
     tracker.trackPoint(newx,newy)
     return object
# create a message route from opencv to python so we can see the coordinate locations
opencv.addListener("publishOpenCVData", python.name, "input", OpenCVData().getClass());

opencv.capture()
Ejemplo n.º 2
0
                spokeScan = False
                spokeSearch = True
            actservox += dirx
            if (actservox < 11 or actservox > 169):
                dirx = -dirx
                while (actservox < 11 or actservox > 169):
                    actservox += dirx
                actservoy += diry
                if actservoy < 81 or actservoy > 159:
                    diry = -diry
                    while (actservoy < 81 or actservoy > 159):
                        actservoy += diry

            pan.moveTo(int(actservox))
            tilt.moveTo(int(actservoy))
            arduino.digitalWrite(10, 0)
            arduino.digitalWrite(9, 1)
            arduino.digitalWrite(4, 1)
            x = actservox
            y = actservoy
            return object


# create a message route from opencv to python so we can see the coordinate locations
opencv.addListener("publishOpenCVData", python.name, "input",
                   OpenCVData().getClass())

opencv.setCameraIndex(1)

# set the input source to the first camera
opencv.capture()