Using the camera autofocus feature in Symbian
Article Metadata
Tested with
Compatibility
S60 3rd Edition, Feature Pack 1
S60 3rd Edition, Feature Pack 2
S60 5th Edition
Article
S60 3rd Edition FP2 and S60 5th Edition: CCameraAdvancedSettings
Contents |
Overview
Some S60 3rd Edition and newer devices support the camera autofocus feature. There are also methods available to use the autofocus in third-party applications. Autofocus is not officially supported in the S60 SDK before S60 5th Edition and there were different solutions introduced for earlier releases. However, now there is a unified interface available that can be used in all Nokia's S60 devices supporting autofocus.
NEW! Using a Nokia Developer CameraWrapper for expanded compatibility (recommended)
To provide developers an easy-to-use interface for camera functions, Nokia Developer has developed a CameraWrapper. The wrapper provides a unified interface for various Symbian and S60 camera APIs, some of which have previously been Feature Pack specific or only available via an SDK plug-in. The supported features include autofocus, digital zoom, flash, and exposure modes. The wrapper supports all Nokia's S60 devices based on S60 3rd Edition and newer platform versions.
The wrapper provides two header files, armv5 and winscw libraries, and a signed installation package for Nokia's S60 devices. Note that while you can build for winscw, you cannot test the wrapper on an S60 SDK emulator as it does not support camera.
The CameraWrapper is published as part of the S60 Platform: Camera Example v3.0 where its usage is demonstrated.
Using the Feature Pack specific APIs
NOTE: Usage of these APIs is not recommended anymore because the CameraWrapper now provides an easier way to access camera functions in different S60 releases.
Using autofocus on S60 3rd Edition, FP2 and newer devices
Autofocus can be controlled via the CCamera::CCameraAdvancedSettings class, which is part of the Symbian Onboard Camera (CCamera) API. In the S60 5th Edition SDK for Symbian OS v0.9 it is defined in ecamadvsettings.h. This class is not part of the S60 3rd Edition, FP2 SDK for Symbian OS v1.1 but you can get it from the SDK API plug-in for the S60 3rd Edition SDK for Symbian OS, for C++, supporting Feature Pack 2 (in version 1.2). Note that the header file name (ecamadvancedsettings.h) and its dependencies somewhat differ from the corresponding file in S60 5th Edition.
Note also that camera hardware used in S60 devices does not support all the functionality defined in CCameraAdvancedSettings. The API provides functions for querying supported settings for each advanced camera feature.
For further information on the usage, see the article Archived:Symbian Onboard Camera Advanced Settings API.
Example application: File:S60 Camera Example AutoFocus 3rd Ed FP2.zip
At least the following S60 3rd Edition, FP2 and newer devices support autofocus: Nokia 5800 XpressMusic, Nokia 6210 Navigator, Nokia 6220 Classic, Nokia N78.
Note: The key event codes and other features of the camera implementations may vary between devices. While supporting most S60 3rd Edition, FP2 devices, the current version of the example application does not yet support Nokia N79 and N96.
Note: When building the example application on the S60 5th Edition SDK, remember to modify the #include's to match the different header file name (ecamadvsettings.h instead of ecamadvancedsettings.h).
Compared to Nokia Developer CameraWrapper, the CCameraAdvancedSettings provides more features. However, you can still use the CameraWrapper as it also provides access to the CCameraAdvancedSettings instance.
Using autofocus on S60 3rd Edition and S60 3rd Edition, FP1 devices
Autofocus was not part of the S60 3rd Edition, FP1 SDK, but it was provided as a plug-in library, included in the S60 Platform: Camera Example with Autofocus Support available on the Nokia Developer website.
Note that because the autofocus implementation has changed in S60 3rd Edition, FP2, there is a binary compatibility break between S60 3rd Edition, FP1 and S60 3rd Edition, FP2. Note that with the introduction of the Nokia Developer CameraWrapper, the use of this plug-in library is not recommended anymore.
Further information on the usage: CS000954 - Implementing autofocus functionality (S60 3rd Edition, pre-FP2)
Archived:Symbian C++ AutoFocus API may return incorrect focus range in S60 3rd Edition (Known Issue)
Example application: S60 Platform: Camera Example with Autofocus Support
The following S60 3rd Edition and S60 3rd Edition, FP1 devices support autofocus: Nokia E66, Nokia E71, Nokia E90 Communicator, Nokia N73, Nokia N82, Nokia N93, Nokia N93i, Nokia N95, Nokia N95-3 NAM, and Nokia N95 8GB.


I have tried compiling the All-In-One example for FPI but could not compile as required header file "CCAMAUTOFOCUS.H" is no more accessible(it was part the older example I guess and it is no more downloadable).I need this header for setting the focus mode. I have the extention API for FP2 so could compile for that. Perhaps those headers also need to be put in this example.
-Pradeep
Bug when releasing the camera
There's a bug in CameraWrapper (version 1.00, 1.10) when calling
Camera status
is returning to
while it's actually
There was a clumsy solution in the Camera Example 3.0 [1] that was deleting the whole camera engine, but if you take into account doing that on every losing/gaining foreground, it's not acceptable. The workaround would include storing the local status as the class member
So when releasing the camera you will have to set the status manually
Remember to reset it after calling constructor
After initializing camera functionality
if (iState == CCameraEngine::EEngineNotReady) { //will finish in MceoCameraReady TRAP(err, iCameraWrapper->ReserveAndPowerOn()); } else if (iState == CCameraEngine::EEngineIdle) { //will finish in MceoViewFinderFrameReady TRAP(err, iCameraWrapper->StartViewFinderL(iViewFinderSize)); } iState = iCameraWrapper->State(); if (err) HandleError(err);Or any other function that's supposed to change the state (like focusing)
Then In the callbacks from the camera engine
void CCameraWrapper::MceoCameraReady() { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoFocusComplete() { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoCapturedDataReady( TDesC8* aData ) { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoCapturedBitmapReady( CFbsBitmap* aBitmap ) { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoViewFinderFrameReady( CFbsBitmap& aFrame ) { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoHandleError( TCameraEngineError aErrorType, TInt aError ) { iState = iCameraWrapper->State(); //... } void CCameraWrapper::MceoHandleOtherEvent( const TECAMEvent& /*aEvent*/ ) { //I'm not actually sure if setting a state here will not spoil the whole workaround //iState = iCameraWrapper->State(); //... }...and after a bit of debugging I realized that errors from autofocus might arrive even after releasing the camera. Then it's better to ignore them as they don't bring much value here.
void CCameraWrapper::MceoHandleError( TCameraEngineError aErrorType, TInt aError ) { if (aErrorType != EErrReserve && aErrorType != EErrPowerOn && aErrorType != EErrViewFinderReady) //ignore errors from autofocus return; iState = iCameraWrapper->State(); //... }Thank you for this tip. We will evaluate it and contribute to the example application.
Seppo, Forum Nokia