Camera Control #76
-
|
Dear all, I try to use MfPack for a little apllication with a Web Cam and would like to control some camera function like autofocus on / off and focus setting. I wanted to use IID_IAMCameraControl : TGUID = '{C6E13370-30AC-11d0-A18C-00A0C9118956}'; because I found with DirectShowCaptureCapabilities-x64.exe from https://alax.info/blog/1531 that my camera supports this interface. But with QueryInterface I get allsways the result $80004002 means E_NOINTERFACE, no such interface supported. Is there a function in your source code what allows to use the interface CameraControl where I can learn out of it how to use it properly? Regards Harals Redelberger |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
|
Hello, Harals. IAMCameraControl is a DirectShow interface. To expose the Media Foundation interfaces it's essential to install the correct camera driver (Windows Driver Model (WDM) ) for Windows 10 and 11. See here. MfPack has a sample SimpleVideoCapture see here to show you the basics about capturing from a camera. This example shows you how to use IMFMediaSource and IMFVideoDisplayControl. Remember these are low-level interfaces, but also the most flexible ones. Other options like the IMFCameraControlDefaults interface gives you more control over your camera see here Here is a sample code to accomplish on what -I think- you want: // Add WinApi.StrmIf to uses clause.
function TMfCaptureEngine.GetCameraSettings(): HRESULT;
var
hr: HRESULT;
mfSource: IMFMediaSource;
amCameraControl: IAMCameraControl;
amVidProcAmp: IAMVideoProcAmp;
rMin: LONG;
rMax: LONG;
rDelta: LONG;
rDeflt: LONG;
cflag: CameraControlFlags;
vflag: VideoProcAmpFlags;
begin
mfSource := m_pSource; // Defined in private section.
if (mfSource <> nil) then
begin
try
// Control the 'camera'.
amCameraControl := mfSource as IAMCameraControl;
if Assigned(amCameraControl) then
begin
hr := amCameraControl.GetRange(LONG(CameraControl_Exposure),
rMin,
rMax,
rDelta,
rDeflt,
LONG(cflag));
// Add to public section of your class.
// MfDeviceCapture.CameraController := amCameraControl;
end;
// Control the 'video'.
amVidProcAmp := mfSource as IAMVideoProcAmp;
if Assigned(amVidProcAmp) then
begin
hr := amVidProcAmp.GetRange(VideoProcAmp_Contrast,
rMin,
rMax,
rDelta,
rDeflt,
LONG(vflag));
// Add to public section of your class.
// MfDeviceCapture.VideoController := amVidProcAmp;
end;
except
on E: Exception do
begin
// Let user know an error has been occured.
// ShowErrorMessage();
end;
end;
end;
end;
Maybe this information will help you further. |
Beta Was this translation helpful? Give feedback.
-
|
Ok, I created MfSimpleCapture Sample 2, where both interfaces are implemented. I hope this will help you further on, |
Beta Was this translation helpful? Give feedback.

Ok, I created MfSimpleCapture Sample 2, where both interfaces are implemented.
Please note that depending on your camera drivers or capabillities some settings could be unsupported.
I hope this will help you further on,
Regards Tony.