I'm using aforge in winforms for video recording. I wanna to record video both (front and back camera) in window tablet. I have able to find list of Video Capture Device but not identify which is front or rear camera.
Name space whose I use:
using AForge.Video;
using AForge.Video.DirectShow;
I have sawed you my finding video capture device snippet of code:
public VideoCaptureDevice cam = null;
public FilterInfoCollection usbCams;
...
usbCams = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (usbCams.Count == 1)
{
cam = new VideoCaptureDevice(usbCams[0].MonikerString);
}
else if (usbCams.Count == 2)
{
cam = new VideoCaptureDevice(usbCams[1].MonikerString);
}
cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
cam.Start();
...
private void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
ImgContainer.Image = bitmap;
}
I have tested in different devices like iball and lenovo yoga 8. I have found one reason is that in Iball tablet return first front camera name and second rear camera but in lenovo tablet return first rear camera and second front camera. I have total confused. How to identify front and rear camera?
A hack is to check the capabilities and set the camera with the highest resolution as back camera. If there is a difference in quality than the back camera is usually the better one.
This won't work always, for example the Surface Pro 1 has 2 cameras with the same resolution.