AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

WebCAm not starting

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

WebCAm not starting

Postby dhelawat » Tue Mar 17, 2015 4:29 pm

Hello,

I am using windows 8 in laptop and my application is using Aforge for webcam in my application.But now problem is one front camera is working fine but back camera not starting when I switch the camera. I have lenova thinkpad.

Default webcam app of tablet is working fine.

Can you help me with the issue.

Using below code:

private void OnStartVideo()
{
CameraNotInitialized = _videoDevices.Count == 0;

if (CameraNotInitialized)
return;

_videoSource = new VideoCaptureDevice(_videoDevices[_activeDeviceIndex].MonikerString);

_videoSource.NewFrame += VideoNewFrame;
_videoSource.Start();

StopCamera.RaiseCanExecuteChanged();
}

private void OnSwitchCamera()
{
if (_videoDevices.Count > 1)
{
_activeDeviceIndex = _activeDeviceIndex == 0 ? 1 : 0;
}
else
_activeDeviceIndex = 0;

if (_videoSource == null) return;

if (_videoSource.IsRunning)
_videoSource.Stop();

UserSettings.DefaultCameraIndex = _activeDeviceIndex;
UserSettings.Save();

OnStartVideo();
}

Thanks
Anand
dhelawat
 
Posts: 11
Joined: Mon Feb 02, 2015 3:14 pm



Return to AForge.NET Framework