|
-
Jun 1st, 2004, 09:57 AM
#1
Thread Starter
New Member
Video streaming, image capture, connectivity issues...
Hello,
I've done extensive searching both on this forum and others, and am happy to say most of the problems I've had with an application I'm building have been solved thanks to people here.
I'm developing an application that captures an image using a digital camera, with the purpose of the image being used on a security badge. The application is being developed in VB .Net, and I am using DirectShow (quartz.dll) as my method for streaming video data to my application, from a web camera or digital camera that has the functionality of a web camera (meaning, it can be connected to the computer and has some mode for video conferencing).
Just as a side note, I am not developing a video conferencing application, I am merely using tools normally used by video conferencing applications to handle the video streaming to the application. Also, the image capture side is not an issue, as that is working just fine in my application.
As for my problem...when the camera I am using (the camera type/model does not appear to matter) is not connected to the computer, the following procedure will throw an HRESULT return with the hex code for "VFW_E_NO_CAPTURE_HARDWARE", meaning the hardware is malfunctioning or isn't connected.
This is DirectShow code:
Code:
Dim filter As IRegFilterInfo
Dim testGraph As FilgraphManager
Dim testRegFilters As Object
Dim fSrc As IFilterInfo
Try
testGraph = New FilgraphManager
testRegFilters = testGraph.RegFilterCollection
For Each filter In testRegFilters
If filter.Name = gFilter Then
filter.Filter(fSrc)
Exit For
End If
Next
Return True
Catch ex as Exception
'Error handling...
Return False
End Try
"gFilter" is a string variable that holds the name of the 'filter' for the camera source. Essentially this is a string that identifies the camera to attempt to connect to.
As should happen when the camera is not connected, the error is thrown on the line: "filter.Filter(fSrc)", a method that attempts to fill the object "fSrc" with the information based on the chosen filter. That's all fine an dandy, I *want* it to throw an error when the camera isn't connected, but again, that's not the key issue.
The code above is part of a simple test function I run to determine if the camera is connected. If it returns a false (thanks to Try...Catch...) then I know the camera's not connected, and if it returns a true I know I'm good to go and can continue running the app.
My problem is this: If the function returns a false I let the application continue to an error page that tells the user to connect the camera. Then, if the camera is properly connected to the computer, and the function above is run *again*, it will still fail and return the HRSEULT as if the camera was not connected. The only way I can make the app accept the fact that the camera is connected is if I completely exit the application, and start it up again (upon where it will acknowledge that the camera is connected, and proceed to work just fine).
My assumption is that the running of the .Filter method leaves some kind of an 'attempted connection' alive in the system that I can't figure out how to kill. I've experimented with running the above test function on its own Thread object, and then setting the Thread object to Nothing and then to a New Thread in an effort to isolate the connection testing process, but I'm not too good with threading in .Net so I'm not certain I'm doing it right.
If anyone has any suggestions, please let me know and you have my sincerest thanks in advance.
Daniel Gow.
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
|