I'm having trouble running the last part of my code here. Im using Raspberry Pi, OpenCV, PiCamera, and servo motors. NOT SHOWN i have the code to find the centroid, and from the centroid it will then determine how far off '160' it is. Im not totally sure if the centroid's middle point is 160, so do any of you know that? As well as I get a SyntaxError on the "if: cx>151 and cx<169", would any of you know why that it, or could you help me to figure out a different approach to telling it how to follow the line?
import RoboPiLib as RPL
import setup
motorL = 0
motorR = 1
#1500 = middle point
#The closer to '1500' the slower it will go
if: cx>151 and cx<169
print "straight"
RPL.servoWrite(motorL, 1000)
RPL.servoWrite(motorR, 2000)
time.sleep(2)
elif x<=150
print "left"
RPL.servoWrite(motorL, 1000)
RPL.servoWrite(motorR, 1750)
time.sleep(2)
elif x>=170
print "right"
RPL.servoWrite(motorL, 1250)
RPL.servoWrite(motorR, 1000)
time.sleep(2)
else print "stop"