Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually focus camera in EMGU CV

I am using EMGU CV library in my application. How i can manually set camera focus to object? Now i'm using Capture class for grab images.

like image 869
SulNR Avatar asked Dec 20 '22 01:12

SulNR


1 Answers

I found the solution by using DirectShow. By IAMCameraControl interface i can control exposure and focusing of camera. Code sample:

 DsDevice[] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); // getting video devices
 IFilterGraph2 graphBuilder = new FilterGraph() as IFilterGraph2; 
 IBaseFilter capFilter = null;
 if (graphBuilder != null)
 graphBuilder.AddSourceFilterForMoniker(devs[0].Mon, null, devs[0].Name, 
    out capFilter); //getting capture filter for converting it into IAMCameraControl
 IAMCameraControl _camera = capFilter as IAMCameraControl;
 _camera.Set(CameraControlProperty.Focus, 250, CameraControlFlags.Manual); //Setting focus to macro (in my camera, range between 0 - 250)
like image 84
SulNR Avatar answered Jan 06 '23 18:01

SulNR