Search code examples
pythonraspberry-pisimplecvwebiopi

Why this happening I don't have line 86


I tried the run this and i just used spaces not tabs but

import time
import sys
import numpy as np
import SimpleCV
import webiopi
from ayarlar import *

GPIO = webiopi.GPIO
GPIO.setFunction(4, GPIO.OUT)
GPIO.setFunction(17, GPIO.OUT)
GPIO.setFunction(18, GPIO.OUT)
GPIO.setFunction(27, GPIO.OUT)
GPIO.setFunction(10, GPIO.OUT)
GPIO.setFunction(25, GPIO.OUT)

def dist_from_color(img_color):
    matrix = (img.getNumpy()[:,:,[2,1,0]] - color) ** 2
    width, height = img.size()
    return matirx.sum() ** 0.5 / (width * height)

def forward():
   GPIO.digitalWrite(18, GPIO.HIGH)
   GPIO.digitalWrite(10, GPIO.LOW)

def reverse():
   GPIO.digitalWrite(18, GPIO.LOW)
   GPIO.digitalWrite(10, GPIO.HIGH)

def right():
   GPIO.digitalWrite(27, GPIO.HIGH)
   GPIO.digitalWrite(25, GPIO.LOW)

def left():
   GPIO.digitalWrite(27, GPIO.LOW)
   GPIO.digitalWrite(25, GPIO.HIGH)

def strop():
   GPIO.digitalWrite(18, GPIO.LOW)
   GPIO.digitalWrite(10, GPIO.LOW)
   GPIO.digitalWrite(27, GPIO.LOW)
   GPIO.digitalWrite(25, GPIO.LOW)

@webiopi.macro
def ButtonForward():
   forward()

@webiopi.macro
def ButtonReverse():
   reverse()

@webiopi.macro
def ButtonTrunLeft():
   left()

@webiopi.macro
def ButtonTrunRight():
   right()
@webiopi.macro
def ButtonStop():
   stop()
def main():
    try:
     print(__doc__)
     GPIO.digitalWrite(4, GPIO.HIGH)
     GPIO.digitalWrite(17, GPIO.HIGH)
     server = webiopi.Server(port=80)
     server.addMacro(ButtonForward)
     server.addMacro(ButtonReverse)
     server.addMacro(ButtonTrunLeft)
     server.addMacro(ButtonTrunRight)
     server.addMacro(ButtonStop)
     cam = SimpleCV.Camera()
     background = cam.getImage()
     print("Tespite Baslaniyor")
     while True:
        try:
           background = cam.getImage()
           time.sleep(0.1)
           img = cam.getImage()
           to_show = img
           to_show.save("../../..//usr/share/webiopi/htdocs/aaa.jpg")
           dist = ((img - background) + (background - img)).dilate(6)   
        except(KeyboardInterrupt, SystemExit):
           del cam
           server.stop()

It gives me this eror even i don't have line 86

File "tespit.py", line 86 ^ IndentationError: unexpected unindent Please help me i can't solve the problem...


Solution

  • You have two try statements, and only one except statement.

    Add an except clause for the first try, at the end of the main function, indented 4 spaces, and it will work.

    Line 86 is just past the end of your code, and is where Python is looking for a matching except.