×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    No front camera snapshot on N96

    Hi,
    my app requirement was to take snapshots from front camera, recognize useless (too dark or monochrome) images and save them into jpeg format.
    I've succesfully accomplished it on all tested device except N96... so i'm searching a reason for it... i always have a totally black image of around 9 KB....

    CCamera::ImageReady() is called with aError==KErrNone; inside this method i perform a duplication:

    Code:
    iBitmapSave->Reset();
    TInt err = iBitmapSave->Duplicate( aBitmap->Handle() );
    and err == 0

    then i call my jpeg encoding method:

    Code:
    /*
     * Returns a buffer with encoded jpeg image
     */
    HBufC8* CFrontCameraApp::GetImageBufferL(CFbsBitmap* aBitmap)
    	{
    		if (aBitmap == NULL)
    			return HBufC8::NewL(0); 
    
    		// set jpeg properties
    		CFrameImageData* frameImageData = CFrameImageData::NewL();
    		CleanupStack::PushL(frameImageData);
    		TJpegImageData* imageData = new (ELeave) TJpegImageData();
    		imageData->iSampleScheme  = TJpegImageData::EColor444;
    		imageData->iQualityFactor = 75; //  set 90 for normal or 100 for high 
    		frameImageData->AppendImageData(imageData);
    				
    		// convert to jpeg synchronously
    		HBufC8* imageBuf = NULL;
    		CImageEncoder* encoder  = CImageEncoder::DataNewL(imageBuf,_L8("image/jpeg"),CImageEncoder::EOptionAlwaysThread);
    		CleanupStack::PushL(encoder);
    		TRequestStatus aStatus = KErrNone; 
    		encoder->Convert( &aStatus, *aBitmap, frameImageData );
    		User::WaitForRequest( aStatus );
    		CleanupStack::PopAndDestroy(encoder);
    				
    		CleanupStack::PopAndDestroy(frameImageData);
    		
    		return imageBuf;
    	}
    but i don't think the problem is in the jpeg conversion, because i used the same function to convert screenshots and it was (it is in fact) working fine in N96 too... but maybe screenshots and snapshot are taken into different memory areas?

    and native camera app on N96 is taking nice snapshots in jpeg format with front camera

    thank you for any hint,
    regards,
    pg

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,567

    Re: No front camera snapshot on N96

    You could draw the image on the screen, just to see what it contains.
    Also search for N96 in the Wiki, there are some known issues about this device, and they are actually related to the camera.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: No front camera snapshot on N96

    Quote Originally Posted by wizard_hu_ View Post
    You could draw the image on the screen, just to see what it contains.
    yep, i'll try this one, because i'm not finding any solution...

    Quote Originally Posted by wizard_hu_ View Post
    Also search for N96 in the Wiki, there are some known issues about this device, and they are actually related to the camera.
    thnx, i already did it, but i don't use any of the advanced features or settings, requirements are very simple and i didn't want to use additional wrapper if not strictly necessary....

    i'll post the solution, if i ever find it....

  4. #4
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: No front camera snapshot on N96

    This is driving me crazy.... :-)
    I've modified a HelloWorld code and added the camera part, just to focus on snapshots only.
    Everything works fine on E72 and other devices i have for test, but not on N96.
    I'm focusing on the basics:

    iCamera = CCamera::NewL(*this,1);
    ...
    iCamera->CameraInfo(iInfo);
    iFormat = ImageFormatMax();
    where

    CCamera::TFormat CFrontCameraEngine::ImageFormatMax() const
    {
    if ( iInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor16M )
    {
    return CCamera::EFormatFbsBitmapColor16M;
    }
    else if ( iInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor64K)
    {
    return CCamera::EFormatFbsBitmapColor64K;
    }
    else
    {
    return CCamera::EFormatFbsBitmapColor4K;
    }
    }

    then i retrieve the smallest supported size:
    iSizeIndex = 0;
    for(TInt i = (iInfo.iNumImageSizesSupported-1);i>=0;i--)
    //for (TInt i=0; i< iInfo.iNumImageSizesSupported; i++)
    {
    TSize supportedSize;
    iCamera->EnumerateCaptureSizes(supportedSize, i, iFormat);
    if(supportedSize.iHeight!=0)
    {
    iSizeIndex = i;
    break;
    }
    }
    and the usual part:

    iCamera->Reserve();
    ...
    iCamera->PowerOn();
    ...
    TRAPD(err,iCamera->PrepareImageCaptureL(iFormat,iSizeIndex));
    ...
    iCamera->CaptureImage();

    void CFrontCameraEngine::ImageReady(CFbsBitmap *aBitmap, HBufC8 *aData, TInt aError)
    {
    if(aError == KErrNone)
    {
    iBitmapSave->Reset();
    TInt err = iBitmapSave->Duplicate( aBitmap->Handle() );
    if(err != KErrNone)
    {
    iCamera->PowerOff();
    iCamera->Release();
    }

    iEncoder = CImageEncoder::FileNewL(iFs, _L("C:\\provasnapshot.jpg"),_L8("image/jpeg"),CImageEncoder::EOptionAlwaysThread);
    iEncoder->Convert( &iStatus, *iBitmapSave);
    SetActive();
    }
    }
    there's no error or leaving anywhere....
    even into last call to RunL, that shows status equal to zero....
    but the saved jpeg is totally black on N96
    same totally black image using N96 rear/primary camera

    i'm stucked, two FP2 devices working opposite....

    i've tried to draw the snaphot as per wizard_hu suggestion, using code from Nokia example, but nothing is drawed to screen...

    any suggestion is welcomed
    thank you
    pg

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

    Re: No front camera snapshot on N96

    Just to make sure: those ...-s are asynchronous, are not they?
    Also, you could make a test with the "official" Camera example (Resources above, Code examples, Symbian C++, Multimedia). The older versions are supposed to be available too, without that magical wrapper API.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: No front camera snapshot on N96

    Quote Originally Posted by wizard_hu_ View Post
    Just to make sure: those ...-s are asynchronous, are not they?
    yes! i'm just too lazy to transcript all the xxComplete() callbacks...
    and this time, just to keep everything as plain as possible, also the Convert method is left asynchronous...

    Quote Originally Posted by wizard_hu_ View Post
    Also, you could make a test with the "official" Camera example (Resources above, Code examples, Symbian C++, Multimedia). The older versions are supposed to be available too, without that magical wrapper API.
    yep! my code is derived from the older example
    unfortunately it doesn't compile... this evening i'll do everything to compile it, even if i'm not too optimist about the final result....
    i'm wondering what's inside that magical wrapper... :-)

    thnx!

  7. #7
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: No front camera snapshot on N96

    Quote Originally Posted by pavarang View Post
    yep! my code is derived from the older example
    unfortunately it doesn't compile... this evening i'll do everything to compile it, even if i'm not too optimist about the final result....
    ok...
    i've tried the provided sis of this one:
    http://wiki.forum.nokia.com/index.ph...3rd_Ed_FP2.zip
    but the app doesn't even start, "feature not supported", i'll try to delete autofocus part...
    and then the camera wrapper (with the second version/update of the wrapper) example sis: i can take one snapshot, then everything freezes....
    that's weird, 'cause people on forum isn't having all these problems with N96...

    Quote Originally Posted by pavarang View Post
    i'm wondering what's inside that magical wrapper... :-)
    is this the source code?
    https://projects.developer.nokia.com...rapper/browser

  8. #8
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: No front camera snapshot on N96

    ok, i've found at last....
    on N96, and maybe on other devices, who knows?, it seems mandatory to call

    iCamera->PrepareImageCaptureL(iFormat,iSizeIndex)
    iCamera->StartViewFinderBitmapsL( iLandscapeSize );
    instead of
    iCamera->PrepareImageCaptureL(iFormat,iSizeIndex)
    iCamera->CaptureImage();
    then, in the callback, i wrote:

    void CFrontCameraEngine::ViewFinderFrameReady(CFbsBitmap &aFrame)
    {
    iCamera->StopViewFinder();
    iCamera->CaptureImage();
    }
    et voila', it ended up with the jpg file

    now, the question is:
    WHY??????????????????????????

    why is N96 working like this and not like the other devices? or viceversa...

    thnx
    pg

Similar Threads

  1. taking snapshot using front side camera
    By jahid_hossain in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2010-10-10, 16:30
  2. front camera not working on N70
    By galaktico in forum Python
    Replies: 7
    Last Post: 2010-04-30, 16:51
  3. Front camera on N78
    By fibrahim in forum Python
    Replies: 7
    Last Post: 2009-01-14, 14:17
  4. Rear/front camera on 6680
    By mberionne in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2007-12-05, 17:23
  5. Camera snapshot on 3250
    By stefanosanna in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2006-05-04, 14:31

Posting Permissions

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