This is what I used to do machine vision homing a couple of years ago: FitElipse is a function that finds the best fit circle in the frame. I can supply that function too if you like. It is adapted from examples I found online.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # homecart.py import sys import urllib2 import random import cv2.cv as cv import time import hal if __name__ == '__main__': h = hal.component("homecart") h.newpin("offset", hal.HAL_FLOAT, hal.HAL_OUT) h.newpin("located", hal.HAL_BIT, hal.HAL_OUT) h.ready() capture = cv.CaptureFromCAM(0) while True: img = cv.QueryFrame(capture) gimg = cv.CreateImage((640,480), cv.IPL_DEPTH_8U, 1) cv.CvtColor(img, gimg, cv.CV_RGB2GRAY) fe = FitEllipse(gimg, 116) h['offset'] = fe.offset h['located'] = fe.located In the hal file, I have: loadusr ./homecart # Can't have .py on the end of the filename then I can use homecart.located and homecard.offset pins. I can't find an example where I actually used it to do the homing though. I must have gotten distracted by something else before I got that step completed. Hope this is useful. -- Ralph -- Ralph ________________________________________ From: sam sokolik [sa...@empirescreen.com] Sent: Tuesday, October 07, 2014 11:59 AM To: Enhanced Machine Controller (EMC) Subject: Re: [Emc-users] opencv for shape recognition You make it sound /so/ easy... :) sam On 10/7/2014 1:09 PM, andy pugh wrote: > On 7 October 2014 19:06, sam sokolik <sa...@empirescreen.com> wrote: >> this is my first real exposure to python. the next step is to see how I >> can fidldle hal stuff with it.. > import hal > > make hal pins, job done :-) > > ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users