|
-
Oct 26th, 2010, 10:54 AM
#1
Thread Starter
Member
[Resolved] Webcam(have code) -> Picturebox
First let me start with the fact that I am a hack of a programmer. I did some VB6 back in the day, I do PHP, but now I am using 2010. I am making a simple application to help me list some odd-ball stuff on ebay. (This takes a pictures of the item from the webcam for me.
So I have this code to start and it works well:
Code:
' This code is (c) 2009 Microsoft Corporation, written by Lucian Wischik.
' It is released under the Microsoft Public License, http://www.microsoft.com/opensource/licenses.mspx#Ms-PL
Public Class Form1
' Note: WebCamLib.dll is x86 only, so we need to build this app for x86 architecture.
Dim Touchless1 As New TouchlessLib.TouchlessMgr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Eliminate flicker on repaint:
SetStyle(ControlStyles.UserPaint, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
' Set up the webcam to fire an event when it captures a frame:
If Touchless1.Cameras.Count = 0 Then MessageBox.Show("This application needs a webcam") : Return
Touchless1.CurrentCamera = Touchless1.Cameras.First
AddHandler Touchless1.CurrentCamera.OnImageCaptured, AddressOf Form1_Capture
' Give the user an opportunity to tweak the camera settings:
'Touchless1.CurrentCamera.ShowPropertiesDialog(Me.Handle)
End Sub
Private Sub Form1_Capture()
' This event runs in a worker thread owned by Touchless. We want to handle the event
' in the main UI thread, so we use BeginInvoke. Note: this is still fine even if the
' form has been disposed before our invoke ends up happening.
Me.BeginInvoke(New EventHandler(AddressOf Me.Invalidate))
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim b = Touchless1.CurrentCamera.GetCurrentImage
If b IsNot Nothing Then e.Graphics.DrawImage(b, 0, 0, Width, Height)
End Sub
End Class
Ok, so I want the capture to be running in a PictureBox, I guess it's currently "painting" on the background of the form. I want to be able to save the image capture from the picture box to a file, preferably a PNG file. I also want to be able to crop the picture before saving, possibly right from the live capture? I think that's something I could start looking into once I have this thing is a damn picture box. Should you be so kind as to help with the code to save the image, I should ask that it's saved without a dialog box, the program will assign it's location and name via other information on the form. If it could be a function, that would be best.
I am going to have it that you click a button for what you are taking a picture of and it saves accordingly (Item 001, Front|Back|Box...) Item number will be the folder and the view will be the file name, but I can do all this myself, just trying to explain why I want the save function to be the way I do.
Last edited by intellilogic; Oct 28th, 2010 at 06:23 PM.
Reason: Resolved
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|