585,763 active members*
4,002 visitors online*
Register for free
Login
Results 1 to 17 of 17
  1. #1
    Join Date
    Nov 2006
    Posts
    104

    webcam edge finder?

    Anyone know of any software for EMC that can use a webcam as a edge finder? I have seen it with mach3 but havent found anything for EMC yet.

  2. #2
    Join Date
    Jun 2010
    Posts
    0

    Talking Webcam center finder for emc2 Ubuntu Hardy Heron

    Hi, this is Mechstew! I love the EMC2 interface, and am new to milling,
    and cnc control. I saw an article referring to a webcam center finder and figured it was worth a try. "After" making it, I could find no program to utilize it with EMC2 2.3.5, all of the blogs and posts i could find were also fruitless.
    Having spent forty bucks on this round thing that I just finished butchering, Wal-Mart would not take it back now! I spent 2 weeks for trial and error to finally have a working 960 X 720 (pixel) window with a crosshair. I am neither a programmer nor a computer guru, I just want to make little pieces out for big pieces and this helps me to do it reliably. If you or anyone else is interested let me know and I will try to relay that information through this portal.
    I am using a Logitek c300 with Ubuntu Hardy Heron, and lauch a .py file outside of EMC2 2.3.5.

    P.S. I do not check my web accounts often (once/week), now its time for me to build!

  3. #3
    Join Date
    Sep 2004
    Posts
    149
    Hi Mechstew,
    I am interested in what you did with the python program.

    Thanks,
    Dan

  4. #4
    Join Date
    Mar 2008
    Posts
    24
    Hi Mechstew,

    I have been down the same path: got working webcam but no software to make use of it!
    It would be great if you could share your solution!

    regards
    Alex

  5. #5
    Join Date
    Jun 2010
    Posts
    0

    Talking Webcam center finder emc2 2.3.5

    Hi All, I will put together the information that I have, and try to post it on Monday.

    Until then, a few things to test first, with the usb webcam plugged in.

    1: Open a "terminal" window, and enter the following:
    xawtv -hwscan
    if this package is not installed, then using a "terminal" window enter:
    sudo apt-get install xawtv
    , enter your login password, then follow
    on screen prompts.

    The xawtv -hwscan the xawtv is only used to find out the type of output
    from the webcamera and if it is connected to the dev/video0 port.

    2: Next, enter the following in a terminal window:
    gst-launch videotestsrc ! xvideosink

    A small window displaying a test pattern should be playing on the screen.
    If nothing happes then the terminal window will probably tell you how to
    install gstreamer.
    I have read that the gts-launch command is for "testing" gstreamer
    applications, which is great, since I only want to test where the location
    of a hole center is in relation to the spindles center.

    If the computer does not have access to the internet I will have to figure
    out how to install the packages needed to run the webcamera.
    You can install a windows .ini driver for a wifi connection by using the synapic package manager (SPM), listed under system, administration. Launch the SPM and search for "ndisgtk", mark the package for install, insert the Ubuntu live cd, and then apply changes in SPM. The package name is "ndisgtk", it is an interface for "ndiswrapper", ndisgtk will create a new icon(link) listed under system, administration for wireless drivers.

    You will find some attached files below, the output size of the video window should match the size of the .png overlay. when first testing do not have other audio or visual elements playing, as is might be using resources you need to use for testing. I pasted the one line command series into a file named center.py, you can use any name but be sure to end it with a .py inorder to assign it a file type. Having done this, you will be able to right click the top Ubuntu panel bar in the grey area and create a new quick launch icon(button for the .py file) you may need to look at the properties of your new .py file and check the "treat as executible" so the execute option shows.
    Hopefuly all is still well. You can make you own icon image for the quicklauch by using the applications/accessories/screencapture with your webcam playing.

    Side Notes:
    My video window can be dragged to any size and the crosshairs remain "centered", if on AV type programs are running.
    My window only works at frame rates =< 10/1 fps.
    I made the .png picture using Gimp, drawing the cross first, using guidelines,
    then colored the remaining back ground to alpha, as the command lines I used project the webcams stream onto this alpha color region.
    When all is hunky-dory, I open EMC2, then quick-launch my.py file, then right click the un-named video window seen in the lower browser-bar to select always on top, then using the lower browser-bar again, select the EMC2, to finaly use the keyboard short cuts to calibrate, then position the part.

    I would not run an EMC g-code unless the video window is closed since the gst launch is "only for testing", and it could effect latency stuff.
    If you run the webcam window through the terminal you will likely see a clock error iterating to infinity, but the window is still reliable and repeatable and does not lug the computer down, unlike (webcamstudio). Anyway as for myself I just want to position parts and pull splinters.

    Remember to try the smaller parts then work up to the whole.



    Sources:
    This source started the mess.
    http://noraisin.net/~jan/diary/?p=40

    This source, once inverted, help finish the mess.
    http://www.opensource-archive.org/sh...d.php?t=181657


    Goodluck!
    Mechstew
    Attached Thumbnails Attached Thumbnails cross640480.png   cross960720.png  
    Attached Files Attached Files

  6. #6
    Join Date
    Nov 2005
    Posts
    496
    Check this out for something similar:
    EMC Documentation Wiki: Axis Embed Video

  7. #7
    Join Date
    May 2006
    Posts
    122
    That is really slick. Thanks Chester.

  8. #8
    Join Date
    May 2005
    Posts
    1662
    That is slick.

    Now where's the Linux version of Tormach's Scan/Cad ? I'm convinced there's an existing combination of open source tools that could turn emc into a scanner, just need to find those tools.

    Well...... that, plus buy a usb microscope
    Anyone who says "It only goes together one way" has no imagination.

  9. #9
    Join Date
    Aug 2010
    Posts
    0

    Patch link dead

    Chester88,

    I'm 95% there... the link for the patch is busted (site gone extinct, I think).

    [2] http://psha.org.ru/p/0001-Added-reparent.patch


    Do you know where I might grab that patch or could you drop a copy on me?

    Thanks,

    John Adam in Libertyville

  10. #10
    Join Date
    Nov 2005
    Posts
    496
    It seems to be back . Maybe it should be added to wiki as a file rather then a link.

  11. #11
    Join Date
    May 2006
    Posts
    122
    the link is dead for me too.

  12. #12
    Join Date
    Jun 2003
    Posts
    232
    I get this on the link but I don't understand what it is or how to use it:

    From 63942679046c9d5a2942c257651270090d6b30d5 Mon Sep 17 00:00:00 2001
    From: Pavel Shramov
    Date: Mon, 4 Oct 2010 00:15:06 +0400
    Subject: [PATCH] Added reparent

    Added ability to embed into other X-window when called with -w/--window
    parametere.

    Signed-off-by: Pavel Shramov
    ---
    camview/camview.c | 28 ++++++++++++++++++++++++++--
    1 files changed, 26 insertions(+), 2 deletions(-)

    diff --git a/camview/camview.c b/camview/camview.c
    index e479512..228dd53 100644
    --- a/camview/camview.c
    +++ b/camview/camview.c
    @@ -7,6 +7,8 @@
    #include

    #include
    +#include
    +#include

    #include
    #include
    @@ -25,6 +27,7 @@ typedef struct _state_t {
    char *xml_fname;
    char *extra_plugin_path;
    int use_gui;
    + int window_id;

    GtkWindow *window;
    GtkWidget *manager_frame;
    @@ -194,7 +197,10 @@ on_save_menu_item_activate (GtkWidget *widget, void * user)
    static void
    setup_gtk (state_t *self)
    {
    - self->window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
    + GtkWindowType type = GTK_WINDOW_TOPLEVEL;
    + if (self->window_id)
    + type = GTK_WINDOW_POPUP;
    + self->window = GTK_WINDOW (gtk_window_new (type));
    gtk_window_set_title(self->window, "Camview");
    gtk_window_set_resizable(self->window, TRUE);
    gtk_window_set_default_size(self->window, 1000, 540);
    @@ -316,6 +322,19 @@ setup_gtk (state_t *self)

    gtk_widget_show_all (GTK_WIDGET (self->window));

    + if (self->window_id) {
    + Window xid = GDK_WINDOW_XID (GTK_WIDGET(self->window)->window);
    + long info[2] = { 0, 1 << 0 /*XEMBED_MAPPED*/ };
    + Display * dpy = GDK_WINDOW_XDISPLAY(GTK_WIDGET(self->window)->window);
    + Atom atom = XInternAtom(dpy, "_XEMBED_INFO", 1);
    + printf("Reparent %d (%p)\n", xid, dpy);
    + XChangeProperty(dpy, xid, atom, atom, 32, PropModeReplace, (unsigned char *)&info, 2);
    + XReparentWindow(dpy, xid, self->window_id, 0, 0);
    + XSync(dpy, 0);
    + XMapWindow(dpy, xid);
    + XSync(dpy, 0);
    + }
    +
    g_timeout_add(250, decay_fps, self);
    }

    @@ -390,6 +409,7 @@ usage()
    "chains. It uses GTK+ 2.0, OpenGL, and libcamunits.\n"
    "\n"
    "Options:\n"
    + " -w, --window WID Embed in window with id WID\n"
    " -c, --chain NAME Load chain from file NAME\n"
    " --no-gui Run without a GUI. If --no-gui is specified,\n"
    " then -c is required.\n"
    @@ -405,11 +425,12 @@ int main (int argc, char **argv)
    state_t * self = (state_t*) calloc (1, sizeof (state_t));
    self->use_gui = 1;

    - char *optstring = "hc:";
    + char *optstring = "hc:w:";
    int c;
    struct option long_opts[] = {
    { "help", no_argument, 0, 'h' },
    { "chain", required_argument, 0, 'c' },
    + { "window", required_argument, 0, 'w' },
    { "plugin-path", required_argument, 0, 'p' },
    { "no-gui", no_argument, 0, 'u' },
    { 0, 0, 0, 0 }
    @@ -418,6 +439,9 @@ int main (int argc, char **argv)
    while ((c = getopt_long (argc, argv, optstring, long_opts, 0)) >= 0)
    {
    switch (c) {
    + case 'w':
    + self->window_id = atoi (optarg);
    + break;
    case 'c':
    self->xml_fname = strdup (optarg);
    break;
    --
    1.7.1

  13. #13
    Join Date
    Sep 2012
    Posts
    0

    Webcan for optical alignment

    I know that this is a very late reply, but CNC Cam is a standalone application to use your webcam for CNC optical alignment.

  14. #14
    Join Date
    Jan 2005
    Posts
    1943
    Quote Originally Posted by Tim Hyde View Post
    I know that this is a very late reply, but CNC Cam is a standalone application to use your webcam for CNC optical alignment.
    A windows program is not too helpful for a linux controller.

    Here is a LinuxCNC/EMC2 webcam plugin

    camview-emc

  15. #15
    Join Date
    Sep 2012
    Posts
    0

    Linux CNC

    Yes I am willing to accept that!

  16. #16
    Join Date
    May 2014
    Posts
    4
    delete this

  17. #17
    Join Date
    May 2014
    Posts
    4

    Re: webcam edge finder?

    works in linux, insert into file "camera_edge_finder.py", then run in terminal "python camera_edge_finder.py":

    Code:
    #!/usr/bin/python
    """
    requires: python-opencv 
    
    """
    import cv2
    
    camera_number = 0 #0, 1, x..
    
    white = 255,255,255
    black = 0,0,0
    red = 0,0,255
    green = 0,255,0
    blue = 255,0,0
    
    color_line = white #lines and circles color
    
    cap = cv2.VideoCapture(camera_number)
    
    while(True):
        # Capture frame-by-frame
        ret, frame = cap.read()
    
        # Display the resulting frame
        cv2.line(frame,(0,240),(640,240),(color_line),1)
        cv2.line(frame,(320,0),(320,480),(color_line),1)
        cv2.circle(frame,(320,240), 10, (color_line), 1)
        cv2.circle(frame,(320,240), 30, (color_line), 1)
        cv2.circle(frame,(320,240), 50, (color_line), 1)
        cv2.circle(frame,(320,240), 70, (color_line), 1)
        cv2.circle(frame,(320,240), 90, (color_line), 1)
        cv2.circle(frame,(320,240), 110, (color_line), 1)
        cv2.circle(frame,(320,240), 130, (color_line), 1)
        cv2.circle(frame,(320,240), 150, (color_line), 1)
        cv2.circle(frame,(320,240), 170, (color_line), 1)
        cv2.circle(frame,(320,240), 190, (color_line), 1)
        cv2.circle(frame,(320,240), 210, (color_line), 1)
    
        cv2.rectangle(frame,(0,450),(80,480),(0,0,0),-1)
        font = cv2.FONT_HERSHEY_SIMPLEX
        cv2.putText(frame,'[q]uit',(10,470), font, 0.7,(255,255,255),1)
        #cv2.putText(frame,'[q]uit    [a]circle+ [z]circle-    [c]olor',(10,470), font, 0.7,(255,255,255),1)
    
        cv2.imshow('frame', frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
        if cv2.waitKey(1) & 0xFF == ord('c'):
            color_line = 0,255,0
    
    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

Similar Threads

  1. My DIY Edge Finder
    By multiplex in forum DIY CNC Router Table Machines
    Replies: 40
    Last Post: 05-25-2010, 05:46 PM
  2. Edge Finder
    By slamman in forum WoodWorking Topics
    Replies: 6
    Last Post: 05-17-2010, 07:15 AM
  3. Edge Finder
    By Ashish B in forum CNC Machining Centers
    Replies: 14
    Last Post: 09-13-2009, 09:51 AM
  4. Edge finder
    By eggo in forum Australia, New Zealand Club House
    Replies: 3
    Last Post: 08-04-2008, 04:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •