[Home]Axis Embed Video

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Embed Live Video to Axis

To embed live video tab into axis you need 3 things:

Most common application that supports v4l/v4l2 cameras and may be embeded is mplayer.

Example config for it would be

 EMBED_TAB_COMMAND = mplayer -wid {XID} tv://0


Another option to embed would be camutils [1] based camview-emc program. You need to add repository [2] and install camview-emc package. Note that you don't need "reparent" patch, it's already included in packages. For more info about them check [3].

Then add following lines to INI file:

 EMBED_TAB_COMMAND = camview-emc  -w {XID}

Screenshot of camview with current axis positions and crosshair placed over live image:

Axisrc code

Download this file and place code from it in your .axisrc



[1] http://code.google.com/p/camunits/

[2] http://psha.org.ru/debian/

[3] http://psha.org.ru/b/camview-emc.html


Added by Bonny

The gap in micrometer is 3 um wide and cheap webcam can be used to align even more precise.

As few people ask me to publis how I get folowing interface here is How it's done.

The system works on Ubuntu Hardy heron and EMC2 is version 2.5.0~pre (latest 2.4.x should work if patch for LOGAPPEND is applied).

So for the start we need to check if our cam is recongnized/woorking. So the right package is 'camview' and is available form web. (apt-get install camview). If cam is working then just save that configuration (from camview) to file 'camviewcfg' in EMC2 machine folder. Now we need the 'camview-emc' package (apt-get install camview-emc). Then we need to say AXIS that we want CAMERA tab and this is way how to get it.

Edit the machine INI file and add in [DISPLAY] section

EMBED_TAB_COMMAND = camview-emc -C camviewcfg -w {XID} </i> Start EMC and there should be camera window. So the next steep is to add some widgets in that window. Change the line from

EMBED_TAB_COMMAND = camview-emc -C camviewcfg -w {XID}
EMBED_TAB_COMMAND = camview-emc -C camviewcfg -g togle-caa.ui -H campins.hal -w {XID}
and download the file 'togle-caa.ui' from (zip file). The file can be created with GladeVCP? too.

And we need to make another HAL file (campins.hal in zip file) for cam support. The file should be in machine INI folder. The file has definition of pins and actions. The pins is linked to HALUI commands so we need to add that commands to the machine INI file in HALUI section. If someone has that section alreday present then should add these line to the bottom and renumber hall commands in campins.hal.

MDI_COMMAND=o<_camcenter4>call </i>
Every action just start that custom file located in PROGRAM_PREFIX folder. The files are in zip file and do folowing:

_camon.ngc When checkbox (G43H99) is checked this is executed. It moves the machine in such way to position camera in place where tool was before. The camera offset (from tool holder) is defined as Tool 99 offset in tolltable.

_camoff.ngc When checkbox (G43H99) is unchecked this is executed. It moves the machine in such way to position tool back where camera is pointing.

_camstore.ngc When SaveXYZ? is clicked the machine store current position in file and preserve last 4 coordinate as variables too. The EMC2 should be patched to have LOGAPPEND command available. (Latest version should already be patched)

_camcenter3.ngc When Center3 is clicked the last 3 saved point is used to calculate circle center. The routine isn't perfect and throw Nonsense coordinates when can't calculate it. (In most case this is when X or Y coordinates of point lie in same line.) The machine does move to the calculated center!

_camcenter4.ngc When Center4 is clicked the last 4 saved point is used to calculate center coordinate. This one is pretty stupid as just expect left-right and up-down pair and find middle position from that. The machine move here!

The sub's uses G92 offset. So If that offset is used in other way then WILL make mess. The only sub's files need to be changed.

That's all. And the big thanks to Pavel Shramov (psha)


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited March 28, 2011 10:28 pm by Psha (diff)
Published under a Creative Commons License