I bet the Marines nearby were hoping that Obama wasn't going to do something silly like salute them. The Marines aren't obligated to do anything but look at him and think "What's that dude doing?".
Obama is not in the executive chain of the military, has not been sworn in as President, isn't an officer of any kind, is saluting with his left hand, isn't facing anyone in particular, is holding an object in his hand, has no recognizable uniform, and for some bloody reason took the initiative to salute a USMC Lance Corporal.
"Who are you, man?" would be the appropriate response from the Marines at the scene. I hated seeing civilian VIPs on base for these reasons. I once saw Mexican Army generals getting a tour of Camp Pendleton and made sure everyone knew that they were nobodies.
But nobodies that are still due a salute as visiting officers, guests of your commanders from a mostly friendly country. Heck your supposed to salute the enemy, while you take his surrender. :)