Since yesterday i am using EmguCV together with XNA. I have some experiences with OpenCV and C++. This is my first post here.
Want i want to do is getting a frame from a webcam and putting it onto a XNA texture. Here is the source:
- Code: Select all
public bool CreateCamera()
{
capture = new Capture();
if (capture != null)
{
capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 320);
capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 240);
return true;
}
else
return false;
}
public void QueryFrame(Texture2D texture)
{
// get frame and copy data to texture
Image<Bgr, Byte> image = capture.QueryFrame();
if (image != null)
{
image.Convert<Bgra, Byte>();
texture.SetData(image.Bytes);
}
}
My program always crashes in the line "texture.SetData(image.Bytes);"
What do i wrong? Or has anyone an example code for me?
