End Google Ads 201810 - BS.net 01 --> using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using OtherLibs;
using CxCore;


namespace oneMoreTry
{
public partial class Form1 : Form
{
private CvCapture VideoCapture;

private IplImage frame;
private IplImage imgMain;

bool capture = false;

public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
capture = true;
}

private void btnVideo_Click(object sender, EventArgs e)
{
double vidWidth, vidHeight;

VideoCapture = highgui.CvCreateCameraCapture(0);

if (btnVideo.Text.CompareTo("Start Video") == 0)
{

if (VideoCapture.ptr == IntPtr.Zero)
{
MessageBox.Show("badtrip ah!!!");
return;
}

btnVideo.Text = "Stop Video";

highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);

highgui.CvQueryFrame(ref VideoCapture);

vidWidth = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH);
vidHeight = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT);

picBoxMain.Width = (int)vidWidth;
picBoxMain.Height = (int)vidHeight;

timerGrab.Interval = 42;
timerGrab.Enabled = true;
}

else
{
btnVideo.Text = "Start Video";
timerGrab.Enabled = false;

if (VideoCapture.ptr == IntPtr.Zero)
{
highgui.CvReleaseCapture(ref VideoCapture);
VideoCapture.ptr = IntPtr.Zero;
}
}
}


private void timerGrab_Tick(object sender, EventArgs e)
{
frame = highgui.CvQueryFrame(ref VideoCapture);

if (frame.ptr == IntPtr.Zero)
{
timerGrab.Stop();
MessageBox.Show("??");
return;
}

imgMain = cxcore.CvCreateImage(cxcore.CvGetSize(ref frame),8,3);

picBoxMain.Image = highgui.ToBitmap(imgMain, false);

cxcore.CvReleaseImage(ref imgMain);
}
}
}


I have this code and when i step through the debugger to find the problem.

The problem i encounter is like this, it says that Cannot evaluate expression because a native frame is on top of the call stack.

when i break the debugger. the program stops at this point of the code. frame = highgui.CvQueryFrame(ref VideoCapture);

i dont know how to or what to revised in the code.