Page 1 of 1

USB Camera

Posted: Tue Feb 19, 2013 3:10 am
by JohnCZ
Hello,

I would like to ask, where can I change version of .Net Framework which is used by iX Developer. Becouse we have simple problem. We try to connect USB cam to TxA to capture screen of products. Here we have C# code thats work when i used in iX Developer (PC) but when we try to converted it to TxA panel there show an error thats refer to iX Developer is using old version 2.0.0.

We have .Net Framwork 4.5
Win 7 ( both version )
iX Dev SP1

Code

Code: Select all


    using System.Windows.Forms;
    using System;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
	using AForge.Video;
	using AForge.Video.DirectShow;
    
    
	public partial class Screen1 
    {
		private FilterInfoCollection VideoCaptureDevices;
		private VideoCaptureDevice FinalVideoSource;
		
		void Screen1_Opened(System.Object sender, System.EventArgs e)
		{
			VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
			
			foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
				{
				ComboBox1.Items.Add(VideoCaptureDevice.Name);
				}
			ComboBox1.SelectedIndex = 0;
			}
		
		void Button1_Click(System.Object sender, System.EventArgs e)
		{
			FinalVideoSource = new VideoCaptureDevice(VideoCaptureDevices[ComboBox1.SelectedIndex].MonikerString);	
			FinalVideoSource.NewFrame += new NewFrameEventHandler(FinalVideoSource_NewFrame);
			FinalVideoSource.Start();
		}	
		void FinalVideoSource_NewFrame(object sender, NewFrameEventArgs EventArgs)	
		{
			Bitmap image = (Bitmap)EventArgs.Frame.Clone();
			PictureBox1.Image = image;
		}
		
		void Screen1_Closed(System.Object sender, System.EventArgs e)
		{
			if(FinalVideoSource.IsRunning)
				{
				FinalVideoSource.Stop();
				}
		}
Error code when i try to converted to TxA panel

Code: Select all

Could not load file or assembly 'System.Drawing, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
It is necessary to System.Drawing, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a it set on actual version
Here i send you project.


BR
JAN

Re: USB Camera

Posted: Tue Feb 19, 2013 8:35 am
by Patrick Hall
The framework used by iX Developer (for the targeted device) is determined by the targeted device. When you change the target from PC to TxA or TxB you are targeting the .NET Compact Framework 3.5 (which is what is installed on the Windows CE 6 devices (TxA and TxB).


The PC project works on a PC because it is targeting the full framework not the compact framework. The PC has a 2.0.0.0 assembly for System.Drawing as part of the package. There are quite a few interop tricks in use in the full framework System.Drawing.

Code: Select all

// mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// kernel32.dll
// gdi32.dll
// user32.dll
// comdlg32.dll
// winspool.drv
// shell32.dll
// oleaut32.dll
// mscoree.dll
// gdiplus.dll
This list above shows all the references used by System.Drawing.dll on the full framework. In the list below you can see that only mscorlib is referenced on the CF 3.5 System.Drawing.dll

Code: Select all

// mscorlib, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac

The problem[s] you have (or will likely have) are...

1, I do not believe there is a USBVideo or WebCam driver (Source on Codeplex) built for the ARM TxA (or x86 ATOM TxB for that matter). The last time I tried to connect a Microsoft USB Webcam to my T7A I was greeted with a driver install prompt. I sent an email with several general questions and a couple of feature requests to Ron Lloyd a while back (July 14 2012) One of the items of interest was support for USB Webcam / USB Video devices via generic HID support.

2, Aforge will need to be recompiled to target the Compact Framework 3.5 to ensure that the built assemblies do not reference Full Compact framework components. In the Case of your previously posted build error "Could not load file or assembly..." this is caused by the Aforge DLL's not the Compact Framework, or iX Developer. Since Aforge was built on the full .NET runtime it is targeting a System.Drawing specific to the Full runtime, and not the stripped down System.Drawing from the CF 3.5 version.

There is no guarantee you can even rebuild the Aforge library to target the CF runtime easily (if at all). While I would certainly like to get the Web Cam functionality working too, without the webcam driver for Arm and x86 targets (see above webcam link on Codeplex) it won't matter what framework we try to use, the hardware may not work. This of course is still based on the assumption that USB Webcam's still prompt for a driver when plugged into the HMI.

Re: USB Camera

Posted: Mon Mar 04, 2013 2:30 am
by JohnCZ
Hello,

Well, we found some drivers on Win CE 6.0 that support web cam on ARM + Some other clues that suggest that it might work. We are testing it on T4A. It's not easy but we should have the results within one month.

BR
JAN