Page 2 of 4

Re: License plate recognition

Posted: Tue Jan 05, 2010 4:43 pm
by Alexander
this would properly 10 minutes of work. I'll post the script this evening.

Re: License plate recognition

Posted: Tue Jan 05, 2010 5:18 pm
by drmacchi
Great ! many thanks. lorenzo

Re: License plate recognition

Posted: Tue Jan 05, 2010 5:40 pm
by Alexander
how do you capture the image btw?

Re: License plate recognition

Posted: Tue Jan 05, 2010 6:02 pm
by drmacchi
i use a cam , with lan port and internal web server. the cam takes picture automatically because has motion detection. these image are already forwarded to my mail everyday. so we (you :D ) should think HS to receive these mails from the cam (they come from a specific account , so ONLY mails from the cam and they have pictures as JPEG attachment).

Re: License plate recognition

Posted: Tue Jan 05, 2010 6:15 pm
by Alexander
hey, be patient with me ;-) I will create the script which checks the file on a file location. Downloading an attachment is another way of saving the file to a location. (next step?)

Is the image you have used to test a picture of your environment, because when i use this one (http://www.abmulderbv.nl/dynimg/1970/14 ... nteken.jpg) i will get "null" back and if using this one (http://www.seat-club.nl/stickerzone/ind ... eken2k.jpg) i get Z3NKFS. Did you tweaked the config.xml ?

Re: License plate recognition

Posted: Tue Jan 05, 2010 6:31 pm
by drmacchi
Yes i forgot that i manually open the attachment , here HS should open the attachment . You're right.
Screenshots are from the programmer of Java applications.
Here : http://javaanpr.sourceforge.net/snapshots.zip

Re: License plate recognition

Posted: Tue Jan 05, 2010 8:56 pm
by drmacchi
i'm playing with plates images. if we use the archive of the sw it works very well.
i used an image of italian plate, but i can not be recognized, so i did a trick : copy and paste that plate with "paint" in one of the car in the archive and it works 80%. must work on config.xml ? where ? dimensions ? what else?

Re: License plate recognition

Posted: Tue Jan 05, 2010 9:08 pm
by Alexander
i think it has something to do with the image specs. (dimension, colordepth)big difference?

First step!

1. Save this code to a script (getlicenseplate.vb as an example)

Code: Select all

Sub Main(parm as object)
   Dim strFileContentConfig, strFileContentLPR,strDevice, strPathJavaANPR, strInputImage As String
   strDevice = "V11" ' which device has to get the license plate number as value
   strPathJavaANPR = "C:\temp\javaanpr\javaanpr\dist" ' location of the javaanpr.jar
   strInputImage = "C:\temp\test_005.jpg" ' complete path to the image to be OCRd

   Shell("cmd /c cd " & strPathJavaANPR & " && java -jar javaanpr.jar -recognize -i " & strInputImage & " >" & Environ("windir") & "\ocrLPR.txt", , True)
   strFileContentConfig = My.Computer.FileSystem.ReadAllText(hs.GetAppPath & "\config\LPR.ini")
   strFileContentLPR = My.Computer.FileSystem.ReadAllText(Environ("windir") & "\ocrLPR.txt")

   hs.SetDeviceString(strDevice, strFileContentLPR.Trim, True)

   If instr(uCase(strFileContentConfig), uCase(strFileContentLPR.Trim)) > 0 Then
      hs.TriggerEvent("Legal license plate detected")
   Else
      hs.TriggerEvent("Illegal license plate detected")
   End If
End Sub
2. change the values of the 3 variables (strDevice, strPathJavaANPR and strInputImage) to the correct value
3. create an event that has a script action to this script.
4. create two additional events called Legal license plate detected and Illegal license plate detected. The first event will be triggered if the license plate is on the list (see next bullet). Obvious, the second event, if it isn't on the list. (example would be to send you an email with the image as attachment)
5. in your HS config directory create a file called LPR.ini. The first line has to be something, i'd written allowed license plates. The additional lines you put in the license plates which are allowed.

Hit it and give feedback. The one thing that has to be arranged is to export the attachment from the mail.

Re: License plate recognition

Posted: Tue Jan 05, 2010 11:08 pm
by drmacchi
Alexander i did it. it works and email arrives, but if you launch it 2-3 times , then you have " running event in bckg" and email does not exit.

Re: License plate recognition

Posted: Tue Jan 05, 2010 11:23 pm
by Alexander
Can you clarify "then you have " running event in bckg" and email does not exit.", because i don't understand this part of your post.

Re: License plate recognition

Posted: Tue Jan 05, 2010 11:45 pm
by drmacchi
Sorry ,

from HS log :
when it works

05/01/2010 21.55.29 Info Running script in background: getlicenseplate.vb
05/01/2010 21.55.31 Info Event Trigger "Illegal license plate detected"
05/01/2010 21.55.31 Info Email successfully sent to xxxxxxxxxxxx
05/01/2010 21.58.51 Info Event Trigger "targhe-riconoscimento"


when it doesn't work

05/01/2010 22.03.30 Info Event Trigger "targhe-riconoscimento"
05/01/2010 22.03.30 Info Running script in background: getlicenseplate.vb

Re: License plate recognition

Posted: Tue Jan 05, 2010 11:56 pm
by Alexander
Not even after a few seconds? Because i can't understand why it won't run a second time. It's like it cant run because the command prompt is stull running from the previous run. That is something i would think of having problem with. Please check if java.exe and/or cmd.exe aren't running anymore on the HS server when you try again.

Re: License plate recognition

Posted: Wed Jan 06, 2010 12:45 am
by drmacchi
None of java or cmd are running on server. it seems to wait for something, but HS doesn't crash and all other functions are working.

Re: License plate recognition

Posted: Wed Jan 06, 2010 1:15 am
by drmacchi
i launched the script with Task manager open , i see cmd.exe and java.exe starting and closing after 2sec.

Re: License plate recognition

Posted: Wed Jan 06, 2010 1:24 am
by Alexander
so thats okay. If i run it two times, i do get this:
  • 6-1-2010 0:19:35 Event Event Trigger "Recognize license plate"
    6-1-2010 0:19:35 Event Running script in background: getlicenseplate.vb
    6-1-2010 0:19:38 Event Event Trigger "Legal license plate detected"
    6-1-2010 0:19:54 Event Event Trigger "Recognize license plate"
    6-1-2010 0:19:54 Event Running script in background: getlicenseplate.vb
    6-1-2010 0:19:57 Event Event Trigger "Legal license plate detected"
But what image are you testing? Can you please test "test_005.jpg" so we test the same. If you than get the same result as i, than please send me the file which you did test and went wrong. But i doubt it if that would be a problem.
Can you put this code between most of the lines of code and change "1" to different one, so that you know which one you would expect to log after the last one has logged itself? Maybe than we can find the line of code that gives a problem (if so)

hs.writelog("test","1")