Skip to content

Instantly share code, notes, and snippets.

@shurru
Created July 20, 2014 03:58
Show Gist options
  • Save shurru/68fd812d7f618549a3d2 to your computer and use it in GitHub Desktop.
Save shurru/68fd812d7f618549a3d2 to your computer and use it in GitHub Desktop.
Imagereader with detection of change in file. Not used for the demo
from SimpleCV import *
from tesseract import *
import datetime
import json
import re
import os, time
path= "/home/shruthi/x/images/07/"
path2= "/home/shruthi/x/files/07/"
filename= "0101.jpg"
vartime= datetime.datetime.now()
while True:
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(path+filename)
if time.ctime(mtime)!= vartime:
img= Image(path+filename)
bined= img.binarize(200)
text = bined.readText()
date= str(datetime.datetime.now())
convert= re.findall('\d+', text)
convert= int(convert[0])
listes = [{"postcode": 600001, "unit":"#01-01", "time": date, "value": convert, "imgUrl": "images/07/0101.jpg"},
{"postcode": 600001, "unit":"#01-02", "time": "2014-07-01 12:00:00", "value": 69568, "imgUrl": "images/07/0102.jpg"},
{"postcode": 600001, "unit":"#01-03", "time": "2014-07-01 12:00:00", "value": 7576, "imgUrl": "images/07/0103.jpg"},
{"postcode": 600001, "unit":"#01-04", "time": "2014-07-01 12:00:00", "value": 19676, "imgUrl": "images/07/0104.jpg"}
]
with open(path2+ '600001.json', 'w') as outfile:
json.dump(listes, outfile)
vartime= time.ctime(mtime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment