Option to ignore identical results?

267 views
Skip to first unread message

Steve Langston

unread,
Aug 20, 2016, 3:51:48 AM8/20/16
to open...@googlegroups.com
I use openalpr to open my gate to my house when a known plate approaches,
(and also to record details of any other plate seen in the lane for security
proposes) it works well, but i have a problem when a plate is parked up near
by for some time - i end up with thousands of images of the same plate in
the same place with thousands of entrys in my spreadsheet (from the
beanstalk) Is there anyway that repeat results can be ignored in alpr
config settings please?

Thanks for the help,

Steve

Matt

unread,
Aug 22, 2016, 10:06:30 PM8/22/16
to OpenALPR
You may be able to do that on your application side.  For example, keep a list of recently seen plates with the last seen timestamp.  If you see the same plate within x seconds, refresh the timestamp, otherwise, drop it from the list.  This way, the same plate will keep refreshing the timestamp, but if it leaves and comes back you'll still record the hit.

st...@frostfields.com

unread,
Aug 24, 2016, 10:55:31 AM8/24/16
to Matt, OpenALPR
Thanks Matt, I have tried doing this, but I think by the time a beanstalk package has been intercepted, read and my Python script decides the number matches with the previous one, the jpg is not yet registering as being present in the folder specified yet, so I am getting a file no found error.  Maybe I need to introduce a small delay before attempting to delete the jpg...?

Steve

Sent from my iPad Air 2
--
You received this message because you are subscribed to the Google Groups "OpenALPR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openalpr+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Bissell

unread,
Aug 24, 2016, 12:06:28 PM8/24/16
to OpenALPR

Hi Steve I'm also interested in your solution to this as I'm currently posting the results to a database via php from the web service call and need to figure out how best to drop multiple plates if seen within a specific time period to avoid the same issue.

Márcus Alves

unread,
Oct 4, 2016, 7:00:37 PM10/4/16
to OpenALPR
Hello guys!

Did you find any answer on how to ignore multiple detection of the same plate?

Also, how did you put the files on a spreadsheet Steve? I'm seeing the data on the beanstalk console, but I can't grab it :/

Thanks! :)

Mark Bissell

unread,
Oct 5, 2016, 3:05:33 PM10/5/16
to OpenALPR
Hi

I used Mats example.

The php webservice checks the recieved plate against the database to see if it has already been created in the database in the last x seconds.

I'm doing this by selecting the max created date for the incoming plate and using some code to calculate the time diff , then it eithers updates the created date for the plate or it creates a new record if over the x time span.

Thanks

st...@frostfields.com

unread,
Oct 5, 2016, 4:01:54 PM10/5/16
to Márcus Alves, OpenALPR
Hi Marcus.  Here is my Python script. It watches for beanstalk jobs, strips out useful info, checks plates against a white list .csv and opens a gate if there is a match.  Then records all detected plates in a .csv plates file.  If there are duplicate plates, it attempts to delete pictures to save space on the Dropbox.

Hope it helps:-)

Steve

#!/usr/bin/python

import beanstalkc
import datetime
import json
import os
import time
import csv
import sys

#start openalpr
os.system("/usr/bin/alprd & ")

#fetch whitelist of plates

f = open('/home/anpr/Dropbox/anpr-whitelist/whitelist.csv')
csv_f = csv.reader(f)
whitelist = []
for row in f:
 whitelist.append (row.strip())
print whitelist

#connect to beanstalk
beanstalk = beanstalkc.Connection(host='localhost', port=11300)
beanstalk.watch('alprd')

def opengate():
   print ("Opening gate.")
   os.system("sudo echo -e '\xff\x01\x01' > /dev/ttyUSB0") #on
   time.sleep(1)
   os.system("sudo echo -e '\\xff\\x01\\x00' > /dev/ttyUSB0") #off
   print ("Gate Opened")
   time.sleep(45)
   emptybeanstalk();

def emptybeanstalk():
   print ("Emptying beanstalk.")
   s = beanstalk.stats_tube("alprd")
   ss = s['current-jobs-ready']
   while (ss > 0):
       bos = beanstalk.reserve()
       bos.delete()
       ss -= 1
   beanstalk.watch('alprd')
       print ("Beanstalk emptied.")
   print ("Watching gate.")

def main():
   emptybeanstalk();
   lastplate = "AAAAAA"
   while True:
       job = beanstalk.reserve()
       jobb = job.body
       job.delete()
       d = json.loads(jobb)
       epoch = d['epoch_time']
#        print d
       realtime = time.strftime('%Y-%m-%d %H:%M:%S')
#        realtime = datetime.datetime.fromtimestamp(epoch).strftime('%Y-%m-%d %H:%M:%S')
       siteid = d['site_id']
       cameraid = d['camera_id']
       plate = d['results'][0]['plate']
       confid = d['results'][0]['confidence']
       uuid = d['uuid']
       if plate in whitelist:
           opengate()
       if lastplate == plate:
           time.sleep(1)
           if os.path.exists("/home/anpr/Dropbox/anpr-pictures/" + str(uuid) + ".jpg"):
               os.remove("/home/anpr/Dropbox/anpr-pictures/" + str(uuid) + ".jpg")
               print ("duplicate pic removed - " + str(uuid) + ".jpg")

       else:
           lastplate = plate
           s = (str(realtime) + ", " + str(plate) + ", " + str(confid) + ", " + str(uuid) + "\n")
           plates = open('/home/anpr/Dropbox/anpr-plates/plates.csv', 'a')
           plates.write(s)
           plates.close()
           print s


if __name__ == "__main__":
   main()

Sent from my iPad Air 2

Márcus Alves

unread,
Oct 17, 2016, 6:43:20 AM10/17/16
to OpenALPR, mvh...@gmail.com
Steve, thanks so much! Your code is working just fine!
Sorry for taking way too much to reply you, I ran in some personal issues in this time.

I've tested your code and it's working how it's suppose to. It's reading the plate, exporting to the CSV file and comparing with the whitelist, opening or not the gate.
Now I'm just trying to create the dropbox folder in order to update remotely from anywhere, instead of updating the file manually using the raspberry.

Thanks again Steve!! :)
Reply all
Reply to author
Forward
0 new messages