Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting orientation value when you are capturing video in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 335
    Comment on it

    If you are looking to know, How to get camera rotation while capturing video with custom camera in android, follow below steps

    Step 1:-Declare OrientationEventListener and the variable that hold the orientation value.

      OrientationEventListener orientationEventListener;
      int orientationValue;
    

    Step 2:-Initialize OrientationEventListener.

    if (orientationEventListener == null)
     {            
       orientationEventListener = new OrientationEventListener(this,   SensorManager.SENSOR_DELAY_NORMAL) 
         {
          @Override
          public void onOrientationChanged(int orientation) 
            {
          if (orientation >= 315 || orientation < 45) //for portrait upside
                {                         
                orientationValue = 1;
            }
          else if (orientation < 315 && orientation >= 225)  //for rightside landscape
                {
                  orientationValue = 3;                     
            }
          else if (orientation < 225 && orientation >= 135) //for portrait downside
               {
                  orientationValue = 2;                      
           }
         else 
               { // orientation <135 && orientation > 45  for leftside landscape
              orientationValue = 4;
               }   
            }
          };
       }
    

    Step 3:-Enable OrientationEventListener when you prepare MediaRecorder

      if(orientationEventListener.canDetectOrientation()) 
          {
        orientationEventListener.enable();
          }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: