How to use WPF to create a frame grabber
I cannot use WPF features to show a webcam video source in the output.
I don't understand which is the problem, LP does not give more feedback about "warnings".
The script here.
Thank you.
I don't understand which is the problem, LP does not give more feedback about "warnings".
The script here.
Thank you.
Comments
Your "NewFrame" event handler is throwing an exception, but because the source is an unmanaged callback, the exception goes nowhere and silently disappears.
Do you have a premium license? If so, download the latest beta of LINQPad, which has as an integrated debugger:
http://www.linqpad.net/beta.aspx
Click the blue bug ("Break when exception is thrown") and run your script. A dialog will pop up right where the exception occurs.
The cause of the error is using Application.Current which is null in LINQPad because there is no current WPF application. Instead, use Dispatcher.CurrentDispatcher - or better - the Dispatcher property of the image control itself.
To make your script work, you must also clone the image that comes back, because the image is not immutable. Also, I notice that you're struggling with a ReadLine to keep the query alive while the message loop runs. The newest beta has a Util.ReadLineAsync method which makes life easier. Even better, there's also now a Cleanup event in the LINQPad.Util class: This example uses Windows Forms. The WPF version is similar except for the conversion from Bitmap into an ImageSource:
http://share.linqpad.net/7sua3s.linq
Yes, I've the premium license and always I the latest beta using this script (that from some versions does not work) .
How can I use the ReadLineAsync to stop the acquiring without close the script?
I tried the Dispatcher.CurrentDispatcher but it does not work and I don't understand why, I use it in all WPF applications (wrapped by my package, of the old), insted control.Dispatcher is ok.
Thank you!
Do the examples that I gave work for you? Tell me what happens when you run:
http://share.linqpad.net/7sua3s.linq
I will publish the script under my LINQPad examples.
P.S. have you any idea of why my LINQPad autoupdater cannot close the LP instance from an external on-fly application, at the beginning it worked.