We need to retrieve resolution of the selected camera for our project so we used CameraStreamResolution sample as reference. While that method works for retrieving the image resolution, it seems like the aspect ratio is locked at 16:9 (for example 1920 x 1080 res frame is retrieved as 1920 x 1080 but 1280 x 1024 is retrieved as 1280 x 720 etc). We realize that there are functions exists to keep the aspect ratio of the retrieved frame but since they required to be called before initialization (with predefined width and height to work), they are not usefull to us. Is it possible to get the resolution of the camera without predefining an aspect ratio and resolution?
static void GetRes()
{
var jpegSource = new JPEGVideoSource(_camera);
jpegSource.Init();
jpegSource.Height = 0;
jpegSource.Width = 0;
Console.WriteLine("Asking for the last recorded image from camera {0} ",
_camera.Name);
var jpegData = jpegSource.GetEnd(); // jpegData is locked 16:9 ratio
if (jpegData == null)
{
Console.WriteLine("No recorded image from " + _camera.Name);
}
else
{
Console.WriteLine("The resolution of the last recorded image " +
"from camera {0} is ({1},{2})" + Environment.NewLine,
_camera.Name,
jpegData.Width,
jpegData.Height);
}
}
