|
Hello,
I had problems with the COM CamServ too.
Firstly, i got "Access Denied" error wich i could correct. But now i have gotten a COM exception, the number error is 80040001, in microsoft.com i found out that this number means "Invalid advise flags", but that doesn't tell me anything.
The error raised in this code line:
byte[] picture = (byte[])cam.GrabFrame( nQuality );
By the way, What does nQuality do?
___________________
Leer es Saber, REEL
|
|
|
|
|
Hi,
I ' ve the same problem, My OS is Win XP SP2,
I use VS .Net 2003,
.Net Framework 1.1.
If anyone solves this prb., pls inform me...
Tnx
|
|
|
|
|
It seems I am the only one having problems.
The web service is running and I see the XML and the image base64-coded.
I don't know how to put that image on my web site.
What should I do ?
Insert and image and specify the address of the web service as source of the image ???
I wrote the URL you wrote in the client section inserting my IP but i get an empty image.
Am I missing something ??
Thanks
|
|
|
|
|
My Question: Can multiple WebCams of the same model run on a PC?
I have successfully previewed video and grabbed images from one Logitech’s QuickCam Express with the following code.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
namespace NETCaptureWindow
{
public class MainCls
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
//user variables
private Form3 CaptureWindow;
public IntPtr hWndC;
public CAPDRIVERCAPS CapDrvCaps;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
CaptureWindow = new Form3();
CaptureWindow.Show();
hWndC = AVICap.capCreateCaptureWindow("My Capture Window", AVICap.WS_CHILD|AVICap.WS_VISIBLE,
0, 0, 352, 288, CaptureWindow.Handle, 1);
AVICap.capDriverConnect(hWndC, 0);
AVICap.capPreviewRate(hWndC, 40);
AVICap.capPreview(hWndC, true);
//AVICap.capCaptureSequence(hWndC);
}
private void button2_Click(object sender, System.EventArgs e)
{
AVICap.capEditCopy(hWndC);
IDataObject iData = Clipboard.GetDataObject();
if(iData.GetDataPresent(DataFormats.Bitmap))
{
pictureBox1.Image = (Bitmap) iData.GetData(DataFormats.Bitmap);
}
}
}
public class Form3 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form3()
{
InitializeComponent();
}
}
internal class AVICap
{
public const int WS_CHILD = 0x40000000;
public const int WS_VISIBLE = 0x10000000;
public const int WM_USER = 0x0400;
public const int WM_CAP_START = WM_USER;
public const int WM_CAP_DRIVER_CONNECT = (WM_CAP_START+ 10);
public const int WM_CAP_SEQUENCE = (WM_CAP_START+ 62);
public const int WM_CAP_SET_PREVIEWRATE = (WM_CAP_START+ 52);
public const int WM_CAP_SET_PREVIEW = (WM_CAP_START+ 50);
public const int WM_CAP_DRIVER_GET_CAPS = (WM_CAP_START+ 14);
public const int WM_CAP_SET_OVERLAY = (WM_CAP_START+ 51);
public const int WM_CAP_SET_SCALE = (WM_CAP_START+ 53);
public const int WM_CAP_EDIT_COPY = (WM_CAP_START+ 30);
private const string vfwdll = "avicap32.dll";
[DllImport(vfwdll)]
public static extern bool capGetDriverDescription(int wDriverIndex, byte[] lpszName, int cbName, byte[] lpszVer, int cbVer);
[DllImport(vfwdll)]
public static extern IntPtr capCreateCaptureWindow(string lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWnd, int nID);
[DllImport("user32.dll")]
public static extern bool IsWindow(IntPtr hWnd /* handle to window*/);
//[DllImport("user32.dll")]
//public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, ref long lParam);
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, long lParam);
public static bool capDriverConnect(IntPtr hwnd, int i)
{
return ((bool)AVICapSM(hwnd, WM_CAP_DRIVER_CONNECT, (int) i, 0L));
}
public static bool capCaptureSequence(IntPtr hwnd)
{
return ((bool)AVICapSM(hwnd, WM_CAP_SEQUENCE, (int) 0, (long) 0L));
}
public static bool capPreviewRate(IntPtr hwnd, int wMS)
{
return ((bool)AVICapSM(hwnd, WM_CAP_SET_PREVIEWRATE, (int)(wMS), 0));
}
public static bool capPreview(IntPtr hwnd, bool f)
{
return ((bool)AVICapSM(hwnd, WM_CAP_SET_PREVIEW, Convert.ToInt32(f), 0L));
}
//#define capDriverGetCaps(hwnd, s, wSize) ((BOOL)AVICapSM(hwnd, WM_CAP_DRIVER_GET_CAPS, (WPARAM)(wSize), (LPARAM)(LPVOID)(LPCAPDRIVERCAPS)(s)))
public static bool capDriverGetCaps(IntPtr hwnd, CAPDRIVERCAPS s, int wSize)
{
return ((bool)AVICapSM(hwnd, WM_CAP_DRIVER_GET_CAPS, (int) wSize, Convert.ToInt64((CAPDRIVERCAPS) s)));
}
//#define capOverlay(hwnd, f) ((BOOL)AVICapSM(hwnd, WM_CAP_SET_OVERLAY, (WPARAM)(BOOL)(f), 0L))
public static bool capOverlay(IntPtr hwnd, bool f)
{
return ((bool)AVICapSM(hwnd, WM_CAP_SET_OVERLAY, Convert.ToInt32(f), 0L));
}
//#define capPreviewScale(hwnd, f) ((BOOL)AVICapSM(hwnd, WM_CAP_SET_SCALE, (WPARAM)(BOOL)f, 0L))
public static bool capPreviewScale(IntPtr hwnd, bool f)
{
return ((bool)AVICapSM(hwnd, WM_CAP_SET_SCALE, Convert.ToInt32(f), 0L));
}
//#define capEditCopy(hwnd) ((BOOL)AVICapSM(hwnd, WM_CAP_EDIT_COPY, 0, 0L))
public static bool capEditCopy(IntPtr hwnd)
{
return ((bool)AVICapSM(hwnd, WM_CAP_EDIT_COPY, 0, 0L));
}
public static bool AVICapSM(IntPtr hwnd, int m, int w, long l)
{
/*
bool iswin = IsWindow(hwnd);
int sm = SendMessage(hwnd, m, w, l);
return Convert.ToBoolean(sm);
*/
//return (IsWindow(hwnd)) ? Convert.ToBoolean(SendMessage(hwnd, Convert.ToUInt32(m), w, ref l)) : Convert.ToBoolean(0);
return (IsWindow(hwnd)) ? Convert.ToBoolean(SendMessage(hwnd, Convert.ToUInt32(m), w, l)) : Convert.ToBoolean(0);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CAPDRIVERCAPS
{
public UInt32 wDeviceIndex; // Driver index in system.ini
public Int16 fHasOverlay; // Can device overlay?
public Int16 fHasDlgVideoSource; // Has Video source dlg?
public Int16 fHasDlgVideoFormat; // Has Format dlg?
public Int16 fHasDlgVideoDisplay; // Has External out dlg?
public Int16 fCaptureInitialized; // Driver ready to capture?
public Int16 fDriverSuppliesPalettes; // Can driver make palettes?
// following always NULL on Win32.
public IntPtr hVideoIn; // Driver In channel
public IntPtr hVideoOut; // Driver Out channel
public IntPtr hVideoExtIn; // Driver Ext In channel
public IntPtr hVideoExtOut; // Driver Ext Out channel
}
}
Teh Joo Peng
|
|
|
|
|
With VFW you might have up to 10 webcams connected, and use all of them.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head Brothers.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
Dear Sir,
Thank you for reading my previous message.
First
I have connect two webcams on one PC. The OS allows two webcams to run simultaneously but the USB bandwidth limit will be exceeded.
Second
I found out that I cannot select capture device using capDriverConnect(hWndc,n) by specifying n.
Instead, I must call capDriverConnect(hWndc,0) twice. The second time I call capDriverConnect(hWndc,0), a video source dialog box with a ComboBox appeared allowing me to select the second capture device.
Also, when I enumerate installed capture device using capGetDriverDescription function, I get
Driver 0 Device Name: Microsoft WDM Image Capture (Win32)
Device Version: Version: 5.1.2600.1106
Driver 1 Device Name:
Device Version:
Driver 2 Device Name:
Device Version:
Driver 3 Device Name:
Device Version:
Driver 4 Device Name:
Device Version:
Driver 5 Device Name:
Device Version:
Driver 6 Device Name:
Device Version:
Driver 7 Device Name:
Device Version:
Driver 8 Device Name:
Device Version:
Driver 9 Device Name:
Device Version:
I later found in Windows Base Services General Technical Articles "VfW-to-WDM Video Capture Mapper on Windows 98 and Windows 2000" which says that
"...
Mapper Limitations:
There is a compatibility issue in allowing a VfW application to programmatically open a specific capture device without using the video source dialog box. However, because most VfW client applications allow a user to bring up the video source dialog, this issue has a workaround.
..."
Sir, it seems that the program is accessing VFM through WDM. And WDM does not allow programmatically opening a specific capture device.
What should I do to specify a capture device? Will it be through registry? Or Should I program using DirectShow instead? Sigh... I am stuck.
Thank you for spending your time to read this long message.
Yours sincerely,
Teh Joo Peng
|
|
|
|
|
Dear Teh Joo Peng,
Thanks for sharing your experience. I knew only according to the documentation that it was possible to have up to 10 webcams: capDriverConnect(hWndc,n). I don't really know what to recommend. I made a second version of this using DirectShow, but I am not a DirectShow expert.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head Brothers.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
I'm Just Asking Why you have to spend time to program this web cam to grab a picture from web cam when you can use the key combination of ALT+Print Screen why don't you develop program to capture movie generated by web cam
|
|
|
|
|
That's another way to see the problem. The issue with your solution is that the webcam is always allocated to your software, so no more video conference with your friend on messenger for example.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head Brothers.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
Hi all.
I've tried to run it on win xp, and it works fine, but when I try to run it on test win 2003 machine, I just keep getting ERROR GrabFrame().
I've tried everything that crossed my mind, including changing users, permissions.....
Nothing.
Any guess? Anybody?
thanks....
|
|
|
|
|
It doesn’t work on W2K3 I had the same issue and had to develop a new solution that uses DirectX – DirectShow. The source are not already available but I will certainly write an article on my site (in French) soon or later. Sorry for that.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head Brothers.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
Hi,
I got an exception when call GrabFrame(quality) function.
Do you know why?
CAMSERVERLib.Camera cam = new CAMSERVERLib.CameraClass();
return (byte[])cam.GrabFrame( nQuality ); <====== Exception right here
Vinni
Vinni
|
|
|
|
|
I got the same exception, although I registered the component.
|
|
|
|
|
I'm getting an exception also
I have tried 2 ways to run GrabFrame(nQ)
First is
CAMSERVERLib.Camera cam = new CAMSERVERLib.Camera();
byte[] picture;
picture = (byte[])cam.GrabFrame(45);
And I get Error "ERROR GrabFrame()"
CAMSERVERLib.Camera cam = new CAMSERVERLib.Camera();
byte[] picture = (byte[])cam.GrabFrame(45);
But this gives what I can only assume a variation on the same error:
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
From What I have read its possible that unhanded Code within the CAMSERVERLib is throwing the error.
HRESULT is a ref to the error in question.
Any help it trying to rectify this error would be greatly appreciated
With kind
Regards
|
|
|
|
|
Hello, i am testing the Active X Client and the Server
I notice that your Inplace ActiveX control has got a Method
which is supposed to connect to the ASP Web Service to invoke
the ComServer Image grabbing component.
A C# tester directly connect to the COMServer work fine.
Going through the Active X Client, i notice that this component
has got an IDispatch methode to invoke a call toward the services
wich is supposed to be remote. I test everything Inproc.
The Active X Method is called:
STDMETHODIMP CCamera::GrabFrame(BSTR strWebServiceURL, short nQuality)
Nethertheless, i don't know wich param have to be passed for the strWebServiceURL param.
When i test the services, by involing http://localhost/WebcamService/Service1.asmx i can see the GrabFrame method but when i invoke, i have a time out and nothing happen.
I look at the WSDL file but i don't understand well.
Should i have to build a proxy by hand and use a c# class separately rather than a web reference if i want a c# project or an ASPX to go through the WebService.
I am only a beginner in dotnet
Programming is not an end in itself but only a means to an end
|
|
|
|
|
Hey, let me say that I love your article. It's easy to follow, and is very clean.
My problem is that I'm writing a program using your WebCam dlls, and when it runs, it slowly gets bigger and bigger, and from a lack of programming experience, I don't know what's causing it. My main lump of code looks something like this....
/////////////////////////////////////// BEGIN CODE ///////////////////////////////////////
public Bitmap GrabBMP( short nQuality )
{
return (new Bitmap(new MemoryStream( (byte[])cam.GrabFrame( nQuality ))));
}
public String FNAME()
{
return (System.DateTime.Now.Month.ToString()+
System.DateTime.Now.Day.ToString()+
System.DateTime.Now.Year.ToString()+
System.DateTime.Now.Hour.ToString()+"-"+
System.DateTime.Now.Minute.ToString()+
System.DateTime.Now.Second.ToString()+
System.DateTime.Now.Millisecond.ToString());
}
private void Form1_Load(object sender, System.EventArgs e)
{
while(true)
{
GrabBMP(100).Save(("\\\\Yare\\Shared\\Caps\\"+ FNAME() +".jpg"),ImageFormat.Jpeg);
}
}
///////////////////////////////////////////////////// END CODE /////////////////////////////
And the program works, but it starts out as a whopping 15 megs in memory, and slowly climbs to 25 or 30 as it takes pictures. Any idea what's wrong with my code that's causing such a huge memory leak? Do I need to dispose of my MemoryStream or something? Any help would be greatly appreciated!
|
|
|
|
|
since .NET doesn't (shouldn't) leak.
it is either
a) .NET being useless at memory utilisation - dispose might help .NET CLR to tidy up more efficiently
b) a leak by an external non .NET object.
c) non of the above and something really strange
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Hi,
Sorry for the late answer. I did not received or saw the first email.
There could be memory leak because we use COM. I have no time right now to investigate that point but ASAP I will have a look to it.
Thanks for the feedback.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
you're welcome guessed you must have forgotten it as you usually don't - I just had a stab at a few suggestions.
The original poster could check your object for leaks by using it in a VC++ application (ie non .net) and see what happens.
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Well, if anyone has found a solution conserning the memory leak i am listening..
I dont know, but the ISampleGrabber is containing a buffer, that might be filled up as the grabs are done, perhaps this could be erased inbetween, or something, but I have not successfully found a cure yet..
|
|
|
|
|
Hi,
I found a exact copy of this article at here.
http://www.csharpfriends.com/Members/main/Tutorials/get_tutorial.aspx?tutID=108
Bizarre
Kant
|
|
|
|
|
|
Hi,
What the hell is this!!! I am fed up of all those copies.
First they copied my website, now it is my articles.
This article was realized on Tech Head on April 10, 2002, here, and here. Then on Codeproject on 14 May 2002.
If you check the copy on csharpfriends it is dated 10/25/2002 10:25:35 PM.
I am really fedup of those a**hole that stole the work of the other and claims that it is there one.
So Mr. narendra , reddy from India you are a F***ING NO BRAIN GUY . Learn technology and stop claims to know.
Best Regards,
Laurent Kempé [Microsoft .NET MVP]
Visit my web site Tech Head.
---
Old programmers never die, they just branch to a new address.
|
|
|
|
|
Very well said.
I fell sorry for you man.
Don't loose your heart, keep up with your good work.
Kant
|
|
|
|
|
Well, first of all i think that your web cam article are very good because they demonstrate know to do a smooth transition from Inplace Active X Control towards C# thanks with remote services and soap facilities (which is far from the old RPC on sun )
What i could recommend you is that you protect your code, always
Don't hesitate to contact me
Thomas
Programming is not an end in itself but only a means to an end
|
|
|
|
|