Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Hybrid View

  1. #1
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    Hi, I'm using this Example: http://www.developer.nokia.com/Commu...3rd_Ed_FP2.zip ,and I want to make it to Snap when I Start the application. Is that possible? And where in the source must I put the DoSnapL() function call?
    All I want is to start the application, taking a shot, and close it.

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    I suppose you could try making it right after in the end of AppUI's ConstructL function, though if you could explain the use case for which you are trying to achieve in more details, maybe there would be better ways on getting it done.

  3. #3
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    But it has a cancel function.
    This is After Function.
    Code:
    void CamExTimer::After(TTimeIntervalMicroSeconds32 aInterval)
    		{	
    		Cancel();
    		iInterval = aInterval;
    		iTimer.After(iStatus,aInterval);
    		SetActive();
    		}

  4. #4
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    This is the Code, but when I start the app it exits with no picture taking. Is there some errors in the script? I'v added this in Red letters.

    Code:
    void CCameraExAppUi::ConstructL()
        {
        // Try to resolve the best orientation for the app
        BaseConstructL(EAknEnableSkin|ResolveCameraOrientation());
    
        // Resolve the Media Gallery application's UID (a native app)
        iMediaGalleryUid3 = KMediaGalleryUID3PostFP1;
        
        // Create a camera controller
        iController = new (ELeave) CCameraExController(*this);
        iController->ConstructL();
          
        CAknAppUiBase::TAppUiOrientation orientation = Orientation();
        if (orientation == CAknAppUiBase::EAppUiOrientationPortrait)
            {
            iController->SetCameraOrientation(ECameraPortrait);
            }
        else
            {
            iController->SetCameraOrientation(ECameraLandscape);
            }
        iView = CCameraExView::NewLC();
        AddViewL( iView );      // transfer ownership to CAknViewAppUi
        CleanupStack::Pop(iView);
        SetDefaultViewL(*iView);
        // Make this class observe changes in foreground events
        iEikonEnv->AddForegroundObserverL( *this );
        
        // Default mode is viewfinding
        iCameraMode = EViewFinding;
    
        // If the image is still being converted, then stop going further.
       TEngineState state = iController->GetEngineState();
    
        if ( state != EEngineIdle && state != EConverted )
            return;
    
        if ( iController->IsCameraUsedByAnotherApp() )
            return;
    
        // Snap the picture and save the image into the specific location
        if ( iCameraMode == EViewFinding )
            {
            // Ensure that there is enough free space left
            if (iController->DiskSpaceBelowCriticalLevel())
              {
              HBufC* resMemoryLow = StringLoader::LoadLC(R_MEMORY_LOW);
              _LIT(KMemoryLowHdr, "");
              iEikonEnv->InfoWinL(*resMemoryLow, KMemoryLowHdr);
              CleanupStack::PopAndDestroy(resMemoryLow);
              }
            else
              {
              // In 3rd Ed. devices, play sound only if not in Meeting or Silent
              // profile
              CRepository* cRepository = CRepository::NewL(KCRUidProfileEngine);
              TInt currentProfileId;
              User::LeaveIfError(cRepository->Get(KProEngActiveProfile,currentProfileId));
              delete cRepository;
              if (currentProfileId != 1 && currentProfileId != 2)  // CSI: 47 # (1 = Meeting, 2 = Silent)
                  {
                  iController->PlaySound(ESoundIdSnap);
                  }
              iController->SnapL();
              iCameraMode = EImageSnapped;
              }
            }
        else if ( iCameraMode == EImageSnapped )
            {
            // Since the camera has taken one picture, then do the viewfinding
            // again
            DoNewImageL();
            }
        }

  5. #5
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    Basically do check your panic code for application exit: http://www.developer.nokia.com/Commu...ded_panic_code likely its crashing. Then find out what code is being executed and which parts are not.

    Also do run the original example and understand how it works. Most likely you would need to make separate Active object class which would go through the different states, and once it has finished taking the picture, then would you call exit from the code.

    Basically the ContructL would simply start the process, and not all can likely be done in there

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    The camera has an asynchronous API, there are a number of calls and callbacks which should happen prior to taking a photo. The minimal set something like Reserve the camera, then you get a notification "reservecomplete". Then you can PowerOn the camera, and get a notification "poweroncomplete", then comes a synchronous PrepareImageCaptureL and CaptureImage. And you get the image in ImageBufferReady. The example uses some more advanced API-s, but practically you can locate where it handles the "poweroncomplete" event, and put SnapL there.

  7. #7
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    This is DoCancel :
    Code:
    void CamExTimer::DoCancel()
    	{	
    		iTimer.Cancel();
    	}

  8. #8
    Nokia Developer Champion vineet.jain's Avatar
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,841
    Can you paste the complete code as at what instances you are calling Inactivity() & After(). Might be an issue of two async requests at same time or something like that.

  9. #9
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    Excuse me. KERN-EXEC 15 it gives me when I'm using Inactive function.
    Code:
    void CamExTimer::Inactivity(TTimeIntervalSeconds aSeconds)
            {	
    	Cancel();
        iTimer.Inactivity(iStatus,aSeconds);
        SetActive();
             }
    When using After() it gives me KERN-EXEC 3

  10. #10
    Nokia Developer Champion vineet.jain's Avatar
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,841
    Cancel() calls DoCancel(), is that implemented already?

  11. #11
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    Hi, I have this switch-case operator and it works fine. When I press OK key it takes a picture. I want to make it after 5 sec. to send a simulate key OK. I found some sources about that , but I don't know where to put them into the Switch operator, to make them work. This is the switch

    Code:
    TKeyResponse CCameraExAppUi::HandleKeyEventL(
      const TKeyEvent& aKeyEvent,TEventCode aType)
        {
    	
        if (!iController)
          {
          return EKeyWasNotConsumed;
          }
    
        if (iController->IsCameraUsedByAnotherApp())
          {
          return EKeyWasNotConsumed;
          }
        // handle autofocus requests
        if ( aKeyEvent.iScanCode == KStdKeyCameraFocus 
             || aKeyEvent.iScanCode == KStdKeyCameraFocus2 )
            {
            TEngineState state = iController->GetEngineState();
            if ( state != EEngineIdle && state != EFocusing )
                {
                return EKeyWasConsumed;
                }
            
            switch ( aType )
                {            
                case EEventKeyDown:
                    iController->StartFocusL();
                    break;
                case EEventKeyUp:
                    iController->FocusCancel();
                    break;
                default:
                    break;
                }
            return EKeyWasConsumed;
            }
    
        switch ( aKeyEvent.iCode )
            {
            case EKeyUpArrow:
                {
                // Increase the zoom factor if possible. It has reached the high
                // limit then it will not change.
                if ( iCameraMode == EViewFinding )
                    iController->SetZoomL( ETrue );
    
                return EKeyWasConsumed;
                }
            case EKeyDownArrow:
                {
                // Decrease the zoom factor if possible. It has reached the low
                // limit then it will not change.
                if ( iCameraMode == EViewFinding )
                   iController->SetZoomL( EFalse );
    
                return EKeyWasConsumed;
                }
               case EKeyOK: 
               case EKeyCamera:
               case KKeyCameraShutter:
               case EKeyCameraNseries2:
                {
                DoSnapL();
                return EKeyWasConsumed;
                }
            default:
                break;
            }
    
        return EKeyWasNotConsumed;
        }
    This is what I want to implement. Can I do that?

    Code:
           User::After(3000000);
    	        TWsEvent  event;
    	    	RWsSession wsSession=CCoeEnv::Static()->WsSession();
    	    	TInt id = wsSession.GetFocusWindowGroup();
    	    	event.SetType(EEventKey);
    	    	event.SetTimeNow();
    	    	event.Key()->iCode = EKeyOK;
    	    	event.Key()->iModifiers = 0;
    	    	event.Key()->iRepeats = 0;
    	    	event.Key()->iScanCode = EKeyOK;
    	    	wsSession.SendEventToWindowGroup( id, event );
    	    	wsSession.Flush();
    or this:
    Code:
    RWsSession wsSession=CCoeEnv::Static()->WsSession();
    	TKeyEvent keyEvent;
    	keyEvent.iCode = EKeyYes;  //member of TKeyCode
    	keyEvent.iScanCode = EStdKeyYes;
    	keyEvent.iModifiers = 0;
    	keyEvent.iRepeats = 0;
    	wsSession.SimulateKeyEvent(keyEvent);
    	wsSession.Flush();
    Last edited by fukatoki; 2013-02-18 at 11:01.

  12. #12
    Nokia Developer Champion pavarang's Avatar
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    577
    Simulating OK press seems a little bit overcomplicate...
    as wizard_hu_ already suggested you simply have to put DoSnapL() in the right place...
    let's suppose that you want keep the example logic, then maybe you are interested in taking the snap when the app gains focus, it's simple, it's called HandleGainingForeground(), from there you are redirected to ResetEngine(), at the end of ResetEngine, you could add a timer at 5 sec, see an example:
    http://www.developer.nokia.com/Commu...implementation
    do not call User::After at the end of ResetEngine, or your camera won't be initialized in the meantime :-)
    When timer expires, if you implement example from wiki, TimerExpired will be called and there you will put DoSnapL()

    hope it helps
    regards
    pg

  13. #13
    Registered User fukatoki's Avatar
    Join Date
    Mar 2012
    Posts
    26
    Yes, this is the whole project ftp://fukatoki.dyndns.org/S60_Camera_Example.rar

  14. #14
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    I would suggest now finding the last line executed. The panic KERN-EXEC 3 indicates that you are using invalid pointer.

    and forgetting to implement DoCancel() would not cause this panic. In that case the default empty implementation would be called.

  15. #15
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Ah, it is your RunL. TimerExpired re-schedules the timer correctly, however after that RunL re-schedules it without any Cancel attempt.
    (Side note: this passing void* and casting it to CamExTimer is not safe, in fact I do not see the need for passing the timer object around, for normal use cases it is owned by the called object anyway. And the complicated, extremist use cases are just not needed here)

Page 1 of 2 12 LastLast

Similar Threads

  1. I want to take snap from mobile camera and sent this image to server
    By sumeshchakra in forum Mobile Java General
    Replies: 2
    Last Post: 2010-03-27, 06:29
  2. Defect to take snap using native camera
    By ashuglaitm in forum Mobile Java Games
    Replies: 1
    Last Post: 2009-10-09, 19:37
  3. N73 camera can't start
    By nemotse in forum General Development Questions
    Replies: 1
    Last Post: 2006-08-31, 15:51
  4. format of bmp after camera snap?
    By stephen_b_g in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2005-08-22, 06:47
  5. image/vnd-nok-camera-snap
    By Brainstorm2003 in forum Streaming and Video
    Replies: 0
    Last Post: 2005-08-12, 12:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved