Hi all
I m new in programming i have epiphan frame grabber which is connected to my other computer to grab screen output i have downloaded SDK from epiphan in which there are few sample codes I have modified VC# code (initial code grab only one picture/screenshot but i have put the method in infinite loop to give it motion) problem is that when i call function(that grab frame) in infinite loop my application hangs and doesnt give any response. I created new thread and put that function in it now it works correctly but when when i comment following lines.
private void GrabFrame()
{
if (OpenGrabber()) {
VideoMode vm = _grabber.DetectVideoMode();
if (vm != null) {
if (vm.IsValid()) {
Frame frame = _grabber.GrabFrame();
if (frame != null) {
//trigger=_grabber.SetMaxFps(1000.0);
// _grabber.Start();
Bitmap bitmap = frame.GetBitmap();
if (bitmap != null) {
//TextOutputAdd("Frame captured (" + vm + ")");
//"Frame captured (" + vm + ")"
// TextOutput.Text = "Frame captured (" + vm + ")" + "\r\n" + TextOutput.Text;
PictureBox.Image = bitmap;
} else {
// TextOutputAdd("Capture format error");");//(display message in text box)
//SetGrabber(null);
}
} else {
//TextOutputAdd("Capture failed");");//(display message in text box)
//SetGrabber(null);
}
} else {
//TextOutputAdd("No signal detected");");//(display message in text box)
}
} else {
//TextOutputAdd("Failed to detect video mode");//(display message in text box)
// SetGrabber(null);
}
}
}
But when I uncomment following lines following error appears
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control 'TextOutput' accessed from a thread other than the thread it was created on.
Code for button that run thread
private void th_instance() {
for (; ; )
{ GrabFrame();
}}
private void CaptureFrame_Click(object sender, EventArgs e)
{
//=====================================================
th1 = new Thread(new ThreadStart(th_instance));
th1.Start();
}
i will highly appreciate if somebody could guide me to solve issue and provide me best solution
regards
VulpesPosted Jun 11, 2012, 2:40 PM
As they don't appear to have a specialist forum, I'd get in touch with their support team:
http://www.epiphan.com/products/frame-grabbers/?gclid=CL-_-ZfqxrACFU4lfAodp3HsWA
zaman soomroPosted Jun 8, 2012, 4:13 PM
thanks for kind help I have solved it my other way I removed text box and display messages in same picture box however I m confused and need help actully i have modified sample code original code just capture only one frame i modified it to give motion using infinite loop and threading if you see entire code there are tow function listed blow for setting max frame per second and start grabbing when i chage the value of setmaxfps(); funtion like 30,300 or 1000 there is no effect in motion of frame i need you help in this regards
//trigger=_grabber.SetMaxFps(1000.0);
// _grabber.Start();
thanks
VulpesPosted Jun 8, 2012, 5:57 AM
If you want to do this synchronously rather than asynchronously, then replace BeginInvoke with Invoke, though I thought that the former might be more appropriate here.