/// <summary>
/// Capture a Gray image frame
/// </summary>
/// <returns> A Gray image frame</returns>
public virtual Image <Gray, Byte> QueryGrayFrame()
{
IntPtr img = CvInvoke.cvQueryFrame(Ptr);
MIplImage iplImage = (MIplImage)Marshal.PtrToStructure(img, typeof(MIplImage));
Image <Gray, Byte> res;
if (iplImage.nChannels == 3)
{ //if the image captured is Bgr, convert it to Grayscale
res = new Image <Gray, Byte>(iplImage.width, iplImage.height);
CvInvoke.cvCvtColor(img, res.Ptr, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2GRAY);
}
else
{
res = new Image <Gray, byte>(iplImage.width, iplImage.height, iplImage.widthStep, iplImage.imageData);
}
//inplace flip the image if necessary
res._Flip(FlipType);
return(res);
}