module Overspeeding

Constants

Distance
SENSOR1
SENSOR2
VERSION

Public Instance Methods

overspeeding() click to toggle source
# File lib/overspeeding.rb, line 68
def overspeeding
        system ('raspistill -o numberplate_image.jpg')
        system('ruby alpr.rb > out.txt')
        line = IO.readlines("out.txt")[2]
    line.rstrip
    line.lstrip
    line=line[6,28]
    line[-20..-1] = ""
    puts "The extracted number plate is #{line}"       
end
speed1() click to toggle source
# File lib/overspeeding.rb, line 18
def speed1

        a = WiringPi.read(SENSOR1)
        b = WiringPi.read(SENSOR2)

        if a == 1
                itime = Time.now
                loop do
                        if b == 1
                                ftime = Time.now
                                time = ftime - itime
                                velocity = Distance/time
                                if velocity > 50
                                        puts 'Overspeeding'
                                        overspeeding
                                        break
                                else
                                        puts 'Acceptable Speed'
                                        break
                                end
                        end
                end
        end
end
speed2() click to toggle source
# File lib/overspeeding.rb, line 43
def speed2

        a = WiringPi.read(SENSOR1)
        b = WiringPi.read(SENSOR2)

        if b == 1
                itime = Time.now
                loop do
                        if a == 1
                                ftime = Time.now
                                time = ftime - itime
                                velocity = Distance/time
                                if velocity > 50
                                        puts 'Overspeeding'
                                        overspeeding
                                        break
                                else
                                        puts 'Acceptable Speed'
                                        break
                                end
                        end
                end
        end
end