×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    26

    performing image processing

    Has anyone performed something similar ?
    -capture an image using phone camera
    -grab the image's data as some form of array and apply some standard perform image processing algorithms on it.
    Waiting for help

  2. #2
    Registered User
    Join Date
    May 2003
    Location
    Budapest(Hungary)
    Posts
    30
    Hi I made a "Security Cam" like app.
    It captures a few low quality images in a second, then compares every two images next to each other, and if the difference between two pics is bigger than a given value, than the Function returns true, and the App performs some action (send alarm to server, save the image etc..)
    I used CPeriodic timer to capture the imagies periodicalli, and TRgb class to get the RGB value of each, pixel in the image. Then I sumarize the Rgb values in a picture, and compare every two pictures abreast, this way. It works quite fine for me, with 6-10 fps.

    Regards Donaks

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Bristol, UK
    Posts
    19
    Hi,

    I am trying to implement an image processing library on the Series 60 platform and have been struggling with creating 2D arrays to store the image data for processing.

    If you have managed to do this would you be able to supply some source code?

    Many thanks!

    Ryan

  4. #4
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Quote Originally Posted by donaks
    Hi I made a "Security Cam" like app.
    It captures a few low quality images in a second, then compares every two images next to each other, and if the difference between two pics is bigger than a given value, than the Function returns true, and the App performs some action (send alarm to server, save the image etc..)
    I used CPeriodic timer to capture the imagies periodicalli, and TRgb class to get the RGB value of each, pixel in the image. Then I sumarize the Rgb values in a picture, and compare every two pictures abreast, this way. It works quite fine for me, with 6-10 fps.

    Regards Donaks
    hi!

    i'm also doing the motion detection which is very similar to what you did.
    I used the ThreadEngine example and modify it to snapping picture. But the system just snap the image only once. Can I get some tips from you?
    thanks!!
    God Bless!

  5. #5
    Registered User
    Join Date
    May 2003
    Location
    Budapest(Hungary)
    Posts
    30

    Re: performing image processing

    Hi I'm not familiar with the ThreadEngine example, but I don't think that you have to use threads for this kind of app, Try to use a Periodic Timer(CPeriodic) that captures images repatedly.

    Regards DonAks

  6. #6
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Quote Originally Posted by donaks
    Hi I'm not familiar with the ThreadEngine example, but I don't think that you have to use threads for this kind of app, Try to use a Periodic Timer(CPeriodic) that captures images repatedly.

    Regards DonAks
    Yeah, I used CPeriodic timer. It works in the emulator but as I install it on the phone the system hangs. I am using Nokia 3230 Series 60 2nd edition

    I used the CameraApp example in the nokia forum and modify it to snapping image every second and process the image captured.

    Do you the problem?

    Thanks for help!!
    God Bless!

  7. #7
    Registered User
    Join Date
    May 2003
    Location
    Budapest(Hungary)
    Posts
    30

    Re: performing image processing

    Hi, after every step when the current CFbsBitmap pointer is no longer used you should delete it(delete iBmp; iBmp = NULL;), but this is only one of the possible causes.
    Another problem could be the syncronization of the steps, ex.: be sure that you call CaptureImage() only when PowerOn() and ReserveCamera() completes. And of course you have to PowerOn and Reserve the camera only once at the beggining of your application.

    DonAks

  8. #8
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Quote Originally Posted by donaks
    Hi, after every step when the current CFbsBitmap pointer is no longer used you should delete it(delete iBmp; iBmp = NULL;), but this is only one of the possible causes.
    Another problem could be the syncronization of the steps, ex.: be sure that you call CaptureImage() only when PowerOn() and ReserveCamera() completes. And of course you have to PowerOn and Reserve the camera only once at the beggining of your application.

    DonAks
    This is my code:

    void CCameraCaptureEngine::DrawL()
    {
    CFbsBitGc* fbsBitGc = CFbsBitGc::NewL(); //graphic context
    CleanupStack::PushL( fbsBitGc );
    if ( iController.CameraMode() == ECameraPortraitMode )
    {
    User::LeaveIfError( iController.GetSnappedImage().
    Resize( iPortraitSize ));
    }
    else
    {
    User::LeaveIfError( iController.GetSnappedImage().
    Resize( iLandscapeSize ));
    }

    CFbsBitmapDevice* bmpDevice =
    CFbsBitmapDevice::NewL( &iController.GetSnappedImage() );
    fbsBitGc->Activate( bmpDevice );

    if ( iController.CameraMode() == ECameraPortraitMode )
    {
    TRect portraitRect = Portrait( iBitmapSave );
    //Shrink to snap image size
    fbsBitGc->DrawBitmap( TRect(iPortraitSize), iBitmapSave,
    portraitRect );
    delete bmpDevice;


    //Full color image
    CFbsBitmapDevice* bmpDeviceSave =
    CFbsBitmapDevice::NewL( iBitmapSave );
    CleanupStack::PushL( bmpDeviceSave );
    fbsBitGc->Activate( bmpDeviceSave );
    fbsBitGc->DrawBitmap( TRect(iPortraitSize), iBitmapSave,
    portraitRect );


    TSize imagesize = iBitmapSave->SizeInPixels();
    for(TInt i=0; i<imagesize.iHeight; i++) {
    for(TInt j=0; j<imagesize.iWidth; j++) {
    iBitmapSave->GetPixel(rgb, TPoint(i, j));
    r=rgb.Red();
    g=rgb.Green();
    b=rgb.Blue();

    if (counter == 0)
    {
    prev.Append((r+g+b)/3);
    }//if
    else
    {
    cur.Append((r+g+b)/3);
    diff = Abs(prev[i*j]-cur[i*j]);

    if ((i==0)&&(j==0))
    {
    prev.Reset();
    prev.Append(cur[i*j]);
    }
    else
    {
    prev.Append(cur[i*j]);
    }

    if (diff > threshold)
    {
    iController.ShowConversionStatusL(KMotionDetected);
    counter=0;
    //To be saved
    User::LeaveIfError( iBitmapSave->Resize( iPortraitSize ));
    CleanupStack::PopAndDestroy(bmpDeviceSave);//bmpDeviceSave
    CleanupStack::PopAndDestroy(fbsBitGc);//fbsBitGc;
    delete iBitmapSave;
    iBitmapSave = NULL;
    StartToSaveImage();

    }//if
    }//else
    }//for
    }//for

    counter++;
    cur.Reset();


    //To be saved
    User::LeaveIfError( iBitmapSave->Resize( iPortraitSize ));
    CleanupStack::PopAndDestroy(bmpDeviceSave);//bmpDeviceSave
    CleanupStack::PopAndDestroy(fbsBitGc);//fbsBitGc;
    delete iBitmapSave;
    iBitmapSave = NULL;
    }
    else
    {

    fbsBitGc->DrawBitmap( TRect(iLandscapeSize), iBitmapSave );
    delete bmpDevice;
    CleanupStack::PopAndDestroy(fbsBitGc);//fbsBitGc;
    // Start to save the image.
    StartToSaveImage();
    }

    }

    I think the problem here is the processing of image in the for-loop but cannot figure it out. In the emulator it is working (snapping every second) but when I insert the for-loop, the application close. Is it correct?

    Hoping for your reply...
    Last edited by pmdr05; 2007-02-20 at 06:43.
    God Bless!

  9. #9
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Need help!

    Pls!!!
    God Bless!

  10. #10
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Need your help immediately..please tell me what's wrong with my code..

    I badly need your advise..

    Thanks!!
    God Bless!

  11. #11
    Registered User
    Join Date
    May 2003
    Location
    Budapest(Hungary)
    Posts
    30

    Re: performing image processing

    HI,

    Well I'm not sure, but as I saw you delete your bitmap pointer inside the for loop where you also use it, this can cause the app to crash. Hope that helps, if not, you have to try step by step modifiing your code untill you can localize the problem.

    DonAks

  12. #12
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Quote Originally Posted by donaks
    HI,

    Well I'm not sure, but as I saw you delete your bitmap pointer inside the for loop where you also use it, this can cause the app to crash. Hope that helps, if not, you have to try step by step modifiing your code until you can localize the problem.

    DonAks
    i am not sure if i use RArray correctly. I dont have any sample codes about it. Instead of using RArray, do you think if I just store the previous image (iBitmapSave) into let's say a buffer (but i dont know how to do it)and delete the bitmap then compare every pixel in that buffer to evry pixel of the current(new) image, will it work fine? Sori, i dont have a wide knowledge on Symbian C++. This is my first time to implement such system using Symbian C++ for my academic requirement. I need to finish it by next week.

    Need you help a lot!!! Pls..
    Last edited by pmdr05; 2007-03-01 at 04:46.
    God Bless!

  13. #13
    Registered User
    Join Date
    May 2003
    Location
    Budapest(Hungary)
    Posts
    30

    Re: performing image processing

    HI,

    Well there is no need 2 RArray's, you should compare the bmp with the array on the fly there is no need for another temporary array. I mean something like this:

    //cur.Append((r+g+b)/3); //no need for this

    diff = Abs(prev[i*j]-(r+g+b)/3);

    //for the next step store the current value
    prev[i*j] = (r+g+b)/3;

    but when you fill prev for the first time you should use Append()!!! so the size of your array is set this way , in general its a better workaround to use Append() instead of []operator for value insertion, so use it carefully

  14. #14
    Registered User
    Join Date
    Jan 2007
    Location
    Philippines
    Posts
    21

    Re: performing image processing

    Hi donaks!

    Do you think i'm doing the right indexing? (prev[i*j]) If i use RArray.Append() it will be a one dimensional array. When i tried to use a counter for example numframes for the purpose of indexing (prev[numframes]) my app crashes but I think it the proper way to use as an index to access the one dimensional array not [i*j]. Am I right??

    I'm not concerned anymore with the use of array.. This is my code right now:

    CFbsBitmap* iBitmapPrev;
    CFbsBitmap* iBitmapCur;

    void CCameraCaptureEngine::ImageReady(CFbsBitmap* aBitmap,HBufC8* /*aData*/,
    TInt aError)
    {
    TInt err(KErrNone);

    if ( !aError )
    {
    iBitmapSave = aBitmap;

    //for motion detection
    if ( iController.CameraMode()==ECameraPortraitMode)
    {

    TRAP(err, HotSpotL(iBitmapSave));
    HandleError( err );

    }
    //for another mode
    else
    {
    TRAP(err, DrawL());
    HandleError( err );
    }
    }
    else
    {
    HandleError( aError );
    }


    }

    void CCameraCaptureEngine::HotSpotL(CFbsBitmap* aBitmap)
    {

    threshold=20;
    diff=0;
    r=0;
    g=0;
    b=0;

    percent = 0;

    //draw bitmap to screen, includes resizing of the image to portrait mode
    DrawL();


    if (counter>=1)
    {

    iBitmapCur = aBitmap;

    TSize imagesize = iBitmapCur->SizeInPixels();

    for(TInt i=0; i<imagesize.iHeight; i+=2) {
    for(TInt j=0; j<imagesize.iWidth; j+=2) {


    iBitmapCur->GetPixel(rgb, TPoint(i,j));
    iBitmapPrev->GetPixel(rgb2, TPoint(i,j));

    r=rgb.Red();
    g=rgb.Green();
    b=rgb.Blue();
    gray = (r+g+b)/3;

    r2=rgb2.Red();
    g2=rgb2.Green();
    b2=rgb2.Blue();
    gray2 = (r2+g2+b2)/3;
    diff = TInt(Abs(gray-gray2));

    if (diff > 20)
    {
    percent++;

    }//if


    }//for
    }//for

    if(percent>=threshold)
    {
    iController.ShowConversionStatusL(KMotionDetected);
    counter=0;

    iController.StopTimerL(); //stop timer
    StartToSaveImage(); //save the image then send
    }

    else
    {
    delete iBitmapPrev;
    iBitmapPrev=NULL;
    iBitmapPrev=aBitmap;
    }


    }//if
    else
    {
    iBitmapPrev = aBitmap;
    }

    counter++;


    }//void

    And my problem now is that the app crashes after saving the image. Do you think I'm using the right pointers?(iBitmapPrev, iBitmapCur). The idea is that the 1st image is pointed by iBitmapPrev, iBitmapCur will point to the next image then compare the bitmaps pointed to by iBitmapPrev and iBitmapCur then assign iBitmapPrev to the new bitmap..the process is repeated until a motion is detected..

    Hope u understand what I mean. Need help..

    Thanks! I'll wait for your reply..
    God Bless!

Posting Permissions

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