|
For: VB .net Express 2005 or 2008.
If have been searching the Internet and various forums for weeks now trying to figure out how to integrate live video in an application I am writing. Nothing I have read or tried seems to fit with what I am trying to do so I am going to explain my application here and hope someone may have an idea.
Application: Automated dart tournament control software to runs dart tournaments for some local taverns I work with. The software will manage all aspects of the tournament and then display on an external television the brackets and which teams are on which boards and other tournament related information. But I want this to be displayed like how espn displays some of its programs. I want a live feed from our cable box displayed in the upper right %65 of the television. I want general information scrolled on the bottom and current tournament status on the remaining left section.
I am using a video to USB adapter on the computer, which works fine in other applications and I have been able to bring it into VB Express 2008 applications with some demo code I have found. But the display in the VB application demo code is subtly choppy and in black and white. I know there has to be a better way to display live video. I just need to display, not capture or record.
Any suggestions would be wonderful. Also, I am generally new to VB coding and getting pointed toward some sample code I could study and learn from would be great. Or even better, a video control I can just drop in.
Thanks,
Ryan Schuster
|
|
|
|
|
Perhaps the input device is set to PAL in your code and is NTSC, or vice versa ?
Absenm wrote: Or even better, a video control I can just drop in.
If you mean a paid one, tvideograbber works great. If you mean a free one, perhaps search the articles on the site.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I will locate the test code I used and see PAL/NTSC. I'll recheck the articles to try to find a free video control but I didn't really see anything in my prior research. I urge others to continue to respond to this thread if you have any ideas (maybe code samples). Thanks.
Ryan
|
|
|
|
|
I have done a lot of video work, and the video feed does get a little shaky and b/w if that setting is wrong. It could be someting else, of course, but I'd look there first.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Well, I really do appreshiate your help on this. My understanding of graphics and especially videa is very limited in VB .net (truth is it is limited in general in most aspects). Below is the sample code I have been studying but I can't see where I would look to change any PAL / NTSC settings. I have seen this code (or very simular) distributed in several places so I figured it would be good to learn from. I also just try a sample app that uses DirectShowLib and I am running into the same BW / choppy situation. My device is a Video to USB adaptor model VA11A made by X10. That is pretty much all I know of the device itself. It works fine in other apps like Windows Movie Maker (which ironically usually gives me the most problems).
Thank for any further advice. In the meantime I will continue to search the net for ideas.
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Const WM_CAP As Short = &H400S
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1
Dim iDevice As Integer = 0 ' Current device ID
Dim hHwnd As Integer ' Handle to preview window
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
<MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
(ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Short, ByVal hWndParent As Integer, _
ByVal nID As Integer) As Integer
Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, _
ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _
ByVal cbVer As Integer) As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadDeviceList()
If lstDevices.Items.Count > 0 Then
btnStart.Enabled = True
lstDevices.SelectedIndex = 0
btnStart.Enabled = True
Else
lstDevices.Items.Add("No Capture Device")
btnStart.Enabled = False
End If
btnStop.Enabled = False
btnSave.Enabled = False
picCapture.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub LoadDeviceList()
Dim strName As String = Space(100)
Dim strVer As String = Space(100)
Dim bReturn As Boolean
Dim x As Integer = 0
'
' Load name of all avialable devices into the lstDevices
'
Do
'
' Get Driver name and version
'
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
'
' If there was a device add device name to the list
'
If bReturn Then lstDevices.Items.Add(strName.Trim)
x += 1
Loop Until bReturn = False
End Sub
Private Sub OpenPreviewWindow()
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
'
' Open Preview window in picturebox
'
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
480, picCapture.Handle.ToInt32, 0)
'
' Connect to device
'
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
'
'Set the preview scale
'
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
'
'Set the preview rate in milliseconds
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
'
'Start previewing the image from the camera
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
'
' Resize window to fit in picturebox
'
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, _
SWP_NOMOVE Or SWP_NOZORDER)
btnSave.Enabled = True
btnStop.Enabled = True
btnStart.Enabled = False
Else
'
' Error connecting to device close window
'
DestroyWindow(hHwnd)
btnSave.Enabled = False
End If
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
iDevice = lstDevices.SelectedIndex
OpenPreviewWindow()
End Sub
Private Sub ClosePreviewWindow()
'
' Disconnect from device
'
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
'
' close window
'
DestroyWindow(hHwnd)
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
ClosePreviewWindow()
btnSave.Enabled = False
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim data As IDataObject
Dim bmap As Image
'
' Copy image to clipboard
'
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
'
' Get image from clipboard and convert it to a bitmap
'
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
picCapture.Image = bmap
ClosePreviewWindow()
btnSave.Enabled = False
btnStop.Enabled = False
btnStart.Enabled = True
If sfdImage.ShowDialog = DialogResult.OK Then
bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Bmp)
End If
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If btnStop.Enabled Then
ClosePreviewWindow()
End If
End Sub
End Class
|
|
|
|
|
Hello
I have posted this problem few weeks back but still it's not been done so i am posting this again
i have create one small application in sql to save image and delete saved image from database it's works fine i can add new images to database and then i can also delete saved images from database but problem is when i add or delete image to database it dosent shows changes on screen i mean if there is 2 images in database and if i delete one image from database it deletes the image and it should shows that there is one image in database but it still shows 2 images in database but if i close the application and re start it then it shows one image in database i am totaly confuse please help me with this issue
i am pasting code for conn, add image and delete image
Private Function GetDBConnection()
' Compose the database file name.
' Modify this if the database is somewhere else.
Dim DBname As String = Application.StartupPath()
DBname = DBname.Substring(0, DBname.LastIndexOf("\bin"))
DBname = DBname & "\Images.mdf"
' Compose the connect string.
Dim connect_string As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & _
DBname & ";Integrated Security=True;User Instance=True"
' Open a database connection.
Dim SqlConn As New Data.SqlClient.SqlConnection(connect_string)
SqlConn.Open()
' Return the connection.
Return SqlConn
End Function
Private Sub LoadImages()
dsImage.Clear()
Try
conImage = GetDBConnection()
daImage.Fill(dsImage, "Images")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conImage.Close()
conImage.Dispose()
Call PoChng()
End Sub
Private Sub PoChng()
If Me.ImagesBindingSource.Count = 0 Then
Label1.Text = "Empty Database"
Else
Label1.Text = (Me.ImagesBindingSource.Position + 1).ToString & " Of " & _
(Me.ImagesBindingSource.Count).ToString
End If
End Sub
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
picImage.Image = Nothing
txtImageFile.Text = ""
txtTitle.Text = ""
OpenFileDialog1.ShowDialog()
Dim sFilePath As String
sFilePath = OpenFileDialog1.FileName
If sFilePath = "" Then Exit Sub
If System.IO.File.Exists(sFilePath) = False Then
Exit Sub
Else
txtImageFile.Text = sFilePath
mImageFilePath = sFilePath
End If
End Sub
Private Sub GetImage()
Dim fs As FileStream = New FileStream(mImageFilePath.ToString(), FileMode.Open)
Dim img As Byte() = New Byte(fs.Length) {}
fs.Read(img, 0, fs.Length)
fs.Close()
mImageFile = Image.FromFile(mImageFilePath.ToString())
Dim imgHeight As Integer = mImageFile.Height
Dim imgWidth As Integer = mImageFile.Width
Dim imgLength As Integer = mImageFile.PropertyItems.Length
Dim imgType As String = Path.GetExtension(mImageFilePath)
mImageFile = Nothing
' image content
Dim pic As SqlParameter = New SqlParameter("@pic", SqlDbType.Image)
pic.Value = img
commImage.Parameters.Add(pic)
' title
Dim title As SqlParameter = New SqlParameter("@title", System.Data.SqlDbType.VarChar, 50)
title.Value = txtTitle.Text.ToString()
commImage.Parameters.Add(title)
' type
Dim itype As SqlParameter = New SqlParameter("@itype", System.Data.SqlDbType.Char, 4)
itype.Value = imgType.ToString()
commImage.Parameters.Add(itype)
' height
Dim iheight As SqlParameter = New SqlParameter("@iheight", System.Data.SqlDbType.Int)
iheight.Value = imgHeight
commImage.Parameters.Add(iheight)
' width
Dim iwidth As SqlParameter = New SqlParameter("@iwidth", System.Data.SqlDbType.Int)
iwidth.Value = imgWidth
commImage.Parameters.Add(iwidth)
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'get sql connection
Try
conImage = GetDBConnection()
Dim sSQL As String = "INSERT INTO Images (Pic,Title, IType, Height, Width) VALUES(" & _
"@pic, @title, @itype, @iheight, @iwidth)"
commImage = New Data.SqlClient.SqlCommand(sSQL, conImage)
Call GetImage()
commImage.ExecuteNonQuery()
MessageBox.Show("Image successfuly saved in database", "Image Load")
Catch ex As Exception
MsgBox(ex.Message)
End Try
commImage.Dispose()
commImage = Nothing
conImage.Close()
conImage.Dispose()
Call LoadImages()
End Sub
please help
waiting for your kind rep.
have a nice day
thank you
|
|
|
|
|
Do you call the code that updates the screen when the image is deleted ? Why do you expect it to redraw itself, despite the fact it is not ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am working with VB.Net 2005 and I am looking at an Access 2003 database. What I need to do is open the database, look for a certain value (coming from text box 1) in a certain table (APCHK) and every one of them with that value replace/update with a different specified value (coming from text box 2),then close the database.
What would be the best way to do this? Thanks for any advice you can give me with this.
|
|
|
|
|
In very liberal psuedocode:
OpenDatabase()
ExecuteSQL("Update APCHK Set ColumnName = '" & TextBox2.Text & "' Where ColumnName = '" & TestBox1.Text & "'")
CloseDatabase()
Is that what you are trying to accomplish?
|
|
|
|
|
Hi,
I have a datagrid that needs to show different columns with different widths. So I use TableStyles and GridColumnStyles, no problem.
There are approximately 12 columns, three of which I need to visually jump out. So I figure I'll just make the font for these columns bold, or better yet, change the background color for these three columns only.
But there is neither a font nor a background color property in the GridColumnStyle.
Apparently I just don't know what to ask for in google, or I am the only person in the world who needs differently colored columns, because all I found was ways to change the background color and/or font of a cell / column when it is activated / clicked on / entered.
Any suggestions at all appreciated.
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
you have to do the drawing yourself by deriving from datagridtextboxcolumn and then overriding the paint-method.
i found this c#-article being helpful:
Changing the background color of cells in a DataGrid[^]
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
I owe you my gratitude !
I can't say I have it figured out completely yet, but you have certainly managed to point me in the right direction, and given me a little push to boot, thanks.
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I've inherited a large VB6 project (with zero chance of moving it to VB.NET) that I am slowly refactoring, beginning with reading the .ini files. Never mind the way it currently works, I just want to read all the section names, then within each section name, read all the keys and values.
According to the documentation on MSDN, this should be simple. The GetPrivateProfileSectionNames function should give me the section names, then GetPrivateProfileString (with a null for key-name) should give me the list of key/value pairs within the specified section. But they're not working.
When the GetPrivateProfileSectionNames wouldn't work, I tried switching to GetPrivateProfileString and passing it a null for the section name (which according to MSDN should do basically the same thing as GetPrivateProfileSectionNames). Again, no luck.
I could copy all the declarations and usages here (and will if I need to), but was hoping someone else may have experienced the same thing and already recognizes the symptoms and knows the answer.
Any help appreciated.
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
Can anyone point me to an article or example that shows how to do the following,
i have a picturebox (sizemode = zoom) inside a panel
when double clicking on the picture, it increases the size of the image by a set factor (1.2 times current size each time its double clicked),
although i can scroll to a point after doing this, i want to scroll to the same point in the image. so if the user doubleclicks on an arrow in the image, after the image is made bigger, i want the panel to scroll to where the arrow is again.
any links or help would be great
thanks
|
|
|
|
|
Not sure, but maybe the code samples here[^] will be helpful, especially the Zoom In and Out, and Fit the image in the PictureBox according to the image's true aspect ratio one.
|
|
|
|
|
unfortunately the firewall here at work doesnt allow me to download things so i cant see that code!
|
|
|
|
|
Hi
In my project for shipment i am using FedEx web service.
i get sample code project and wsdl both, i copied n took reference of wsdl it is ok
But when I run my code am getting
Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\0mjvfr_h.0.cs' could not be found
error CS2008: No inputs specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\0mjvfr_h.0.cs' could not be found
error CS2008: No inputs specified
any help from anybody
thanks in advans
ShivashankarThe Value Has Its Value Only Its Value Is Valied
|
|
|
|
|
|
Hello to everyone
I receive the following error message when trying to do some simple remoting tasks on my computer. Can anybody tell the meaning of this message and, if any, suggest a solution please?
Unhandled Exception: System.Security.SecurityException: Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level.
Pleeeease ... don't tell me to search Google (as someone did before) because I have already done so, but it didn't do any better
I also tried typeFilterLevel="Full" ... but, no difference ...
Thank you.
|
|
|
|
|
H[^] is the google search with info on your problem. You may want to read the article I link to in my sig.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi all, i need help in extracting the time and date of different files. Example .ppt files... I need to compare the time date so as to know wat file i want to delete. Thanks....
|
|
|
|
|
Do you mean date and time of created file?
If yes you can use the FileInfo
Dim fil As New IO.FileInfo("Your File Name")
MsgBox(fil.CreationTime)
Shay Noy
|
|
|
|
|
Yes almost there.. but the problem is that i need to use the creation time and date to compare with the time and date now and if the file is 4 days old i have to delete it..
|
|
|
|
|
The rest is so trivial, you really need a VB.NET book if you don't know it.
DateTime.Now is the current date/time. If you subtract one DateTime from another, you get a TimeSpan which has a days property.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the advise. I have tried the code and indeed it can show the date but it needs specific URL. What i ask to do is to look through a folder and know all the date of the files inside.. I try edit to use .directory but was unsuccessful. Any other ways that i can do?
|
|
|
|
|