Get category id when SEO URL is turned on

Use this function to get current cateogry in wp :

function getCurrentCatID(){

 global $wp_query;
 if(is_category() || is_single()){
  $cat_ID = get_query_var('cat');
 }
 return $cat_ID;

}

echo getCurrentCatID();

Just found for you, try this,

if(isset($wp_query->get_queried_object()->cat_ID))
{
    $cur_catId = $wp_query->get_queried_object()->cat_ID;
}
if(issset($wp_query->get_queried_object()->ID))
{
    $cur_postId = $wp_query->get_queried_object()->ID;
}