|
|
#1 |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
[Vb.Net] WebCam Class (ICam)
Ok I Wrote this class to get to grips with the .NET enviroment so the coding may not be the best but it works. I've also attatached a project which uses the class its all simple enough
The class will make it easy for your app to view a webcamera set FPS etc. Ok the class, First 3 variables which can be changed within the class are, Code:
Private CamFrameRate As Integer = 15
Private OutputHeight As Integer = 240
Private OutputWidth As Integer = 360
CamFrameRate - Starting frame rate how much of a gap there is between frames 15ms (About 65 FPS) NOTE - You can changes the FPS through a sub this is just the initial frame rate. OutputHeight/OutputWidth - Fairly self explanitory, just sets the dimensions of output. VB Code:
This can be called at anytime and will return if the camera is running or not VB Code:
How To Use The Class VB Code:
From here you can call a range of functions using the syntax, VB Code:
Functions initCam(ByVal parentH As Integer) - This is where it all starts you must call this to set the camera up first ParentH is where we want to prievew, so if we have a pictureBox on our form, named picoutput. VB Code:
resetCam() - If you need to reset the camera call this function, you most proberly wont but its here incase you do VB Code:
setFrameRate(ByVal iRate As Long) - Here you can set the frame rate by passing FPS it will then be converted into how much time between frames. VB Code:
closeCam() - Allways call when closing the application, just clears things up. VB Code:
copyFrame(ByVal src As PictureBox, ByVal rect As RectangleF) - This sub returns an image of the current frame. You need to pass to it the source picture box (Where the camera image is) and then a rectangle specifying size dimensions. VB Code:
FPS() - This sub returns the current FPS VB Code:
As I say code may not be great but it works good, and i just hope sompeople may find it useful. I'd appriciate people not replying here but Pm'ing me with any problems since i'd like to keep this thread as clean as possible! Pino
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files Last edited by Hack; Jan 13th, 2006 at 09:00 AM. |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Jun 05
Posts: 24
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Is there a motion detection function included?..
|
|
|
|
|
|
#3 | |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Quote:
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files |
|
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
![]() ![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
OK, this is my conversion, it's in 2005. The only difference I think is the Running property as 2003 doesn't support Public and Friend property with the same name.
VB Code:
VB Code:
VB Code:
The logging I hope to seperate into a seperate class that deals soley with logging. ANyways, have a play, tell me where I have gone wrong. Woof
__________________
My .NET Tutorials: • Silverlight Enabled WebPart in WSS My VB.NET Code Examples: • Create IIS Virtual Directory • Validate Login Against Active Directory • Automatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET My ASP.NET Code Examples: • Login To Website (Forms Authentication) • Login To Website (Custom Authentication) My VB6 Code Projects: • Multithreading In VB6 • Custom Tooltips • Multi Language Support • Item Selector Control • Annimated Systray Icon • Simple Effective Graph Control • Download From Web • LiveUpdate, download application updates from the web automatically • Systray Notification Messages • Skin A Form • API Timer • Badger Messenger, an MSN clone that uses the MSN Network • Wokawidgets VB6 Component Suite |
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 06
Posts: 9
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Hi,
I changed WebCamViewer to get the real frame rate using the CallBack function and I get about 6 frames per second. Can you really have a 25 frames/s ? |
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
![]() ![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
What did u change? Pino's vb6 version, or my .NET conversion?
Woof
__________________
My .NET Tutorials: • Silverlight Enabled WebPart in WSS My VB.NET Code Examples: • Create IIS Virtual Directory • Validate Login Against Active Directory • Automatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET My ASP.NET Code Examples: • Login To Website (Forms Authentication) • Login To Website (Custom Authentication) My VB6 Code Projects: • Multithreading In VB6 • Custom Tooltips • Multi Language Support • Item Selector Control • Annimated Systray Icon • Simple Effective Graph Control • Download From Web • LiveUpdate, download application updates from the web automatically • Systray Notification Messages • Skin A Form • API Timer • Badger Messenger, an MSN clone that uses the MSN Network • Wokawidgets VB6 Component Suite |
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 06
Posts: 9
![]() |
Re: [Vb.Net] WebCam Class (ICam)
I changed .Net code.
|
|
|
|
|
|
#8 |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Woka!
My Code was .net! My code was .Net 2003 wokas is .net 2005
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files |
|
|
|
|
|
#9 |
|
Member
Join Date: Jul 06
Location: Taiwan
Posts: 37
![]() |
Re: [Vb.Net] WebCam Class (ICam)
are these code applicable to all webcam ?
i'm using logitech quickcam express woka's code consist of WebCamLib ? what is it ? i got an error when debugging |
|
|
|
|
|
#10 |
|
New Member
Join Date: Jan 07
Posts: 2
![]() |
Re: [Vb.Net] WebCam Class (ICam)
If another application is using the web cam and we start our application, a selection device window apears, what can I do to not see this window? (sorry for my english, is not perfect) I been waiting for a solution for this problem for like two weeks, can someone help me?
|
|
|
|
|
|
#11 |
|
New Member
Join Date: Apr 06
Posts: 9
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Hi,
I get the solution, after a long an hard job ! See VB.NET sources here : http://edid.free.fr/shared/webcam/index.php Solution is in the registry database. Last edited by edid; Jan 11th, 2007 at 05:57 AM. |
|
|
|
|
|
#12 |
|
Super Moderator
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
![]() ![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Nice code...just looking at it now.
Although he's used the VisualBasic namespace I believe, and the code in certain places is a little left to be desired Could really do with going through and tidying all the lose ends etc.I actually cannot get it to work either...but am still working on that. Woka
__________________
My .NET Tutorials: • Silverlight Enabled WebPart in WSS My VB.NET Code Examples: • Create IIS Virtual Directory • Validate Login Against Active Directory • Automatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET My ASP.NET Code Examples: • Login To Website (Forms Authentication) • Login To Website (Custom Authentication) My VB6 Code Projects: • Multithreading In VB6 • Custom Tooltips • Multi Language Support • Item Selector Control • Annimated Systray Icon • Simple Effective Graph Control • Download From Web • LiveUpdate, download application updates from the web automatically • Systray Notification Messages • Skin A Form • API Timer • Badger Messenger, an MSN clone that uses the MSN Network • Wokawidgets VB6 Component Suite |
|
|
|
|
|
#13 |
|
New Member
Join Date: Apr 06
Posts: 9
![]() |
Re: [Vb.Net] WebCam Class (ICam)
I'll be happy you give me advices.
|
|
|
|
|
|
#14 |
|
Super Moderator
Join Date: Nov 01
Location: Headingly Occupation: Classified
Posts: 9,589
![]() ![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Well remove the VisualBasic reference from the project.
Then slowly convert the code to "proper" .NET, ie: VB Code:
VB Code:
Others include: VB Code:
VB Code:
VB Code:
VB Code:
The code itself isn't the neatest. Poor error handling, poor variable naming and the code construction isn't the best. An example of this would be: VB Code:
VB Code:
Will take a few hours to convert completely, and then a few more to iron out all the bugs. Hope that helps. WOka
__________________
My .NET Tutorials: • Silverlight Enabled WebPart in WSS My VB.NET Code Examples: • Create IIS Virtual Directory • Validate Login Against Active Directory • Automatically retrieve Identity field value from inserted DataRow using SQL Server and ADO.NET My ASP.NET Code Examples: • Login To Website (Forms Authentication) • Login To Website (Custom Authentication) My VB6 Code Projects: • Multithreading In VB6 • Custom Tooltips • Multi Language Support • Item Selector Control • Annimated Systray Icon • Simple Effective Graph Control • Download From Web • LiveUpdate, download application updates from the web automatically • Systray Notification Messages • Skin A Form • API Timer • Badger Messenger, an MSN clone that uses the MSN Network • Wokawidgets VB6 Component Suite |
|
|
|
|
|
#15 |
|
New Member
Join Date: Aug 07
Posts: 1
![]() |
Re: [Vb.Net] WebCam Class (ICam)
I want to save each 10 Sekonds a new picture.
In the following function i don´t know how I can pass the new picture form the cam to bmp. The bmp.Save function is running correctly, I already tested it. Private Sub Save() Me.Show() Dim myCam As New iCam Dim i As Integer = 0 Dim numerOfPicture As String Dim bmp As Bitmap numerOfPicture = i.ToString bmp = '**********this line is the problem********** bmp.Save("C:\Pictures\Picture" + numerOfPicture + ".bmp") i = i + 1 Me.Close() End Sub I tried to use the origin code by change it a little, but I got a big Problem. The following changes work correctly if I click the button every 10 Sekonds. Now the problem: If I let the Button click by software, in the pictureBox is no longer the picture but a part of the desktop which is seen right behind the pictureBox. Private myCam As iCam Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.picOutput.SizeMode = PictureBoxSizeMode.StretchImage myCam = New iCam myCam.initCam(Me.picOutput.Handle.ToInt32) End Sub Private Sub cmdViewStill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdViewStill.Click If myCam.iRunning Then Dim a As FrmImage a = New FrmImage a.picImage.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _ Me.picOutput.Width, Me.picOutput.Height)) Me.Show() Else MessageBox.Show("Camera Is Not Running!") End If End Sub Now I want to save the picture: Private Sub Save() Me.Show() Dim myCam As New iCam Dim i As Integer = 0 Dim numerOfPicture As String Dim bmp As Bitmap numerOfPicture = i.ToString bmp = CType(picImage.Image, Bitmap) bmp.Save("C:\Pictures\Picture" + numerOfPicture + ".bmp") i = i + 1 Me.Close() End Sub and this works If I click the button who is starting Save(), but If I let the Button click by software, in the pictureBox is no longer the picture but a part of the desktop which is seen right behind the pictureBox. So I thought don´t use a button but a funtion wich starts without a button to take a picture every 10 Sekonds. -> The same result:In the pictureBox is the desktop which is seen right behind the pictureBox. -> And in the file it is also. Could somebody show me a line of code with wich I can save the taken picture of the cam directly in a bitmap. Then I could simply save the bitmap. That means to replace these 2 lines: a.picImage.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _ Me.picOutput.Width, Me.picOutput.Height)) in something like: Dim bmp as Bitmap bmp = '*****here should the cam pass one picture to bmp so I can save bmp direktly***** I would be obliged if somebody could help me. I use WinXP and VisualBasic Express |
|
|
|
|
|
#16 |
|
New Member
Join Date: Oct 07
Posts: 4
![]() |
Re: [Vb.Net] WebCam Class (ICam)
I downloaded the original source for VS2003 Framework 1.1 and it appeared to work fine. I wanted to use the 2005 Framework 2.0 copy that Wokawidget posted though. I put it into VS2005 and it compiled without errors. I can start and stop the webcam (the green light goes on and off) however the ImageChanged event never seems to fire even when the cam is on (I put logging in that event in the class to verify it... I also kept tabs on the _Picture variable and it doesn't appear to have anything, like the system isn't returning it).
I know the class is talking to the web cam somewhat because it will turn it on and off, but I can't see to pull the images from it. Thoughts? Here's the example code from my form that's trying to use the class: vb Code:
|
|
|
|
|
|
#17 |
|
New Member
Join Date: Dec 06
Location: Cornwall, England
Posts: 1
![]() |
Re: [Vb.Net] WebCam Class (ICam)
thanks for this code its ace.
One little problem i have found, im using VS 2008 and have managed to get an application to work on my laptop which opens up a 348x270 capture window, enables to user to press "Take Photo" and save. Perfect yeah... Well now ive tried transferring the application it to another PC i only get half of the picture box showing (capture frame) and the other half is the form behind coming through, as if the window isnt redrawing corrrectly so you dont get a proper image being viewed let alone saved? Does that make sense?Any suggestions? Last edited by gonkowonko; Jan 22nd, 2008 at 10:13 AM. |
|
|
|
|
|
#18 |
|
New Member
Join Date: Feb 07
Posts: 14
![]() |
Hello,
This code is amazingI as wondering if there would be a way to add effects to the webcam stream. Like black and white, filters etc. Let me know. Thanks, Adam. |
|
|
|
|
|
#19 |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
I'm not too sure if you can add any affects to the stream. I'll have a look into it if I get a few minutes!
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files |
|
|
|
|
|
#20 |
|
New Member
Join Date: Jan 08
Posts: 1
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Thanks for the great code.
I am trying to modify the code so that I can capture the image not just with a button, but also when the user presses the button on the webcam. Any suggestions? Thanks, Didius |
|
|
|
|
|
#21 |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Didius,
Thanks! As for your question, I'm not too sure that would involve looking at the hardware you are using. Thanks
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files |
|
|
|
|
|
#22 |
|
Member
Join Date: Nov 07
Posts: 58
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Ok ... i managed to capture images from webcam ... but I need to send those images to another computer ... like an livestream ... how can I do that ?
|
|
|
|
|
|
#23 |
|
New Member
Join Date: Apr 08
Posts: 1
![]() |
Re: [Vb.Net] WebCam Class (ICam)
I took the time to register for the forum just so that I could properly thank pino for this code. it was precisely what I need for a project I'm working on. this was after trying several others that didn't work or didn't work well. thanks!
|
|
|
|
|
|
#24 | |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Quote:
Good luck with the project! Pino
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files |
|
|
|
|
|
|
#25 |
|
Member
Join Date: Nov 07
Posts: 58
![]() |
Re: [Vb.Net] WebCam Class (ICam)
well jaguar ...
I think too the pino's code is great ... but too advanced for what I need right now ... a great code that works can be found at http://www.webtropy.com/articles/art7-2.asp ... it's easy to use too pino thanks for the code |
|
|
|
|
|
#26 | |
|
Super Moderator
Join Date: Dec 03
Location: Manchester, UK
Posts: 4,761
![]() ![]() ![]() |
Re: [Vb.Net] WebCam Class (ICam)
Quote:
Pino
__________________
Vb .Net - iCam Class : Random Numbers : iCards VB 6: Winsock(Chat Application) : Winsock(Packet Delimeters) : BitBlt : Useful Functions(23 Functions) : Basic Text Files Last edited by Pino; Apr 7th, 2008 at 04:32 AM. |
|
|
|
|
|
|
#27 |
|
New Member
Join Date: May 08
Location: Kent, England
Posts: 4
![]() |
Re: [Vb.Net] WebCam Class (ICam)
great webcam code, by far the best way of doing it in VB, I've added motion detection to it, pic below, this is my first attempt at motion detection so the code maybe very grude.
![]() I will post the source later when I've cleaned it up a little. I thought i would add the motion detection with a visual twist, you can see what motion has been picked up by the green indicator. I also added track bars which control how sensitive it is, and also the object size it responds to. Might be handy for a security thing, you can set the size to only go off to people and not a cat for example. Kind Regards, OuTa-SyNc |
|
|
|
|
|
#28 | |
|
New Member
Join Date: May 08
Posts: 5
![]() |
Quote:
Sir i was Looking for this type of application can you please post a draft here or email me perhaps. I need this for my thesis im gonna add sms features to it and post it here. please please please .....
|
|
|
|
|
|
|
#29 |
|
New Member
Join Date: May 08
Location: Kent, England
Posts: 4
![]() |
Re: [Vb.Net] WebCam Class (ICam)
here you go...full source iCam with Motion detection
ignore the commented out lines, these are for a project I'm working on. Like I said the method I used may be grude but it works...and at the same speed as the webcam. It uses 2 timers, each is set with an interval the same as the frame rate (i.e. if the cam is set to 30 FPS then the timer interval would be 33) but I changed it to 30. If anyone can improve it please post back, as I would like an optimised version myself
|
|
|
|
|
|
#30 | |
|
New Member
Join Date: May 08
Posts: 5
![]() |
Quote:
thnx so much i will be working with this.. well as i can see you used the lockbits. i saw that in c# and add me up in YM macrulz2004.. haha.. il add saving of image when motion detected plus sms sending when motion detected plus email.. i did it back in vb6,0.. thanx so much dont forget to add me. we can work with this together haha thnx
|
|
|
|
|
|
|
#31 |
|
New Member
Join Date: May 08
Location: Kent, England
Posts: 4
![]() |
Re: [Vb.Net] WebCam Class (ICam)
does anyone know how I can hide the cam picturebox and display only the output produced from the motion detection?
If I set the cam picturebox to visible = false nothing works because the camera output is not being produced, basically I want to get the frames from the camera, add my motion detection method to it and display the results in the output picturebox only. I've tried rendering over the image set in the cam picturebox but with no luck. Not sure if anyone has noticed but if you place anything in front of the picturebox with the cam running then it is treader as output produced from the cam??? Thanks in advance |
|
|
|
|
|
#32 |
|
New Member
Join Date: May 08
Posts: 5
![]() |
Re: [Vb.Net] WebCam Class (ICam)
hey since you helped me haha im helping you too here i solved the problem and added a feature where you can select the device where the program will get the image.
do re upload your webcam motion detection using my code here. i used copying from the clipboard and retrieving it.. if anyone can optimize this please do so thnx |
|
|
|
|
|
#33 |
|
New Member
Join Date: Sep 08
Posts: 1
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Hello,
a simply great class. How can I get a second camera? I'm testing it now with two cameras. Thanks. |
|
|
|
|
|
#34 |
|
New Member
Join Date: Sep 08
Posts: 1
![]() |
hi every body this class is a develop on icam
and can capture image with no problem even when the window is minimized no problem .with time adding .auto capturing and ......
|
|
|
|
|
|
#35 |
|
New Member
Join Date: Sep 08
Posts: 2
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Hi guys
If I was to use this class without using a picturebox to show the webcam feed all the time but rather initiate the camera and then when buttons are clicked grab a picture then how would I go about doing that? I can only initiate the camera with a handle to a picturebox as of now |
|
|
|
|
|
#36 |
|
New Member
Join Date: Sep 08
Posts: 2
![]() |
Re: [Vb.Net] WebCam Class (ICam)
Ok so I found a somewhat workable solution to my own problem.
As wrote if I placed the picturebox outside the form the GrabIt picture is black also if I make the picturebox 0,0 in size the picture would be black. So what I did was to leave the picturebox at 1,1 in size and place it somewhere on the main form where it is unnoticed and I can now GrabIt and get perfect webcam shot when buttons are clicked. |
|
|
|
|
|
#37 | |
|
New Member
Join Date: Feb 09
Posts: 1
![]() |
Quote:
Thanks, D.M |
|
|
|
|
|
|
#38 |
|
New Member
Join Date: May 08
Location: Kent, England
Posts: 4
![]() |
Re: [Vb.Net] WebCam Class (ICam)
|
|
|
|
|
|
#39 |
|
New Member
Join Date: Mar 09
Posts: 2
![]() |
Re: [Vb.Net] WebCam Class (ICam)
This is simpe webcam code. You create simple user interface with startrecord, stoprecord, and stopcam, one listbox contain webcam device.
change name of button according to name in sourcecode and you can use this code to record webcam vb.net Code:
|
|
|
|
|
|
#40 |
|
New Member
Join Date: Apr 09
Posts: 3
![]() |
Re: [Vb.Net] WebCam Class (ICam)
very nice class...
however i think this will be great if there is a record functionality.
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|