Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,775 members, 7,817,174 topics. Date: Saturday, 04 May 2024 at 07:49 AM

Capture Image From Webcam And Store In Mysql Database From C Sharp Winform - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Capture Image From Webcam And Store In Mysql Database From C Sharp Winform (4655 Views)

Most Used Mysql Database Functions / ''no Row At Position 0'' When Retrieving Image From An Sql Database Using Vb.net / Sql Statement On How To Create Users In Mysql Help! (2) (3) (4)

(1) (Reply) (Go Down)

Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by ewom1028(m): 2:33pm On Jun 08, 2012
Hi all,i need help on a project i am working on that will need to capture an image from a webcam on "button click"
and store it in a MySQL database(along with other data) when the save/submit button is clicked.
The examples i got from the internet were all developed using visual studio 2005 and do not seem to work
(For whatever reason even after converting to .NET framework 4.0 using VS2010).
I am willing to show my code snippets to anyone that is willing to help.
Thanks.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by Kobojunkie: 3:00pm On Jun 08, 2012
ewom1028: Hi all,i need help on a project i am working on that will need to capture an image from a webcam on "button click"
and store it in a MySQL database(along with other data) when the save/submit button is clicked.
The examples i got from the internet were all developed using visual studio 2005 and do not seem to work
(For whatever reason even after converting to .NET framework 4.0 using VS2010).
I am willing to show my code snippets to anyone that is willing to help.
Thanks.

1) Why did you think you needed to convert to .NET 4.0 to get it working?
2) Does the code itself compile?
3) Share your code snippet so we can better help.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by ewom1028(m): 3:09pm On Jun 08, 2012
Well,when i ran the source in VS2010, it notified me that the code was targeting an older framework....NET 2.0...while i have 4.0
installed on my system.

The first issue is the code that searches for attached webcams.It always reports no video found even when
i have a webcam attached.This is the method that checks for webcams:
private bool CreateCamera()
{
bool done = false;
CollectionClass wiaDevs = null;
DeviceInfoClass devInfo = null;

try {
wiaManager = new WiaClass();

object foundID = null;
int foundCount = 0;
wiaDevs = wiaManager.Devices as CollectionClass; // call Wia.Devices to get all devices
if( wiaDevs != null )
{
foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass) Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );
Marshal.ReleaseComObject( wiaObj );
if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}
Marshal.ReleaseComObject( devInfo ); devInfo = null;
}
}
if( foundCount < 1 )
{
MessageBox.Show( this, "no WIA video devices found!", "WIA", MessageBoxButtons.OK, MessageBoxIcon.Stop );
return false;
}

if( foundCount > 1 )
foundID = System.Reflection.Missing.Value;
wiaCamera = (ItemClass) wiaManager.Create( ref foundID ); // ask user if more then one video device
done = wiaCamera != null;
return done;
}
catch( Exception ) {
MessageBox.Show( this, "Create WIA camera failed", "WIA", MessageBoxButtons.OK, MessageBoxIcon.Stop );
return false;
}
finally {
if( devInfo != null )
Marshal.ReleaseComObject( devInfo );
if( wiaDevs != null )
Marshal.ReleaseComObject( wiaDevs );
if( ! done )
{
if( wiaCamera != null )
Marshal.ReleaseComObject( wiaCamera ); wiaCamera = null;
if( wiaManager != null )
Marshal.ReleaseComObject( wiaManager ); wiaManager = null;
}
}
}
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by Kobojunkie: 3:12pm On Jun 08, 2012
Did you then install .NET 2.0 on your machine? If the code is targeting an older framework, what you need is simply install the version it is looking for. Have you done that?

1) what, if any other, libraries (third-party libraries) are you using?
2) confirm that the webcam you are working with is WIA compatible. It is quite possible that this is the reason why your program is unable to find the device.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by kadeerna: 3:22pm On Jun 08, 2012
You did not mention what OS version the program will (be) run on.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by ewom1028(m): 4:49pm On Jun 08, 2012
It is WIA compatible..cos another project i tried shows the device in a common dialog box.
And btw...when it was being converted....visual studio asked if i wanted to change the framework to 4.0
and i said yes.
Will try that though.
It will run on windows xp sp2/sp3.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by Kobojunkie: 5:24pm On Jun 08, 2012
ewom1028: It is WIA compatible..cos another project i tried shows the device in a common dialog box.
And btw...when it was being converted....visual studio asked if i wanted to change the framework to 4.0
and i said yes.
Will try that though.
It will run on windows xp sp2/sp3.

Converting the project itself should not really change much of what the API does. And installing .NET 2.0, if it is what you need, should not affect it much. I was able to get some of the bits you sent me to compile well in 4.0.

Have you tried stepping through the part of your code that is supposed to check for available devices, to see what is happening, if an exception is being thrown somewhere in there? I had tried similar on my end earlier and I did get an exception. Since you have Visual Studio 2010, why not create a test project and have it run through each unit, especially the one that retrieves the list of devices on your machine, to help figure out where there may be a fault not being caught.
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by Beaf: 6:52pm On Jun 08, 2012
ewom1028: It is WIA compatible..cos another project i tried shows the device in a common dialog box.
And btw...when it was being converted....visual studio asked if i wanted to change the framework to 4.0
and i said yes.
Will try that though.
It will run on windows xp sp2/sp3.

I very much doubt that the problem has anything to do with the framework (except if it uses deprecated code components).

One thing to look out for is if COM+ is doing things differently than COM.

If you need an easy framework to use, try OpenFrameworks:
Github - https://github.com/openframeworks/ofSite
Website - http://www.openframeworks.cc
Re: Capture Image From Webcam And Store In Mysql Database From C Sharp Winform by ewom1028(m): 9:52pm On Jun 09, 2012
Aiight...will do that

(1) (Reply)

Are There Pentesters In Nigeria? / Full-stack Developer - Full-time / Semalt Shares A Guide To Blocking And Removing Google Analytics Spam

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.