×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    4

    About the Camera

    Dear Administrator:

    I'm writing a program that needs to call the camera of the device to capture images, but the device(nokia 6120c) did not response after installing on it. I'm wondering if the flow to call the camera is right. Here are the codes:

    head file:
    class CCamEngine : public CBase,MCameraObserver
    {
    public: // Constructors and destructor

    /**
    * Destructor.
    */
    ~CCamEngine();

    /**
    * Two-phased constructor.
    */
    static CCamEngine* NewL(CSymbian2AppView& aView);

    /**
    * Two-phased constructor.
    */
    static CCamEngine* NewLC(CSymbian2AppView& aView);

    void Reserve();
    void HandleError(TInt aError);
    void Exit();
    void SetZoomFactorL(TBool aEnable);
    private:

    /**
    * Constructor for performing 1st stage construction
    */
    CCamEngine(CSymbian2AppView& aView);

    /**
    * EPOC default constructor for performing 2nd stage construction
    */
    void ConstructL();

    //virtual functions from MCameraObserver
    void ReserveComplete(TInt aError);
    void PowerOnComplete(TInt aError);
    void ViewFinderFrameReady(CFbsBitmap& aFrame);
    void ImageReady(CFbsBitmap* aBitmap,HBufC8* aData,TInt aError);
    void FrameBufferReady(MFrameBuffer* aFrameBuffer,TInt aError);

    private:
    TCameraInfo iInfo;
    CCamera* iCamera;
    TInt iWidth; //width of image
    TInt iHeight;//height of image
    TSize iSize; //size of image
    CSymbian2AppView* iView;
    TBool iDecodingNow;
    TInt iZoomFactor;
    CFbsBitmap* iBitmap;

    };

    Source file:
    CCamEngine::CCamEngine(CSymbian2AppView& aView)
    {
    // No implementation required
    iView=&aView;
    }


    CCamEngine::~CCamEngine()
    {
    delete iCamera;
    }

    CCamEngine* CCamEngine::NewLC(CSymbian2AppView& aView)
    {
    CCamEngine* self = new (ELeave)CCamEngine(aView);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    CCamEngine* CCamEngine::NewL(CSymbian2AppView& aView)
    {
    CCamEngine* self=CCamEngine::NewLC(aView);
    CleanupStack::Pop(); // self;
    return self;
    }

    void CCamEngine::ConstructL()
    {
    if(!CCamera::CamerasAvailable())
    {
    HandleError(KErrHardwareNotAvailable);
    return;
    }
    iCamera=CCamera::NewL(*this,0);
    iCamera->CameraInfo(iInfo);
    iSize=TSize(200,176);
    iDecodingNow=EFalse;
    iZoomFactor=NULL;
    }

    void CCamEngine::Reserve()
    {
    iCamera->Reserve();
    }

    void CCamEngine::ReserveComplete(TInt aError)
    {
    if (aError)
    {
    HandleError(aError);
    }
    else
    {
    // message("Reserved complete");
    iCamera->PowerOn();
    }
    }

    void CCamEngine::PowerOnComplete(TInt aError)
    {
    if(aError)
    {
    HandleError(aError);
    }
    else
    {
    TInt Count;

    for(Count=iInfo.iNumImageSizesSupported-1;Count>=0;Count--)
    {
    iCamera->EnumerateCaptureSizes(iSize,Count,CCamera::EFormatFbsBitmapColor16M);
    if(iSize.iHeight*iSize.iWidth>=76800)
    {
    break;
    }
    }
    iCamera->StartViewFinderBitmapsL(iSize);
    iCamera->SetExposureL();
    iView->iCamStart=ETrue;
    }
    }
    void CCamEngine::HandleError(TInt aError)
    {

    }
    void CCamEngine::Exit()
    {
    iCamera->StopViewFinder();
    iCamera->PowerOff();
    iCamera->Release();
    }
    void CCamEngine::ViewFinderFrameReady(CFbsBitmap& aFrame)
    {
    iView->DrawImageNow(&aFrame);

    if(!iDecodingNow)
    {
    //data processing
    }

    }
    void CCamEngine::ImageReady(CFbsBitmap* aBitmap,HBufC8* aData,TInt aError)
    {

    }

    void CCamEngine::FrameBufferReady(MFrameBuffer* aFrameBuffer,TInt aError)
    {

    }

    void CCamEngine::SetZoomFactorL(TBool aEnable)
    {
    // TInt bitmapCount = ECameraZoomLimit - ECameraZoom2Uid;
    if ( iInfo.iMaxZoomFactor != 0 && iInfo.iMaxZoomFactor != 1 )//both 0 and 1 indicate that
    //zoom functionality is not supported
    {
    if ( aEnable && iZoomFactor < iInfo.iMaxZoom )
    {
    iZoomFactor++;
    }
    if ( !aEnable && iZoomFactor > iInfo.iMinZoom )
    {
    iZoomFactor--;
    }
    iCamera->SetZoomFactorL( iZoomFactor );
    // return ( iInfo.iMaxZoom > bitmapCount )?KErrNotFound:iZoomFactor-1;//Zoom ind. bitmap offset
    }
    if ( iInfo.iMaxDigitalZoomFactor != 0 && iInfo.iMaxDigitalZoomFactor != 1 )
    {
    if ( aEnable && iZoomFactor < iInfo.iMaxDigitalZoom )
    {
    iZoomFactor++;
    }
    if ( !aEnable && iZoomFactor > 0 )
    {
    iZoomFactor--;
    }
    iCamera->SetDigitalZoomFactorL(iZoomFactor);

    In class appview,
    void CSymbian2AppView::ConstructL( const TRect& aRect )
    {
    // Create a window for this application view
    CreateWindowL();

    // Set the windows size
    SetRect( aRect );
    meg->message("CW");
    // Activate the window, which makes it ready to be drawn
    ActivateL();
    iCamStart=EFalse; //iCamStart is defined in head file as Tbool
    iEngine = CCamEngine::NewL(*this); //iCamStart is defined in head file as CCamEngine* iEngine
    iEngine->Reserve();


    Are there any fatal errors cause the codes can not run in the device?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    48

    Re: About the Camera

    Hi,

    Maybe you should try on device debugging with carbide, and try to pintpoint the problem by youself. You can find more info from here http://www.forum.nokia.com/info/sw.n..._1_en.pdf.html

  3. #3
    Nokia Developer Expert
    Join Date
    Dec 2003
    Posts
    148

    Re: About the Camera

    In case you are having problems in running your code you should provide more elaborated description about the problem you are having. Does the application start? Do you get an error code or leave? What is the error code? What function leaves? Does you application panic? What is the panic code? And so on...
    janza

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    4

    Re: About the Camera

    it shows in Chinese "因安全原因,无法执行文件"("for security reason, can not execute the file")

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: About the Camera

    Adding UserEnvironment capability will solve that.

Similar Threads

  1. Python for S60 1.4.0 released
    By jplauril in forum Symbian
    Replies: 43
    Last Post: 2009-05-24, 09:22
  2. Nokia N-Series Complete Model Line-Up
    By Dopod in forum General Development Questions
    Replies: 6
    Last Post: 2008-07-22, 20:16
  3. Camera API on Symbian 9.1 (Nokia N80)
    By srigans1 in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2007-10-20, 05:31
  4. embedable camera application??
    By zhengyu97 in forum Symbian
    Replies: 0
    Last Post: 2005-04-22, 11:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×