Created
June 19, 2012 17:34
-
-
Save oostendo/2955452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import SimpleSeer.models as M | |
@core.state('start') | |
def start(state): | |
state.core.set_rate(10.0) | |
return state.core.state('waitforbuttons') | |
@core.state('waitforbuttons') | |
def waitforbuttons(state): | |
while True: | |
core.tick() | |
scan = core.cameras[0] | |
if scan.device.email or scan.device.file: | |
return state.core.state('scan') | |
@core.state('scan') | |
def scan(state): | |
core = state.core | |
scan = core.cameras[0] | |
scan.setProperty("resolution", 75) | |
scan.setProperty("mode", "gray") | |
preview = scan.getPreview() | |
blobs = preview.findBlob(minarea = 250) | |
if not blobs: | |
return core.state('start') | |
topleft, bottomright = blobs[-1].mBoundingBox[0], blobs[-1].mBoundingBox[2] | |
scan.setROI(topleft, bottomright) | |
scan.setProperty("resolution", 1200) | |
scan.setProperty("mode", "color") | |
for f in core.capture(): | |
process(frame) | |
frame.save() | |
scan.setROI() | |
return core.state('start') | |
def process(frame): | |
frame.features = [] | |
frame.results = [] | |
for inspection in M.Inspection.objects: | |
if inspection.parent: | |
return | |
if inspection.camera and inspection.camera != frame.camera: | |
return | |
results = inspection.execute(frame.image) | |
frame.features += results | |
for m in inspection.measurements: | |
m.execute(frame, results) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment