Machsupport Forum

Mach Discussion => Mach SDK plugin questions and answers. => Finished Plugins for Download => Topic started by: Klaus1311 on April 07, 2009, 03:36:14 AM

Title: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 07, 2009, 03:36:14 AM
Hi all,

a member in the German forum had performance problems with the video plugin supplied with mach3, the CPU consumption was 100%. For test reasons I wrote a small program for the webcam to test the performance of his computer, my program had only about 80% CPU consumption. The next step was to write a plugin, it is named webcam.dll. This plugin is written with visual studio 2008. You can download the selfextracting file from: http://www.kd-dietz.de


regards
Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 07, 2009, 06:23:48 AM
Klaus

That plugin works great.  Well done.

If I can be cheeky and ask if you can make the window resizable.   :D

Using a webcam for job setup usually means we must jog about while monitoring the webcam.

Your window stays on top which is essential,  now if only we could reduce it's size so as to have more room for better access to Mach controls while still seeing the cross hairs.

Perhaps an option to hide the control panel also.

Not asking much hey.   ;D ;D

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 07, 2009, 07:28:25 AM
Klaus

I discovered on your site the MachScreen screen design program.

WOW  I never knew it existed.

Have not had a chance to give it a good try out yet but I will.

Why don't you make a post in the screens forum about it.

http://www.machsupport.com/forum/index.php/board,17.0.html

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 07, 2009, 07:33:03 AM
Hi Greg,

I changed the dialogbox to sizable. Now you can change the size of the video window and also the size of the Dialogbox. This gives you the opportunity to hide the controls and set the the visual part of the video window with the crosshair to the size you want.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 07, 2009, 08:24:28 AM
Hey that's great Klaus.

Now can it remember the size when opened?  :D

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: ger21 on April 07, 2009, 11:30:35 AM
Very cool Screen Designer. :)
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 07, 2009, 12:07:22 PM
Hi

thanks for your praise. Plugin version V1.05 is available. The size of the dialogbox and the size of the video-window will be stored at exiting the dialog via button "close" and icon "close".

Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: poppabear on April 07, 2009, 12:23:31 PM
Klaus,

    Very nice Job on your Screen designer!!

But:   could you fix a few things?

1).  Can you put a way to "Z" layer the Bitmaps?, for example I have a Bitmap image that has Labels on top of it, when I import a screen into your designer the Labels disappear behind the Bitmap.  
2).  Most of all of your DROS show up as a Black box, sometimes you can see the "number" formatting in the DRO sometimes just the black box.
3). Can you implement "Horizontal Sliders", as well as Vertical Sliders.
4). I noticed when you go to add a OEM object, lets say the X position DRO, that the dropdown nameing list you can set to X Position DRO OEM, but you then have to go and put the Code for that DRO "800" in the code line below it.  On the OEM stuff, if your users pick lets say an OEM object then the code for the name of that object should automatically appear in the code line below it. This would save having users have to search of OEM codes for the objects that you have already listed the names.
5). "Help"  The help file will not come up on my comp.  I am running Vista 64 bit (unfortunatly, but had no choice).

Wish List:

1). Is there a way you could add "Dynamic" scaling to the entire screen and all objects on the screen??  I.e. if you click a cornor to resize the Runtime screen that that screen and all objects in it will rescale both horizontally and Vertically to the size you change it to.

2). I like the "Red dotted" screen boarder lines you put into the screen, can you make a button or dialog that you could set the Extends of the screen you are building so that, the Red boarder lines would show on all screens?  You would then know exactly how far you could place objects on the bottom and right side for the screen resolution you have choosen.

3).  Is there a way that you could tie "buttons" (User and OEM), to other objects in Mach3"  For instance if LED 1201 came on, or some DRO was this or that value, then the button that is watching that event would Trigger.

Scott

Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 07, 2009, 01:00:17 PM
Hi Scott

before we go off topic, I will open a new thread for my "machscreen" under mach screen. If this is the wrong discussion please move it.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 07, 2009, 07:30:09 PM
Tried the latest version that remembers the window size.   

Thanks very much Klaus.  I have been wanting exactly this for ages.

The other video apps available try to do too many things, too many bells and whistles (for me) and are not resizable.  Take up too much screen space.

This one is perfect.  :)

Greg

EDIT:  The Mach Video Window app runs my CPU at about 25% ......  Klaus' video app runs it at about 5%
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 08, 2009, 04:11:25 AM
Using the video plugin in a real situation did not prove so good.

The resize function reduces the video window from the bottom right corner. 

As it is reduced the crosshair moves to stay in the middle of the remaining visible video window.

So in other words the crosshairs move in relation to the centre of the camera/spindle. Not good.

It needs to reduce the video frame from all sides equally so that the crosshair stays static in relation to the camera position.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 08, 2009, 06:25:47 AM
Hi Greg

in version V1.06 you can configure the behaviour under config plugins. You have the option to keep the crosshair on its place, or the crosshair stays centered in the video window, in dependence of the video window size.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 08, 2009, 06:32:33 AM
Klaus

I have a situation where a setting has become "stuck"

Tried reinstalling the plugin but that did not fix it.

Where does it store its setup info between sessions.

Looked in the XML and it does not appear to be there.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 08, 2009, 06:37:51 AM
Hi Greg

all settings are stored in the registry. You find it HKEY_CURRENT_USER\Software\KD-Soft\PluginWebCam.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 08, 2009, 06:52:06 AM
Can I simply delete those entries from the rgistry and  Webcam will reenter them?

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 08, 2009, 06:56:02 AM
yes

Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 08, 2009, 07:37:50 AM
As far as the window resize we are half way there.

Now the cross hairs remain static with the camera but we can still only reduce size from one direction.

As shown in the pics.  One at full screen and the other at reduced window.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Ron Ginger on April 08, 2009, 12:17:24 PM
Can the camera plugin be modified so we can adjust the crosshairs to an adjustable center? As it is we must mke a mechanical adjustment to get eh camera exactly centered on the axis of the spindle. If the crosshair was adjustable we could do it in software and make a much more accurate adjustment.

thanks
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 08, 2009, 02:50:22 PM
Hi


@Greg,
you are right, it is only possible to re size the way you want, only from bottom right. Due to my performance approach, I don't see a simple way, to get it the way you want.


@Ron
you can set the offset from the camera to your spindle in the config menu. After positioning is done, clicking the button "calc offset" the machine will move to the set edge.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: poppabear on April 09, 2009, 02:35:57 PM
Klaus,

   Mabey look at your dc and see how your doing your screen child dc cooridinate system.......

Mabey you can do a child dc offset, to a "zero" position for the center of what ever the child window extends is
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 12, 2009, 04:05:52 AM
Unfortunately I have had to abandon this video plugin and go back to the one provided with Mach.

I really liked the small size window and especially the fine cross hair line.  Mach's is a larger window and about three pixel wide cross hair line. Too fat.

However Klaus's dominates the USB.  I jog by keyboard and Shuttle Pro and the plugin makes them both erratic and unpredictable for small movements.

I don't suppose anything can be done to fix that?

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 13, 2009, 07:26:07 AM
Hi Greg,

a few questions:
do you have your jogging devices on the same USB-hub as the camera?
what kind of USB are using USB 1 or USB 2?
can you adjust the bandwidth for the camera? When you start settings, you probably get a dialog where you can set many parameters within the camera driver, at least  mine does.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: RICH on April 13, 2009, 08:35:01 AM
Hi Greg and Klaus,
I liked the plug in Klaus provided with the features provided, but,........
I found it didn't work with CopyCAT and the XBOX for reasons you have mentioned.
Maybe i was doing something wrong.
RICH
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 13, 2009, 08:24:24 PM

do you have your jogging devices on the same USB-hub as the camera?

what kind of USB are using USB 1 or USB 2?

I have four USB 2.0 on the Motheboard and a PCI card with four USB2.0.

Keyboard, mouse, shuttle pro and USB stick when needed, on the MoB

Camera all on it's own on the PCI card

Quote
can you adjust the bandwidth for the camera? When you start settings, you probably get a dialog where you can set many parameters within the camera driver, at least  mine does.


Yes I can adjust the bandwidth on the settings, which brings up a a dialogue box that belongs to the camera driver I presume.

It was on auto (6) and I took it down to 1

If it made any difference at all, I could not tell.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 14, 2009, 06:48:17 AM
Hi Greg

I don't suppose the problem you are having is an USB problem. Perhaps you can give me some more details, how is the problem look like?




Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 14, 2009, 07:10:13 AM
It is like the keyboard only gets to send info every half second.

If I tap an arrow key to jog, sometimes nothing happens, on release of the key jogging will sometimes continue for half a second.

This only happens when your video plugin is running.

Does not happen when the standard Mach video is running.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 14, 2009, 09:54:21 AM
Hi Greg,

as you can see on my homepage, I first made a standalone webcam program. The minmum framerate was 20ms. To get the same framerate with the plugin I used the windows timer. At the moment my machine isn't ready yet, so I can't test the plugin in motion. In the new version V1.07 I removed the use of the windows timer. This means, the minimum framerate is now 100ms. This is for test reasons only, I want to find out, wether I'm on the right track. It would be nice, if you'd give me a feedback.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 14, 2009, 07:33:07 PM
Klaus

No it is still the same with the V1.07

Another clue you may be able to see without a machine is when dragging the video window by the
mouse (USB) to position it on screen the motion is visually jerky.

Not much, but noticeable compared to dragging the Mach standard video window.

If it would help I could make a small movie of the jogging with and without video plugin running.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on April 15, 2009, 04:55:18 AM
Hi Greg,

the installation routine is changed. To me, it looks like a performance problem. In version V1.08 I changed the handling mode to view the datastream.

To get the same test-conditions, you have I'd like to know:
what version of Mach3 are using
what is your processor speed
how much RAM do you have
what display adapter and how much Video-RAM are you using

Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on April 15, 2009, 06:15:22 AM
Klaus

what version of Mach3 are using   Version R3.042.026

what is your processor speed   Core2 CPU 6400 @ 2.13GHz

how much RAM do you have   1GB ram

what display adapter and how much Video-RAM are you using  NVIDIA GeForce 7300 GS    512MB Ram

Tried V 1.08 and it is the same but I think I am getting used to it.  :)   It is hard to quantify or explain the effect.

The best way to see it is drag the video widow around the screen and see the jerkiness.  As opposed to dragging the mach video window around which is smooth.

Also when pressing an onscreen button (zeroing a DRO for example) you can see a very slight delay that is not there at other times.   I am sorry I can not be more concise.

Really do like your video better, as there is no delay to showing the axis movemment on camera.  S'pose that is the price you pay.  :D

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on May 20, 2009, 02:22:15 PM
Hi Greg

I 've rebuilt the plugin, actual version is V2.00. Perhaps you can have a look at it and tell me your experience.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on May 21, 2009, 02:55:33 AM
Klaus

Sorry to say this one seems less stable than the previous versions.

Cross hairs flicker on and off.

Settings will not come up.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on May 21, 2009, 03:06:48 AM
Hi Greg

OK, in that case I have to finish my machine first, for testing.



Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on May 21, 2009, 03:18:08 AM
Klaus

Yes get your machine finished.

Not sure it will help with debugging this software but you will have more fun playing with it.  ;D

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: lelelodi on May 22, 2009, 09:28:38 AM
Hi Klaus, thank you for your plugin, really well done and useful.
Can you do a version without the blue bar on top ( the bar of the operating system) and around the window ?
I ask fot his improvement because if i can resize the video window at the sane size of the toolpath window i can use a button to recall the webcam that it's shown directly at the same place of the toolpath. With anoter button i can turn off and have it again the toolpath.
What do you think about this ?
Thank you

Lele
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on May 24, 2009, 08:17:32 AM
Hi

obviously this plugin works on some machines. For that reason I decided to make yet another version. I optimized the timing and added the possibility to switch off the system menu. Please keep in mind, when the system menu is switched off, you cannot move the window, you have to use the resizing ability instead.



Klaus

Title: Re: Webcam plugin with low CPU consumption
Post by: lelelodi on May 24, 2009, 09:46:00 AM
Hi Klaus, thank you for the reply, but i don't undertand if this new version it's yet online or not.

Thank you again for your good job.

Lele
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on May 24, 2009, 11:07:53 AM
Hi Lele,

meanwhile I released V2.00.3 ready for download from http://www.kd-dietz.de.  Enabled the "settings" option again and inserted a debug mode (reporting errors)




Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: lelelodi on May 24, 2009, 11:42:24 AM
Thank you very much

Lele
Title: Re: Webcam plugin with low CPU consumption
Post by: lelelodi on May 24, 2009, 12:05:48 PM
Wow, work very well ! Thank you.
Now the last question  ;D.
I use a button to open your plugin ( command Sendkeys("PM") ), but i can't figure how i can close your plugin with a VBScript. Can you help me again ?
Because i resize your wonderful plugin to stay exactly in place of toolpath wiindow. I would like to close your plugin window with a button to come back to toolpath.
I will post a screencapture of my screen with your plugin open soon.

Thank you again

Best regards

Lele
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on May 25, 2009, 10:08:58 AM
Hi Lele

sorry, I can't help you with VB, my knowledge about VB is almost zero. This plugin is developed with Visual Studio 2008 and I don't want to spend to much time in try and error. When the SDK for Visual Studio 2008 is available, I may continue developing the plugin ( I have a solution in mind).  But until then we have to wait.



Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: jalessi on October 18, 2009, 10:53:43 AM
Klaus,

Is there a way to lock the screen position so it does not need to be reset every time Mach3 is closed and restarted?

Thank You

Jeff...
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on October 19, 2009, 05:50:05 AM
Hey Jeff,

I'll see what I can do.


Klaus

Title: Re: Webcam plugin with low CPU consumption
Post by: jalessi on October 19, 2009, 09:18:54 AM
Klaus,

Thank you for the fast reply.

Please keep us posted.

Jeff...
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on October 21, 2009, 07:44:25 AM
Hello

sorry, it took a bit longer, but I'm moving over to windows 7 and the first installation didn't work. I implemented the remember position and size feature in version V2.04 which can be downloaded from my website. This feature is switched on if the "remember window positions" checkbox is checked.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: jalessi on October 21, 2009, 09:22:34 AM
Klaus,

Ver 2.04 remembers its position however the cross-hairs do not center.

Thank you for your hard work,

Jeff...
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on October 21, 2009, 10:48:05 AM
Hey Jeff

if the checkbox "crosshair centered" is checked in the settings dialog and you size the camera window the crosshair should be centered. To move the camera window be sure the dialog window is greater then the video window.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: jalessi on October 21, 2009, 11:33:01 AM
Klaus,

The cross-hair will not self center with the remember position enabled.

Jeff...
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on October 23, 2009, 10:47:58 AM
Hey Jeff,

I changed the behaviour of the "center crosshair" in version 2.05.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: jalessi on October 23, 2009, 05:08:37 PM
Klaus,

Absolutely perfect, awesome work.

Thank you very much.

Jeff...
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on July 04, 2010, 10:59:49 PM
Klaus

I have been using your video plugin since you first released it here.

Have not updated for a while and have done so now.  V2.08.1

Very good to have the control separate to the main window.

However the "Remember Window Position" is not working for me anymore.

It remembers the width of the window but forgets the height.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on July 05, 2010, 06:47:40 AM
Hi Greg,

I will fix that.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Klaus1311 on July 05, 2010, 01:24:06 PM
Hi Greg,

this is problem is fixed in version V2.8.2 and can be downloaded from my site.


Klaus
Title: Re: Webcam plugin with low CPU consumption
Post by: Greolt on July 06, 2010, 06:04:26 AM
Thank you very much Klaus.

Greg
Title: Re: Webcam plugin with low CPU consumption
Post by: peu on August 09, 2010, 06:27:45 PM
Klaus, Im testing your plugin under win 7 and Im only able to open the crosshair screen, no video feed. Mach default video works ok.
To be able to see the crosshair I need to start the mach default video plugin first, otherwise camera is not detected by your plugin with a "No Camera Found" error messagebox

Is there something I can test?

my Setup:
what version of Mach3 are using 3.042.029
what is your processor speed intel quad core i5
how much RAM do you have 4gb
what display adapter  nvidia 9500gt
and how much Video-RAM are you using 512mb
Windows 7 ultimate

Thanks!!